raziul/shurjopay-php

ShurjoPay payment gateway integration for PHP applications.

v1.0.1 2022-06-16 14:31 UTC

This package is auto-updated.

Last update: 2024-09-16 23:36:01 UTC


README

ShurjoPay payment gateway integration for PHP applications

ShurjoPay PHP Library

Using this library you can integrate ShurjoPay payment gateway into your PHP applications.

If you face any problem then create issues or make a PR with your solution.

Requirement

  • PHP 7.3 or Later
  • curl extension

Installation

The installation is pretty easy using Composer

composer require raziul/shurjopay-php

Usage

You can check the examples directory for full code.

Configuration

$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',
];

Creating a payment

require __DIR__ . '/vendor/autoload.php';

// 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

You can also use method chaining like below

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

After making a successfull payment, user will be redirected to the success_url with order_id query parameter in the URI.

Verify Payment

// 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();
}

Available methods in the Payment class.

Error Handling

This package throws Raziul\ShurjoPay\ShurjoPayException on error. You can use try-catch for better error handling.

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();
}

Suggestion/Issues

If you found any issues or have any suggestion then please create an issue.

You can also submit PR regarding any issues.

License

The MIT License (MIT). Please see License File for more information.

Thank You

Thanks for using this package and If you foound this package useful then consider giving it a star.