seofood/omnipay-sofort

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

3.0.1 2018-11-27 18:56 UTC

This package is auto-updated.

Last update: 2024-09-28 07:33:52 UTC


README

Build Status

为优秀的Omnipay库提供的SOFORT Überweisung网关。

API说明

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

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

安装

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

{
    "require": {
        "seofood/omnipay-sofort": "~3.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();
}