You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
1.1 KiB

package alipay_test
import (
"context"
"yunyan/sys/pay/wechat"
"fmt"
"os"
"testing"
)
// Test_Sys 使用微信支付系统对象创建订单的最小集成测试。
// 参数:
// - t: Go 测试对象
//
// 返回值:
// - 无
//
// 异常:
// - 当未启用集成测试时跳过
// - 当初始化或下单失败时,测试失败
func Test_Sys(t *testing.T) {
if os.Getenv("WECHAT_PAY_INTEGRATION_TEST") == "" {
t.Skip("跳过测试:未设置环境变量 WECHAT_PAY_INTEGRATION_TEST")
}
if sys, err := wechat.NewSys(
wechat.SetAppID("wx4b5ec8957ad5e425"),
wechat.SetMchID("1719983673"),
wechat.SetApiV3Key("rV7cE1xZ9bN3mK5jH8gT0wQ2sF4dG6yU"),
wechat.SetPrivateKeyPath("./apiclient_key.pem"),
wechat.SetCertSerialNo("2D27CEB52B98DDEB1CC65E4D96A041E7408F58D0"),
); err != nil {
t.Fatalf("Sys Init err:%v", err)
} else {
orderid := sys.GenerateOrderNo("APP")
fmt.Println(orderid)
results, err := sys.CreateAppOrder(context.TODO(), orderid, 100, "vip购买", "https://api.ideapsound.com/api/heom/pay_wechatnotify")
if err != nil {
t.Fatalf("CreateAppOrder 失败: %v", err)
}
t.Logf("CreateAppOrder 成功: %+v", results)
}
}