A Ping++ driver for the Omnipay PHP payment processing library. 一个支持支付宝(APP、Wap、PC、即时到账、扫码、企业付款),微信(APP、公众号、红包), 银联网关、银联企业网银、Apple Pay、QQ 钱包、易宝支付、百度钱包、京东支付、京东白条、招行一网通、分期支付等国内主流支付渠道的聚合支付网关
phoenixg/omnipay-pingpp
A Ping++ driver for the Omnipay PHP payment processing library. 一个支持支付宝(APP、Wap、PC、即时到账、扫码、企业付款),微信(APP、公众号、红包), 银联网关、银联企业网银、Apple Pay、QQ 钱包、易宝支付、百度钱包、京东支付、京东白条、招行一网通、分期支付等国内主流支付渠道的聚合支付网关
Ping++ driver for the Omnipay PHP payment processing library, (*2)
Ping++ is a Chinese leading payment integration service provider,
which support various mainstream payment gateways in China, eg. Alipay, Wechat Pay, UnionPay,
Apple Pay, QQ Wallet, YeePay, Baidu Wallet, JDPay, etc., (*3)
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP.
It has a clear and consistent API, and is fully unit tested. This package implements Ping++ support for Omnipay., (*4)
Installation
Omnipay is installed via Composer. To install, simply add it
to your composer.json file:, (*5)
The following gateways are provided by this package:, (*7)
Pingpp
For general usage instructions, please see the main Omnipay
repository., (*8)
Initialization
require './vendor/autoload.php';
use Omnipay\Omnipay;
use Omnipay\Pingpp\Common\Helpers;
use Omnipay\Pingpp\Common\Channels;
/**
* Get key and App ID in Ping++ Dashboard: https://dashboard.pingxx.com/
*/
$skLiveKey = 'sk_live_************************';
$appId = 'app_****************';
/**
* The payment channel you have configured in Ping++
*/
$channel = Channels::ALIPAY_WAP;
try {
/**
* @var $gateway \Omnipay\Pingpp\Gateway
*/
$gateway = Omnipay::create('Pingpp');
$gateway->initialize(array(
'apiKey' => $skLiveKey, // if test key is passed, all transactions will happen in test mode
'privateKey' => file_get_contents(PINGPP_ASSET_DIR.'/sample_rsa_private_key.pem') // optional, see: https://help.pingxx.com/article/123161/
));
} catch (\Exception $e) {
echo $e->getMessage();
}
To configure your webhooks URL, simply login Ping++ Dashboard, for more information, check out: docs, (*13)
Code below shows how you can verify whether the webhooks you receive is sent by Ping++:, (*14)
// Retrieve signature in header
$signature = $headers['X-Pingplusplus-Signature'] ?: null;
// Get the Ping++ RSA Public Key in Dashboard
$pub_key_contents = file_get_contents(__DIR__ . "/pingpp_rsa_public_key.pem");
if (openssl_verify(file_get_contents('php://input'), base64_decode($signature), $pub_key_contents, 'sha256')) {
// Congrats! This request is from Ping++
exit;
}
http_response_code(400);
pingpp.js
The minimum integration for PC payment is simple, first you need to load pingpp.js ,
then test with code below:, (*15)
银联网页支付支付宝网页支付企业网银支付
Test Mode
Pingpp accounts have test-mode API keys as well as live-mode API keys. These keys can be active
at the same time. Data created with test-mode credentials will never hit the real payment channel networks
and will never cost anyone money., (*16)
Unlike some gateways, there is no test mode endpoint separate to the live mode endpoint, the
Pingpp API endpoint is the same for test and for live., (*17)
FAQ
Is it compatible with Ping++ official SDK?
Yes. It's 100% compatible with official API., (*18)
Why use omnipay-pingpp instead of Ping++ official SDK?
It's simpler, more elegant, more consistantly designed
简单,优雅,一致的设计
The implementation to the official API is more covered than SDK
对官方常用 API 的实现比 SDK 覆盖更多
It's fully unit tested
完全的单元测试
It's easier to switch between Chinese and other payment gateways (like Paypal) if you're running global business
国内国外支付网关的切换变得一致和流畅
你需要一个聚合了国内主流渠道的支付网关,并且希望它遵循一套合理的标准
你没有打算使用 Ping++ 账户系统和商户系统的复杂接口(本类库没有集成那些接口, KISS)
You like keeping thing simple, you want to care about only the needed parameters, not all
你希望世界是简单的,可能只提供你需要关心的那些参数即可,你不打算了解每一个很可能不会用到的支付参数
Terminology
transactionId is the Merchant’s reference to the transaction - so typically the ID of the payment record in the Merchant Site’s database. In Ping++, it's often called order_no.
transactionReference is the Payment Gateway’s reference to the transaction. In Ping++, it's often called Charge Id, Red Envelope Id, Transfer Id.
returnUrl is used by drivers when they need to tell the Payment Gateway where to redirect the customer following a transaction. Typically this is used by off-site ‘redirect’ gateway integrations. In Ping++, it's called differently by various payment channels.
notifyUrl is used by drivers to tell the Payment Gateway where to send their server-to-server notification, informing the Merchant Site about the outcome of a transaction. In Ping++, it's called differently by various payment channels.
Support
If you are having general issues with Omnipay, we suggest posting on
Stack Overflow. Be sure to add the
omnipay tag so it can be easily found., (*19)
If you believe you have found a bug, please report it using the GitHub issue tracker,
or better yet, fork the library and submit a pull request., (*20)
A Ping++ driver for the Omnipay PHP payment processing library. 一个支持支付宝(APP、Wap、PC、即时到账、扫码、企业付款),微信(APP、公众号、红包), 银联网关、银联企业网银、Apple Pay、QQ 钱包、易宝支付、百度钱包、京东支付、京东白条、招行一网通、分期支付等国内主流支付渠道的聚合支付网关
A Ping++ driver for the Omnipay PHP payment processing library. 一个支持支付宝(APP、Wap、PC、即时到账、扫码、企业付款),微信(APP、公众号、红包), 银联网关、银联企业网银、Apple Pay、QQ 钱包、易宝支付、百度钱包、京东支付、京东白条、招行一网通、分期支付等国内主流支付渠道的聚合支付网关
A Ping++ driver for the Omnipay PHP payment processing library. 一个支持支付宝(APP、Wap、PC、即时到账、扫码、企业付款),微信(APP、公众号、红包), 银联网关、银联企业网银、Apple Pay、QQ 钱包、易宝支付、百度钱包、京东支付、京东白条、招行一网通、分期支付等国内主流支付渠道的聚合支付网关