PHPackages                             mofing/omnipay-alipay - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. mofing/omnipay-alipay

ActiveLibrary[Payment Processing](/categories/payments)

mofing/omnipay-alipay
=====================

Alipay gateway for Omnipay payment processing library

1.0.3(6y ago)0854↓50%MITPHP

Since May 15Pushed 6y ago1 watchersCompare

[ Source](https://github.com/wcj343169893/omnipay-alipay)[ Packagist](https://packagist.org/packages/mofing/omnipay-alipay)[ Docs](https://github.com/lokielse/omnipay-alipay)[ RSS](/packages/mofing-omnipay-alipay/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Omnipay: Alipay
===============

[](#omnipay-alipay)

[![travis](https://camo.githubusercontent.com/22f4cd28d59eb0d4e5fd736513f50c012d3a15b6d192323132d4117626517f6e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c6f6b69656c73652f6f6d6e697061792d616c697061792f6d61737465722e737667)](https://travis-ci.org/lokielse/omnipay-alipay)[![Latest Version on Packagist](https://camo.githubusercontent.com/86da9796afce9b10f884a944ec79d9906a75f6a73c160e001d619abd9cc51e70/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f6b69656c73652f6f6d6e697061792d616c697061792e737667)](https://packagist.org/packages/lokielse/omnipay-alipay)[![Total Downloads](https://camo.githubusercontent.com/c93ebdf990ca13784b4859bc9630ebfc487487c096f6f9a9b33059ca379e9041/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f6b69656c73652f6f6d6e697061792d616c697061792e737667)](https://packagist.org/packages/lokielse/omnipay-alipay)[![Code Coverage](https://camo.githubusercontent.com/9c2dbb52456fa9c08295c735c430ac9d03d0efd23f0c6a91006db1ecff381f29/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6c6f6b69656c73652f6f6d6e697061792d616c697061792f6d61737465722e737667)](https://codecov.io/github/lokielse/omnipay-alipay?branch=master)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Donate](https://camo.githubusercontent.com/65a6994b3a22721d9c258fd45142b2fd6f3824e4092cc7132cf97849af3b3d2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2546302539462538442542432d646f6e6174652d6666363962342e737667)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=lokielse%40gmail%2ecom&lc=US&item_name=Omnipay%20Alipay&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted)[![Donate](https://camo.githubusercontent.com/9484ebc029b006d8c4ab83f30b2375e86919af95101624f9864d1296493894df/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d2545372542412541322545352538432538352d7265642e7376673f6c6f676f3d64617461253341696d616765253246706e672533426261736536342532436956424f5277304b47676f414141414e53556845556741414142414141414151434159414141416638253246396841414141475852465748525462325a30643246795a5142425a4739695a53424a6257466e5a564a6c5957523563636c6c5041414141795270564668305745314d4f6d4e76625335685a4739695a5335346258414141414141414477253246654842685932746c644342695a576470626a3069373775253246496942705a443069567a564e4d4531775132566f61556836636d5654656b355559337072597a6c6b496a38253242494478344f6e68746347316c6447456765473173626e4d366544306959575276596d5536626e4d366257563059533869494867366547317764477339496b466b62324a6c4946684e5543424462334a6c494455754d79316a4d444578494459324c6a45304e5459324d5377674d6a41784d6938774d6938774e6930784e446f314e6a6f794e7941674943416749434167496a346750484a6b5a6a70535245596765473173626e4d36636d526d50534a6f644852774f693876643364334c6e637a4c6d39795a7938784f546b354c7a41794c7a49794c584a6b5a69317a6557353059586774626e4d6a496a346750484a6b5a6a70455a584e6a636d6c7764476c76626942795a47593659574a76645851394969496765473173626e4d366547317750534a6f644852774f693876626e4d7559575276596d5575593239744c336868634338784c6a41764969423462577875637a70346258424e545430696148523063446f764c32357a4c6d466b62324a6c4c6d4e7662533934595841764d5334774c3231744c79496765473173626e4d36633352535a575939496d6830644841364c793975637935685a4739695a53356a62323076654746774c7a45754d43397a56486c775a5339535a584e7664584a6a5a564a6c5a694d694948687463447044636d566864473979564739766244306951575276596d5567554768766447397a6147397749454e544e69416f5457466a6157353062334e6f4b53496765473177545530365357357a644746755932564a52443069654731774c6d6c705a446f774f5445304e4551334f546442524559784d555532516b5647526b51304f444d334d304d33525463774e43496765473177545530365247396a6457316c626e524a52443069654731774c6d52705a446f774f5445304e45513351546442524559784d555532516b5647526b51304f444d334d304d33525463774e4349253242494478346258424e545470455a584a70646d566b526e4a766253427a64464a6c5a6a7070626e4e305957356a5a556c4550534a346258417561576c6b4f6a41354d545130524463334e304645526a457852545a4352555a47524451344d7a637a517a64464e7a41304969427a64464a6c5a6a706b62324e316257567564456c4550534a34625841755a476c6b4f6a41354d545130524463344e304645526a457852545a4352555a47524451344d7a637a517a64464e7a413049693825324249447776636d526d4f6b526c63324e796158423061573975506941384c334a6b5a6a70535245592532424944777665447034625842745a585268506941385033687759574e725a5851675a57356b50534a79496a38253242586625324679355141414171704a52454655654e7030557a317645304551666274376e375a6a78253242416b566f5170454a25324269534957514b4f6d436f456b48346b38674370416f6b4a436f614f6b7045564c5338522532426743494a494a4369437942454a4a4c46444570253246744f3939353734625a4d344545784568375a383374764466767a56675145644b6c785a767877737648744c4e3169595a4a45566b475a436d513870763448495951674f4f45736a36393673376465617175584673512532427350696a656a3573336b4d49682532463848634d684441415a4545326a516b747772526a395a6b4c53664d64786825324636395237665677366d786557592532426c544d6d796568435368424b776d7055494b7365714b63356c33484f67444359556b79554b487a374f6d50682532423859466d576f6d4862564b47554657585069334770446a555a374c446959527664344164515935734f5275744f316766373135527432644b44394a4d7849326f356f6a4d774633396a5255505142556959384434515777616a556b792532467349307948615955512532467767454a6b4c4c47505538456363774a5a6d504a58734842325a6f573649644170636f41466844306b4a313030597837704a494d4664385439564b526d32475a4a64644278584e4678746f48513431654d6b51636446436f7373357746253242424c73435453494544444c7770767a47496559736b38505a5974387a4561312532466e743252596d584225324664747a3353747332463749765330457979253246365a4c6469627a753662344d43776343514e4350444b2532466d5972645633736b4c72707347452532467a3077434662524c4355666d646f33454d774951706945534b6c5863746361355a7857616e433845715a6870315a4838562532467764416f733047726755486945696a47796549307851427533253242314d63313279474e64253246414e67526d47327a6d632532464f6f50594441594f6a376650532532465a37472532464f31486a326b4a6b714f4177694550416e4e6d316430484c6957596c61427375664356583838734b58435a7444566b6c76386b69634e756868315547625844527550463570643979794c65722532426b6d4e6b37444c7252436642253242713757755a71756c316d54426d25324250316c427851374948684d4e72503130376b6e6152456f7578356d436f56306563253246322532464a4f473074624c514e25324258313076253242797538685a395a37325525324231573463532532425032314667526b6c757125324243365a5a545061566e6633384847377262653725324654556878514e752532424d565041515941714e56596c616f25324255553841414141415355564f524b3543594949253344)](https://cloud.githubusercontent.com/assets/1573211/18808259/a283d596-828f-11e6-8810-4a2e16d5e319.jpg)

**Alipay driver for the Omnipay PHP payment processing library**

[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP. This package implements Alipay support for Omnipay.

> Cross-border Alipay payment please use [`lokielse/omnipay-global-alipay`](https://github.com/lokielse/omnipay-global-alipay)

> Legacy Version please use [`"lokielse/omnipay-alipay": "dev-legacy"`](https://github.com/lokielse/omnipay-alipay/tree/legacy)

Installation
------------

[](#installation)

Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it to your `composer.json` file:

```
"lokielse/omnipay-alipay": "^2.0",

```

And run composer to update your dependencies:

```
$ composer update -vvv

```

Basic Usage
-----------

[](#basic-usage)

The following gateways are provided by this package:

GatewayDescription说明 LinksAlipay\_AopPageAlipay Page Gateway电脑网站支付 - new[Usage](https://github.com/lokielse/omnipay-alipay/wiki/Aop-Page-Gateway) [Doc](https://doc.open.alipay.com/doc2/detail.htm?treeId=270&articleId=105901&docType=1)Alipay\_AopAppAlipay APP GatewayAPP支付 - new[Usage](https://github.com/lokielse/omnipay-alipay/wiki/Aop-APP-Gateway) [Doc](https://doc.open.alipay.com/docs/doc.htm?treeId=204&articleId=105051&docType=1)Alipay\_AopF2FAlipay Face To Face Gateway当面付 - new[Usage](https://github.com/lokielse/omnipay-alipay/wiki/Aop-Face-To-Face-Gateway) [Doc](https://doc.open.alipay.com/docs/doc.htm?treeId=194&articleId=105072&docType=1)Alipay\_AopWapAlipay WAP Gateway手机网站支付 - new[Usage](https://github.com/lokielse/omnipay-alipay/wiki/Aop-WAP-Gateway) [Doc](https://doc.open.alipay.com/docs/doc.htm?treeId=203&articleId=105288&docType=1)Alipay\_AopJsAlipay Js GatewayJSAPI - new[Usage](https://github.com/lokielse/omnipay-alipay/wiki/Aop-JS-Gateway) [Doc](https://myjsapi.alipay.com/jsapi/native/trade-pay.html)Alipay\_LegacyAppAlipay Legacy APP GatewayAPP支付[Usage](https://github.com/lokielse/omnipay-alipay/wiki/Legacy-APP-Gateway) [Doc](https://doc.open.alipay.com/doc2/detail?treeId=59&articleId=103563&docType=1)Alipay\_LegacyExpressAlipay Legacy Express Gateway即时到账[Usage](https://github.com/lokielse/omnipay-alipay/wiki/Legacy-Express-Gateway) [Doc](https://doc.open.alipay.com/docs/doc.htm?treeId=108&articleId=103950&docType=1)Alipay\_LegacyWapAlipay Legacy WAP Gateway手机网站支付[Usage](https://github.com/lokielse/omnipay-alipay/wiki/Legacy-WAP-Gateway) [Doc](https://doc.open.alipay.com/docs/doc.htm?treeId=60&articleId=103564&docType=1)Alipay\_OauthAlipay Oauth支付宝自动授权登陆Usage
-----

[](#usage)

### 支付宝自动登录

[](#支付宝自动登录)

```
/**
 *
 * @var \Omnipay\Alipay\OauthGateway $gateway
 */
$gateway = Omnipay::create("Alipay_Oauth");
$gateway->setSignType('RSA2'); // RSA/RSA2/MD5
$gateway->setAppId($this->getConfig("appId"));
$gateway->setPrivateKey($this->getConfig("privateKey"));
$gateway->setAlipayPublicKey($this->getConfig("alipayPublicKey"));

/**
 *
 * @var \Omnipay\Alipay\Requests\SystemOauthTokenRequest $request
 */
$request = $gateway->purchase();
if (! empty($refreshToken)) {
    $request->setRefreshToken($refreshToken);
} else {
    $request->setCode($code);
}
$response = $request->send();
if($response->isSuccessful()){
    return $response->getData();
}
return false;
```

### Purchase (购买)

[](#purchase-购买)

```
/**
 * @var AopAppGateway $gateway
 */
$gateway = Omnipay::create('Alipay_AopPage');
$gateway->setSignType('RSA2'); // RSA/RSA2/MD5
$gateway->setAppId('the_app_id');
$gateway->setPrivateKey('the_app_private_key');
$gateway->setAlipayPublicKey('the_alipay_public_key');
$gateway->setReturnUrl('https://www.example.com/return');
$gateway->setNotifyUrl('https://www.example.com/notify');

/**
 * @var AopTradePagePayResponse $response
 */
$response = $gateway->purchase()->setBizContent([
    'subject'      => 'test',
    'out_trade_no' => date('YmdHis') . mt_rand(1000, 9999),
    'total_amount' => '0.01',
    'product_code' => 'FAST_INSTANT_TRADE_PAY',
])->send();

$url = $response->getRedirectUrl();
```

### 支付宝sdk授权登陆签名

[](#支付宝sdk授权登陆签名)

```
$gateway = Omnipay::create("Alipay_Sdk");
$gateway->setSignType('RSA2');
$gateway->setAppId('the_app_id');
$gateway->setPid("parter_id");
$gateway->setAppId('the_app_id');
$gateway->setPrivateKey('the_app_private_key');
$gateway->setAlipayPublicKey('the_alipay_public_key');
$request = $gateway->purchase();
$data= $request->getData();
```

返回 { "apiname": "com.alipay.account.auth", "app\_id": "201510000934009", "app\_name": "mc", "auth\_type": "AUTHACCOUNT", "biz\_type": "openservice", "method": "alipay.open.auth.sdk.code.get", "pid": "208831001128084", "product\_id": "APP\_FAST\_LOGIN", "scope": "kuaijie", "sign\_type": "RSA2", "target\_id": "2018091018001867226", "sign": "BtAZTli9Lv7rRJxD14139v/5g0nCH1vIwn/1SsNQpL1FQrgLkizUeN/pwa5Dnmz5i0jV0Rbj3tKR4z1uxFojthIzum0gQ9TmaxZwNsOFfwg1JFoqAy41cOEHp9nnhDeDjr/SZa00BIPtjgN/pwcQhS6za/8xfiG8EAcjptjNsQTgKm2OcwOdcp7xjUBAqk49feJ+PRVxmQ1+XVjyRs+QkI4CFLh1aDl59vYZkHJKP9Y7NnSn18aX66PtQ5+B9v2L34pV+E9uly3f3tTHl/2SSI9NRFgCQxukHWwTGa7LmDjo16/jaUymGiMVDHO/Hz1zH6K4KAbs+qTLWLCaHEVBTw==" }

For general usage instructions, please see the main [Omnipay](https://github.com/omnipay/omnipay)repository.

Related
-------

[](#related)

- [Laravel-Omnipay](https://github.com/ignited/laravel-omnipay)
- [Omnipay-GlobalAlipay](https://github.com/lokielse/omnipay-global-alipay)
- [Omnipay-WechatPay](https://github.com/lokielse/omnipay-wechatpay)
- [Omnipay-UnionPay](https://github.com/lokielse/omnipay-unionpay)

Support
-------

[](#support)

If you are having general issues with Omnipay, we suggest posting on [Stack Overflow](http://stackoverflow.com/). Be sure to add the [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which you can subscribe to.

If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/lokielse/omnipay-alipay/issues), or better yet, fork the library and submit a pull request.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~173 days

Total

4

Last Release

2400d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ba50770ab3b983b6876cc5d96fb7915f8f1ff6efeb560de643d7c6948aa8f56?d=identicon)[wcj343169893](/maintainers/wcj343169893)

---

Top Contributors

[![wcj343169893](https://avatars.githubusercontent.com/u/502789?v=4)](https://github.com/wcj343169893 "wcj343169893 (7 commits)")

---

Tags

paymentgatewaypaymerchantomnipaypurchasealipay

### Embed Badge

![Health badge](/badges/mofing-omnipay-alipay/health.svg)

```
[![Health](https://phpackages.com/badges/mofing-omnipay-alipay/health.svg)](https://phpackages.com/packages/mofing-omnipay-alipay)
```

###  Alternatives

[lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

587421.0k11](/packages/lokielse-omnipay-alipay)[lokielse/omnipay-global-alipay

Alipay global gateway for Omnipay payment processing library

3048.9k](/packages/lokielse-omnipay-global-alipay)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
