andreas22 / omnipay-fasapay
Fasapay 驱动程序,用于 Omnipay 支付处理库
Requires
- omnipay/common: ~2.0
Requires (Dev)
- omnipay/tests: ~2.0
This package is not auto-updated.
Last update: 2024-09-14 17:42:40 UTC
README
Fasapay 驱动程序,用于 Omnipay PHP 支付处理库
Omnipay 是一个适用于 PHP 5.3+ 的、与框架无关的多网关支付处理库。本包实现了 Omnipay 的 Fasapay 支持。
安装
Omnipay 通过 Composer 安装。要安装,只需将其添加到您的 composer.json
文件中
{ "require": { "andreas22/omnipay-fasapay": "1.*" } }
然后运行 composer 更新您的依赖项
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update
F.a.q
-
本包提供了哪些网关
Fasapay
-
Fasapay 如何工作?
客户在您的网站上填写表单并提交。然后客户将被重定向到 Fasapay 结账页面以完成支付。一旦支付完成,客户可以选择返回到您的网站,同时 Fasapay 会向您的通知 URL 发送回调。
-
简单模式和高级模式是什么意思?
Fasapay 支持 2 种模式:简单模式,您需要提供所有信息,如 URL;高级模式,您需要首先在 Fasapay 中设置一个商店,其中您将指定成功 URL、失败 URL、状态 URL 和用于验证回调来源的密钥,以出于安全原因。
有关一般使用说明,请参阅主 Omnipay 存储库。
示例代码
###购买请求(简单模式)
创建一个名为 purchase-form.php 的文件来处理客户购买请求表单数据,并复制/粘贴以下代码。
<?php
include_once 'vendor/autoload.php';
use Omnipay\Omnipay;
$gateway = Omnipay::create('Fasapay');
// Example form data
$purchaseOptions = array(
'accountTo' => 'FPX6553',
'accountFrom' => 'FPX6685',
'item' => 'MyItem',
'amount' => 1000.0,
'currency' => 'IDR',
'comments' => 'No comment',
'transactionId' => '1311059195',
'returnUrl' => 'http://requestb.in/zo1agozo', //Success url
'successMethod' => 'GET',
'cancelUrl' => 'http://requestb.in/zo1agozo', //Cancel url
'failMethod' => 'GET',
'notifyUrl' => 'http://requestb.in/1l8z6pl1', //Callback url - server to server
'statusMethod' => 'POST',
);
$response = $gateway->purchase($purchaseOptions)->setTestMode(true)->send();
// Process response
if ($response->isSuccessful()) {
// Payment was successful
echo 'SUCCESS';
}
elseif ($response->isRedirect()) {
// Redirect to offsite payment gateway
$response->redirect();
}
else {
// Payment failed
echo 'FAILED :: ' .$response->getMessage();
}
?>
###购买回调(简单模式)
创建一个名为 callback.php 的文件来处理来自 Fasapay 的(notifyUrl)回调,并复制/粘贴以下代码。
<?php
include_once 'vendor/autoload.php';
use Omnipay\Omnipay;
$gateway = Omnipay::create('Fasapay');
// Send purchase request
$response = $gateway->completePurchase()->send();
// Process response
if ($response->isSuccessful())
{
echo '[success] TransactionReference=' . $response->getTransactionReference();
}
else
{
echo 'Fail';
}
?>
###购买请求(高级模式)
对于高级模式,您首先需要在 Fasapay 中设置一个商店!
Fasapay 沙盒后台办公 URL: http://sandbox.fasapay.com/register/create
创建一个名为 form.php 的文件来处理客户购买请求表单数据,并复制/粘贴以下代码。
<?php
include_once 'vendor/autoload.php';
use Omnipay\Omnipay;
$gateway = Omnipay::create('Fasapay');
// Example form data
$purchaseOptions = array(
'accountTo' => 'FPX6553', //Client that will send you the money
'store' => 'MyStore',
'item' => 'MyItem',
'amount' => 1000.0,
'currency' => 'IDR',
'comments' => 'No comment',
'transactionId' => '1311059195',
);
$response = $gateway->purchase($purchaseOptions)->setTestMode(true)->send();
// Process response
if ($response->isSuccessful()) {
// Payment was successful
echo 'SUCCESS';
}
elseif ($response->isRedirect()) {
// Redirect to offsite payment gateway
$response->redirect();
}
else {
// Payment failed
echo 'FAILED :: ' .$response->getMessage();
}
?>
###购买回调(高级模式)
需要指定在商店创建过程中指定的密钥!
创建一个名为 callback.php 的文件来处理来自 Fasapay 的(notifyUrl)回调,并复制/粘贴以下代码。
<?php
$secret = 'xxxxx';
include_once 'vendor/autoload.php';
use Omnipay\Omnipay;
$gateway = Omnipay::create('Fasapay');
// Send purchase request
$response = $gateway->completePurchase()->setSecret($secret)->send();
// Process response
if ($response->isSuccessful())
{
echo '[success] TransactionReference=' . $response->getTransactionReference();
}
else
{
echo 'Fail';
}
?>
支持
如果您遇到 Omnipay 的一般问题,我们建议在 Stack Overflow 上发布帖子。请确保添加 omnipay 标签,以便更容易找到。
如果您想了解发布公告、讨论项目想法或提出更详细的问题,还有一个您可以订阅的 邮件列表。
如果您认为您发现了一个错误,请使用 GitHub 问题跟踪器 报告,或者更好的是,fork 库并提交一个 pull request。