-
Notifications
You must be signed in to change notification settings - Fork 140
/
api_native_example_test.go
131 lines (115 loc) · 3.46 KB
/
api_native_example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Copyright 2021 Tencent Inc. All rights reserved.
//
// Native支付
//
// Native支付API
//
// API version: 1.2.3
// Code generated by WechatPay APIv3 Generator based on [OpenAPI Generator](https://openapi-generator.tech); DO NOT EDIT.
package native_test
import (
"context"
"time"
"github.com/wechatpay-apiv3/wechatpay-go/core"
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/native"
)
func ExampleNativeApiService_CloseOrder() {
var (
ctx context.Context
client *core.Client
)
// 假设已获得初始化后的 core.Client
svc := native.NativeApiService{Client: client}
result, err := svc.CloseOrder(ctx,
native.CloseOrderRequest{
OutTradeNo: core.String("outTradeNo_example"),
Mchid: core.String("1230000109"),
},
)
// TODO: 处理返回结果
_, _ = result, err
}
func ExampleNativeApiService_Prepay() {
var (
ctx context.Context
client *core.Client
)
// 假设已获得初始化后的 core.Client
svc := native.NativeApiService{Client: client}
resp, result, err := svc.Prepay(ctx,
native.PrepayRequest{
Appid: core.String("wxd678efh567hg6787"),
Mchid: core.String("1230000109"),
Description: core.String("Image形象店-深圳腾大-QQ公仔"),
OutTradeNo: core.String("1217752501201407033233368018"),
TimeExpire: core.Time(time.Now()),
Attach: core.String("自定义数据说明"),
NotifyUrl: core.String("https://www.weixin.qq.com/wxpay/pay.php"),
GoodsTag: core.String("WXG"),
LimitPay: []string{"LimitPay_example"},
SupportFapiao: core.Bool(false),
Amount: &native.Amount{
Currency: core.String("CNY"),
Total: core.Int64(100),
},
Detail: &native.Detail{
CostPrice: core.Int64(608800),
GoodsDetail: []native.GoodsDetail{native.GoodsDetail{
GoodsName: core.String("iPhoneX 256G"),
MerchantGoodsId: core.String("ABC"),
Quantity: core.Int64(1),
UnitPrice: core.Int64(828800),
WechatpayGoodsId: core.String("1001"),
}},
InvoiceId: core.String("wx123"),
},
SettleInfo: &native.SettleInfo{
ProfitSharing: core.Bool(false),
},
SceneInfo: &native.SceneInfo{
DeviceId: core.String("013467007045764"),
PayerClientIp: core.String("14.23.150.211"),
StoreInfo: &native.StoreInfo{
Address: core.String("广东省深圳市南山区科技中一道10000号"),
AreaCode: core.String("440305"),
Id: core.String("0001"),
Name: core.String("腾讯大厦分店"),
},
},
},
)
// TODO: 处理返回结果
_, _, _ = resp, result, err
}
func ExampleNativeApiService_QueryOrderById() {
var (
ctx context.Context
client *core.Client
)
// 假设已获得初始化后的 core.Client
svc := native.NativeApiService{Client: client}
resp, result, err := svc.QueryOrderById(ctx,
native.QueryOrderByIdRequest{
TransactionId: core.String("transactionId_example"),
Mchid: core.String("mchid_example"),
},
)
// TODO: 处理返回结果
_, _, _ = resp, result, err
}
func ExampleNativeApiService_QueryOrderByOutTradeNo() {
var (
ctx context.Context
client *core.Client
)
// 假设已获得初始化后的 core.Client
svc := native.NativeApiService{Client: client}
resp, result, err := svc.QueryOrderByOutTradeNo(ctx,
native.QueryOrderByOutTradeNoRequest{
OutTradeNo: core.String("outTradeNo_example"),
Mchid: core.String("mchid_example"),
},
)
// TODO: 处理返回结果
_, _, _ = resp, result, err
}