go-pay / gopay Goto Github PK
View Code? Open in Web Editor NEW微信、支付宝、通联支付、拉卡拉、PayPal、Apple 的Go版本SDK。【极简、易用的聚合支付SDK】
Home Page: https://github.com/go-pay/gopay
License: Apache License 2.0
微信、支付宝、通联支付、拉卡拉、PayPal、Apple 的Go版本SDK。【极简、易用的聚合支付SDK】
Home Page: https://github.com/go-pay/gopay
License: Apache License 2.0
方法内部把值写死了,沙箱不好验签。另外getSanBoxKey方法考虑公开不呢
verify sign error: crypto/rsa: verification error
notifyReq, err := wechat.ParseNotifyToBodyMap(ctx.Request)
// 验签操作
ok, err := wechat.VerifySign(apiKey, wechat.SignType_MD5, notifyReq)
log.Println(ok) // false
log.Println(err) //
这是什么操作??????
你好,我看到4月25日更新时
type NotifyRequest struct
被标记为弃用,想了解下原因.
支付宝一些接口还支持MD5的签名方式,后续版本会集成进来吗?
更新了版本,发现grpc冲突了,虽然可以replace解决,但还是以前的清爽
https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3
企业给个人付款之后的查询接口没找到,还有App登录是GetAppLoginAccessToken 这个接口,但是没发现有App获取用户信息的
不知道能加上吗
现在证书内容是接受文件路径,现在怎么接受文件内容?
另外,p12和 cert/key 这两个能二选一传递吗?
版本:v1.5.14 - v1.5.16
测试发现client.AddCertFilePath()
方法没有生效;
目前只能在client.Refund()
中传入证书地址才有效;
/root/go/pkg/mod/github.com/i!google-ink/[email protected]/xlog/debug_logger.go:27:58: undefined: log.Lmsgprefix
body := make(gopay.BodyMap)
body.Set("grant_type", "authorization_code")
body.Set("code", authCode)
//发起请求
aliRsp, err := client.SystemOauthToken(body)
if err != nil {
fmt.Println("err:", err)
}
fmt.Println(aliRsp)
通过其它sdk 测试参数没有错误,生成签名的时候报错
报错
err: asn1: structure error: tags don't match (2 vs {class:0 tag:16 length:13 isCompound:true}) {optional:false explicit:false application:false private:false defaultValue: tag: stringType:0 timeType:0 set:false omitEmpty:false} @5
异步通知字段"voucher_detail_list"含有"voucherId",怀疑是未解析出该字段,导致验签失败。
error: crypto/rsa: verification error
asn1: structure error: tags don't match (2 vs {class:0 tag:16 length:13 isCompound:true}) {optional:false explicit:false application:false private:false defaultValue: tag: stringType: 0 timeType: 0 set: false omitEmpty:false} @5asn1: structure error: tags don't match (2 vs {class:0 tag:16 length:13 isCompound:true}) {optional:false explicit:false application:false private:false defaultValue: tag: stringType: 0 timeType: 0 set: false omitEmpty:false} @5
有时可以,有时错误,错误提示:json.Marshal(�� Q ˮ ń Ӈ , }��2W +q�$?ɘ ʏ j q/ ԁX G i| : p � (ӵ& b x06�ܵr\ Hü /R ↵ 6y +we . G (| f ' �3 V? ��' �� o1 9Cx X ���Qw):invalid character '\x1f' looking for beginning of value,错误信息一串乱码,invalid character '\x1f'单引号里的值是变化的。这是什么原因?
后端验证是http直接将请求转发至grpc服务,因此这个方法使用不方便,希望能新增一个方法,传入解析好的url.Values
我都没办法在别的结构体引用这个client了。
参考文档:
微信签名算法
签名生成的通用步骤如下:
第一步,设所有发送或者接收到的数据为集合M,将集合M内非空参数值的参数按照参数名ASCII码从小到大排序(字典序),使用URL键值对的格式(即key1=value1&key2=value2…)拼接成字符串stringA。
特别注意以下重要规则:
◆ 参数名ASCII码从小到大排序(字典序);
◆ 如果参数的值为空不参与签名;
◆ 参数名区分大小写;
◆ 验证调用返回或微信主动通知签名时,传送的sign参数不参与签名,将生成的签名与该sign值作校验。
◆ 微信接口可能增加字段,验证签名时必须支持增加的扩展字段
第二步,在stringA最后拼接上key得到stringSignTemp字符串,并对stringSignTemp进行MD5运算,再将得到的字符串所有字符转换为大写,得到sign值signValue。
证书内容不是文件,是保存在数据库的内容,希望尽快支持下,非常感谢
在SystemOauthToken 换取授权访问令牌那发现几个问题。选择的加签模式是公钥证书模式,没加app_cert_sn和alipay_root_cert_sn字段通不过验签.最后return没返回值报错.报错不提示rsp.ErrorResponse.SubMsg里面的报错信息问题.没判断是否请求成功就返回rsp
想请教一下,为什么有部分接口直接返回参数呢?
alipay/client.go:687
doAliPay
// ...
switch method {
case "alipay.trade.app.pay":
return []byte(param), nil
case "alipay.trade.wap.pay", "alipay.trade.page.pay", "alipay.user.certify.open.certify":
if !a.IsProd {
return []byte(sandboxBaseUrl + "?" + param), nil
}
return []byte(baseUrl + "?" + param), nil
default:
httpClient := xhttp.NewClient()
// ...
在这里针对固定的几个接口,直接返回了参数,而默认的 default 是会请求支付宝的。
https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=4_3
官方文档只有php需要两个证书,其他语言只要.p12格式的证书就行了,这要怎么做?
希望作者补全苹果支付和谷歌支付
type authTokenAppResponse struct {
Code string `json:"code,omitempty"`
Msg string `json:"msg,omitempty"`
SubCode string `json:"sub_code,omitempty"`
SubMsg string `json:"sub_msg,omitempty"`
UserId string `json:"user_id,omitempty"`
AuthAppId string `json:"auth_app_id,omitempty"`
AppAuthToken string `json:"app_auth_token,omitempty"`
AppRefreshToken string `json:"app_refresh_token,omitempty"`
ExpiresIn string `json:"expires_in,omitempty"`
ReExpiresIn string `json:"re_expires_in,omitempty"`
Tokens []*struct {
AppAuthToken string `json:"app_auth_token,omitempty"`
AppRefreshToken string `json:"app_refresh_token,omitempty"`
AuthAppId string `json:"auth_app_id,omitempty"`
ExpiresIn string `json:"expires_in,omitempty"`
ReExpiresIn string `json:"re_expires_in,omitempty"`
UserId string `json:"user_id,omitempty"`
} `json:"tokens,omitempty"`
}
这里面的ExpiresIn 好像都是int类型,或者有没有办法强制转成string
现在VerifyAliPaySign都是直接用AliPayPublicKey字符串来做验签的,没有通过crt文件来验签。
crt文件读出来的SN字符怎么来做验签?您有空加一下?我自己也看看怎么搞。
go: downloading github.com/iGoogle-ink/gopay v1.5.22
verifying github.com/flosch/pongo2/[email protected]: checksum mismatch
downloaded: h1:6eZe8NSNxtTTGwXgJqqXiiLEDAj7CvkwiYrZFQRW6cQ=
go.sum: h1:89EuG/yHG6NE7KFmeg5GwnHYiiPQQXA1SGr12O9umVE=
SECURITY ERROR
其他API也缺少这2个字段
body中有数据,但ParseNotify会解析错误xml.NewDecoder.Decode:EOF,ParseNotifyToBodyMap则是xml.Unmarshal err
hi, 微信支付返回客户端需要返回sign,生成sign的方法没法引用呢
bm.Set("trade_type", gopay.TradeType_Mini)
支付宝支付回调验签,验证失败,报错信息:crypto/rsa: verification error,出现三次。偶现。发现一个客户 两个订单都出现了这种情况。
body.Set("out_biz_no", out_biz_no)
body.Set("payee_type", "ALIPAY_LOGONID")
e.g.
func (bm BodyMap) Set(key string, value interface{}) BodyMap {
...
return bm
}
body.Set("out_biz_no", out_biz_no).Set("payee_type", "ALIPAY_LOGONID")
在沙箱环境下用微信支付接口签名校验工具测得sign匹配不一致
cannot unmarshal number into Go struct field oauthTokenInfo.alipay_system_oauth_token_response.expires_in of type string
var client = alipay.NewClient(fmt.Sprintf("%d", appId), privateKey, true).SetNotifyUrl("XXXXX")
func ParseNotifyAndVerifySign(req *http.Request) (bool, *webHook) {
// 解析请求参数
bm, err := alipay.ParseNotifyToBodyMap(req)
if err != nil {
fmt.Println("err:", err)
return false, nil
}
fmt.Println("notifyReq:", bm)
// 验签
ok, err := alipay.VerifySign(publicKey, bm)
if err != nil || !ok {
fmt.Println("err:", err)
return false, nil
}
log.Println("支付宝验签是否通过:", ok)
……
}
请问问题出在哪里呢
希望增加服务商模式,谢谢
不兼容的更改最好安装go module规则来
不兼容更新,需要升级大版本号
如题
原因是NotifyRequest缺少
支付宝回调貌似没有哦
如题,希望能增加一个 debug 开关,在开发阶段方便打印提交到接口的原始数据,还有响应的原始数据
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.