PHP code example of riazxrazor / payumoney

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

    

riazxrazor / payumoney example snippets


Riazxrazor\Payumoney\PayumoneyServiceProvider::class,

'Payumoney' => Riazxrazor\Payumoney\PayumoneyFacade::class



// All of these parameters are money::pay([
                       'txnid'       => 'A_UNIQUE_TRANSACTION_ID',
                       'amount'      => 10.50,
                       'productinfo' => 'A book',
                       'firstname'   => 'Peter',
                       'email'       => '[email protected]',
                       'phone'       => '1234567890',
                       'surl'        => url('payumoney-test/return'),
                       'furl'        => url('payumoney-test/return'),
                   ])->send();
                               
 
// In the return method of controller
$result = \Payumoney::completePay($_POST);

if ($result->checksumIsValid() AND isSuccess()) {
  print 'Payment was successful.';
} else {
  print 'Payment was not successful.';
}


The `PayumoneyResponse` has a few more methods that might be useful:


$result = \Payumoney::completePay($_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();



// pay.php

use Riazxrazor\Payumoney;

'KEY' => 'YOUR_MERCHANT_KEY',
    'SALT'  => 'YOUR_MERCHANT_SALT',
    'TEST_MODE'   => true, // optional default to true
    'DEBUG' => FALSE // optional default to false
]);

// All of these parameters are /localhost/payumoney-test/return.php',
    'furl'        => 'http://localhost/payumoney-test/return.php',
];

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


// return.php

use Riazxrazor\Payumoney;

Y' => 'YOUR_MERCHANT_KEY',
    'SALT'  => 'YOUR_MERCHANT_SALT',
    'TEST_MODE'   => true, // optional default to true
    'DEBUG' => FALSE // optional default to false
]);

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

if ($result->checksumIsValid() && $result->isSuccess()) {
  print 'Payment was successful.';
} else {
  print 'Payment was not successful.';
}

$result = $payumoney->completePay($_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();
console
php artisan vendor:publish --tag=config