PHP code example of pashamesh / psb-acquiring-php-sdk
1. Go to this page and download the library: Download pashamesh/psb-acquiring-php-sdk 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/ */
pashamesh / psb-acquiring-php-sdk example snippets
use Pashamesh\PsbAcquiringPhpSdk\Config;
use Pashamesh\PsbAcquiringPhpSdk\PsbClient;
$config = Config::fromArray([
'component1' => '<COMPONENT1>',
'component2' => '<COMPONENT2>',
'merchantName' => 'Real Shop',
'merchantNumber' => '<MERCHANT_NUMBER>',
'terminalNumber' => '<TERMINAL_NUMBER>',
'merchantEmail' => '<MERCHANT_EMAIL>',
'notifyUrl' => 'https://some.domain/notify.php',
'returnUrl' => 'https://some.domain/',
]);
$psb = new PsbClient($config);
use Pashamesh\PsbAcquiringPhpSdk\Config;
use Pashamesh\PsbAcquiringPhpSdk\PsbClient;
$testEnvironmentConfig = Config::fromArray([
'merchantName' => 'Test Shop',
'merchantNumber' => '000599979036777',
'terminalNumber' => '79036777',
'merchantEmail' => '[email protected] ',
'notifyUrl' => 'https://some.domain/notify.php',
'returnUrl' => 'https://some.domain/',
]);
$psb = new PsbClient($testEnvironmentConfig);
$customerEmail = '[email protected] ';
$orderId = '620749153';
$amount = 300.;
$psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->preauthorize($amount)
->sendForm();
$preauthorizeFormHtml = $psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->preauthorize($amount)
->getForm();
$expiresAt = '01.04.2023 03:30:00';
$preauthorizeLink = $psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->additionalInfo('Additional information')
->preauthorize($amount)
->getLink($expiresAt);
$psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->preauthorizeAndSaveCard($amount)
->sendForm();
$cardTokenId = '<CARD_TOKEN_UUID>';
$psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->preauthorizeUsingCard($amount, $cardTokenId)
->sendForm();
$rrn = '<PREAUTHORIZATION_RETRIEVAL_REFERENCE_NUMBER>';
$intRef = '<PREAUTHORIZATION_INTERNAL_REFERENCE>';
$finalAmount = 300.;
$syncResponse = $psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->transaction($rrn, $intRef, $amount)
->completePreauthorization($finalAmount)
->sendRequest();
$syncResponse = $psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->transaction($rrn, $intRef, $amount)
->cancelPreauthorization($finalAmount)
->sendRequest();
$psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->purchase($amount)
->sendForm();
$preauthorizeFormHtml = $psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->purchase($amount)
->getForm();
$expiresAt = '01.04.2023 03:30:00';
$purchaseLink = $psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->purchase($amount)
->getLink($expiresAt);
$psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->purchaseAndSaveCard($amount)
->sendForm();
$cardTokenId = '<CARD_TOKEN_UUID>';
$psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->purchaseUsingCard($amount, $cardTokenId)
->sendForm();
$frequency = 1;
$expirationDate = '20240101';
$psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->purchase($amount)
->registerRecurring($frequency, $expirationDate)
->sendForm();
$recurringRrn = '<RECURRING_RETRIEVAL_REFERENCE_NUMBER>';
$recurringIntRef = '<RECURRING_INTERNAL_REFERENCE>';
$syncResponse = $psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->doRecurringPayment($amount, $recurringRrn, $recurringIntRef)
->sendRequest();
$rrn = '<PURCHASE_RETRIEVAL_REFERENCE_NUMBER>';
$intRef = '<PURCHASE_INTERNAL_REFERENCE>';
$response = $psb
->customer($customerEmail)
->order($orderId, "Order #{$orderId}")
->transaction($rrn, $intRef, $amount)
->refund($finalAmount)
->sendRequest();
$rrn = '<RETRIEVAL_REFERENCE_NUMBER>';
$intRef = '<INTERNAL_REFERENCE>';
$syncResponse = $psb
->customer($customerEmail)
->order($orderId, "Test payment")
->transaction($rrn, $intRef)
->saveCard()
->sendRequest();
$cardTokenId = '<CARD_TOKEN_UUID>';
$syncResponse = $psb
->forgetCard($cardTokenId)
->sendRequest();
if ($syncResponse->isOperationApproved()) {
// The card token was forgotten.
}
try {
$payload = $client->handleCallbackRequest($_POST);
if ($payload->isOperationApproved()) {
$orderId = $payload->order;
$referenceReturnNumber = $payload->rrn;
$internalReference = $payload->int_ref;
// Process data here. For example store in database.
}
echo "OK";
} catch (Exception $exception) {
echo $exception->getMessage();
}