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.
37 lines
862 B
37 lines
862 B
# 支付
|
|
|
|
### 支付宝支付
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"git.oa00.com/go/alipay"
|
|
"github.com/smartwalle/alipay/v3"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
// 初始化配置
|
|
if err := pay.InitAlipay(pay.AlipayConfig{
|
|
AppId: "appId",// appId
|
|
PrivateKey: "privateKey",// 商户私钥
|
|
AliPublicKey: "aliPublicKey",// 支付宝公钥
|
|
IsProduction: isProduction,// 是否线上环境
|
|
}); err != nil {
|
|
log.Panicln("支付宝支付错误:", err)
|
|
}
|
|
|
|
// app支付
|
|
param := alipay.TradeAppPay{}
|
|
param.OutTradeNo = "payNo"
|
|
param.TotalAmount = "0.01"
|
|
param.Subject = "subject"
|
|
param.TimeExpire = time.Now().Add(time.Minute * time.Duration(15)).Format("2006-01-02 15:04:05")
|
|
param.NotifyURL = "notifyURL"
|
|
result, err := pay.Alipay.TradeAppPay(param)
|
|
log.Println(result, err)
|
|
|
|
// 详细使用文档见 https://github.com/smartwalle/alipay
|
|
}
|
|
``` |