PHP code example of faganchalabizada / kapital-merchant-txpg

1. Go to this page and download the library: Download faganchalabizada/kapital-merchant-txpg 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/ */

    

faganchalabizada / kapital-merchant-txpg example snippets



use FaganChalabizada\KapitalMerchantTXPG\Merchant;
use FaganChalabizada\KapitalMerchantTXPG\OrderType;
use FaganChalabizada\KapitalMerchantTXPG\Exception\OrderException;

//İstifadə üçün ilk olaraq Merchant classını çağırmaq lazımdır.
$merchant = new Merchant();

try {

//ödəniş sorğusunu yaradırıq 
$create_order = $merchant->createOrder(OrderType::PURCHASE, 1, "AZN", "az", "https://SİZİN_ÖDƏNİŞİ_YOXLAMAQ_ÜÇÜN_OLAN_LİNKİNİZ.COM/checkPayment");

//qaytarılan $order_id dəyişkənini Məlumat Bazasında saxlamaq lazımdır. 
$order_id = $create_order->getId();

//$full_url dəyişkəni isə ödəniş səhifəsinin linkidir. İstifadəçını həmin linkə yönləndirmək lazımdır.
$full_url = $create_order->getFullRedirectUrl();

//yönləndiririk
header('Location: '.$full_url);

} catch (OrderException $e) {
    //burada ödəniş sorğusu yaradılan zaman hər hansı səhv baş verirsə əks olunacaq.
    echo $e->getMessage();
}

use FaganChalabizada\KapitalMerchantTXPG\Merchant;
use FaganChalabizada\KapitalMerchantTXPG\PaymentStatuses;

$merchant = new Merchant();

$id = intval($_GET['ID']); //order ID

$res = $merchant->getOrderStatus($id);//Ödənişi yoxlayırıq

if ($res->getStatus() == PaymentStatuses::FULLY_PAID) {//Ödəniş uğurludur

    $order_id = $res->getId();//order ID. Məlumat bazasından tapmaq üçün
    $amount = $res->getAmount();//Ödənilən məbləğ təkrar yoxlanış üçün.

    echo "Ödəniş uğurludur.<br/>";
    echo "Order ID: " . $order_id . "<br/>";
    echo "Məbləğ: " . $amount . "<br/>";

} else {

    echo "Ödəniş uğursuzdur.<br/>";
    echo "Order ID: " . $order_id . "<br/>";
    echo "Məbləğ: " . $amount . "<br/>";

    echo "Ətraflı: " . PaymentStatuses::getDescription($res->getStatus());//Ödənişin hal hazırki statusu.
}

$merchant->setAuth("BANKIN_VERDIYI_USERNAME", "BANKIN_VERDIYI_PASSWORD");