From 675a6e42fbef1df71bdf2a5c252a8af98078bea7 Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Mon, 27 May 2024 09:55:23 +0800 Subject: [PATCH] yeepay --- etc/mix/mix-test.yaml | 9 ++++++++- library/configcenter/configcenter.go | 10 +++++----- library/payclients/yeepaycli/client.go | 5 ++++- library/payclients/yeepaycli/client_test.go | 9 +++++---- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/etc/mix/mix-test.yaml b/etc/mix/mix-test.yaml index baf3238b..d5f6230d 100644 --- a/etc/mix/mix-test.yaml +++ b/etc/mix/mix-test.yaml @@ -143,4 +143,11 @@ elastic_search: uri: "http://127.0.0.1:9200" username: "elastic" password: "Wishpal@2024" - sniff: false \ No newline at end of file + sniff: false + +yeepay: + appid: "app_10090316660" + parent_merchant_no: "10090316660" + merchant_no: "10090326142" + notify_url: "https://testapi.tiefen.fun/ext/vas/yeepay_callback" + private_key: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC8Zfd0RVnpmPuodc0N8XLLI8DWT4hTAyOlwbE5LLiiguG5W0AghvddreO73T51BGK4V05Taxdpv7j7KNl39OUzKA0tpmoLwC4f6II1Op4tY05NnUgOFbno01vE7cN5BWLwVA35dfgQm1jtzXECdTufavYH/qPCzpvd7OTbmdHonMVjanjz+XOfnFowxq8ap3F63ocF4LR3KalsC/cTvW7LYnendjjiFGbMm7DlLEUtHRZ0EzrmM6SVxXRcibKZd7Dy6QpNXLu615cJLui6eS/zmxG2pUoNI31ajh+ZybZ61/Lwsq3JylmXHoSu1WkydfHnIEbr1PasaoD//7BzySQzAgMBAAECggEAFZoRehT7nsPKU0ISnX8qXO2ADnK3HGGXREnFwtsEXqnoLOMwIqqnEWg/XQqcvzkeAqoMEpeMazUvBilkahM79pYokKvsq+VAxKrZxzWt7mFdGJwop2jJVM9rTdS/XZCHDCxvH8PtiiXt1/J++zuq9vgCNt91MoCTMaqYgS+NeIDS0UaNQ6AcwFqyY8XUUXe6phCr2NC9iyOeTXE4HhfuoNJd/H8zmVOYkrfzgYLU/uHhfskGFhCDIO/V3yxZy7K7Z74ECOifGNpH/QV7vK4OHI+2DEOAS0E8G2jNGR67OpmbM7Jgw/8k7xl9sB18zS+Eor1BsnIM8MKSR4ss624NEQKBgQDpwHa21ESDfjYBiDh8MhLnNPzIHHozIIimXd4o36nBgGqH8ciblSWg5KPZmL2U3rVucd6TF0qXZlX6FlsGfp6poKiRMyl8Knc3j3KiyAdpyP9k26ifve4YquOkhNMOaVqO5YJpmfVEppsWy2wA2p3USYecAhHc7KDTlz2TLhT80QKBgQDOVG5dosS/4AJQ4AKE5hd5d7qJfo/VeNx6i4MtMJ4IznO6IE2O1oHuUQOr+6n3QvIGhe1J3Tt8+rv7j1Wp3y16dAPxWJblPCYWw+a6wkNY5ByMeaMzvvLqU/WdyEQzAE7yUPBfxMuhZDEp3ndK/PVVqjR6NPDJ+Dhcel9ntMPBwwKBgFa7WBEcj9NueCF3ZuYGOmdZjNW/Y0QnNSzttWnbG4S13lFU0EeSPqUFURqDBwz+2bkCPUC8qqukiBBETUAKqVptRz6hCiqNIzEVY8asi7ufncvRiS7EbVzvw4me0yUMyFIvLIV8X7o6S19Y2VkzxM4o/k1Po0si7cW0318GATmRAoGBAJD4M79ooPLr0tS+QCbef/nhjNgUa70iuU8E/TrgIPmxDRDmp3fH8ezfUUQig+5uRB0fNnUikyyiAziiIh9D5vFV2HtXslYIZ/6w0EnCOo2XYRO2V1wBOy43paih0IFBIzcQdYPkguq3ue9gFtNCXqI8/7gpwFE4LWmUtbnpAW3/AoGAW9ma4+4+QfGOGb9N38IyzHcXiyAkteQMX72Hxb0HK+nz9QwGXObqFvwnJ7IV8aJ0ZAUGDUfTToorNRSnmPdnq4BG5uKisIONp5pe0ZchlhXAEgKZnCgVmrEHgtzv3U8ffOfbNjoTufI/ZZoyl+7Kr1+o32VikquuMxeNpR9T6Fw=" diff --git a/library/configcenter/configcenter.go b/library/configcenter/configcenter.go index 2681664d..ffa6284c 100644 --- a/library/configcenter/configcenter.go +++ b/library/configcenter/configcenter.go @@ -175,11 +175,11 @@ type ElasticSearchConfig struct { // 易宝支付配置 type YeepayClientConfig struct { - Appid string `json:"appid" yaml:"appid"` // 商户id - ParentMerchantNo string `json:"parent_merchant_no"` // 父商编 系统商或平台商场景下为主商户商户编号,否则为收单商户编号 - MerchantNo string `json:"merchant_no"` // 子商编 收单商户商编 - NotifyUrl string `json:"notify_url"` // 回调通知 - PrivateKey string `json:"private_key"` // 私钥 + Appid string `json:"appid" yaml:"appid"` // 商户id + ParentMerchantNo string `json:"parent_merchant_no" yaml:"parent_merchant_no"` // 父商编 系统商或平台商场景下为主商户商户编号,否则为收单商户编号 + MerchantNo string `json:"merchant_no" yaml:"merchant_no"` // 子商编 收单商户商编 + NotifyUrl string `json:"notify_url" yaml:"notify_url"` // 回调通知 + PrivateKey string `json:"private_key" yaml:"private_key"` // 私钥 } func LoadConfig(configFilePath string, cfg interface{}) error { diff --git a/library/payclients/yeepaycli/client.go b/library/payclients/yeepaycli/client.go index 1966ac27..1668f174 100644 --- a/library/payclients/yeepaycli/client.go +++ b/library/payclients/yeepaycli/client.go @@ -7,7 +7,9 @@ import ( "github.com/yop-platform/yop-go-sdk/yop/request" "github.com/yop-platform/yop-go-sdk/yop/response" "net/http" + "service/bizcommon/util" "service/library/configcenter" + "service/library/logger" "time" ) @@ -71,7 +73,7 @@ func (c *YeepayClient) AggPay(ctx context.Context, param *AggPayParam) (resp *re req.AddParam("merchantNo", c.MerchantNo) req.AddParam("orderId", param.OutTradeNo) req.AddParam("orderAmount", float64(param.TotalAmount)/100.0) - req.AddParam("expiredTime", time.Now().Add(DefaultOrderTimeoutSeconds).Format("2006-01-02 15:04:05")) + req.AddParam("expiredTime", time.Unix(time.Now().Unix()+DefaultOrderTimeoutSeconds, 0).Format("2006-01-02 15:04:05")) req.AddParam("goodsName", param.Description) req.AddParam("notifyUrl", c.NotifyUrl) req.AddParam("payWay", param.PayWay) @@ -83,5 +85,6 @@ func (c *YeepayClient) AggPay(ctx context.Context, param *AggPayParam) (resp *re if err != nil { return } + logger.Info("yeepay AggPay param: %v, resp: %v", util.ToJson(req.Params), util.ToJson(resp)) return } diff --git a/library/payclients/yeepaycli/client_test.go b/library/payclients/yeepaycli/client_test.go index aeb543e2..1c1b54b4 100644 --- a/library/payclients/yeepaycli/client_test.go +++ b/library/payclients/yeepaycli/client_test.go @@ -13,8 +13,8 @@ func TestInit(t *testing.T) { Appid: "app_10090316660", ParentMerchantNo: "10090316660", MerchantNo: "10090326142", - NotifyUrl: "xx", - PrivateKey: "MIIEpAIBAAKCAQEA0OBsOyM4MpvXew772Fn590K2qQoAJJw46OR+qz5ZqaWtLk98lM/44T7SEul/yNMcP9gg/Zy//rjYjw6QTWI3whK+qlbV+IMbxNEzKN18kJLtvbnglAFesls/TmwZRna8Sv7inelaSYDKDWq73Ny8ZkUth4TF96QO+JiSRZlcuKVBmWAgym7e+aFPWpYP1EeqQIJxYFGH5BMVJFe35VN7xBQOefbwe6NUZBye/2IN6rn/jUrx3M48Mnkcji713BztE98R4Ix+3Pc7ZhrwQaQASJnRJJKQjUsXWBnVc41EUGp5v5DYqNwDX9mnShw8Kn+2GfZdg5pC/AtEqyJfDf/V0QIDAQABAoIBAAz0b/htABSXeNJfkaKPotxa+jRBJztRQYnxETzyuLuEx7+j222C+dDFxWBTgU+5B25oRVRYqMnJUiXxRWVSe0EH45gLm0+QZiQ0+DZt7xNfOx9b/3NLVttUcHhr/1dQ9u9NBrLvlBN5/IFZIAscDHobvhRCv/qF5ado4xP6mPcbE0XO+RLRcBQYbOlkr7l84GrDc+jrmU9hIRQDyuUYEoFyApcWi2HdDU3YiVLcmT7JMev8AazYU4P7bWYg4WKkPE+/9wk2kxMOnv3IGQ8Q4taHVxhTITswVXhRBhSJqSvac+GHA9KGSmT+KkNrNRgCfVZ0xAnOha33dsvhGw7WdKcCgYEA8nCnA7JksP+VEj7QtzqQ9UXXyZwSNwkWpVP4mvi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ooPLr0tS+QCbef/nhjNgUa70iuU8E/TrgIPmxDRDmp3fH8ezfUUQig+5uRB0fNnUikyyiAziiIh9D5vFV2HtXslYIZ/6w0EnCOo2XYRO2V1wBOy43paih0IFBIzcQdYPkguq3ue9gFtNCXqI8/7gpwFE4LWmUtbnpAW3/AoGAW9ma4+4+QfGOGb9N38IyzHcXiyAkteQMX72Hxb0HK+nz9QwGXObqFvwnJ7IV8aJ0ZAUGDUfTToorNRSnmPdnq4BG5uKisIONp5pe0ZchlhXAEgKZnCgVmrEHgtzv3U8ffOfbNjoTufI/ZZoyl+7Kr1+o32VikquuMxeNpR9T6Fw=", } Init(cfg) @@ -25,8 +25,9 @@ func TestInit(t *testing.T) { TotalAmount: 100, RedirectUrl: "", PayWay: "H5_PAY", - PayChannel: "WECHAT", - Ip: "127.0.0.1", + //PayChannel: "WECHAT", + PayChannel: "ALIPAY", + Ip: "127.0.0.1", } resp, err := c.AggPay(context.Background(), param) t.Log(util.ToJson(param))