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.
44 lines
1.4 KiB
44 lines
1.4 KiB
package paypal_test
|
|
|
|
import (
|
|
"context"
|
|
"yunyan/sys/pay/paypal"
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func Test_Sys(t *testing.T) {
|
|
if sys, err := paypal.NewSys(
|
|
paypal.SetClientID("AUjApGHJm31MT101xA6koKAnZBZvo6ZxzRYAyXRXFQjlBYoj2i7Hg33clMIaIqyziFhmY0TX_EN_hgDL"),
|
|
paypal.SetSecret("EKlnsMTODfMFfOsnkfyifDRexw3dPk9Ldzv5b-a3Yu-Gq0cYFF7roQsrSaBv572kW9n_u25lHBDabemq"),
|
|
// PayPal 正确的 Sandbox API 域名应为 api-m.sandbox.paypal.com
|
|
paypal.SetBaseURL("https://api-m.sandbox.paypal.com"),
|
|
paypal.SetWebhookID("0PR35225Y36017238"),
|
|
paypal.SetDebug(true),
|
|
); err != nil {
|
|
fmt.Printf("Sys Init err:%v", err)
|
|
return
|
|
} else {
|
|
orderid := sys.GenerateOrderNo("APP")
|
|
fmt.Println(orderid)
|
|
results, err := sys.CreateAppOrder(context.TODO(), orderid, 100, "Sandbox测试购买", "", "")
|
|
fmt.Println(results, err)
|
|
}
|
|
}
|
|
|
|
func Test_Sys_CaptureOrder(t *testing.T) {
|
|
if sys, err := paypal.NewSys(
|
|
paypal.SetClientID("AUjApGHJm31MT101xA6koKAnZBZvo6ZxzRYAyXRXFQjlBYoj2i7Hg33clMIaIqyziFhmY0TX_EN_hgDL"),
|
|
paypal.SetSecret("EKlnsMTODfMFfOsnkfyifDRexw3dPk9Ldzv5b-a3Yu-Gq0cYFF7roQsrSaBv572kW9n_u25lHBDabemq"),
|
|
// PayPal 正确的 Sandbox API 域名应为 api-m.sandbox.paypal.com
|
|
paypal.SetBaseURL("https://api-m.sandbox.paypal.com"),
|
|
paypal.SetWebhookID("0PR35225Y36017238"),
|
|
paypal.SetDebug(true),
|
|
); err != nil {
|
|
fmt.Printf("Sys Init err:%v", err)
|
|
return
|
|
} else {
|
|
results, err := sys.CaptureOrder(context.TODO(), "1A196717NX085042G")
|
|
fmt.Println(results, err)
|
|
}
|
|
}
|
|
|