gentor / omnipay-sofort
SOFORT Überweisung gateway for Omnipay payment processing library
2.3.0
2016-06-27 10:40 UTC
Requires
- omnipay/common: ~2.0
Requires (Dev)
- omnipay/tests: ~2.0
- satooshi/php-coveralls: dev-master
README
SOFORT Überweisung gateway for awesome Omnipay library.
API Notes
This gateway only provides 2 methods to place a successful transaction. The first one is purchase
which initializes a purchase and returns a redirect url.
The second one is acceptNotification
. This method receives status notification from SOFORT Überweisung and validates it by getting transaction_details
from the API.
Installation
Omnipay is installed via Composer. To install, simply run:
composer require gentor/omnipay-sofort
Usage
For general usage instructions, please see the main Omnipay repository.
1. Purchase
$gateway = Omnipay::create('Sofort'); $gateway->initialize(array( 'username' => 'sofort_customer_id', 'password' => 'sofort_api_key', 'projectId' => 'sofort_project_id', 'testMode' => true )); $response = $gateway->purchase(array( 'amount' => 199.00, 'description' => 'Google Nexus 4', ))->send(); if ($response->isSuccessful() && $response->isRedirect()) { // redirect to offsite payment gateway $transactionReference = $response->getTransactionReference(); $transactionStatus = $response->getTransactionStatus(); $response->redirect(); } else { // payment failed: display message to customer echo $response->getMessage(); }
2. Accept Notification
$gateway = Omnipay::create('Sofort'); $gateway->initialize(array( 'username' => 'sofort_customer_id', 'password' => 'sofort_api_key', 'projectId' => 'sofort_project_id', 'testMode' => true )); $response = $gateway->acceptNotification()->send(); if ($response->isSuccessful()) { // payment was successful $transactionReference = $response->getTransactionReference(); $transactionStatus = $response->getTransactionStatus(); print_r($response); } else { // payment failed: display message to customer echo $response->getMessage(); }