|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- package test
-
- import (
- fb "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/fb_pay"
- zhios_pay_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/utils"
- "testing"
- "time"
- )
-
- func TestFBPayUnification(t *testing.T) {
- unification := fb.GetUnificationByVendorSn("2022120518415543840a")
- var ordCreat fb.OrderCreateParameters
- ordCreat.OrderCreateMustParameters.MerchantOrderSn = "202212061833-01"
- ordCreat.OrderCreateMustParameters.TotalAmount = 0.1
- ordCreat.OrderCreateMustParameters.PayType = "alipay"
- ordCreat.OrderCreateMustParameters.UserId = "userid"
- ordCreat.OrderCreateMustParameters.MerchantId = 1979251
- unification.Nonce = ordCreat.OrderCreateMustParameters.MerchantOrderSn + time.Now().Format("20060102150405")
- param := zhios_pay_utils.Struct2Map(ordCreat)
- for key, value := range param {
- if value == "" {
- delete(param, key)
- }
- }
- unification.SetBizContent(param)
- unification.SetSign("c5d47b9e515594313d80fb9903ece2d8")
- send, err := unification.Send(false)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调数据:%s\n", send)
- }
-
- func TestFBPayOrderQrcode(t *testing.T) {
- unification := fb.GetOrderQrcodeByVendorSn("2022120518415543840a")
- var orderQrcode fb.OrderQrcodeParameters
- orderQrcode.OrderQrcodeMustParameters.MerchantOrderSn = "20221208-02"
- orderQrcode.OrderQrcodeMustParameters.TotalAmount = 0.1
- orderQrcode.OrderQrcodeMustParameters.PayType = "alipay"
- orderQrcode.OrderQrcodeMustParameters.StoreId = 1331462
- unification.Nonce = orderQrcode.OrderQrcodeMustParameters.MerchantOrderSn + time.Now().Format("20060102150405")
- param := zhios_pay_utils.Struct2Map(orderQrcode)
- for key, value := range param {
- if value == "" {
- delete(param, key)
- }
- }
- unification.SetBizContent(param)
- unification.SetSign("c5d47b9e515594313d80fb9903ece2d8")
- send, err := unification.Send(false)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调数据:%s\n", send)
- }
-
- func TestFBPayOrderWxconfig(t *testing.T) {
- requestParameters := fb.GetRequestParametersByVendorSn("2022120518415543840a")
- requestParameters.Method = "fbpay.order.wxconfig"
- requestParameters.SignMethod = "md5"
- requestParameters.Nonce = time.Now().Format("20060102150405")
- param := make(map[string]interface{})
- param["merchant_id"] = 1979251
- param["store_id"] = 1331462
- param["sub_appid"] = "wx43207c79f84a14ca"
- param["account_type"] = "01"
- for key, value := range param {
- if value == "" {
- delete(param, key)
- }
- }
- requestParameters.SetBizContent(param)
- requestParameters.SetSign("c5d47b9e515594313d80fb9903ece2d8")
- send, err := requestParameters.Send(false)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调数据:%s\n", send)
- }
-
- func TestFBAccreditQuery(t *testing.T) {
- requestParameters := fb.GetRequestParametersByVendorSn("2022120518415543840a")
- requestParameters.Method = "openapi.share.accredit.query"
- requestParameters.SignMethod = "md5"
- requestParameters.Nonce = time.Now().Format("20060102150405")
- param := make(map[string]interface{})
- param["merchant_id"] = 1989190
- for key, value := range param {
- if value == "" {
- delete(param, key)
- }
- }
- requestParameters.SetBizContent(param)
- requestParameters.SetSign("c5d47b9e515594313d80fb9903ece2d8")
- send, err := requestParameters.Send(false)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调数据:%s\n", send)
- }
-
- func TestFBAccountOrderSwitch(t *testing.T) {
- requestParameters := fb.GetRequestParametersByVendorSn("2022120518415543840a")
- requestParameters.Method = "openapi.agent.account.order.switch"
- requestParameters.SignMethod = "md5"
- requestParameters.Nonce = time.Now().Format("20060102150405")
- param := make(map[string]interface{})
- param["merchant_id"] = 1989190
- param["state"] = 1
- param["share_percent"] = 60
- for key, value := range param {
- if value == "" {
- delete(param, key)
- }
- }
- requestParameters.SetBizContent(param)
- requestParameters.SetSign("c5d47b9e515594313d80fb9903ece2d8")
- send, err := requestParameters.Send(false)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调数据:%s\n", send)
- }
-
- func TestFBMerchantIncomeSuccess(t *testing.T) {
- requestParameters := fb.GetRequestParametersByVendorSn("2022120518415543840a")
- requestParameters.Method = "openapi.merchant.income.status.query"
- requestParameters.SignMethod = "md5"
- requestParameters.Nonce = time.Now().Format("20060102150405")
- param := make(map[string]interface{})
- param["merchant_code"] = "139334168531126"
- for key, value := range param {
- if value == "" {
- delete(param, key)
- }
- }
- requestParameters.SetBizContent(param)
- requestParameters.SetSign("c5d47b9e515594313d80fb9903ece2d8")
- send, err := requestParameters.Send(false)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调数据:%s\n", send)
- }
-
- func TestFBUrlSet(t *testing.T) {
- requestParameters := fb.GetRequestParametersByVendorSn("2022120518415543840a")
- requestParameters.Method = "fbpay.pay.callback.config"
- requestParameters.SignMethod = "md5"
- requestParameters.Nonce = time.Now().Format("20060102150405")
- param := make(map[string]interface{})
- param["second_callback_url"] = "http://api.zhiyingos.com/api/v1/comm/pay/fb/callback"
- for key, value := range param {
- if value == "" {
- delete(param, key)
- }
- }
- requestParameters.SetBizContent(param)
- requestParameters.SetSign("c5d47b9e515594313d80fb9903ece2d8")
- send, err := requestParameters.Send(false)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调数据:%s\n", send)
- }
|