-
Notifications
You must be signed in to change notification settings - Fork 19
Payment
Rene Korss edited this page Jan 25, 2019
·
5 revisions
<?php
require __DIR__ . '/vendor/autoload.php';
use RKD\Banklink;
// Init protocol
$protocol = new Banklink\Protocol\IPizza(
'uid100010', // seller ID (VK_SND_ID)
__DIR__ . '/../keys/seb_user_key.pem', // private key
'', // private key password, leave empty, if not needed
__DIR__ . '/../keys/seb_bank_cert.pem', // public key
'http://localhost/banklink/SEB.php' // return url
);
// Init banklink
$seb = new Banklink\EE\SEB($protocol);
// Set payment data and get payment request object
// orderId, sum, message, language
$request = $seb->getPaymentRequest(123453, 150, 'Example payment', 'EST');
// You can also add custom request data and/or override request data
// Optional
$request = $seb->getPaymentRequest(123453, 150, 'Example payment', 'EST', 'EUR', [
'VK_REF' => 'my_custom_reference_number', // Override reference number
'INAPP' => true // Pocopay specific example
]);
?>
<form method="POST" action="<?php echo $request->getRequestUrl(); ?>">
<?php echo $request->getRequestInputs(); ?>
<input type="submit" value="Pay with SEB!" />
</form>
<?php
/**
* Assume we have previously created $seb object
*/
// Get response object
$response = $seb->handleResponse($_POST);
// Successful
if ($response->wasSuccessful()) {
// Get whole array of response
$responseData = $response->getResponseData();
// User prefered language
$language = $response->getLanguage();
// Payment data
$orderId = $response->getOrderId();
$sum = $response->getSum();
$currency = $response->getCurrency();
$sender = $response->getSender();
$transactionId = $response->getTransactionId();
$transactionDate = $response->getTransactionDate();
$message = $response->getMessage();
$automatic = $response->isAutomatic(); // true if response was sent automatically by bank
// Failed
} else {
// Payment data
$orderId = $response->getOrderId(); // Order id to cancel order etc.
}
?>