Simple and efficient multi-user, multi-language converged payment system. Provides cash payment and Auto Debit via one URL, supports Alipay China, Alipay Global and Paypal, etc., it can be extended through plug-ins. Admin Panel can view logs, transaction flow, configuration.
简洁、高效的多用户、多语言的聚合支付系统。 通过一个 URL 提供现金付款和订阅支付(Auto Debit),支持支付宝中国,支付宝国际版和 Paypal 等,可通过插件扩展。Admin panel 可查看日志、交易流水,配置。
Suitable for cashier, multi-channel collection, multi-channel settlement, four-party payment, payment load balancing and other scenarios.
适合收银台、多渠道收款、多渠道结算、四方支付、支付负载均衡等场景。
The system shall not be used for any purposes prohibited by laws of mainland China, Hong Kong or the United States.
The system shall not be used for commercial purposes without permission.
本系统不得用于中国大陆、香港、美国法律所禁止的用途。
未经许可,不得用于商业用途。
Admin
Account: admin
Password: yzhan
source install.sql
- Get your
app_id
client_id
secret
key
from Alipay China / Alipay Global / Paypal - Find
yzhan_channel
, updateconfig
field
# Front-End: Enter Project Root Directory /
npm install
# Back-End: Eneter /src/api/
composer require
Add the URL below to the scheduled task
{Your Website Url}/api/run/{Maximum number of tasks per run}
Examples of setting scheduled tasks:
crontab -e # Edit Crontab
*/1 * * * * wget {Your Website Url}/api/run/{Maximum number of tasks per run} # wget / curl URL every 1 minute
Cash payment and Subscription payment are combined into one API:
API Document
// JSON doesn't support comments.
// Please delete comments when copying
{
"name": "paypal", // Plugin Name
"version": "1.0.0", // Plugin Version
"displayname": "Paypal", // Plugin Display Name
"type": "pay", // Plugin Type, Optional: pay / theme / language
"payment": "depositcard,paypal", // Payment provided by the plug-in to the user
"ability": "checkout,subscription", // Payment ability provided by plugin
"author": "mantoufan", // Plugin author
"link": "https://github.com/mantoufan", // Plugin Website URL
"input": [ // Configurable items provided by plugin, it can be configured in Admin Panel
{ "type":"text", "label":"Client ID", "name":"client_id" },
{ "type":"text", "label":"Secret", "name":"secret" },
{ "type":"checkout", "label":"Sandbox", "name":"is_sandbox" }
],
"composer": {
"require": { // Dependent third-party components
"paypal/paypal-checkout-sdk": "^1.0",
"andreimosman/paypal-subscriptions-sdk": "^1.0"
}
}
}
- Save JSON as config.json
- Put it into new folder
- Rename folder name with plugin name
- Create a php named plugin name
- Implement abstract class in it
abstract class MyPaymentPlugin {
public function getGateway($channel_id) // Get the configuration and initialize the gateway
{
$config = PluginService::GetChannelConfig($channel_id);
if (empty($config)) {
$this->export(array('status' => 403));
}
if ($config['env'] === 'sandbox') {
$environment = new SandboxEnvironment($config['client_id'], $config['secret']);
} else {
$environment = new ProductionEnvironment($config['client_id'], $config['secret']);
}
return new PayPalHttpClient($environment);
}
abstract public function checkout($channel_id, $params); // Single Payment -> Pay Channel Cashier
abstract public function sync($channel_id); // Process sync notifications received by checkout / subscribe
abstract public function async($channel_id); // Process async notifications received by checkout / subscribe
abstract public function cancel($channel_id); // Process user cancel, paypal only
abstract public function subscribe($channel_id, $params); // Subscribe Payment -> Pay Channel Agreement or Auth Page
abstract public function syncSubscribe($channel_id); // Process sync notifications received by subscribe
abstract public function asyncSubscribe($channel_id); // Process async notifications received by subscribe
abstract public function charge($channel_id, $params = array('trade_no' => 0, 'customer_id' => 0, 'subscription_id' => 0, 'note' => '', 'amount' => 0, 'currency' => ''));
// Subscribe Payment -> Initiate the request to deduct the fee, Alipay Global Only
}
const TRADE_STATUS = array(
'CREATED' => 'CREATED',
'CHECKOUT_SUCCEED' => 'CHECKOUT_SUCCEED',
'CHECKOUT_FAIL' => 'CHECKOUT_FAIL',
'SUBSCRIPTION_WAIT_REMIND' => 'SUBSCRIPTION_WAIT_REMIND',
'SUBSCRIPTION_WAIT_CHARGE' => 'SUBSCRIPTION_WAIT_CHARGE',
'SUBSCRIPTION_CHARGE_SUCCEED' => 'SUBSCRIPTION_CHARGE_SUCCEED',
'SUBSCRIPTION_CHARGE_FAIL' => 'SUBSCRIPTION_CHARGE_FAIL',
'CLOSED' => 'CLOSED',
);