Dipu Dey 22nd Sep 2022

Upay Payment is a Bangladeshi Payment Gateway System. This is a Laravel/PHP package for Upay BD Payment Gateway. This package can be used in laravel or without laravel/php projects. You can use this package for headless/rest implementation as well as blade or regular mode development. We created this package while working for a project and thought to made it release for all so that it helps. In this blog, I explain how you can easily use Upay Payment Gateway API by using laravel.

Upay(BD) Payment Gateway – Laravel/PHP Package source code available via github and released via Packagist as regular regular php composer package.

Features

  • Create Payment/Take to Payment Page
  • Create Payment for Headless/REST API
  • Query Payment/Payment Details

Requirements

  • PHP >=7.4
  • Laravel >= 6

Installation

<code class="language-php">
composer require codeboxr/upay
</code>

vendor publish (config)

<code class="language-php">
php artisan vendor:publish --provider="Codeboxr\Upay\UpayServiceProvider"
</code>

After publish config file setup your credential. you can see this in your config directory upay.php file

<code class="language-php">
return [
    "sandbox"                => env("UPAY_SANDBOX", false), // for sandbox use true
    "server_ip"              => env("UPAY_SERVER_IP", ""),
    "merchant_id"            => env("UPAY_MERCHANT_ID", ""),
    "merchant_key"           => env("UPAY_MERCHANT_KEY", ""),
    "merchant_code"          => env("UPAY_MERCHANT_CODE", ""),
    "merchant_name"          => env("UPAY_MERCHANT_NAME", ""),
    "merchant_mobile"        => env("UPAY_MERCHANT_MOBILE", ""),
    "merchant_city"          => env("UPAY_MERCHANT_CITY", ""),
    "merchant_category_code" => env("UPAY_CATEGORY_CODE", ""),
    "redirect_url"           => env("UPAY_CALLBACK_URL", "")
];
</code>

Set .env configuration

<code class="language-php">
UPAY_SANDBOX=true // for production use false
UPAY_SERVER_IP="" // Upay only support IPV4 for production server don't needed sandbox
UPAY_MERCHANT_ID=""
UPAY_MERCHANT_KEY=""
UPAY_MERCHANT_CODE=""
UPAY_MERCHANT_NAME=""
UPAY_MERCHANT_MOBILE=""
UPAY_MERCHANT_CITY=""
UPAY_CATEGORY_CODE=""
UPAY_CALLBACK_URL=""
</code>

Usage

1. Create Payment
<code class="language-php">
use Codeboxr\Upay\Facade\Payment;

return Payment::executePayment($amount, $invoiceId, $txnId, $date);
</code>
Example
<code class="language-php">
return Payment::executePayment(10, 'CBX10101', '10127373', '2022-08-26');
</code>
2. Create Payment for REST API
<code class="language-php">
use Codeboxr\Upay\Facade\Payment;

return Payment::createPayment($amount, $invoiceId, $txnId, $date);
</code>
Example
<code class="language-php">
return Payment::createPayment(10, 'CBX10101', '10127373', '2022-08-26');
</code>
3. Query Payment
<code class="language-php">
use Codeboxr\Upay\Facade\Payment;

Payment::queryPayment($invoiceId); // Invoice ID 
</code>

Note: Upay only support IPV4 for production server

Contributing

Contributions to the Upay package are welcome. Please note the following guidelines before submitting your pull request.

  • Follow PSR-4 coding standards.
  • Read Upay API documentations first.Please contact with Upay for their api documentation and sandbox access.

License

Upay package is licensed under the MIT License.
Copyright 2022 Codeboxr

We are not affiliated with Upay and don’t give any guarantee.