Saferpay Omnipay gateway
, (*1)
Saferpay gateway for awesome Omnipay library., (*2)
Warning: Only works with omnipay 1.* versions for the moment, (*3)
Installation
To install, simply add it to your composer.json file:, (*4)
{
"require": {
"asci/omnipay-saferpay": "dev-master"
}
}
and run composer update
, (*5)
Usage
1. Authorize, (*6)
$gateway = new \Asci\Omnipay\SaferPay\Gateway();
$gateway->initialize(array(
'accountId' => 'your_account_id',
'testMode' => true,
));
$response = $gateway->authorize(array(
'amount' => 199.00,
'description' => 'Google Nexus 4',
))->send();
if ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
2. Complete Authorize, (*7)
$gateway = new \Asci\Omnipay\SaferPay\Gateway();
$gateway->initialize(array(
'accountId' => 'your_account_id',
'testMode' => true,
));
$response = $gateway->completeAuthorize()->send();
if ($response->isSuccessful()) {
// payment was successful
print_r($response);
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
3. Capture, (*8)
$gateway = new \Asci\Omnipay\SaferPay\Gateway();
$gateway->initialize(array(
'accountId' => 'your_account_id',
'testMode' => true,
));
$response = $gateway->capture()->send();
if ($response->isSuccessful()) {
// payment was successful
print_r($response);
} else {
// payment failed: display message to customer
echo $response->getMessage();
}