rafaeltpires/omnipay-eupago

用于Omnipay支付处理库的EuPago驱动程序

dev-main 2023-09-16 00:26 UTC

This package is auto-updated.

Last update: 2024-09-16 02:55:59 UTC


README

警告:仍为工作状态 - 可用,但请谨慎使用!

Omnipay PHP支付处理库的EuPago驱动程序

Omnipay 是一个与框架无关的、多网关的PHP支付处理库。此包实现了Omnipay的PayPal支持。

安装

Omnipay通过 Composer 安装。要安装,只需使用Composer要求 league/omnipayrafaeltpires/omnipay-eupago

composer require league/omnipay rafaeltpires/omnipay-eupago

基本用法

此包提供以下支付方式

  • Multibanco
  • MBWay
  • 信用卡

有关一般使用说明,请参阅主 Omnipay 存储库。

注意事项

从purchase()响应中获取的交易参考不能用于退款。应使用completePurchase()响应中的交易参考。

支持

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

用法

Multibanco

use Omnipay\Omnipay;

$gateway = Omnipay::create('EuPago\Multibanco');

$formData = [
    'key' => 'demo-008c-5a63-8245-40e',     // Required
    'amount' => '125.15',                   // Required
    'id' => 'identifier',                   // Optional
    'clientEmail' => 'jdoe@example.dev',    // Optional
    'clientPhone' => '912345678',           // Optional
    'perDup' => 0,                          // Required
    'startDate' => '2023-09-16',            // Optional
    'endDate' => '2023-10-15',              // Optional
    'maxAmount' => 0.0,                     // Optional
    'minAmount' => 0.0,                     // Optional
    'failOver' => 0,                        // Optional
    'extraFields' => [                      // Optional
        'id' => 564,
        'valor' => 'my-custom-id'
    ],
    'testMode'       => true                // Optional
];

$response = $gateway->purchase($formData)->send();

if($response->isSuccessful()) {
    echo $response->getReference() . "<br>";
    echo $response->getEntity() . "<br>";
    echo $response->getAmount() . "<br>";
    echo $response->getMaxValue() . "<br>";
    echo $response->getMinValue() . "<br>";
    echo $response->getEndDate() . "<br>";
    echo $response->getStartDate() . "<br>";
}

MBWay

use Omnipay\Omnipay;

$gateway = Omnipay::create('EuPago\MBWay');

$formData = [
    'key' => 'xxxx-xxxx-xxxx-xxx',          // Required
    'amount' => '125.25',                   // Required
    'clientPhone' => '912345678',           // Optional
    'id' => 'identifier',                   // Optional
    'clientEmail' => 'jdoe@example.dev',    // Optional
    'failOver' => 1,                        // Optional
    'description' => 'MyCoolStore',         // Optional
    'paymentPhone' => '912345678',          // Required
    'testMode' => true                      // Optional
];

$response = $gateway->purchase($formData)->send();

if($response->isSuccessful()) {
    echo $response->getReference() . "<br>";
    echo $response->getMessage() . "<br>";
    echo $response->getAmount() . "<br>";
}

信用卡

use Omnipay\Omnipay;

$gateway = Omnipay::create('EuPago\Card');

$formData = [
    'key' => 'xxxx-xxxx-xxxx-xxx',          // Required
    'currency' => 'EUR',                    // Required 
    'amount' => '125.15',                   // Required
    'id' => 'identifier',                   // Optional
    'successUrl' => 'https://success.test', // Required
    'errorUrl' => 'https://error.test',     // Required
    'cancelUrl' => 'https://cancel.test',   // Required
    'notify' => 1,                          // Required
    'language' => 'PT',                     // Required
    'clientEmail' => 'jdoe@example.dev',    // Required
    'testMode' => true,                     // Optional
];

$response = $gateway->purchase($formData)->send();

if($response->isSuccessful()) {
    header('Location: ' . $response->getRedirectUrl());
}

属性

改编自 Stowify/omnipay-ifthenpay 👌