GithubHelp home page GithubHelp logo

shurjopay-laravel's Introduction

ShurjoPay payment gateway integration for Laravel

ShurjoPay payment gateway integration for Laravel

This is a Laravel package for integrating ShurjoPay payment gateway in your Laravel application.


Features

  • Easy to use.
  • Friendly simple interface.
  • Laravel Facade.

Installation

Add the dependency to your Laravel project using Composer:

composer require raziul/shurjopay-laravel

Note: This package supports Laravel auto-discovery. You don't need to add the service provider manually.

Configuration

You can add ShurjoPay mercant credentials in the .env file like below:

# ShurjoPay merchant credentials
SHURJOPAY_SANDBOX_MODE=false
SHURJOPAY_MERCHANT_USERNAME="<your-merchant-username>"
SHURJOPAY_MERCHANT_PASSWORD="<your-merchant-password>"
SHURJOPAY_MERCHANT_PREFIX="<your-merchant-prefix>"

or you can publish the config file:

php artisan vendor:publish --provider="Raziul\Shurjopay\ShurjopayServiceProvider"

It should copy the config file to config/shurjopay.php of your project.

Usage Guide

Whenever you need to use Shurjopay payment gateway, just use the Shurjopay Facade.

use Raziul\Shurjopay\Facades\Shurjopay;

To make a payment

In your controller

// The payload will be passed to Shurjopay.
$payload = [
    // order info
    // customer info
    // custom values
];

// set the callback url
Shurjopay::setCallbackUrl($success_url, $cancel_url);

// Make a payment
Shurjopay::makePayment($payload);

// OR use methond chaining like below:
Shurjopay::setCallbackUrl($success_url, $cancel_url)->makePayment($payload);

Verify Payment

Note: You need to call this method in the callback url. The order_id will be available in the query string.

$payment = Shurjopay::verifyPayment($order_id);

if ($payment->success()) {
    // payment success
} else {
    // payment failed
}

Shurjopay::verifyPayment return an instance of Raziul\Shurjopay\Data\Payment.

Available methods in the Payment class.

Method Description
$payment->success() Return payment success status
$payment->failed() Return payment failed status
$payment->message() Get the success/error message
$payment->orderId() Get the order ID
$payment->currency() Get currency code
$payment->amount() Get the amount
$payment->customerOrderId() Get customer order ID
$payment->paymentMethod() Get the payment method name
$payment->dateTime() Get the transaction date time
$payment->toArray() Get all the data as array

Error Handling

For better error handling you can catch the Raziul\Shurjopay\Exceptions\ShurjopayException.

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

	// or verfication
	Shurjopay::verifyPayment($order_id);

} catch (Raziul\Shurjopay\Exceptions\ShurjopayException $e) {
	return $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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.