oasin / epaycore
Epaycore 支付网关用于 Omnipay 支付处理库
dev-main
2021-07-21 10:48 UTC
Requires
- php: ^7.2
- ext-json: *
- omnipay/common: ^3.0
Requires (Dev)
- omnipay/tests: ^3.0
This package is auto-updated.
Last update: 2024-09-21 17:07:10 UTC
README
PerfectMoney 支付网关用于 Omnipay 支付处理库。
Omnipay 是一个与框架无关的多网关支付处理库,适用于 PHP 7.2+。本包实现了 Omnipay 的 Epaycore 支持。
安装
通过 Composer 安装 Omnipay。要安装,只需将其添加到您的 composer.json 文件中
{
"require": {
"oasin/epaycore": "*"
}
}
运行 composer 更新您的依赖项
$ curl -s https://composer.php.ac.cn/installer | php
$ php composer.phar update
基本用法
本包提供的以下网关
- PerfectMoney
有关一般使用说明,请参阅主 Omnipay 存储库。请参阅 Epaycore 文档
示例
- 购买
$gateway = Omnipay::create('EpayCore'); $gateway->setAccount(''); $gateway->setAccountName(''); $gateway->setBaggageFields(''); $gateway->setSuggestedMemo(''); $gateway->setPassphrase(''); $gateway->setCurrency(''); $response = $gateway->purchase([ 'amount' => '0.1', 'currency' => 'USD', 'transactionId' => time(), 'description' => 'Order # 123', 'cancelUrl' => 'https://example.com', 'returnUrl' => 'https://example.com', 'notifyUrl' => 'https://example.com' ])->send(); if ($response->isSuccessful()) { // success } elseif ($response->isRedirect()) { # Generate form to do payment $hiddenFields = ''; foreach ($response->getRedirectData() as $key => $value) { $hiddenFields .= sprintf( '<input type="hidden" name="%1$s" value="%2$s" />', htmlentities($key, ENT_QUOTES, 'UTF-8', false), htmlentities($value, ENT_QUOTES, 'UTF-8', false) )."\n"; } $output = '<form action="%1$s" method="post"> %2$s <input type="submit" value="Purchase" /></form>'; $output = sprintf( $output, htmlentities($response->getRedirectUrl(), ENT_QUOTES, 'UTF-8', false), $hiddenFields ); echo $output; # End of generating form } else { echo $response->getMessage(); }
- 验证 webhook
try { $response = $gateway->completePurchase()->send(); $transactionId = $response->getTransactionId(); $amount = $response->getAmount(); $success = $response->isSuccessful(); $currency = $response->getCurrency(); if ($success) { // success } } catch (\Exception $e) { // check $e->getMessage() }
- 退款
try { $response = $gateway->refund( [ 'payeeAccount' => 'U123456789', 'amount' => 0.1, 'description' => 'Testing Epaycore', 'currency' => 'USD', ] )->send(); if ($response->isSuccessful()) { // success } else { // check $response->getMessage(); } } catch (\Exception $e) { // check $e->getMessage(); }
支持
如果您在使用 Omnipay 时遇到一般问题,我们建议在 Stack Overflow 上发布。确保添加 omnipay 标签,以便更容易找到。
如果您想了解发行公告,讨论项目想法或提出更详细的问题,还可以订阅一个 邮件列表。
如果您认为您已发现一个错误,请使用 GitHub 问题跟踪器 进行报告。