See the Developer
API docs.
You can install the package via composer:
composer require arifpay/arifpay
With version 5.4 or below, you must register your facades manually in the aliases section of the config/app.php configuration file.
"aliases": {
"Arifpay": "Arifpay\\Arifpay\\Facades\\Arifpay"
}
The package needs to be configured with your account's API key, which is available in the Arifpay Dashboard. Require it with the key's value. After install the package. you can use as follow.
⚠️ Since V2Arifpay->create()
is deprecated andArifpay->checkout->create()
should be used.
use Arifpay\Arifpay\Arifpay;
...
$arifpay = new Arifpay('your-api-key');
After importing the arifpay
package, use the checkout property of the Arifpay instance to create or fetch checkout sessions
.
use Arifpay\Arifpay\Arifpay;
use Arifpay\Arifpay\Helper\ArifpaySupport;
use Arifpay\Arifpay\Lib\ArifpayBeneficary;
use Arifpay\Arifpay\Lib\ArifpayCheckoutItem;
use Arifpay\Arifpay\Lib\ArifpayCheckoutRequest;
use Arifpay\Arifpay\Lib\ArifpayOptions;
use Illuminate\Support\Carbon;
$arifpay = new Arifpay('your-api-key');
$d = new Carbon::now();
$d->setMonth(10);
$expired = ArifpaySupport::getExpireDateFromDate($d);
$data = new ArifpayCheckoutRequest(
cancel_url: 'https://api.arifpay.com',
error_url: 'https://api.arifpay.com',
notify_url: 'https://gateway.arifpay.net/test/callback',
expireDate: $expired,
nonce: floor(rand() * 10000) . "",
beneficiaries: [
ArifpayBeneficary::fromJson([
"accountNumber" => '01320811436100',
"bank" => 'AWINETAA',
"amount" => 10.0,
]),
],
paymentMethods: ["CARD"],
success_url: 'https://gateway.arifpay.net',
items: [
ArifpayCheckoutItem::fromJson([
"name" => 'Bannana',
"price" => 10.0,
"quantity" => 1,
]),
],
);
$session = $arifpay->checkout->create($data, new ArifpayOptions(sandbox: true));
echo $session->session_id;
::Note
you Must use use Illuminate\Support\Carbon
instead of use Carbon\Carbon
to get the expire date
After putting your building ArifpayCheckoutRequest
just call the create
method. Note passing sandbox: true
option will create the session in test environment.
This is session response object contains the following fields
{
sessionId: string;
paymentUrl: string;
cancelUrl: string;
totalAmount: number;
}
To track the progress of a checkout session you can use the fetch method as shown below:
$arifpay = new Arifpay('API KEY...');
// A sessionId will be returned when creating a session.
$session = $arifpay->checkout->fetch('checkOutSessionID', new ArifpayOptions(true));
The following object represents a session
{
public int $id,
public ArifpayTransaction $transcation,
public float $totalAmount,
public bool $test,
public string $uuid,
public string $created_at,
public string $update_at
}
If the merchant want to cancel a checkout session. it's now possible as shown below.
$arifpay = new Arifpay('API KEY...');
// A sessionId will be returned when creating a session.
$session = $arifpay->checkout->cancel('checkOutSessionID', new ArifpayOptions(true));
The ArifpayCheckoutSession
class is returned.
learn more about DirectPay here
$session = $arifpay->checkout->create($data, new ArifpayOptions(true));
return $arifpay->directPay->telebirr->pay($session->session_id);
$session = $arifpay->checkout->create($data, new ArifpayOptions(true));
return $arifpay->directPay->awash_wallet->pay($session->session_id);
$session = $arifpay->checkout->create($data, new ArifpayOptions(true));
return $arifpay->directPay->awash->pay($session->session_id);
Released Date: v1.0.0
June 09, 2022
- Initial Release
Released Date: v1.2.0
June 30, 2022
- Name space changed. use Arifpay/Arifpay
- Exception Handling Improved
Released Date: v1.3.0
June 30, 2022
expiredate
parameter in checkout session create formate changed to LocalDateTime format- Exception Handling For Non Exsisting Session
Released Date: v2.0.0
Aug 10, 2022
DirectPay
added for Telebirr and Awash payment options
The MIT License (MIT). Please see License File for more information.