maree / alrajhibank-payments
package to integrate with alrajhai bank payment api باكدج للربط مع خدمات الدفع الالكتروني مع بنك الرجحي السعودي
dev-main
2022-04-20 22:56 UTC
This package is auto-updated.
Last update: 2025-04-21 05:13:45 UTC
README
Installation
You can install the package via Composer.
composer require maree/alrajhibank-payments
Publish your alrajhibank config file with
php artisan vendor:publish --provider="maree\alrajhibankPayments\AlrajhibankServiceProvider" --tag="alrajhiBank"
then change your AlrajhiBank config from config/alrajhiBank.php file
"id" => "" , "password" => "" , "currencyCode" => "682",//SAR => 682 "encryption_key" => "",
Usage
first step
use maree\alrajhibankPayments\AlrajhiBank; $response = AlrajhiBank::checkout($amount = 0.0,$responseURL='',$errorURL='');
note
- this function return ['key' => 'success' ,'checkoutId' => $payment_id , 'responseData' => $responseData] //key = success or fail
- use checkoutId to save transaction in database
- use checkoutId in view page in next step
second step
- return view page with $checkoutId to show payment proccess
<iframe src="{{config('alrajhiBank.view_url').$checkoutId}}" style="width: 100%; height: 100%" title="description"></iframe>
note
- create route for response url 'show-response-route' EX: Route::get('show-response-route', 'PaymentsController@paymentresponse')->name('show-response-route');
- create route for error response url 'show-response-error' EX: Route::get('show-response-error', 'PaymentsController@paymentresponseError')->name('show-response-error');
- create function for checkout response 'paymentresponse' and error 'paymentresponseError'
- use that function to check if payment failed or success
inside 'paymentresponse' and 'paymentresponseError' functions use:
use maree\alrajhibankPayments\AlrajhiBank; //trandata = $request->trandata $response = AlrajhiBank::checkoutResponseStatus($trandata);
return response like:
['key' => 'success' , 'responseData' => $responseData];
or
['key' => 'fail', 'responseData' => $responseData];
note: you can use response from data to save transactions in database