add payment type field (alipay/wxpay) to EPay config
This commit is contained in:
@@ -14,9 +14,10 @@ import (
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
Pid string
|
||||
Url string
|
||||
Key string
|
||||
Pid string
|
||||
Url string
|
||||
Key string
|
||||
Type string
|
||||
}
|
||||
|
||||
type Order struct {
|
||||
@@ -37,11 +38,12 @@ type queryOrderStatusResponse struct {
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
func NewClient(pid, url, key string) *Client {
|
||||
func NewClient(pid, url, key string, Type string) *Client {
|
||||
return &Client{
|
||||
Pid: pid,
|
||||
Url: url,
|
||||
Key: key,
|
||||
Pid: pid,
|
||||
Url: url,
|
||||
Key: key,
|
||||
Type: Type,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +55,7 @@ func (c *Client) CreatePayUrl(order Order) string {
|
||||
params.Set("notify_url", order.NotifyUrl)
|
||||
params.Set("out_trade_no", order.OrderNo)
|
||||
params.Set("pid", c.Pid)
|
||||
params.Set("type", c.Type)
|
||||
params.Set("return_url", order.ReturnUrl)
|
||||
|
||||
// Generate the sign using the CreateSign function
|
||||
@@ -117,6 +120,7 @@ func (c *Client) structToMap(order Order) map[string]string {
|
||||
result["notify_url"] = order.NotifyUrl
|
||||
result["out_trade_no"] = order.OrderNo
|
||||
result["pid"] = c.Pid
|
||||
result["type"] = c.Type
|
||||
result["return_url"] = order.ReturnUrl
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package epay
|
||||
import "testing"
|
||||
|
||||
func TestEpay(t *testing.T) {
|
||||
client := NewClient("", "http://127.0.0.1", "")
|
||||
client := NewClient("", "http://127.0.0.1", "", "")
|
||||
order := Order{
|
||||
Name: "测试",
|
||||
OrderNo: "123456789",
|
||||
@@ -19,7 +19,7 @@ func TestEpay(t *testing.T) {
|
||||
|
||||
func TestQueryOrderStatus(t *testing.T) {
|
||||
t.Skipf("Skip TestQueryOrderStatus test")
|
||||
client := NewClient("Pid", "Url", "Key")
|
||||
client := NewClient("Pid", "Url", "Key", "Type")
|
||||
orderNo := "123456789"
|
||||
status := client.QueryOrderStatus(orderNo)
|
||||
t.Logf("OrderNo: %s, Status: %v\n", orderNo, status)
|
||||
@@ -40,7 +40,7 @@ func TestVerifySign(t *testing.T) {
|
||||
}
|
||||
|
||||
key := "LbTabbB580zWyhXhyyww7wwvy5u8k0wl"
|
||||
c := NewClient("Pid", "Url", key)
|
||||
c := NewClient("Pid", "Url", key, "Type")
|
||||
if c.VerifySign(params) {
|
||||
t.Logf("Sign verification success!")
|
||||
} else {
|
||||
|
||||
@@ -65,9 +65,10 @@ func GetSupportedPlatforms() []types.PlatformInfo {
|
||||
Platform: EPay.String(),
|
||||
PlatformUrl: "",
|
||||
PlatformFieldDescription: map[string]string{
|
||||
"pid": "PID",
|
||||
"url": "URL",
|
||||
"key": "Key",
|
||||
"pid": "PID",
|
||||
"url": "URL",
|
||||
"key": "Key",
|
||||
"type": "Type",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user