forked from checkout/checkout-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
payments.go
156 lines (145 loc) · 8.42 KB
/
payments.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
package abc
import (
"encoding/json"
"time"
"github.com/PaddleHQ/checkout-sdk-go/common"
"github.com/PaddleHQ/checkout-sdk-go/payments"
)
// Request
type (
PaymentRequest struct {
Source payments.PaymentSource `json:"source,omitempty"`
Amount int64 `json:"amount,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
MerchantInitiated bool `json:"merchant_initiated"`
Reference string `json:"reference,omitempty"`
Description string `json:"description,omitempty"`
Capture bool `json:"capture"`
CaptureOn *time.Time `json:"capture_on,omitempty"`
Customer *common.CustomerRequest `json:"customer,omitempty"`
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
ShippingDetails *payments.ShippingDetails `json:"shipping,omitempty"`
PreviousPaymentId string `json:"previous_payment_id,omitempty"`
Risk *payments.RiskRequest `json:"risk,omitempty"`
SuccessUrl string `json:"success_url,omitempty"`
FailureUrl string `json:"failure_url,omitempty"`
PaymentIp string `json:"payment_ip,omitempty"`
ThreeDsRequest *payments.ThreeDsRequest `json:"3ds,omitempty"`
PaymentRecipient *payments.PaymentRecipient `json:"recipient,omitempty"`
Processing *payments.ProcessingSettings `json:"processing,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
PayoutRequest struct {
Destination payments.Destination `json:"destination,omitempty"`
Amount int64 `json:"amount,omitempty"`
FundTransferType payments.FundTransferType `json:"fund_transfer_type,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
Reference string `json:"reference,omitempty"`
Description string `json:"description,omitempty"`
Capture bool `json:"capture"`
CaptureOn *time.Time `json:"capture_on,omitempty"`
Customer *common.CustomerRequest `json:"customer,omitempty"`
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
ShippingDetails *payments.ShippingDetails `json:"shipping,omitempty"`
ThreeDsRequest *payments.ThreeDsRequest `json:"3ds,omitempty"`
PreviousPaymentId string `json:"previous_payment_id,omitempty"`
Risk *payments.RiskRequest `json:"risk,omitempty"`
SuccessUrl string `json:"success_url,omitempty"`
FailureUrl string `json:"failure_url,omitempty"`
PaymentIp string `json:"payment_ip,omitempty"`
PaymentRecipient *payments.PaymentRecipient `json:"recipient,omitempty"`
Processing *payments.ProcessingSettings `json:"processing,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
CaptureRequest struct {
Amount int64 `json:"amount,omitempty"`
Reference string `json:"reference,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
)
// Response
type (
PaymentResponse struct {
HttpMetadata common.HttpMetadata
ActionId string `json:"action_id,omitempty"`
Amount int64 `json:"amount,omitempty"`
Approved bool `json:"approved,omitempty"`
AuthCode string `json:"auth_code,omitempty"`
Id string `json:"id,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
Customer *common.CustomerResponse `json:"customer,omitempty"`
Source *SourceResponse `json:"source,omitempty"`
Status payments.PaymentStatus `json:"status,omitempty"`
ThreeDs *payments.ThreeDsEnrollment `json:"3ds,omitempty"`
Reference string `json:"reference,omitempty"`
ResponseCode string `json:"response_code,omitempty"`
ResponseSummary string `json:"response_summary,omitempty"`
Risk *payments.RiskAssessment `json:"risk,omitempty"`
ProcessedOn *time.Time `json:"processed_on,omitempty"`
Processing *payments.PaymentProcessing `json:"processing,omitempty"`
Eci string `json:"eci,omitempty"`
SchemeId string `json:"scheme_id,omitempty"`
Links map[string]common.Link `json:"_links"`
}
GetPaymentResponse struct {
HttpMetadata common.HttpMetadata
Id string `json:"id,omitempty"`
RequestedOn *time.Time `json:"requested_on,omitempty"`
Source interface{} `json:"source,omitempty"`
Destination interface{} `json:"destination,omitempty"`
Amount int64 `json:"amount,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
PaymentType payments.PaymentType `json:"payment_type,omitempty"`
Reference string `json:"reference,omitempty"`
Description string `json:"description,omitempty"`
Approved bool `json:"approved,omitempty"`
Status payments.PaymentStatus `json:"status,omitempty"`
ThreeDs *payments.ThreeDsData `json:"3ds,omitempty"`
Risk *payments.RiskAssessment `json:"risk,omitempty"`
Customer *common.CustomerResponse `json:"customer,omitempty"`
BillingDescriptor *payments.BillingDescriptor `json:"billing_descriptor,omitempty"`
ShippingDetails *payments.ShippingDetails `json:"shipping,omitempty"`
PaymentIp string `json:"payment_ip,omitempty"`
PaymentRecipient *payments.PaymentRecipient `json:"recipient,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Eci string `json:"eci,omitempty"`
SchemeId string `json:"scheme_id,omitempty"`
Actions []payments.PaymentActionSummary `json:"actions,omitempty"`
Links map[string]common.Link `json:"_links"`
}
GetPaymentActionsResponse struct {
HttpMetadata common.HttpMetadata
Actions []PaymentAction `json:"actions,omitempty"`
}
PaymentAction struct {
Id string `json:"id,omitempty"`
Type payments.ActionType `json:"type,omitempty"`
ProcessedOn *time.Time `json:"processed_on,omitempty"`
Amount int64 `json:"amount,omitempty"`
Approved bool `json:"approved,omitempty"`
AuthCode string `json:"auth_code,omitempty"`
ResponseCode string `json:"response_code,omitempty"`
ResponseSummary string `json:"response_summary,omitempty"`
Reference string `json:"reference,omitempty"`
Processing *payments.Processing `json:"processing,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Links map[string]common.Link `json:"_links"`
}
GetPaymentListResponse struct {
HttpMetadata common.HttpMetadata
Limit int `json:"limit,omitempty"`
Skip int `json:"skip,omitempty"`
TotalCount int `json:"total_count,omitempty"`
Data []GetPaymentResponse `json:"data,omitempty"`
}
)
func (p *GetPaymentActionsResponse) UnmarshalJSON(data []byte) error {
var actions []PaymentAction
if err := json.Unmarshal(data, &actions); err != nil {
return err
}
p.Actions = actions
return nil
}