|
|
@@ -1,4 +1,4 @@ |
|
|
|
package alipay |
|
|
|
package gopay |
|
|
|
|
|
|
|
import ( |
|
|
|
"applet/app/db" |
|
|
@@ -7,10 +7,10 @@ import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" |
|
|
|
"github.com/go-pay/gopay" |
|
|
|
"github.com/go-pay/gopay/alipay" |
|
|
|
"github.com/go-pay/xlog" |
|
|
|
"github.com/go-pay/gopay/pkg/xlog" |
|
|
|
) |
|
|
|
|
|
|
|
type InitStruct struct { |
|
|
|
type InitAlipayStruct struct { |
|
|
|
IsProd bool `json:"is_prod" label:"是否生产环境"` |
|
|
|
AlipayAppId string `json:"alipay_app_id" label:"支付宝商家应用appid"` |
|
|
|
AlipayPrivateKey string `json:"alipay_private_key" label:"支付宝商家应用私钥"` |
|
|
@@ -20,15 +20,15 @@ type InitStruct struct { |
|
|
|
AppPublicContent []byte `json:"app_public_content" label:"应用公钥证书"` |
|
|
|
} |
|
|
|
|
|
|
|
// Init 初始化支付宝客户端 |
|
|
|
// InitAlipay 初始化支付宝客户端 |
|
|
|
// appid:应用ID |
|
|
|
// privateKey:应用私钥,支持PKCS1和PKCS8 |
|
|
|
// isProd:是否是正式环境,沙箱环境请选择新版沙箱应用。 |
|
|
|
func Init(initData *InitStruct) (client *alipay.Client, err error) { |
|
|
|
func InitAlipay(initData *InitAlipayStruct) (client *alipay.Client, err error) { |
|
|
|
if initData == nil { |
|
|
|
sysCfgDb := implement.NewSysCfgDb(db.Db, cache.GetPool().Get()) |
|
|
|
sysCfgMap := sysCfgDb.SysCfgFindWithDb(enum.AlipayAppId, enum.AlipayPrivateKey, enum.AlipayPublicKey, enum.AlipayPublicContentRSA2, enum.AlipayRootContent, enum.AppPublicContent) |
|
|
|
initData = &InitStruct{ |
|
|
|
initData = &InitAlipayStruct{ |
|
|
|
IsProd: true, |
|
|
|
AlipayAppId: sysCfgMap[enum.AlipayAppId], |
|
|
|
AlipayPrivateKey: sysCfgMap[enum.AlipayPrivateKey], |