michelmelo/omnipay-eupago

omnipay 中的 euPago 集成

0.0.1 2022-01-05 14:30 UTC

This package is auto-updated.

Last update: 2024-09-05 20:25:52 UTC


README

这是 omnipay 支付处理库的 euPago 解决方案

Eupago 是一个提供多种支付方式的可用的葡萄牙支付网关。要使用它,您需要在 euPago 网站上创建一个账户。安装并配置后,您就可以使用我们 API 的所有功能。

安装

有关安装详细信息,请查看 omnipay git 页面。

实现的支付方式

  • Multibanco - 创建有/无开始/结束日期的 MB 引用,支持最小/最大金额(只需设置相应的参数)
  • MBWay - MBWay 支付系统
  • PayShop
  • Pagaqui
未来实现
  • 信用卡

必填字段

  • 'apiKey' - 请在他们的网站上 创建账户 以生成您的 API 密钥
  • 'currency' - 货币是必需的,必须是 'EUR' 或 '€'
  • 'amount' - 购买金额
  • 'transactionId' - 通常这是订单 ID

示例

创建 Multibanco 引用

$gateway = Omnipay::create('Eupago_Multibanco');

// required fields
$gateway->setApiKey('xxx-xxx-xxx-xxx');
$gateway->setCurrency('EUR');
$gateway->setTransactionId('xxxxx');
// Optionally with start/end date
$gateway->setStartDate(new \DateTime);
$gateway->setEndDate((new \DateTime)->modify('48 hours'));

$response = $gateway->purchase(['amount' => '10.00'])->send();

if ($response->isSuccessful()) {
	// return the euPago api response with payment credentials
	// see src/Message/MultibancoResponse.php methods for more information
	$paymentData = $response->getData();

	// return the Transaction Reference
	// the transaction Reference is required for call the status of payment, you should store them in your "orders" table related database
	$referenceId = $response->getTransactionReference();
} else {
    // Transaction creation failed: display message to customer
    echo $response->getMessage();
}

检查 Multibanco 引用状态

$gateway = Omnipay::create('Eupago_Multibanco');

// The transaction reference is required
$paymentStatus = $gateway->checkStatus([
	'transactionReference' => 'xxxxxx'
])->send();

if ($paymentStatus->isPaid()) {
    // payment was successful: update database
} else {
    // payment failed: display message to customer
    echo $paymentStatus->getMessage();
}