PHP code example of worldline-ind / php-checkoutjs

1. Go to this page and download the library: Download worldline-ind/php-checkoutjs 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/ */

    

worldline-ind / php-checkoutjs example snippets



     use WorldlineInd\CheckoutJS\Checkout;

    $checkout = new Checkout("YOUR_MERCHANT_CODE", "INR", "YOUR_SALT");

    


    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $data = [
            'mrctCode' => $_POST['mrctCode'],
            'txn_id' => $_POST['txn_id'],
            'amount' => $_POST['amount'],
            'custID' => $_POST['custID'],
            'mobNo' => $_POST['mobNo'],
            'email' => $_POST['email'],
            'returnUrl' => $_POST['returnUrl'],
        ];
        
        $checkout->processPayment($data);
    }
    
    

    
    $response = $_POST;
    $verified = $checkout->verifyResponse($response);
    
    if ($verified) {
        if ($response['statusCode'] == '0300') {
            echo "Transaction Successful";
        } else {
            echo "Transaction Failed";
        }
    } else {
        echo "Invalid response hash";
    }
    
    

    
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $transactionIdentifier = $_POST['transactionIdentifier'];
        $fromDate = $_POST['fromtransactionDate'];
        $toDate = $_POST['totransactionDate'];
    
        $reconciliationData = $checkout->reconcile($transactionIdentifier, $fromDate, $toDate);
        // Process reconciliation data
    }