gentor/omnipay-sofort

SOFORT Überweisung支付网关,用于Omnipay支付处理库

2.3.0 2016-06-27 10:40 UTC

This package is auto-updated.

Last update: 2024-09-09 03:04:27 UTC


README

Build Status Coverage Status Scrutinizer Code Quality

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();
}