Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

alipay-global-sdk-php

> 编程语言
Open source

Alipay global Third Party SDK with Authorization and Auto debit. Alipay 国际版 A+ 接口第三方 PHP SDK,实现了现金支付、用户授权、自动代扣和 RSA2 加密异步通知应答,示例完整,使用简单

392 stars0 likes3 views
WebsiteGitHub

About

Alipay Global SDK PHP

Alipay Global A+ SDK

This project is based on Alipay Global Offical PHP SDK
Since official SDK mainly shows how to access the alipay gateway and does not contain complete functions such as authorization and auto debit, I have added some logic and further realized the standard interface of Alipay Global A+

Attention!

0.0.3+: sendNotifyResponse sendNotifyResponseWithRSA are methods of $notify, eg:

php
$notify = $alipayGlobal->getNotify();
$notify->sendNotifyResponse(); // $alipayGlobal->sendNotifyResponse() is desprecated
$notify->sendNotifyResponseWithRSA(); // $alipayGlobal->sendNotifyResponseWithRSA() is desprecated
/* getNotifyResponse and getNotifyResponseWithRSA are added,
   so you can process it by yourself in memory frameworks like Webman */
$notifyResponseWithRSA =  $notify->getNotifyResponse();
$notifyResponseWithRSA =  $notify->getNotifyResponseWithRSA();

Demo

The use and functionality of the SDK have been shown with Examples in the project folder

Use

bash
composer require mantoufan/alipay-global-sdk-php

How to use

Initialize

php
$alipayGlobal = new Mantoufan\AliPayGlobal(array(
    'client_id' => 'SANDBOX_5Y3A2N2YEB3002022', // Client ID
    'endpoint_area' => 'ASIA', // Optional: NORTH_AMERIA / ASIA / EUROPE
    'merchantPrivateKey' => '', // Merchant Private Key
    'alipayPublicKey' => '', // Alipay Public Key
    'is_sandbox' => true, // Whether to use the Sandbox environment
));

Required fields will be mark with *

Online payment - Payment - Pay (Cashier Payment)

API: ac/ams/payment_cashier
DEMO: pay/cashier

…

Online Payment - Authorization - Consult

API: ac/ams/authconsult
DEMO: auth/consult

…

Online Payment - Authorization - ApplyToken - Using AuthCode

API: ac/ams/accesstokenapp
DEMO: auth/apply_token/auth_code

…

Online Payment - Authorization - ApplyToken - Using RefreshToken

API: ac/ams/accesstokenapp
DEMO: auth/apply_token/refresh_token

…

Online payment - Payment - Pay (Auto Debit)

API: ac/ams/payment_agreement
DEMO: pay/agreement

…

Online payment - Payment - NotifyPayment

API: ac/ams/paymentrn_online
DEMO: notify

…

Online Payment - Authorization - NotifyAuthorization

API: ac/ams/notifyauth
DEMO: notify/auth/auth_code

…

Online Payment - Refund - Refund

API: ac/ams/refund_online
DEMO: refund/refund_online

php
try {
    $result = $alipayGlobal->sendRefund(array(
        'paymentId' => '20181129190741010007000000XXXX', // Unique ID assigned by Alipay for the original payment to be refunded.
        'refundRequestId' => 'S7mMoYxQxWjJDWwm2NG4WxmNbM5z3GvSB6PEPvMeYP21PQUtrX9hXlgbQMajt2on', // Unique ID assigned by the merchant to identify a refund request.
        'refundAmount' => array(
            'currency' => 'USD', // Currency of refund
            'value' => '100', // Amount of refund
        )
    ));
    var_dump($result);
} catch (Exception $e) {
    echo $e->getMessage();
}

Return Url

DEMO: return

php
/** Return immediately after payment or authorization
 * After Payment, user will be redirected only
 * After Authorization, user will be redirected with authCode
 * Suggestion: The Return URL is only used as a reminder
 * It's beter to process business in asynchronous payment notification and asynchronous authorization notification
**/
echo 'Payment Or Authorization completed';

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPalipaypaymentsdk

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言