aimeoscom/omnipay-sofort

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

3.1.0 2020-02-19 17:02 UTC

This package is auto-updated.

Last update: 2024-09-26 01:38:25 UTC


README

Build Status Coverage Status Scrutinizer Code Quality

SOFORT Überweisung 网关,用于出色的 Omnipay 库。

API 注意事项

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

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

安装

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

{
    "require": {
        "aimeoscom/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(
    'transactionReference' => $transactionReference,
))->send();

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