PHP code example of paykun / checkout

1. Go to this page and download the library: Download paykun/checkout library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paykun / checkout example snippets




use Paykun\Checkout\Payment;

$obj = new Payment('<merchantId>', '<accessToken>', '<encryptionKey>');

// Initializing Order
// default currency is 'INR'
$obj->initOrder('<orderId>', '<Purpose or ProductName>', "<amount>", '<successUrl.example.com>',  '<failUrl.example.com>', 'INR');

// Add Customer
$obj->addCustomer('<customerName>', '<customerEmail>', '<customerContactNo>');

// Add Shipping address
$obj->addShippingAddress('<country>', '<state>', '<city>', '<postalCode>', '<fullAddress>');

// Add Billing Address
$obj->addBillingAddress('<country>', '<state>', '<city>', '<postalCode>', '<fullAddress>');

echo $obj->submit();

/* Check for transaction status
 * Once your success or failed url called then create an instance of Payment same as above and then call getTransactionInfo like below
 *  $obj = new Payment('merchantUId', 'accessToken', 'encryptionKey');
 *  $transactionData = $obj->getTransactionInfo(Get payment-id from the success or failed url);
 *  Process $transactionData as per your 



/**
 *  Parameters Id provided by Paykun
 *  accessToken => Access Token provided by Paykun
 *  encKey =>  Encryption provided by Paykun
 *  isLive => Set true for production environment and false for sandbox or testing mode
 *  isCustomTemplate => Set true for non composer projects, will disable twig template
 */

$obj = new \Paykun\Checkout\Payment('<merchantId>', '<accessToken>', '<encryptionKey>', true, true);

// Initializing Order
// default currency is 'INR'
$obj->initOrder('<orderId>', '<Purpose or ProductName>', "<amount>", '<successUrl.example.com>',  '<failUrl.example.com>', 'INR');

// Add Customer
$obj->addCustomer('<customerName>', '<customerEmail>', '<customerContactNo>');

// Add Shipping address
$obj->addShippingAddress('<country>', '<state>', '<city>', '<postalCode>', '<fullAddress>');

// Add Billing Address
$obj->addBillingAddress('<country>', '<state>', '<city>', '<postalCode>', '<fullAddress>');

//Render template and submit the form
echo $obj->submit();

/* Check for transaction status
 * Once your success or failed url called then create an instance of Payment same as above and then call getTransactionInfo like below
 *  $obj = new Payment('merchantUId', 'accessToken', 'encryptionKey', true, true); //Second last false if sandbox mode
 *  $transactionData = $obj->getTransactionInfo(Get payment-id from the success or failed url);
 *  Process $transactionData as per your