asci/omnipay-sofort

SOFORT Überweisung 付款处理库的网关

v2.2.1 2014-11-05 08:58 UTC

This package is not auto-updated.

Last update: 2024-09-23 15:44:54 UTC


README

Build Status Latest Stable Version Total Downloads

SOFORT Überweisung 网关,为强大的 Omnipay 库。

重要提示:Omnipay 1.x 用户

如果您正在使用 Omnipay 1.x 版本,请使用 1.x 树。有关详细信息,您可以查看 Omnipay 的 2.0 发布说明

API 注意事项

此网关仅提供两种方法来放置成功的交易。第一种是 authorize,它初始化授权并返回一个重定向 URL。

第二种是 completeAuthorize。此方法实际上并不完成任何事情。由于 SOFORT Überweisung 没有捕获功能,了解交易的唯一方法是通过检查交易详情。根据官方文档,如果没有任何成功或失败的交易,API 将返回空的 transactions XML 对象。

安装

要安装,只需将其添加到您的 composer.json 文件

{
    "require": {
        "asci/omnipay-sofort": "~2.0"
    }
}

并运行 composer update

使用方法

有关一般使用说明,请参阅主要的 Omnipay 仓库。

1. 授权

$gateway = Omnipay::create('Sofort');
$gateway->initialize(array(
    'username' => 'your_account_id',
    'password' => 'password',
    'projectId' => 'sofort_project_id',
    'testMode' => true
));

$response = $gateway->authorize(array(
    'amount' => 199.00,
    'description' => 'Google Nexus 4',
))->send();

$transactionReference = $response->getTransactionReference();

if ($response->isRedirect()) {
    // redirect to offsite payment gateway
    $response->redirect();
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}

2. 完成授权

$gateway = Omnipay::create('Sofort');
$gateway->initialize(array(
    'username' => 'your_account_id',
    'password' => 'password',
    'projectId' => 'sofort_project_id',
    'testMode' => true
));

$response = $gateway->completeAuthorize(array(
    'transactionId' => $transactionReference,
))->send();

if ($response->isSuccessful()) {
    // payment was successful
    print_r($response);
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}