1. Go to this page and download the library: Download basgate/laravel-payment-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
basgate / laravel-payment-sdk example snippets
use Bas\LaravelPayment\Facades\BasPaymentFacade as BasPayment;
// Initiate a payment transaction
$orderId = 'ORDER_' . time();
$amount = 100.00;
$currency = 'YER';
$payment = BasPayment::initiateTransaction($orderId, $amount, $currency);
if ($payment['status'] === 1 && $payment['code'] === '1111') {
$trxToken = $payment['body']['trxToken'];
// Store trxToken for later reference
}
use Bas\LaravelPayment\Facades\BasPaymentFacade as BasPayment;
$orderId = 'ORDER_123';
$status = BasPayment::checkTransactionStatus($orderId);
if ($status['body']['transaction_status'] === 'SUCCESS') {
// Payment successful - update order status
} elseif ($status['body']['transaction_status'] === 'FAILED') {
// Payment failed - handle accordingly
}
use Bas\LaravelPayment\Facades\BasPaymentFacade as BasPayment;
$trxToken = 'your_transaction_token';
$reason = 'Customer requested refund';
$refund = BasPayment::refund($trxToken, $reason);
if ($refund['status'] === 1) {
// Refund processed successfully
}
use Bas\LaravelPayment\Facades\BasPaymentFacade as BasPayment;
$orderId = 'ORDER_123';
$message = 'Your payment has been received successfully';