PHP code example of athlan / yetipay

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

    

athlan / yetipay example snippets


 

use Yetipay as Yetipay;

$merchantId = '';
$authKey1 = '';
$authKey2 = '';

$yetipay = new Yetipay\Client($merchantId, $authKey1, $authKey2);
$pingback = new Yetipay\TransactionPingback($yetipay);

$params = $_POST; // or more proper way in frameworks, from Request object

if($pingback->validateHash($params['hash'], $params)) {
    // activate product here
    
    die('ACK'); // yetipay expects "ACK" string in response to confirm transaction
}

die('FAILED');




use Yetipay as Yetipay;

$merchantId = '';
$authKey1 = '';
$authKey2 = '';

$yetipay = new Yetipay\Client($merchantId, $authKey1, $authKey2);

$amount = 5;
$description = 'Test payment';

$button = new Yetipay\PaymentButton($amount, $description);
$button->setUserId('userid_here');
$button->setProductId('productid_here');
$button->setReturnUrl('http://localhost/validate-transaction.php?transactionId=%transactionId%');

$buttonGenerator = new Yetipay\PaymentButtonCodeGenerator($yetipay);


 

use Yetipay as Yetipay;

$merchantId = '';
$authKey1 = '';
$authKey2 = '';

$yetipay = new Yetipay\Client($merchantId, $authKey1, $authKey2);
$pingback = new Yetipay\TransactionValidate($yetipay);

$transactionId = $_GET['transactionId']; // or more proper way in frameworks, from Request object
$data = $pingback->validateTransaction($transactionId);

if($data['status'] == 200) {
    // activte product here
}