generated from mythrnr/template-lib-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenario_web_payment.go
171 lines (159 loc) · 4.99 KB
/
scenario_web_payment.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package paypayopa
import (
"context"
"net/http"
)
// WebPayment provides an API for PayPay's web payment functionality.
//
// WebPayment は PayPay のウェブペイメント機能の API を提供する.
//
// # Docs
//
// https://developer.paypay.ne.jp/products/docs/webpayment
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/webcashier
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/webcashier
type WebPayment struct{ client *opaClient }
// NewWebPayment returns a client for Web Payment.
//
// NewWebPayment は Web Payment のクライアントを返す.
func NewWebPayment(creds *Credentials) *WebPayment {
return &WebPayment{client: newClient(creds)}
}
// NewWebPaymentWithHTTPClient returns a Web Payment client
// that performs with a pre-configured *http.Client.
//
// NewWebPaymentWithHTTPClient は設定済みの *http.Client を用いて通信を行う
// Web Payment のクライアントを返す.
func NewWebPaymentWithHTTPClient(
creds *Credentials,
client *http.Client,
) *WebPayment {
return &WebPayment{client: newClientWithHTTPClient(creds, client)}
}
// CreateQRCode creates a QR code for payment.
//
// CreateQRCode は支払い用の QR コードを作成する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/webcashier#operation/createQRCode
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/webcashier#operation/createQRCode
func (w *WebPayment) CreateQRCode(
ctx context.Context,
req *CreateQRCodePayload,
) (*QRCodeResponse, *ResultInfo, error) {
return createQRCode(ctx, w.client, req)
}
// DeleteQRCode deletes a QR Code that has already been created.
//
// DeleteQRCode は作成済みの QR コードを削除する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/webcashier#operation/deleteQRCode
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/webcashier#operation/deleteQRCode
func (w *WebPayment) DeleteQRCode(
ctx context.Context,
codeID string,
) (*ResultInfo, error) {
return deleteQRCode(ctx, w.client, codeID)
}
// GetPaymentDetails retrieves the details of a payment.
//
// GetPaymentDetails は決済の詳細を取得する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/webcashier#operation/getPaymentDetails
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/webcashier#operation/getPaymentDetails
func (w *WebPayment) GetPaymentDetails(
ctx context.Context,
merchantPaymentID string,
) (*Payment, *ResultInfo, error) {
return getCodePaymentDetails(ctx, w.client, merchantPaymentID)
}
// CancelPayment cancels the payment.
//
// CancelPayment は支払いのキャンセルをする.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/webcashier#operation/cancelPayment
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/webcashier#operation/cancelPayment
func (w *WebPayment) CancelPayment(
ctx context.Context,
merchantPaymentID string,
) (*ResultInfo, error) {
return cancelPayment(ctx, w.client, merchantPaymentID)
}
// CapturePaymentAuthorization captures
// the payment authorization for a payment.
//
// CapturePaymentAuthorization は支払い承認を取得する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/webcashier#operation/capturePaymentAuth
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/webcashier#operation/capturePaymentAuth
func (w *WebPayment) CapturePaymentAuthorization(
ctx context.Context,
req *CapturePaymentAuthorizationPayload,
) (*Payment, *ResultInfo, error) {
return capturePaymentAuthorization(ctx, w.client, req)
}
// RevertPaymentAuthorization cancels the payment authorization
// if the user cancels the order.
//
// RevertPaymentAuthorization はユーザーが注文のキャンセルをした場合に
// 支払い承認の取り消しをする.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/webcashier#operation/revertAuth
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/webcashier#operation/revertAuth
func (w *WebPayment) RevertPaymentAuthorization(
ctx context.Context,
req *RevertPaymentAuthorizationPayload,
) (*RevertedPaymentResponse, *ResultInfo, error) {
return revertPaymentAuthorization(ctx, w.client, req)
}
// RefundPayment refunds the payment.
//
// RefundPayment は返金を行う.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/webcashier#operation/refundPayment
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/webcashier#operation/refundPayment
func (w *WebPayment) RefundPayment(
ctx context.Context,
req *RefundPaymentPayload,
) (*RefundResponse, *ResultInfo, error) {
return refundPayment(ctx, w.client, req)
}
// GetRefundDetails gets the refund details.
//
// GetRefundDetails は返金の詳細を取得する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/webcashier#operation/getRefundDetails
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/webcashier#operation/getRefundDetails
func (w *WebPayment) GetRefundDetails(
ctx context.Context,
merchantRefundID string,
) (*RefundResponse, *ResultInfo, error) {
return getRefundDetails(ctx, w.client, merchantRefundID)
}