You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
郭向斌 53c180105a
'init'
2 years ago
..
.idea 'init' 2 years ago
src 'init' 2 years ago
test 'init' 2 years ago
vendor 'init' 2 years ago
README.md 'init' 2 years ago
composer.json 'init' 2 years ago

README.md

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

alipay

===

支付宝支付

目前只支持支付宝的app唤起支付、回调、退款

安装

Composer

alipay采用composer进行安装要使用alipay功能只需要在composer.json中添加如下依赖

{
  "require": {
    "jucheng/alipay": "1.*"
  }
}

手动

  1. 手动下载或clone最新版本alipay代码
  2. 把alipay放入项目目录
  3. require alipay src目录下面的AlipayClient.php即可使用如把alipay放在当前目录下只需要:
require __DIR__ . "/alipay/src/AlipayClient.php";

用法

  • 准备必要参数
//AppID
$appid = 1400009099; 

// 用户私钥
$rsaPrivateKey = "用户私钥";

//支付宝公钥
$alipayrsaPublicKey="支付宝公钥";

//支付回调地址
$notifyUrl="https://www.baidu.com"

- **app唤起支付**

```php
use alipay;
$app_client=new alipay\AlipayClient($appid,$rsaPrivateKey,$alipayrsaPublicKey);
$data["total_amount"]="0.01";
$data["subject"]="预定酒店消费";
$data["out_trade_no"]="JD201909051809240201";
$data["product_code"]="QUICK_MSECURITY_PAY";
$result=$app_client->appPay($data,$notifyUrl);

Note 如需要自定义data参数 请查看支付宝官方文档 https://docs.open.alipay.com/api_1/alipay.trade.app.payNote 将$result传给手机端唤起支付。

  • 回调参数验签
use alipay;
$app_client=new alipay\AlipayClient($appid,$rsaPrivateKey,$alipayrsaPublicKey);
$flag = $app_client->rsaCheckV1($_POST, NULL, "RSA2");

Note 对$flag进行操作。

  • 退款
use alipay;
$app_client=new alipay\AlipayClient($appid,$rsaPrivateKey,$alipayrsaPublicKey);
$data["out_trade_no"]="JD201909051809240201";
$data["trade_no"]="2019090922001444760542604693";
$data["refund_amount"]="0.01";
$result=$app_client->refundOrder($data);

Note 退款是否成功对$result进行判断。

Note 所有方法错误码请以官方错误码为准 https://docs.open.alipay.com/api_1/alipay.trade.app.pay