PHP code example of codifyllc / solid-trust-pay-php

1. Go to this page and download the library: Download codifyllc/solid-trust-pay-php 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/ */

    

codifyllc / solid-trust-pay-php example snippets


$stpButton = new StpButton();
$stpButton->setMerchantAccount('YourMerchantValue');
$stpButton->setItemId('YourMerchantValue');
$stpButton->setSciName('YourMerchantValue');
$stpButton->setLogo('YourMerchantValue');
$stpButton->setUser1('user1 value');
$stpButton->setUser2('user2 value');
$stpButton->setUser3('user3 value');
// setUser* (up to 10)

$stpButton->setReturnUrl('http://yourReturnUrl.com/thankyou');
$stpButton->setCancelUrl('http://yourReturnUrl.com/cancel');
$stpButton->setNotifyUrl('http://yourReturnUrl.com/yourCallbackScript.php');
$stpButton->setAmount('25.99');

// Enable Test Mode
$stpButton->setTestMode('On');

$stpCallback = new StpCallbck();

$status = $stpCallback->getStatus();
$user1 = $stpCallback->getUser1();
$user2 = $stpCallback->getUser2();

switch($status) {
    case 'COMPLETE':
        // This is successful!
        
        $stpTransId = $stpCallback->getTrId();
        break;
        
    default:
        // Something went wrong...
        break;
}