generated from mythrnr/template-lib-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenario_continuous_payment.go
215 lines (201 loc) · 6.61 KB
/
scenario_continuous_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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
package paypayopa
import (
"context"
"net/http"
)
// ContinuousPayment provides an API for PayPay's
// Continuous Payment functionality.
//
// ContinuousPayment は PayPay の継続課金機能の API を提供する.
//
// # Docs
//
// https://developer.paypay.ne.jp/products/docs/continuouspayment
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/continuous_payments
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/continuous_payments
type ContinuousPayment struct {
client *opaClient
creds *Credentials
}
// NewContinuousPayment returns a client for Continuous Payment.
//
// NewContinuousPayment は Continuous Payment のクライアントを返す.
func NewContinuousPayment(creds *Credentials) *ContinuousPayment {
return &ContinuousPayment{
client: newClient(creds),
creds: creds,
}
}
// NewContinuousPaymentWithHTTPClient returns a Continuous Payment client
// that performs with a pre-configured *http.Client.
//
// NewContinuousPaymentWithHTTPClient は設定済みの *http.Client を用いて通信を行う
// Continuous Payment のクライアントを返す.
func NewContinuousPaymentWithHTTPClient(
creds *Credentials,
client *http.Client,
) *ContinuousPayment {
return &ContinuousPayment{
client: newClientWithHTTPClient(creds, client),
creds: creds,
}
}
// CreateContinuousPayment create a continuous payment
// and start the money transfer.
//
// CreateContinuousPayment は継続課金リクエストを作成して送金を開始する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/continuous_payments#operation/createPayment
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/continuous_payments#operation/createPayment
func (c *ContinuousPayment) CreateContinuousPayment(
ctx context.Context,
req *CreateContinuousPaymentPayload,
) (*Payment, *ResultInfo, error) {
return createContinuousPayment(ctx, c.client, req)
}
// GetPaymentDetails retrieves the details of a payment.
//
// GetPaymentDetails は決済の詳細を取得する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/continuous_payments#operation/getPaymentDetails
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/continuous_payments#operation/getPaymentDetails
func (c *ContinuousPayment) GetPaymentDetails(
ctx context.Context,
merchantPaymentID string,
) (*Payment, *ResultInfo, error) {
return getPaymentDetails(ctx, c.client, merchantPaymentID)
}
// CancelPayment cancels the payment.
//
// CancelPayment は支払いのキャンセルをする.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/continuous_payments#operation/cancelPayment
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/continuous_payments#operation/cancelPayment
func (c *ContinuousPayment) CancelPayment(
ctx context.Context,
merchantPaymentID string,
) (*ResultInfo, error) {
return cancelPayment(ctx, c.client, merchantPaymentID)
}
// RefundPayment refunds the payment.
//
// RefundPayment は返金を行う.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/continuous_payments#operation/refundPayment
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/continuous_payments#operation/refundPayment
func (c *ContinuousPayment) RefundPayment(
ctx context.Context,
req *RefundPaymentPayload,
) (*RefundResponse, *ResultInfo, error) {
return refundPayment(ctx, c.client, req)
}
// GetRefundDetails gets the refund details.
//
// GetRefundDetails は返金の詳細を取得する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/continuous_payments#operation/getRefundDetails
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/continuous_payments#operation/getRefundDetails
func (c *ContinuousPayment) GetRefundDetails(
ctx context.Context,
merchantRefundID string,
) (*RefundResponse, *ResultInfo, error) {
return getRefundDetails(ctx, c.client, merchantRefundID)
}
// CreateAccountLinkQRCode creates a ACCOUNT LINK QR
// and display it to the user.
//
// CreateAccountLinkQRCode はアカウントリンクQRを作成し, ユーザーに表示する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/account_link.html#operation/createQRSession
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/account_link.html#operation/createQRSession
func (c *ContinuousPayment) CreateAccountLinkQRCode(
ctx context.Context,
req *CreateAccountLinkQRCodePayload,
) (*CreateAccountLinkQRCodeResponse, *ResultInfo, error) {
return createAccountLinkQRCode(ctx, c.client, req)
}
// UnlinkUser unlinks an user from the client.
//
// UnlinkUser はクライアントからユーザーのリンクを解除する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/continuous_payments#operation/unlinkUser
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/continuous_payments#operation/unlinkUser
func (c *ContinuousPayment) UnlinkUser(
ctx context.Context,
userAuthorizationID string,
) (*ResultInfo, error) {
return unlinkUser(ctx, c.client, userAuthorizationID)
}
// GetUserAuthorizationStatus gets the authorization status of a user.
//
// GetUserAuthorizationStatus はユーザー認可状態を取得する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/continuous_payments#operation/getUserAuthorizationStatus
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/continuous_payments#operation/getUserAuthorizationStatus
//
//nolint:lll
func (c *ContinuousPayment) GetUserAuthorizationStatus(
ctx context.Context,
userAuthorizationID string,
) (*GetUserAuthorizationStatusResponse, *ResultInfo, error) {
return getUserAuthorizationStatus(ctx, c.client, userAuthorizationID)
}
// GetMaskedUserProfile retrieves the masked phone number of the user.
//
// GetMaskedUserProfile はマスクされたユーザーの電話番号を取得する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/continuous_payments#operation/getMaskedUserProfile
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/continuous_payments#operation/getMaskedUserProfile
func (c *ContinuousPayment) GetMaskedUserProfile(
ctx context.Context,
userAuthorizationID string,
) (*GetMaskedUserProfileResponse, *ResultInfo, error) {
return getMaskedUserProfile(ctx, c.client, userAuthorizationID)
}
// DecodeResponseToken decodes and returns the JWT of
// the user's authorization result.
//
// DecodeResponseToken はユーザーの認可の結果の JWT をデコードして返す.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/account_link.html
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/account_link.html
func (c *ContinuousPayment) DecodeResponseToken(
_ context.Context,
token string,
) (*AuthorizationResponseToken, error) {
return decodeAuthorizationResponseToken(c.creds, token)
}