PHP code example of v3labs / payubiz

1. Go to this page and download the library: Download v3labs/payubiz 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/ */

    

v3labs / payubiz example snippets



// purchase.php

use V3labs\PayUbiz\PayUbiz;

'YOUR_MERCHANT_ID',
    'secretKey'  => 'YOUR_SECRET_KEY',
    'testMode'   => true
));

// All of these parameters are [email protected]',
    'phone'       => '1234567890',
    'surl'        => 'http://localhost/payubiz-php/return.php',
    'furl'        => 'http://localhost/payubiz-php/return.php',
];

// Redirects to PayUbiz
$client->initializePurchase($params)->send();


// return.php

use V3labs\PayUbiz\PayUbiz;

UR_MERCHANT_ID',
    'secretKey'  => 'YOUR_SECRET_KEY',
    'testMode'   => true
]);

$result = $payubiz->completePurchase($_POST);

if ($result->checksumIsValid() && $result->getStatus() === PayUbiz::STATUS_COMPLETED) {
  print 'Payment was successful.';
} else {
  print 'Payment was not successful.';
}

$result = $payubiz->completePurchase($_POST);

// Returns Complete, Pending, Failed or Tampered
$result->getStatus(); 

// Returns an array of all the parameters of the transaction
$result->getParams();

// Returns the ID of the transaction
$result->getTransactionId();

// Returns true if the checksum is correct
$result->checksumIsValid();