mantoufan / alipay-global-sdk-php Goto Github PK
View Code? Open in Web Editor NEWAlipay global Third Party SDK with Authorization and Auto debit. Alipay 国际版 A+ 接口第三方 PHP SDK,实现了现金支付、用户授权、自动代扣和 RSA2 加密异步通知应答,示例完整,使用简单
Alipay global Third Party SDK with Authorization and Auto debit. Alipay 国际版 A+ 接口第三方 PHP SDK,实现了现金支付、用户授权、自动代扣和 RSA2 加密异步通知应答,示例完整,使用简单
We use alipay global's public key:(sandbox)
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtOcJhqk3mKhcGC0ARNjdFoZtYGEhfcgrUEUe9CF+sDzIJZMMVypRY67GoDQEdZTmHBPnVtsBRKNGSq4/h8r4BZ3XNE81K8CqwX0YzwqEvd0qlhyn9KzGCQF3Ps9wQRkPKdFzvmYcrW4WXmMOVMDg+XxuzNpXygqpxOJ++7Dpi8E6Ste0/ZtrJ2ACLIZVKCh951Cko25ePd2QyJpXq1g2jyWMRQVIapPp+t+UHG/4affBYI5GNREsxcXukg+SeymMlR2TwZvbyGYMlEb34icznLeD4jdkXOnU3pmkxYg2FmVCg0YujqrUL6yjQ648WkGruKFAyMkXC9inj9eZJwn8eQIDAQAB
And the notify verification is always 0.
Could you help to figure out the verify testing use case and we can check if code is correct?
e.g.
<?php
function verify($httpMethod, $path, $clientId, $rspTime, $rspBody, $signature, $alipayPublicKey)
{
$rspContent = genSignContent($httpMethod, $path, $clientId, $rspTime, $rspBody);
return verifySignatureWithSHA256RSA($rspContent, $signature, $alipayPublicKey);
}
function genSignContent($httpMethod, $path, $clientId, $timeString, $content)
{
$payload = $httpMethod . " " . $path . "\n" . $clientId . "." . $timeString . "." . $content;
return $payload;
}
function verifySignatureWithSHA256RSA($rspContent, $rspSignValue, $alipayPublicKey)
{
$pubKey = "-----BEGIN PUBLIC KEY-----\n" .
wordwrap($alipayPublicKey, 64, "\n", true) .
"\n-----END PUBLIC KEY-----";
if (
strstr($rspSignValue, "=")
|| strstr($rspSignValue, "+")
|| strstr($rspSignValue, "/")
|| $rspSignValue == base64_encode(base64_decode($rspSignValue))
) {
$originalRspSignValue = base64_decode($rspSignValue);
} else {
$originalRspSignValue = base64_decode(urldecode($rspSignValue));
}
$verifyResult = openssl_verify($rspContent, $originalRspSignValue, $pubKey, OPENSSL_ALGO_SHA256);
return $verifyResult;
}
$httpMethod = "POST";
$path = "";
$clientId = "SANDBOX_5Y606G2YJPQB00270";
$rspTime = "2022-04-26T04:39:22Z";
$signature = "bc6MuaBUCbIgxG6fbGh6MHJP%2FqiI6lrosdnN8mEEunDRR3k5j8cjRbGI8fAeE%2Bibhu%2FN4JxjGGCY7c%2B%2FTM8kUdv8nTdHU2MERsBn3mRcFe4eBW%2BxtFLL2brYaKSc%2Bb3mwIA0icHoUpwirVbfl9RrUviMsEJtSFW14rzKVjqBvwNo4iqzkh%2B2UIjzx%2FI7pbrSinZcJNZdjmMRRReQAMsYcrGGrzR%2BPtUjS%2FwNtA8NVHHk2LUeTuwtDVt%2F2ZxrsVm6C%2FufIZ3dz4yInSoR6fRms2%2FP67lb9PSTq0LGNM9EcXhtb3gCWmfdPPrUUuqxuBgDFno7%2F2%2BaPcht3GKP%2FPNrAg%3D%3D";
$alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAi1ltikGrnsmknSD/OYNQSMw485C/OF7Y9MVxHIDkbIWZm8JC9cuhdZbduTmx2AKeDmkYK73dbF1xZnZQGd38sSKAkiWOSbz15a0bfd/XMlcx5ICqjkWi6gMWYOgUBp1RLuHvisjicwb4fBIN7IPySGMvSFFgPspUUc6gY3HKJgP59KAUJR1WA7B7tPw0C/xhcRFKln0nsU7wzk7R4HhYzKua0BxV6mYYDxGbVepH5tJ5ZzSNVR3IGJRQc6c7+gU1F6z5Jc3V4NT7EHOmu7T888A+Uhec+4XymTVNkRZ+u6ZEj03oMwtv7NcQf2z8Kcp1/VeyOg7toXoQjNtH2oEIWQIDAQAB";
$rspBody = '{
"notifyType": "PAYMENT_RESULT",
"result": {
"resultCode": "SUCCESS",
"resultStatus": "S",
"resultMessage": "success"
},
"paymentRequestId": "20200101234567890444",
"paymentId": "20200101234567890132",
"paymentAmount": {
"value": "8000",
"currency": "EUR"
},
"actualPaymentAmount": {
"value": "8000",
"currency": "EUR"
},
"paymentCreateTime": "2020-01-01T12:01:00+08:30",
"paymentTime": "2020-01-01T12:01:01+08:30"
}';
echo (int) verify($httpMethod, $path, $clientId, $rspTime, $rspBody, $signature, $alipayPublicKey);
the above data is from alipay global's inotify testing data.
All fields is copied at alipay's console except path field, according to the API document notify need to fill the path filed. Could you help me to check if path is needed and how to fill this field when we verify the notification from the payment transaction(async) .
好像不兼容webman之类的常驻内存的框架
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.