音乐/omnipay-esafe

Omnipay支付处理库的Esafe网关

1.0.0 2019-12-18 09:25 UTC

This package is auto-updated.

Last update: 2024-09-18 20:44:04 UTC


README

ESafe PHP支付处理库的驱动程序。

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

安装

本包提供以下网关

  • 银行转账(银行虚拟账户转账)
  • 条码(便利店条码缴费)
  • 货到付款
  • 信用卡支付
  • 支付码(便利店支付码缴费)
  • 台湾支付(Taiwaypay 缴费)
  • 银联卡支付
  • 网络ATM缴费

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

使用方法

首先,应创建网关实例

<?php

use Omnipay\Omnipay;
use Muzik\OmnipayEsafe\EsafeGatewayFactory;
use Muzik\OmnipayEsafe\CreditCardGateway;

Omnipay::setFactory(new EsafeGatewayFactory());
$gateway = Omnipay::create(CreditCardGateway::class);
// When using testing endpoint for refunding, please use `$gateway->setTestMode(true)`
$gateway->setTestMode(true);

$gateway->setApiKey('abcd5888');
// The following two methods also can setting transaction password(API KEY) 
// $gateway->initialize(['api_key' => 'abcd5888']);
// $gateway->initialize(['transaction_password' => 'abcd5888']);

信用卡

支付

<?php

$response = $gateway->completePurchase([
    // POST from esafe.com.tw webhook
])->send();

if ($response->isSuccessful()) {
    // 付款成功
    var_dump($response->getData()); // 取得紅陽的回傳資料
} else {
    // 付款失敗
    var_dump($response);
}

退款

<?php

$response = $gateway->refund([
    // 商家代號
    'web' => 'S1103020010',
    // 交易金額
    'MN' => '1688',
    // 紅陽交易編號
    'buysafeno' => '2400009912300000019',
    // 商家訂單編號
    'Td' => 'AC9087201',
    // 退貨原因
    'RefundMemo' => 'Foo Bar', 
])->send();

if ($response->isSuccessful()) {
    // 退款成功
} else {
    // 退款失敗
    var_dump($response->getData());
}
  • 注意事项
    • webMNbuysafenoTdRefundMemo 都是必填项,且不能使用空字符串
    • 底层SDK会根据API密钥及相关信息自动生成 ChkValue

银联卡

支付

<?php

$response = $gateway->completePurchase([
    // POST from esafe.com.tw webhook
])->send();

if ($response->isSuccessful()) {
    // 付款成功
    var_dump($response->getData()); // 取得紅陽的回傳資料
} else {
    // 付款失敗
    var_dump($response);
}

退款

<?php

$response = $gateway->refund([
    // 商家代號
    'web' => 'S1103020010',
    // 交易金額
    'MN' => '1688',
    // 紅陽交易編號
    'buysafeno' => '2400009912300000019',
    // 商家訂單編號
    'Td' => 'AC9087201',
    // 退貨原因
    'RefundMemo' => 'Foo Bar', 
])->send();

if ($response->isSuccessful()) {
    // 退款成功
} else {
    // 退款失敗
    var_dump($response->getData());
}
  • 注意事项
    • webMNbuysafenoTdRefundMemo 都是必填项,且不能使用空字符串
    • 底层SDK会根据API密钥及相关信息自动生成 ChkValue

支持的API

描述

  • 所有网关都支持处理来自esafe.com.tw的webhook的 completePurchase()
  • 只有信用卡和银联卡网关支持 refund()
  • 有一些异步支付网关支持 acceptNotification()
    • 获取银行转账信息
    • 获取条码或支付码

列表

  • 银行转账
    • completePurchase(array $options = []): CompletePurchaseRequest
    • acceptNotification(array $options = []): AcceptNotificationRequest
  • 条码
    • completePurchase(array $options = []): CompletePurchaseRequest
    • acceptNotification(array $options = []): AcceptNotificationRequest
  • 货到付款
    • completePurchase(array $options = []): CompletePurchaseRequest
    • acceptNotification(array $options = []): AcceptNotificationRequest
  • 信用卡
    • completePurchase(array $options = []): CompletePurchaseRequest
    • refund(array $options = []): RefundRequest
  • 支付码
    • completePurchase(array $options = []): CompletePurchaseRequest
    • acceptNotification(array $options = []): AcceptNotificationRequest
  • 台湾支付
    • completePurchase(array $options = []): CompletePurchaseRequest
  • 银联
    • completePurchase(array $options = []): CompletePurchaseRequest
    • refund(array $options = []): RefundRequest
  • 网络ATM
    • completePurchase(array $options = []): CompletePurchaseRequest

许可证

此库受MIT许可证的约束。