PHP code example of webchemistry / thepay

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

    

webchemistry / thepay example snippets



$config = [
    'merchantId' => 100,
    'accountId' => 100,
    'password' => 'pswd',
    'dataApiPassword' => 'apiPswd'
];
$thepay = new WebChemistry\ThePay\ThePay($config);

/** @var WebChemistry\ThePay\ThePay */
$thepay;

$sender = $thePay->createSender(199); // Price

$sender->setDescription('Super product'); // Description for easier identification in administration
$sender->setMerchantData('Customer id is 150.');
// or
$sender->setMerchantData([
    'customer' => 150
]);

echo $sender->render();

/** @var WebChemistry\ThePay\ThePay */
$thepay;

$receiver = $thepay->getReceiver();

if (!$receiver->verifySignature(FALSE)) {
    die('Bad request.');
}
if (!$receiver->isSuccess()) {
    die('Payment was not successful.');
}
// Get info from api
$remotePayment = $receiver->getRemotePayment();
if ($remotePayment) {
    $remotePayment->getValue(); // Price
}


$payment = $thepay->createPermanent('merchantData', 'description', 'localhost/returnUrl.php');

$payment->getMethods(); // Array of methods with payment information