Jeremy Shipman
Merchant
Gateway
Provider
Developer
Bank
Customer
On Site
Off Site
$
$
Purchase
Tokenisation
Rebilling
Notify
Refund
Authorise & Capture
(delayed purchase)
Void
Look up
PHP 5.3+
Standardisation:
learn one code base
Easy support for multiple gateways
Well thought out
Stateless...
Composer
use Omnipay\Omnipay;
$gateway = Omnipay::create('Stripe');
$gateway->setApiKey('abc123');
$formData = [
'number' => '4242424242424242',
'expiryMonth' => '6',
'expiryYear' => '2016',
'cvv' => '123'
];
$response = $gateway->purchase([
'amount' => '10.00',
'currency' => 'USD',
'card' => $formData
])->send();
if ($response->isSuccessful()) {
// payment was successful: update database
print_r($response);
} elseif ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
Payment DataObject
Messages / Logging
YAML _config
Off-Site Payment Handling
Form Field Generation
Exception Handling
PaymentAdmin
Payable DataExtension
silverstripe-framework
omnipay (PHP library)
silverstripe-omnipay (SS module)
gateway API
your website / module
---
Name: payment
---
Payment:
allowed_gateways:
- 'PayPal_Express'
parameters:
PayPal_Express:
username: 'example.username.test'
password: 'txjjllae802325'
signature: 'wk32hkimhacsdfa'
$amount = $payable->Amount;
$currency = "NZD";
$payment = Payment::create()
->init("PxPayGateway", $amount, $currency);
$payment->write();
$response = PurchaseService::create($payment)
->setReturnUrl($this->Link())
->purchase($form->getData());
$response->redirect();
if($payment->isCaptured()){
$payable->Status = "Paid";
$payable->write();
$this->redirect('success');
}
$gateways = GatewayInfo::get_supported_gateways();
$factory = new GatewayFieldsFactory($gateway);
$fields = $factory->getFields();
Merchant
Developer
Merchant
Developer
Developer
Gateway
Provider
$ composer require burnbright/silverstripe-omnipay
$ composer require burnbright/omnipay-poli
$ composer require vendor/omnipay-gateway
> |
Omnipay 2
Authorise & Capture
Improve Administration
Tokenisation / Saved Cards