107 lines
3.7 KiB
Go
107 lines
3.7 KiB
Go
package paymentService
|
|
|
|
import (
|
|
"PaymentCenter/config"
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"github.com/qit-team/snow-core/kernel/server"
|
|
"github.com/qit-team/snow-core/log/logger"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestPsbcPay(t *testing.T) {
|
|
c := context.Background()
|
|
//解析启动命令
|
|
opts := config.GetOptions()
|
|
if opts.ShowVersion {
|
|
fmt.Printf("%s\ncommit %s\nbuilt on %s\n", server.Version, server.BuildCommit, server.BuildDate)
|
|
os.Exit(0)
|
|
}
|
|
|
|
//加载配置
|
|
opts.ConfFile = "../../../.env"
|
|
cf, err := config.Load(opts.ConfFile)
|
|
if err != nil {
|
|
return
|
|
}
|
|
//注册日志类服务
|
|
err = logger.Pr.Register(logger.SingletonMain, cf.Log, true)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
//data := `{"merchant_id": "your_merchant_id", "mcht_no": "your_mcht_no", "app_id": "your_app_id", "sop_public_key": "your_sop_public_key", "private_key": "your_private_key", "pubkey": "your_pubkey", "bank_key": "your_bank_key", "sha": "your_sha_key", "return_url": "https://example.com/return", "success_url": "https://example.com/success", "notify_url": "https://example.com/notify", "show_title_bar": "1", "login_host": "https://login.example.com", "order_host": "https://order.example.com", "file_host": "https://file.example.com", "shop_id": "your_shop_id"}`
|
|
|
|
psbc := PsbcPay{
|
|
MerchantId: "testMerchant001",
|
|
MchtNo: "100610100019042",
|
|
AppID: "961925472724332544001",
|
|
SopPublicKey: "04CABE03249C94BDC8A6A4440DA1B2ADFACF73F4340E5F1B9A76463694B44C2E5600A9BEAA035739383C292CF9F1C4695FAAC7963CD5033D5D647A6B1EBE78EC6A",
|
|
PrivateKey: "140c5c68da1829b79d8e4629a8b9548bd694ccc7061fbacb1079aed0e5ac33fa",
|
|
PrivateKeyCallback: "1F0E2F085955461A9B87820AFBD513712CAEA89687BE657DE4EC91613BE62D32",
|
|
Pubkey: "0447fe9ed13aac6200c92b893ad1289a98437c8404e64b1d2f7c755698a8b8e8acb35c1db2bedc5213c930bdfc10efb0e12269cf6a06877679f114fe5ae9dd4469",
|
|
BankKey: "04E0E2E37F11901483CDFBC47F489D87D5D78C55DD7F919B73DEA83007748668B7871A1BA9608F156E25B7D64C7821379BAC1E2C591D5A50FF311D1AAE026C1DAE",
|
|
Sha: "636879vrt96t57w6f59",
|
|
ReturnUrl: "http://milk.h5.test.86698.cn/#/pages/ycnc/order",
|
|
SuccessUrl: "http://milk.h5.test.86698.cn/#/pages/ycnc/orderDetail?isPayBack=true&order_no=",
|
|
NotifyUrl: "http://milk.test.api.cdlsxd.cn/api/v1/order/notify",
|
|
ShowTitleBar: "true",
|
|
LoginHost: "http://wap.dev.psbc.com/sop-h5/biz/crecard/",
|
|
OrderHost: "http://wap.dev.psbc.com/sop-h5/biz/unionpay/",
|
|
FileHost: "",
|
|
ShopId: "LSXD0001",
|
|
}
|
|
data, _ := json.Marshal(psbc)
|
|
fmt.Println(string(data))
|
|
//err = sonic.Unmarshal([]byte(data), &psbc)
|
|
//if err != nil {
|
|
// fmt.Println(err)
|
|
// return
|
|
//}
|
|
|
|
request := PayOrderRequest{
|
|
PayChannelId: 8935141660703064070,
|
|
OrderId: 374700296052352,
|
|
ChannelType: 11, // 11-邮储支付
|
|
Description: "测试商品",
|
|
Amount: 100,
|
|
PayerClientIp: "192.168.110.235",
|
|
Psbc: psbc,
|
|
}
|
|
////支付
|
|
//orderResult := PaymentService(c, request)
|
|
//t.Log(orderResult)
|
|
|
|
// 查询订单
|
|
qreq := PayOrderQueryRequest{
|
|
OrderId: request.OrderId,
|
|
PayChannel: 3,
|
|
Psbc: request.Psbc,
|
|
}
|
|
queryResult := PayOrderQuery(c, qreq)
|
|
t.Log(queryResult)
|
|
|
|
//// 退款
|
|
//refund := OrderRefundRequest{
|
|
// OrderId: 3747002960422784848,
|
|
// RefundOrderId: 2017620703512514385,
|
|
// RefundReason: "测试支付商品",
|
|
// RefundAmount: 500,
|
|
// PayChannel: 11,
|
|
// Psbc: request.Psbc,
|
|
//}
|
|
//refundResult := OrderRefund(c, refund)
|
|
//t.Log(refundResult)
|
|
|
|
//// 关闭订单
|
|
//closeOrder := OrderCloseRequest{
|
|
// OrderId: request.OrderId,
|
|
// PayChannel: 3,
|
|
// Psbc: request.Psbc,
|
|
//}
|
|
//closeResutl := OrderClose(c, closeOrder)
|
|
//t.Log(closeResutl)
|
|
}
|