mo fing / omnipay-alipay
用于 Omnipay 支付处理库的支付宝网关
Requires
- omnipay/common: ~2.0
Requires (Dev)
- omnipay/tests: ~2.0
This package is auto-updated.
Last update: 2024-09-17 21:21:15 UTC
README
Omnipay PHP 支付处理库的支付宝驱动程序
Omnipay 是一个不依赖于框架、多网关的 PHP 支付处理库。本包实现了 Omnipay 的支付宝支持。
跨境支付宝支付请使用
lokielse/omnipay-global-alipay
安装
Omnipay 通过 Composer 安装。要安装,只需将其添加到您的 composer.json
文件中
"lokielse/omnipay-alipay": "^2.0",
然后运行 composer 更新您的依赖关系
$ composer update -vvv
基本用法
本包提供以下网关
用法
支付宝自动登录
/** * * @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;
购买(购买)
/** * @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 授权登录签名
$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==" }
有关一般使用说明,请参阅主要的 Omnipay 仓库。
相关
支持
如果您遇到 Omnipay 的一般问题,我们建议在 Stack Overflow 上发布。确保添加 omnipay 标签,以便易于找到。
如果您想了解发布公告、讨论项目想法或提出更详细的问题,还有一个您可订阅的 邮件列表。
如果您认为您已发现一个错误,请使用 GitHub 问题跟踪器 报告,或者更好的方法是分叉库并提交一个拉取请求。