generated from mythrnr/template-lib-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscenario_request_money.go
180 lines (168 loc) · 5.36 KB
/
scenario_request_money.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
package paypayopa
import (
"context"
"net/http"
)
// RequestMoney provides an API for PayPay's payment request functionality.
//
// RequestMoney は PayPay の支払リクエスト機能の API を提供する.
//
// # Docs
//
// https://developer.paypay.ne.jp/products/docs/pendingpayment
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/pending_payments
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/pending_payments
type RequestMoney struct {
client *opaClient
creds *Credentials
}
// NewRequestMoney returns a client for Request Money.
//
// NewRequestMoney は Request Money のクライアントを返す.
func NewRequestMoney(creds *Credentials) *RequestMoney {
return &RequestMoney{
client: newClient(creds),
creds: creds,
}
}
// NewRequestMoneyWithHTTPClient returns a Request Money client
// that performs with a pre-configured *http.Client.
//
// NewRequestMoneyWithHTTPClient は設定済みの *http.Client を用いて通信を行う
// Request Money のクライアントを返す.
func NewRequestMoneyWithHTTPClient(
creds *Credentials,
client *http.Client,
) *RequestMoney {
return &RequestMoney{
client: newClientWithHTTPClient(creds, client),
creds: creds,
}
}
// CreatePendingPayment sends a push notification
// to the user requesting payment.
//
// CreatePendingPayment はユーザーに支払いを求める通知を送信する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/pending_payments#operation/createPayment
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/pending_payments#operation/createPayment
func (r *RequestMoney) CreatePendingPayment(
ctx context.Context,
req *CreatePendingPaymentPayload,
) (*PendingPayment, *ResultInfo, error) {
return createPendingPayment(ctx, r.client, req)
}
// GetPaymentDetails retrieves the details of a payment.
//
// GetPaymentDetails は決済の詳細を取得する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/pending_payments#operation/getPaymentDetails
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/pending_payments#operation/getPaymentDetails
func (r *RequestMoney) GetPaymentDetails(
ctx context.Context,
merchantPaymentID string,
) (*Payment, *ResultInfo, error) {
return getRequestedPaymentDetails(ctx, r.client, merchantPaymentID)
}
// CancelPendingOrder deletes a pending payment.
//
// CancelPendingOrder は保留中の支払いを削除する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/pending_payments#operation/cancelPendingOrder
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/pending_payments#operation/cancelPendingOrder
func (r *RequestMoney) CancelPendingOrder(
ctx context.Context,
merchantPaymentID string,
) (*ResultInfo, error) {
return cancelPendingOrder(ctx, r.client, merchantPaymentID)
}
// RefundPayment refunds the payment.
//
// RefundPayment は返金を行う.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/pending_payments#operation/refundPayment
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/pending_payments#operation/refundPayment
func (r *RequestMoney) RefundPayment(
ctx context.Context,
req *RefundPaymentPayload,
) (*RefundResponse, *ResultInfo, error) {
return refundPayment(ctx, r.client, req)
}
// GetRefundDetails gets the refund details.
//
// GetRefundDetails は返金の詳細を取得する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/pending_payments#operation/getRefundDetails
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/pending_payments#operation/getRefundDetails
func (r *RequestMoney) GetRefundDetails(
ctx context.Context,
merchantRefundID string,
) (*RefundResponse, *ResultInfo, error) {
return getRefundDetails(ctx, r.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 (r *RequestMoney) CreateAccountLinkQRCode(
ctx context.Context,
req *CreateAccountLinkQRCodePayload,
) (*CreateAccountLinkQRCodeResponse, *ResultInfo, error) {
return createAccountLinkQRCode(ctx, r.client, req)
}
// GetMaskedUserProfile retrieves the masked phone number of the user.
//
// GetMaskedUserProfile はマスクされたユーザーの電話番号を取得する.
//
// # API Docs
//
// EN: https://www.paypay.ne.jp/opa/doc/v1.0/pending_payments#operation/getMaskedUserProfile
//
// JP: https://www.paypay.ne.jp/opa/doc/jp/v1.0/pending_payments#operation/getMaskedUserProfile
func (r *RequestMoney) GetMaskedUserProfile(
ctx context.Context,
userAuthorizationID string,
) (*GetMaskedUserProfileResponse, *ResultInfo, error) {
return getMaskedUserProfile(ctx, r.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 (r *RequestMoney) DecodeResponseToken(
_ context.Context,
token string,
) (*AuthorizationResponseToken, error) {
return decodeAuthorizationResponseToken(r.creds, token)
}