Library / SDK
yansongda/pay avatar
yansongda/pay

yansongda/pay: one PHP SDK for Alipay, WeChat, Douyin, UnionPay and five more gateways

Possibly the most elegant payment SDK package I've ever used, for Alipay, WeChat Pay, Douyin Pay, Unipay and Bank of Jiangsu.

5,373 stars1,055 forksPHPMIT

At a glance

What is it?
yansongda/pay is a PHP payment SDK that covers Alipay, WeChat Pay, Douyin Pay, UnionPay, Bank of Jiangsu, Allinpay, BestPay and Apple Pay verification behind one configuration style. Its v3 architecture replaced v2, and framework users need a separate extension package.
Who is it for?
yansongda/pay fits PHP projects that need Alipay, WeChat Pay or one of the other seven supported gateways behind a consistent API, especially if you also want Swoole or multi-tenant support. It is a weaker fit if you need a gateway outside the eight listed, since the project asks for a pull request rather than offering one itself, or if you use Laravel, Hyperf or Yii, since those need a separate extension package.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 11 days ago.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 14, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • yansongda/pay5,373 ★ · +5
Star history
Repository2026-09-232026-11-14
yansongda/pay5.4k5.4k

5 Stars in the last 52 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Version 3 is a rewrite, not an update, of version 2

The author states plainly that v3 differs greatly from v2 at a low level, with the underlying architecture redesigned to be easier to extend and more convenient to use. The motivation given is personal: after writing Alipay and WeChat integrations many times, and not finding an existing package that felt right, the author built this one.

That history matters if you are migrating. Code written against v2 is not a drop-in fit for v3, because the redesign touches the base architecture, not just the gateway list. Before upgrading an existing integration, read the version planning page and the documentation site rather than assuming the method names carry over.

Framework support is split into separate packages

The core package is framework agnostic. For Hyperf there is a separate extension at yansongda/hyperf-pay. For Laravel there is yansongda/laravel-pay. For Yii there is a third-party package, guanguans/yii-pay, built by a different maintainer.

If you pull in only yansongda/pay, you get the SDK itself, following PSR-2, PSR-3, PSR-4, PSR-7, PSR-11, PSR-14 and PSR-18, which the README offers as the reason integration with your framework should be straightforward. But convenience features tied to a specific framework, such as service provider registration, live in those separate packages, so check which one matches your stack before assuming auto-discovery will work.

Eight payment channels, each with its own configuration block

The supported methods list names Alipay, WeChat, Douyin, UnionPay, Bank of Jiangsu's e-rong payment, Allinpay, BestPay and Apple Pay. Each channel is configured under its own top-level key with a default sub-key, matching the examples shown for Alipay, WeChat, Douyin and the Bank of Jiangsu gateway. The Alipay example asks for an app_id, an application secret or certificate, an application public certificate path and the Alipay public certificate path. The WeChat example asks for a merchant ID and separate v2 and v3 merchant secret keys.

The README states that yansongda/pay is 100% compatible with all features of Alipay, WeChat and UnionPay, including provider functions, introduced through what it calls a plugin mechanism. Built-in plugins for each channel are documented on the project site rather than fully listed in the README.

Apple Pay support is verification and decryption, not a storefront integration

The Apple Pay entry is different in kind from the others. It covers verifying and decrypting Apple Pay payment tokens on your own server, decrypting card data locally, proxying merchant session verification for Apple Pay on the web, querying App Store transactions and refund history and subscription status, and verifying App Store Server Notifications V2 callbacks.

That is server-side cryptographic and API work around Apple's payment data, not a checkout flow you render to a user. If your product needs an Apple Pay button and a charge, this package handles the verification side of that pipeline, and you still need Apple's own client-side APIs to collect the payment token in the first place.

Douyin's configuration separates the app credential from the payment signing key

The Douyin example shows three distinct values with three distinct sources inside Douyin's developer console. The app_id, described as the Mini Program's client_key, comes from the application's basic information page. The app_secret, used to obtain a client_token, comes from the same basic information page. A separate application private key, used to sign orders, is retrieved from the payment settings section under the application's payment information.

Mixing these up is an easy mistake, because two of the three sit on the same console page while the third is elsewhere. The Douyin feature list covers Mini Program payment through the general transaction system with JSAPI order signing, order queries, CPS queries, refunds, refund review, and callbacks for payment, refund and refund application.

The install command may pin an older line than the newest release

The README's install instructions is:

shell
composer require yansongda/pay:~3.7.0 -vvv

The tilde constraint allows any 3.7.x release but not 3.8. The releases list, however, shows the newest tags as 3.8.0 betas: v3.8.0-beta.9 on 2026-11-02, v3.8.0-beta.8 on 2026-10-13 and v3.8.0-beta.7 on 2026-10-08. Running the README's command as written would install the latest 3.7 release, not these newer betas.

If you want the 3.8 line's features, you need a different constraint, and because the current 3.8 releases are tagged beta, weigh that against how much stability your project needs. The last push to the repository was on 2026-10-27, and the license is MIT.

Only eight gateways are built, and anything else is a pull request away

The contribution section is direct about scope: because of testing and usage constraints, only Alipay, WeChat Pay, Douyin Pay, UnionPay, Bank of Jiangsu, Allinpay and BestPay gateways have been developed in this project. If you need a different payment gateway, or find code in the project that needs improvement, the README asks you to fork and submit a pull request.

That means there is no roadmap commitment to add a ninth gateway on request; the plugin mechanism exists precisely so outside contributors can add gateways the maintainer has no way to test. A security policy file and a code of conduct are included for contributors, alongside a changelog and automated test configuration in the repository.

Editorial conclusion

yansongda/pay fits PHP projects that need Alipay, WeChat Pay or one of the other seven supported gateways behind a consistent API, especially if you also want Swoole or multi-tenant support. It is a weaker fit if you need a gateway outside the eight listed, since the project asks for a pull request rather than offering one itself, or if you use Laravel, Hyperf or Yii, since those need a separate extension package. Check the composer version constraint against the beta releases before you install.

Frequently asked questions

What is yansongda/pay?

It is a PHP SDK that unifies Alipay, WeChat Pay, Douyin Pay, UnionPay, Bank of Jiangsu, Allinpay, BestPay and Apple Pay verification behind one configuration and plugin style, licensed under MIT.

Does yansongda/pay work with Laravel or Hyperf?

The core package is framework agnostic. Laravel and Hyperf each have their own extension package, yansongda/laravel-pay and yansongda/hyperf-pay, and Yii has a third-party package by a different maintainer.

How do I install yansongda/pay?

Run composer require yansongda/pay:~3.7.0 -vvv. That constraint stays on the 3.7 line, so check the release list if you want a newer 3.8 beta instead.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. yansongda/pay on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/yansongda-pay.svg)](https://hysenlabs.com/projects/yansongda-pay)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/yansongda-pay.svg)](https://hysenlabs.com/projects/yansongda-pay)

Was this useful?