PHP code example of basit / laravel-fastpay-integration

1. Go to this page and download the library: Download basit/laravel-fastpay-integration 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/ */

    

basit / laravel-fastpay-integration example snippets


use Basit\FastpayPayment\Fastpay;

$cart = [
    [
        "name" => "Scarf",
        "qty" => 1,
        "unit_price" => 5000,
    ],
    [
        "name" => "T-Shirt",
        "qty" => 2,
        "unit_price" => 10000,
    ]
];

// Replace YOUR_ORDER_ID with the unique identifier for your customer's order
$orderId = "YOUR_ORDER_ID";

$response = Fastpay::initiate($orderId, $cart);

use Basit\FastpayPayment\Fastpay;

// Replace YOUR_ORDER_ID with the merchant_order_id received from the IPN callback
$merchantOrderId = "YOUR_ORDER_ID";

$response = Fastpay::validate($merchantOrderId);

use Basit\FastpayPayment\Fastpay;

// Replace YOUR_ORDER_ID with the merchant_order_id for the order to be refunded
$merchantOrderId = "YOUR_ORDER_ID";

// Replace CUSTOMER_PHONE_NUMBER with the customer's phone number
$msisdn = "CUSTOMER_PHONE_NUMBER";

// Replace AMOUNT_TO_REFUND with the amount to be refunded (float)
$amount = AMOUNT_TO_REFUND;

$response = Fastpay::refund($merchantOrderId, $msisdn, $amount);

use Basit\FastpayPayment\Fastpay;

// Replace YOUR_ORDER_ID with the merchant_order_id received from the IPN callback
$merchantOrderId = "YOUR_ORDER_ID";

$response = Fastpay::refundValidate($merchantOrderId);
bash
php artisan vendor:publish --tag="fastpay"