|
|
@@ -20,6 +20,7 @@ import ( |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
"github.com/go-pay/gopay" |
|
|
|
"github.com/jinzhu/copier" |
|
|
|
"net/url" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
@@ -412,8 +413,7 @@ func LaunchBindAlipayAccount(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var alipayStruct *alipay.InitAlipayStruct |
|
|
|
client, err := alipay.InitAlipay(alipayStruct) |
|
|
|
client, err := alipay.InitAlipay(nil) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
@@ -421,9 +421,12 @@ func LaunchBindAlipayAccount(c *gin.Context) { |
|
|
|
appId := client.AppId |
|
|
|
redirectUri := req.RedirectUri |
|
|
|
scope := "auth_user" |
|
|
|
url := fmt.Sprintf("https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=" + appId + "&scope=" + scope + "&redirect_uri=" + redirectUri) |
|
|
|
|
|
|
|
e.OutSuc(c, url, nil) |
|
|
|
reqUrl := fmt.Sprintf("https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=%s&scope=%s&redirect_uri=%s", appId, scope, redirectUri) |
|
|
|
reqUrl = url.QueryEscape(reqUrl) |
|
|
|
res := "alipays://platformapi/startapp?appId=20000067&url=" + reqUrl |
|
|
|
|
|
|
|
e.OutSuc(c, res, nil) |
|
|
|
} |
|
|
|
|
|
|
|
// BindAlipayAccount |
|
|
@@ -456,7 +459,7 @@ func BindAlipayAccount(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var bm gopay.BodyMap |
|
|
|
bm := make(gopay.BodyMap) |
|
|
|
bm = bm.Set("grant_type", "authorization_code") |
|
|
|
bm = bm.Set("code", req.AuthCode) |
|
|
|
|
|
|
|