eonlab/omnipay-eupago

omnipay中的euPago集成

2.1.0 2019-10-30 12:36 UTC

This package is auto-updated.

Last update: 2024-09-26 04:46:35 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();
}