generated from mythrnr/template-lib-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_schema.go
94 lines (84 loc) · 3.18 KB
/
api_schema.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
package paypayopa
import (
"encoding/json"
"net/http"
)
// response is the root object of the PayPay API response.
//
// response は PayPay API のレスポンスのルートオブジェクト.
type response struct {
Result *ResultInfo `json:"resultInfo"`
Data json.RawMessage `json:"data,omitempty"`
}
// ResultInfo is the result object of the PayPay API processing.
// The JSON of the response does not contain the HTTP status,
// but the SDK sets it in this object and returns it for convenience.
//
// ResultInfo は PayPay API の処理結果オブジェクト.
// レスポンスの JSON には HTTP ステータスは含まれないが,
// SDK は利便性の為にこのオブジェクトにセットして返す.
type ResultInfo struct {
Code string `json:"code"`
Message string `json:"message"`
CodeID string `json:"codeId"`
StatusCode int `json:"-"`
}
// Success returns the success or failure of the operation.
// Based on HTTP status, less than 400 is considered success.
// 3xx is not returned now.
//
// Success は処理の成否を返す.
// HTTP ステータスを基準に, 400 未満を成功と判定する.
// 3xx は現時点では返されない.
func (r *ResultInfo) Success() bool {
return r.StatusCode < http.StatusBadRequest
}
type Capture struct {
AcceptedAt int64 `json:"acceptedAt"`
MerchantCaptureID string `json:"merchantCaptureId"`
Amount *MoneyAmount `json:"amount"`
OrderDescription string `json:"orderDescription"`
RequestedAt int64 `json:"requestedAt"`
ExpiresAt *int64 `json:"expiresAt"`
Status string `json:"status"`
}
type MerchantOrderItem struct {
Name string `json:"name"`
Category string `json:"category"`
Quantity int `json:"quantity"`
ProductID string `json:"productId"`
UnitPrice *MoneyAmount `json:"unitPrice"`
}
type MoneyAmount struct {
Amount int `json:"amount"`
Currency Currency `json:"currency"`
}
type Payment struct {
PaymentID string `json:"paymentId"`
Status string `json:"status"`
AcceptedAt int64 `json:"acceptedAt"`
Refunds struct {
Data []*RefundResponse `json:"data"`
} `json:"refunds"`
Captures struct {
Data []*Capture `json:"data"`
} `json:"captures"`
Revert *Revert `json:"revert"`
MerchantPaymentID string `json:"merchantPaymentId"`
Amount *MoneyAmount `json:"amount"`
RequestedAt int64 `json:"requestedAt"`
ExpiresAt *int64 `json:"expiresAt"`
CanceledAt *int64 `json:"canceledAt"`
StoreID string `json:"storeId"`
TerminalID string `json:"terminalId"`
OrderReceiptNumber string `json:"orderReceiptNumber"`
OrderDescription string `json:"orderDescription"`
OrderItems []*MerchantOrderItem `json:"orderItems"`
Metadata *json.RawMessage `json:"metadata"`
}
type Revert struct {
AcceptedAt int64 `json:"acceptedAt"`
MerchantRevertID string `json:"merchantRevertId"`
RequestedAt int64 `json:"requestedAt"`
Reason string `json:"reason"`
}