PHP code example of niranjan94 / payumoney

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

    

niranjan94 / payumoney example snippets



// purchase.php

use CodeZero\PayUMoney\PayUMoney;

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

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

// Redirects to PayUMoney
$payumoney->initializePurchase($params)->send();


// return.php

use CodeZero\PayUMoney\PayUMoney;
use CodeZero\PayUMoney\PurchaseResult;

R_SECRET_KEY',
    'testMode'   => true
]);

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

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

$result = $payumoney->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();