PHP package for Betterpay (previously known as QlicknPay) payment gateway solution API.
Register for sandbox account to start testing.
- Tokenization - MasterCard Payment Gateway Service (MPGS)
- Standard Payment Gateway
- Direct Payment
- Recurring Payment - Direct Debit
- Refund
Install package via Composer:
composer require sykez/betterpay
Add the environment variables to your .env
:
BETTERPAY_API_KEY=
BETTERPAY_MERCHANT_ID=
BETTERPAY_CALLBACK_URL=https://example.com/callback
BETTERPAY_SUCCESS_URL=https://example.com/success
BETTERPAY_FAIL_URL=https://example.com/fail
Create verification link for Tokenization:
use Sykez\Betterpay\Betterpay;
$bp = new Betterpay($api_key, $merchant_id, $api_url, $callback_url, $success_url, $fail_url);
$response = $bp->createTokenizationUrl($reference_id); // unique $reference_id
header('Location: '.$response['credit_card_verification_url']); // redirect to payment gateway
Token is returned to your callback/success URL upon success.
Charge card:
$token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // token returned from verification
$bp->charge($token, $invoice, $amount);
Laravel: Charge card:
This package includes Laravel's Service Provider, which injects the dependencies.
use Sykez\Betterpay\Betterpay;
public function charge(Betterpay $bp, Request $request)
{
$invoice = bin2hex(random_bytes(5));
$token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$amount = 10.5;
return $bp->charge($token, $invoice, $amount);
}
Contributions are welcome 😄
The MIT License (MIT). Please see License File for more information.