Giter VIP home page Giter VIP logo

cakephp-4-paymob's Introduction

CAKEPHP 4 Paymob

paymob

paymob payment gateway https://paymob.com

Installation

composer require ahmedebead/cakephp-4-paymob

Usage In CakePhp

Enable Plugin

// src/Application.php

public function bootstrap()
{
    $this->addPlugin('CakephpLte', ['autoload' => true, 'bootstrap' => true, 'routes' => true]);
}

Or, you can load the plugin using the shell command

   $ bin/cake plugin load CakeRestApi

Configure

// new config/cakephplte.php file

return [
    'CakephpPaymob' => [
        'apiKey' => '{your-api-key-here-from-your-account}',
        'card_integration_id' => 'card_integration_id', //https://accept.paymob.com/portal2/en/PaymentIntegrations
        'mobile_wallet_integration_id' => 'mobile_wallet_integration_id', //https://accept.paymob.com/portal2/en/PaymentIntegrations

    ]
];

// config/bootstrap.php

Configure::load('cakephppaymob', 'default');

Usage

step 1 :

use CakephpPaymob\CakephpPaymob;

step 2 :

Init new client

 $client = new CakephpPaymob();

step 3 :

Order Registration

$orderData = [
   "delivery_needed" => "false",  // Required -- Set it to be true if your order needs to be delivered by Accept's product delivery services.
   "amount_cents" => 100, // price * 100  Required
   "currency" => "EGP", // Required
   "merchant_order_id" => 5, 
   "items" => [// Required
         [
            "name" => "ASC1515", 
            "amount_cents" => "500000", 
            "description" => "Smart Watch", 
            "quantity" => "1" 
         ], 
         [
               "name" => "ERT6565", 
               "amount_cents" => "200000", 
               "description" => "Power Bank", 
               "quantity" => "1" 
            ] 
      ], 

]; 

 $order = $client->OrderRegistrationAPI($orderData);

Card Payment

use CakephpPaymob\PaymentTypes\Card;

 $card = new Card();
        $PaymentKey =  $card->PaymentKeyRequest([
            'amount_cents' => 150 * 100, //put your price
            'currency' => 'EGP',
            'order_id' => $order['id'],// From step 3 before
            "billing_data" => [ // put your client information
                "apartment" => "803",
                "email" => "[email protected]",
                "floor" => "42",
                "first_name" => "Clifford",
                "street" => "Ethan Land",
                "building" => "8028",
                "phone_number" => "+86(8)9135210487",
                "shipping_method" => "PKG",
                "postal_code" => "01898",
                "city" => "Jaskolskiburgh",
                "country" => "CR",
                "last_name" => "Nicolas",
                "state" => "Utah"
            ]
        ]);

        $this->set('PaymentKey',$PaymentKey);

finally create view and use your iframe like this ( Card Payment)

card information testing

Card number : 4987654321098769
Cardholder Name : Test Account
Expiry Month : 05
Expiry year : 21
CVV : 123

  <iframe width="100%" height="800" src="https://accept.paymob.com/api/acceptance/iframes/{{your_frame_id_here}}?payment_token=<?= $PaymentKey // from steps ?>"> 
  <!-- https://accept.paymob.com/portal2/en/iframes -->
 

TODO

Mobile Wallets

Cash Collection

cakephp-4-paymob's People

Contributors

ahmed3bead avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.