gentor / omnipay-sofort
SOFORT Überweisung支付网关,用于Omnipay支付处理库
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网关,用于优秀的Omnipay库。
API说明
此网关仅提供两种方法来放置成功的交易。第一种是purchase
,它初始化购买并返回重定向URL。
第二种是acceptNotification
。此方法接收SOFORT Überweisung的状态通知,并通过从API获取transaction_details
来验证它。
安装
Omnipay通过Composer安装。要安装,只需运行
composer require gentor/omnipay-sofort
使用方法
有关一般使用说明,请参阅主要的Omnipay仓库。
1. 购买
$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. 接受通知
$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(); }