PHP code example of raziul / shurjopay-php

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

    

raziul / shurjopay-php example snippets


$config = [
	// set this to false if you are running in live mode
	'sandbox_mode'  =>  true,

	// ShurjoPay credentials [Change these with your details]
	'username' => 'sp_sandbox',
	'password' => 'pyyk97hu&6u6',
	'prefix'  =>  'NOK',
];



// create ShurjoPay instance
$sp = new \Raziul\ShurjoPay\ShurjoPay($config);

// set callback url
$sp->setCallbackUrl($success_url, $cancel_url);

// make payment
$sp->makePayment($payload); // it will redirect to the payment page


ShurjoPay::create($config)->setCallbackUrl($success_url, $cancel_url)->makePayment($payload);

// retrieve order id from the URI
$order_id = $_GET['order_id'];

// verify payment
$payment = $sp->verify($order_id);

// check success status
if ($payment->success()) {
	// show the payment method
	echo $payment->paymentMethod();
}

try {
	// making payment
	ShurjoPay::create($config)
		->setCallbackUrl($success_url, $cancel_url)
		->makePayment($payload);

	// also for verfication
	ShurjoPay::create($config)
		->verify($order_id);

} catch (Raziul\ShurjoPay\ShurjoPayException $e) {
	echo $e->getMessage();
}