worldstream-labs/

omnipay-paysafe-payment-hub

Paysafe Payment Hub 是用于 Neteller(以及后来的 Skrill)的 Omnipay 支付处理库的驱动程序

v1.1.0 2020-08-03 08:26 UTC

This package is auto-updated.

Last update: 2024-09-14 22:36:24 UTC


README

Build Status Latest Stable Version Total Downloads License

Paysafe Payment Hub 是用于 Omnipay V3 支付库的库,用于 Neteller(以及后来的 Skrill)。

安装

使用 composer 将库作为项目的依赖项添加 composer require league/omnipay worldstream-labs/omnipay-paysafe-payment-hub

开发

为了进行开发设置
composer install

使用

设置

<?php

require 'vendor/autoload.php';

use Omnipay\Omnipay;

$gateway = Omnipay::create('PaysafePaymentHub');
$gateway->setApiKey('yourApiKey');

// When deploying to production, don't forget to set test mode to false
$gateway->setTestMode(false);

创建 Neteller 的支付处理

<?php

require 'vendor/autoload.php';

use Omnipay\Omnipay;

$gateway = Omnipay::create('PaysafePaymentHub');
$gateway->setApiKey('yourApiKey');

$response = $gateway->purchase([
    'amount'         => 11.00,
    'currency'       => 'EUR',
    'successUrl'     => 'https://url/success',
    'failureUrl'     => 'https://url/failure',
    'returnUrl'      => 'https://url/return',
    'consumerId'     => 'consumer@example.com',
    'merchantRefNum' => 'abcdefg',
    'description'    => 'description',
    'text'           => 'text',
    'paymentMethod'  => 'neteller',
])->send();

redirect($response->getRedirectUrl());

此调用将返回 PurchaseResponse 对象。如果调用成功,则可以将客户重定向到 redirectUrl。根据下一屏幕的结果,客户将被重定向到成功或失败 URL。

注意:请求中的 consumerId 是可选的,如果省略 consumerId,请务必添加 consumerIdLocked 并将其值设置为 false

完成支付

在您可以完成支付之前,请确保使用 getPaymentHandle 调用已成功创建并可支付的支付处理。

<?php

$gateway = Omnipay::create('PaysafePaymentHub');
$gateway->setApiKey('yourApiKey');

$response = $gateway->getPaymentHandle([
    'paymentHandleId' = $paymentHandleId,
])->send();

$paymentHandle = $response->getPaymentHandle();
if ($response->getPaymentHandle()->isPayable()) {
    $completePurchaseResponse = $gateway->completePurchase([
        'amount'             => 11.00,
        'currency'           => 'EUR',
        'paymentHandleToken' => $paymentHandle->getPaymentHandleToken(),
        'merchantRefNum'     => 'ref2',
        'dupCheck'           => false,
        'settleWithAuth'     => true,
        'customerIp'         => '172.0.0.1',
        'description'        => 'description',
    ])->send();
}

获取交易

<?php

$gateway = Omnipay::create('PaysafePaymentHub');
$gateway->setApiKey('yourApiKey');

$response = $gateway->fetchTransaction([
    'transactionId' => $webhook['payload']['id'],
])->send();

if ($response->isComplete()) {
    // payment is complete
}

测试

使用 composer run test 运行单元测试

支持

如果您遇到 Omnipay 的一般问题,我们建议您在 Stack Overflow 上发布。请务必添加 omnipay 标签,以便轻松找到。

如果您认为您已发现一个错误,请使用 GitHub 问题跟踪器 报告它,或者更好的是,分叉库并提交一个拉取请求。

参考文献

Paysafe Payment Hub 文档