PHP code example of alet-systems / alet-payment

1. Go to this page and download the library: Download alet-systems/alet-payment 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/ */

    

alet-systems / alet-payment example snippets


use AletPayment\AletPayment\AletPayment;

...

$alet-systems = new AletPayment('your-api-key');



use AletPayment\AletPayment\AletPayment;
use AletPayment\AletPayment\Helper\AletPaymentSupport;
use AletPayment\AletPayment\Lib\AletPaymentBeneficary;
use AletPayment\AletPayment\Lib\AletPaymentCheckoutItem;
use AletPayment\AletPayment\Lib\AletPaymentCheckoutRequest;
use AletPayment\AletPayment\Lib\AletPaymentOptions;

use Illuminate\Support\Carbon;

$alet-systems = new AletPayment('your-api-key');
$d = new  Carbon::now();
$d->setMonth(10);
$expired = AletPaymentSupport::getExpireDateFromDate($d);
$data = new AletPaymentCheckoutRequest(
    cancel_url: 'https://api.alet-systems.com',
    error_url: 'https://api.alet-systems.com',
    notify_url: 'https://gateway.alet-systems.net/test/callback',
    expireDate: $expired,
    nonce: floor(rand() * 10000) . "",
    beneficiaries: [
        AletPaymentBeneficary::fromJson([
            "accountNumber" => '01320811436100',
            "bank" => 'AWINETAA',
            "amount" => 10.0,
        ]),
    ],
    paymentMethods: ["CARD"],
    success_url: 'https://gateway.alet-systems.net',
    items: [
        AletPaymentCheckoutItem::fromJson([
            "name" => 'Bannana',
            "price" => 10.0,
            "quantity" => 1,
        ]),
    ],
);
$session =  $alet-systems->checkout->create($data, new AletPaymentOptions(sandbox: true));
echo $session->session_id;


 $alet-systems = new AletPayment('API KEY...');
// A sessionId will be returned when creating a session.
 $session = $alet-systems->checkout->fetch('checkOutSessionID', new AletPaymentOptions(true));

{
  public int $id, 
  public AletPaymentTransaction $transcation, 
  public float $totalAmount, 
  public bool $test,  
  public string $uuid, 
  public string $created_at, 
  public string $update_at
}

 $alet-systems = new AletPayment('API KEY...');
// A sessionId will be returned when creating a session.
 $session = $alet-systems->checkout->cancel('checkOutSessionID', new AletPaymentOptions(true));
 
     $session = $alet-systems->checkout->create($data, new AletPaymentOptions(true));

    return $alet-systems->directPay->telebirr->pay($session->session_id);
 
     $session = $alet-systems->checkout->create($data, new AletPaymentOptions(true));

    return $alet-systems->directPay->awash_wallet->pay($session->session_id);
 
     $session = $alet-systems->checkout->create($data, new AletPaymentOptions(true));

    return $alet-systems->directPay->awash->pay($session->session_id);
json config/app.php

"aliases": {
            "AletPayment": "AletPayment\\AletPayment\\Facades\\AletPayment"
        }