glhcp/server/vendor/alipaysdk/easysdk/go/README.md

91 lines
3.0 KiB
Java
Raw Blame History

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.

[![Latest Stable Version](https://poser.pugx.org/alipaysdk/easysdk/v/stable)](https://packagist.org/packages/alipaysdk/easysdk)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Falipay%2Falipay-easysdk.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Falipay%2Falipay-easysdk?ref=badge_shield)
使 Alipay **Easy** SDK for Go
Alipay Esay SDK for Go访SDKHTTP
Alipay Easy SDK for Go 使
##
Alipay Easy SDK****
##
1. Alipay Easy SDK for Go `Go 1.12`
2. 使 Alipay Easy SDK for Go [-](https://openhome.alipay.com/platform/developerIndex.htm)完成开发者接入的一些准备工作,包括创建应用、为应用添加功能包、设置应用的接口加签方式等。
3. 使SDK
*
`AppId`````````
*
`AppId`````
##
go
## 使
使Alipay Easy SDK for GoAPI3
1.
2. API
3.
```go
package main
import (
"encoding/json"
"fmt"
"kernel"
"time"
)
func init() {
account:= kernel.Client{}
account.Protocol = "https"
account.GatewayHost = "openapi.alipay.com"
account.AppId = "<-- 请填写您的AppId例如2019022663440152 -->"
account.SignType = "RSA2"
account.AlipayPublicKey = "<-- 请填写您的支付宝公钥例如MIIBIjANBg... -->"
account.MerchantPrivateKey = "<-- 请填写您的应用私钥例如MIIEvQIBADANB ... ... -->"
kernel.InitClient(account)
}
func main() {
result, _ := kernel.Execute("alipay.trade.create", nil, getBizParams(time.Now().Format("2006-01-02 15:04:05")))
fmt.Println(result)
}
func getBizParams(outTradeNo string) map[string]string {
bizParams := map[string]string{
"subject": "phone6 16G",
"out_trade_no": outTradeNo,
"total_amount": "0.10",
"buyer_id": "2088002656718920",
"extend_params": getHuabeiParams(),
}
return bizParams
}
func getHuabeiParams() string {
extendParams := map[string]string{
"hb_fq_num": "3",
"hb_fq_seller_percent": "3",
}
byt, _ := json.Marshal(extendParams)
return string(byt)
}
```
##
[Alipay Easy SDK](./../README.md)