ptuchik/omnipay-binancepay

BinancePay gateway for Omnipay payment processing library

1.0.3 2022-02-27 15:08 UTC

This package is auto-updated.

Last update: 2024-12-13 10:42:51 UTC


README

BinancePay driver for the Omnipay Laravel payment processing library

Latest Stable Version Total Downloads

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.5+. This package implements BinancePay support for Omnipay.

Installation

Omnipay is installed via Composer. To install, simply add it to your composer.json file:

{
    "require": {
        "ptuchik/omnipay-binancepay": "~1.0"
    }
}

And run composer to update your dependencies:

composer update

Or you can simply run

composer require ptuchik/omnipay-binancepay

Basic Usage

  1. Use Omnipay gateway class:
    use Omnipay\Omnipay;
  1. Initialize BinancePay gateway:
    $gateway = Omnipay::create('BinancePay');
    $gateway->setApiKey(env('API_KEY'));
    $gateway->setSecret(env('SECRET'));
  1. Call purchase, it will automatically redirect to BinancePay's hosted page
    $purchase = $gateway->purchase();
    $purchase->setCryptoCurrency('USDT'); // Currenctly supports only USDT
    $purchase->setNonce(\Str::random(32));
    $purchase->setAmount(10); // Amount to charge
    $purchase->setDescription(XXXX); // Some description about the items you sell
    $purchase->setReturnUrl(XXXX); // Set the URL where the customer will be directed after successful payment
    $purchase->setCancelUrl(XXXX); // Set the URL where the customer will be directed on failed or cancelled payment
    
    $purchase->send()->redirect();
  1. Create a webhook controller to handle the callback request at your webhook endpoint and catch the webhook as follows
    $gateway = Omnipay::create('BinancePay');
    $gateway->setApiKey(env('API_KEY'));
    $gateway->setSecret(env('SECRET'));
    
    $request = $gateway->completePurchase()
    $request->setNonce(\Str::random(32));
    $request->setTransactionId(XXXX); // Transaction ID from your system
    
    $purchase = $request->send();
    
    // Do the rest with $purchase and response with 'OK'
    if ($purchase->isSuccessful()) {
        
        // Your logic
        
    }
    
    return \Response::json([
            'returnCode'    => 'SUCCESS',
            'returnMessage' => null
        ]);

For general usage instructions, please see the main Omnipay repository.

Support

If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.

If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.