SuperCLine

Every Morning Tell Yourself That You Are Getting More And More Better!

GO微信小程序登录和支付


本文仅适用于微信小程序登录、支付golang服务器实现,而通用golang支付实现(支付宝、微信)请看另一篇。

一、微信开发文档

二、微信管理后台业务

  1. APPID、APPSECRET用于登录获取openid、sessionkey,其中openid用于支付API
  2. 开发配置小程序服务器域名和端口(eg: https://supercline.com:8090),如下图

三、HTTPS证书

# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650

四、源码

wxpay_payconfig.go 支付配置模块

wxpay_util.go 支付通用模块

wxpay_paydata.go 支付通信数据模块

wxpay_payapi.go 支付API模块

wxpay_payclient.go 与微信后台通信模块

以上模块构成go支付SDK

wxpay_default_listener.go 支付回调监听

wxpay_default_service.go 基于支付SDK实现的默认支付服务

开发者可以根据以上模块实现自己的支付服务