service/library/payclients/alipaycli/client_test.go

40 lines
2.3 KiB
Go
Raw Normal View History

2023-12-21 22:17:40 +08:00
package alipaycli
import (
"context"
"fmt"
"os"
"service/library/configcenter"
"service/library/idgenerator"
"testing"
)
func TestMain(m *testing.M) {
cfg := &configcenter.AlipayClientConfig{
Appid: "2021004115647165",
PrivateKey: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCeA8ADj0arLzUK5B3R5bqbOkXm8TBe0dI6XpefxnHeNyksEFhQuWTFtQA550lGj/VMyNQC0R+gL6VK/5SdgonzxMx8bC+/1lIWrl3Q8F+JLsAUcNh6C+WzDw7m5YSrG9361f3+i/gPVC4GRTzx91qLdk1ySGZv/GpSVv49k9qtD83gRCbxJq5FY1QA83Wb5xkJoMwl+SlKvFLNxIIzPQh9DvDF+32FTsVQgm3sX1lsArTA4yp7Y4SG3A8mkOanidYX1KiUawMBWaDgZi1CMpQ+Zbb3w0C0txCeZ8ek5JeUw2EYHJ0awMnFE6+vPDm1LNJ0DodkvszGbmLvXQS2eMfVAgMBAAECggEABj1nq7xQshnfIlr3wn4r7E1UzVXg7x2iC6QIoMqZXIkZGyBaHHX1wMjxBVhY0GyG501W8fWIJi87e8az+7RX9kRjPtaW3CB+hV7FXabgXu51r1j1c3xcycFieUO/BXLIRUuGCDNGzHQqjRzW10dJUBCP5l9tjCaPnEjLKWtZS1QwhtmjmAJalC+oQLnhvlmURSWwyvIIgrqK82DZj5DFgXrxlah21Sou/N4xV/W/d0OkaouDxHtQ4Oy/yE/oc2z+vbcBcHrIt+r2g8gymKPdsDFyglUqZeNRlwYnifSUH7Bmn+1uiXAi86RlUdtCYngNUUNoOStB9oC7gidPHyeb0QKBgQDV58AFBOCHdG2gO+VvKiIpbquWMYTbmbRGmCai911G6zX8X/37nawKWZkyk4kIkrohZtwwL5s6AIlD5F9nRBp+Uk1QvlIYokD3vjUuVPyvpC3raASUvTs0WoWbq3gfPH5Qn5vS1C89CQ/68FC+89CYiexxwq7ybX86lzhYGpRXrwKBgQC9HE7e5Cr9akJrUuPW8NjbKATYg2h8s3/FMa4AbeTLPSEPPp20yRGA5P0xPgV1JocfmVd3VC6ivF6YHKKVnKoVbR74InCi4hhriGb3uLz7i6ngjcxysBfOlKA8lOlMAMY4ZrE2zTp2mUKF1Wp3a0IiC0xGPmdh44xvrO8h4UK1uwKBgGkY3Lealdb31YUM6MWdpftFbPj2i5h6BKFK0HDxqNrXZkcBwwCFj6nmK+c1pfaYYOtYZocmXNY6vTamVlmelIXMWkB5wkxoLBONWQPSrfR+bjFjghyyfQxUDaFWtkZiqo1iXmVP64XJlhhtSr8HfE32Nj4OsXZbZk+bTQu8w3XxAoGBAJJg3wvYQQ52uYKpXoJ5WuIIT/fnf3FG35ebpLvgVECcyIIsTZYqLMpAdVswTrknYWAsKW/MUWzVscK8J3z3DxAWruoSfm0V5SEXK9yDuoRazttp5t6/Py5ADOfXu92Am+38Tx/EK4SxjLRbRVW6SC5h4GBe3Vb/8yxeB5uJ6UERAoGAbsCHaS1NW21qYxeWAD8XC1x8B5vLwcVILP0kIt5CPFgKRcRbJPEfnSF8fFC0OKwJrp32+AhMTOEISwJVkR10Jzqn7VU1bu7lHYkiiOIZJCb1cdjfPxYUR60vpIttoKuz+CBIgc0zo1tu3TgCVdCy//coVRCoLeK+JawP43VLJ+g=",
NotifyUrl: "",
}
err := Init(cfg)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
m.Run()
}
func TestAlipayClient_AppPay(t *testing.T) {
cli := GetDefaultAlipayClient()
paramStr, err := cli.AppPay(context.Background(), &AppPayParam{
OutTradeNo: idgenerator.GenOrderId(),
Subject: "哈哈",
TotalAmount: 1,
TimeOutSeconds: 0,
})
if err != nil {
fmt.Println(err)
return
}
fmt.Println(paramStr)
}