-
Notifications
You must be signed in to change notification settings - Fork 22
/
payments.go
517 lines (448 loc) · 21.4 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
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
package payments
import (
"time"
"github.com/checkout/checkout-sdk-go/common"
"github.com/checkout/checkout-sdk-go/sessions"
)
const PathPayments = "payments"
type PaymentType string
const (
Regular PaymentType = "Regular"
Recurring PaymentType = "Recurring"
MOTO PaymentType = "MOTO"
Installment PaymentType = "Installment"
Unscheduled PaymentType = "Unscheduled"
)
type PaymentStatus string
const (
Active PaymentStatus = "Active"
Pending PaymentStatus = "Pending"
Authorized PaymentStatus = "Authorized"
CardVerified PaymentStatus = "Card Verified"
Voided PaymentStatus = "Voided"
PartiallyCaptured PaymentStatus = "Partially Captured"
Captured PaymentStatus = "Captured"
PartiallyRefunded PaymentStatus = "Partially Refunded"
Refunded PaymentStatus = "Refunded"
Declined PaymentStatus = "Declined"
Canceled PaymentStatus = "Canceled"
Expired PaymentStatus = "Expired"
Requested PaymentStatus = "Requested"
Paid PaymentStatus = "Paid"
)
type Exemption string
const (
None Exemption = "none"
LowValue Exemption = "low_value"
RecurringOperation Exemption = "recurring_operation"
TransactionRiskAssessment Exemption = "transaction_risk_assessment"
SecureCorporatePayment Exemption = "secure_corporate_payment"
TrustedListing Exemption = "trusted_listing"
ThreeDsOutage Exemption = "3ds_outage"
ScaDelegation Exemption = "sca_delegation"
OutOfScaScope Exemption = "out_of_sca_scope"
Other Exemption = "other"
LowRiskProgram Exemption = "low_risk_program"
)
type ThreeDsEnrollmentStatus string
const (
Yes ThreeDsEnrollmentStatus = "Y"
No ThreeDsEnrollmentStatus = "N"
U ThreeDsEnrollmentStatus = "U"
)
type ActionType string
const (
AuthorizationYes ActionType = "Authorization"
CardVerification ActionType = "Card Verification"
Void ActionType = "Void"
Capture ActionType = "Capture"
Refund ActionType = "Refund"
Payout ActionType = "Payout"
Return ActionType = "Return"
)
type NetworkTokenType string
const (
Vts NetworkTokenType = "vts"
Mdes NetworkTokenType = "mdes"
ApplePay NetworkTokenType = "applepay"
GooglePay NetworkTokenType = "googlepay"
)
type PreferredSchema string
const (
Visa PreferredSchema = "visa"
Mastercard PreferredSchema = "mastercard"
CartesBancaires PreferredSchema = "cartes_bancaires"
)
type ProductType string
const (
QrCode ProductType = "QR Code"
InApp ProductType = "In-App"
OfficialAccount ProductType = "Official Account"
MiniProgram ProductType = "Mini Program"
)
type MerchantInitiatedReason string
const (
DelayedCharge MerchantInitiatedReason = "Delayed_charge"
Resubmission MerchantInitiatedReason = "Resubmission"
NoShow MerchantInitiatedReason = "No_show"
Reauthorization MerchantInitiatedReason = "Reauthorization"
)
type TerminalType string
const (
App TerminalType = "APP"
Wap TerminalType = "WAP"
Web TerminalType = "WEB"
)
type OsType string
const (
Android OsType = "ANDROID"
Ios OsType = "IOS"
)
type ShippingPreference string
const (
NoShipping ShippingPreference = "NO_SHIPPING"
SetProvidedAddress ShippingPreference = "SET_PROVIDED_ADDRESS"
GetFromFile ShippingPreference = "GET_FROM_FILE"
)
type UserAction string
const (
PayNow UserAction = "PAY_NOW"
Continue UserAction = "CONTINUE"
)
type FundTransferType string
const (
AA FundTransferType = "AA"
PP FundTransferType = "PP"
FT FundTransferType = "FT"
FD FundTransferType = "FD"
PD FundTransferType = "PD"
LO FundTransferType = "LO"
OG FundTransferType = "OG"
CO4 FundTransferType = "CO4"
CO7 FundTransferType = "CO7"
C52 FundTransferType = "C52"
C55 FundTransferType = "C55"
)
type PaymentContextsShippingMethod string
const (
Digital PaymentContextsShippingMethod = "Digital"
PickUp PaymentContextsShippingMethod = "PickUp"
BillingAddress PaymentContextsShippingMethod = "BillingAddress"
OtherAddress PaymentContextsShippingMethod = "OtherAddress"
)
type (
AirlineData struct {
Ticket *Ticket `json:"ticket,omitempty"`
Passenger *Passenger `json:"passenger,omitempty"`
FlightLegDetails []FlightLegDetails `json:"flight_leg_details,omitempty"`
}
Ticket struct {
Number string `json:"number,omitempty"`
IssueDate string `json:"issue_date,omitempty"`
IssuingCarrierCode string `json:"issuing_carrier_code,omitempty"`
TravelAgencyName string `json:"travel_agency_name,omitempty"`
TravelAgencyCode string `json:"travel_agency_code,omitempty"`
}
Passenger struct {
Name *PassengerName `json:"name,omitempty"`
DateOfBirth string `json:"date_of_birth,omitempty"`
CountryCode common.Country `json:"country_code,omitempty"`
}
PassengerName struct {
FullName string `json:"full_name,omitempty"`
}
FlightLegDetails struct {
FlightNumber int64 `json:"flight_number,omitempty"`
CarrierCode string `json:"carrier_code,omitempty"`
ServiceClass string `json:"service_class,omitempty"`
DepartureDate string `json:"departure_date,omitempty"`
DepartureTime string `json:"departure_time,omitempty"`
DepartureAirport string `json:"departure_airport,omitempty"`
ArrivalAirport string `json:"arrival_airport,omitempty"`
StopoverCode string `json:"stopover_code,omitempty"`
FareBasisCode string `json:"fare_basis_code,omitempty"`
}
ShippingInfo struct {
ShippingCompany string `json:"shipping_company,omitempty"`
ShippingMethod string `json:"shipping_method,omitempty"`
TrackingNumber string `json:"tracking_number,omitempty"`
TrackingUri string `json:"tracking_uri,omitempty"`
ReturnShippingCompany string `json:"return_shipping_company,omitempty"`
ReturnTrackingNumber string `json:"return_tracking_number,omitempty"`
ReturnTrackingUri string `json:"return_tracking_uri,omitempty"`
}
ShippingDetails struct {
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Email string `json:"email,omitempty"`
Address *common.Address `json:"address,omitempty"`
Phone *common.Phone `json:"phone,omitempty"`
FromAddressZip string `json:"from_address_zip,omitempty"`
Timeframe sessions.DeliveryTimeframe `json:"time_frame,omitempty"`
Method PaymentContextsShippingMethod `json:"method,omitempty"`
Delay int `json:"delay,omitempty"`
}
PaymentSegment struct {
Brand string `json:"brand,omitempty"`
BusinessCategory string `json:"business_category,omitempty"`
Market string `json:"market,omitempty"`
}
PaymentRetryRequest struct {
Enabled bool `json:"enabled,omitempty"`
MaxAttempts int `json:"max_attempts,omitempty"`
EndAfterDays int `json:"end_after_days,omitempty"`
}
BillingDescriptor struct {
Name string `json:"name,omitempty"`
City string `json:"city,omitempty"`
// Not available on Previous
Reference string `json:"reference,omitempty"`
}
ThreeDsRequest struct {
Enabled bool `json:"enabled"`
AttemptN3D bool `json:"attempt_n3d"`
Eci string `json:"eci,omitempty"`
Cryptogram string `json:"cryptogram,omitempty"`
Xid string `json:"xid,omitempty"`
Version string `json:"version,omitempty"`
Exemption Exemption `json:"exemption,omitempty"`
ChallengeIndicator common.ChallengeIndicator `json:"challenge_indicator,omitempty"`
AllowUpgrade bool `json:"allow_upgrade,omitempty"`
// Not available on Previous
Status string `json:"status,omitempty"`
AuthenticationDate *time.Time `json:"authentication_date,omitempty"`
AuthenticationAmount float64 `json:"authentication_amount,omitempty"`
FlowType common.ThreeDsFlowType `json:"flow_type,omitempty"`
StatusReasonCode string `json:"status_reason_code,omitempty"`
ChallengeCancelReason string `json:"challenge_cancel_reason,omitempty"`
Score string `json:"score,omitempty"`
CryptogramAlgorithm string `json:"cryptogram_algorithm,omitempty"`
AuthenticationId string `json:"authentication_id,omitempty"`
}
RiskRequest struct {
Enabled bool `json:"enabled"`
DeviceSessionId string `json:"device_session_id,omitempty"`
}
PaymentRecipient struct {
DateOfBirth string `json:"dob,omitempty"`
AccountNumber string `json:"account_number,omitempty"`
Address *common.Address `json:"address,omitempty"`
CountryCode common.Country `json:"country_code,omitempty"`
Zip string `json:"zip,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
}
ProcessingSettings struct {
OrderId string `json:"order_id,omitempty"`
TaxAmount int64 `json:"tax_amount,omitempty"`
DiscountAmount int64 `json:"discount_amount,omitempty"`
DutyAmount int64 `json:"duty_amount,omitempty"`
ShippingAmount int64 `json:"shipping_amount,omitempty"`
ShippingTaxAmount int64 `json:"shipping_tax_amount,omitempty"`
Aft bool `json:"aft,omitempty"`
PreferredScheme PreferredSchema `json:"preferred_scheme,omitempty"`
MerchantInitiatedReason MerchantInitiatedReason `json:"merchant_initiated_reason,omitempty"`
CampaignId int64 `json:"campaign_id,omitempty"`
ProductType ProductType `json:"product_type,omitempty"`
OpenId string `json:"open_id,omitempty"`
OriginalOrderAmount int64 `json:"original_order_amount,omitempty"`
ReceiptId string `json:"receipt_id,omitempty"`
TerminalType TerminalType `json:"terminal_type,omitempty"`
OsType OsType `json:"os_type,omitempty"`
InvoiceId string `json:"invoice_id,omitempty"`
BrandName string `json:"brand_name,omitempty"`
Locale string `json:"locale,omitempty"`
ShippingPreference ShippingPreference `json:"shipping_preference,omitempty"`
UserAction UserAction `json:"user_action,omitempty"`
SetTransactionContext []map[string]string `json:"set_transaction_context,omitempty"`
AirlineData []AirlineData `json:"airline_data,omitempty"`
OtpValue string `json:"otp_value,omitempty"`
PurchaseCountry common.Country `json:"purchase_country,omitempty"`
CustomPaymentMethodIds []string `json:"custom_payment_method_ids,omitempty"`
MerchantCallbackUrl string `json:"merchant_callback_url,omitempty"`
ShippingDelay int64 `json:"shipping_delay,omitempty"`
ShippingInfo string `json:"shipping_info,omitempty"`
LineOfBusiness string `json:"line_of_business,omitempty"`
// Only available on Previous
SenderInformation *SenderInformation `json:"senderInformation,omitempty"`
Purpose string `json:"purpose,omitempty"`
Dlocal *DLocalProcessingSettings `json:"dlocal,omitempty"`
}
ThreeDsEnrollment struct {
Downgraded bool `json:"downgraded,omitempty"`
Enrolled ThreeDsEnrollmentStatus `json:"enrolled,omitempty"`
UpgradeReason string `json:"upgrade_reason,omitempty"`
}
RiskAssessment struct {
Flagged bool `json:"flagged,omitempty"`
Score float64 `json:"score,omitempty"`
}
PaymentProcessing struct {
RetrievalReferenceNumber string `json:"retrieval_reference_number,omitempty"`
AcquirerTransactionId string `json:"acquirer_transaction_id,omitempty"`
RecommendationCode string `json:"recommendation_code,omitempty"`
Scheme string `json:"scheme,omitempty"`
PartnerMerchantAdviceCode string `json:"partner_merchant_advice_code,omitempty"`
PartnerResponseCode string `json:"partner_response_code,omitempty"`
PartnerOrderId string `json:"partner_order_id,omitempty"`
PartnerSessionId string `json:"partner_session_id,omitempty"`
PartnerClientToken string `json:"partner_client_token,omitempty"`
PartnerPaymentId string `json:"partner_payment_id,omitempty"`
ContinuationPayload string `json:"continuation_payload,omitempty"`
Pun string `json:"pun,omitempty"`
PartnerStatus string `json:"partner_status,omitempty"`
PartnerTransactionId string `json:"partner_transaction_id,omitempty"`
PartnerErrorCodes []string `json:"partner_error_codes,omitempty"`
PartnerErrorMessage string `json:"partner_error_message,omitempty"`
PartnerAuthorizationCode string `json:"partner_authorization_code,omitempty"`
PartnerAuthorizationResponseCode string `json:"partner_authorization_response_code,omitempty"`
}
PaymentRetryResponse struct {
MaxAttempts int `json:"max_attempts,omitempty"`
EndsOn *time.Time `json:"ends_on,omitempty"`
NextAttemptOn *time.Time `json:"next_attempt_on,omitempty"`
}
ThreeDsData struct {
Downgraded bool `json:"downgraded,omitempty"`
Enrolled string `json:"enrolled,omitempty"`
UpgradeReason string `json:"upgrade_reason,omitempty"`
SignatureValid string `json:"signature_valid,omitempty"`
AuthenticationResponse string `json:"authentication_response,omitempty"`
AuthenticationStatusReason string `json:"authentication_status_reason,omitempty"`
Cryptogram string `json:"cryptogram,omitempty"`
Xid string `json:"xid,omitempty"`
Version string `json:"version,omitempty"`
Exemption Exemption `json:"exemption,omitempty"`
ExemptionApplied string `json:"exemption_applied,omitempty"`
Challenged bool `json:"challenged,omitempty"`
}
PaymentActionSummary struct {
Id string `json:"id,omitempty"`
Type ActionType `json:"type,omitempty"`
ResponseCode string `json:"response_code,omitempty"`
ResponseSummary string `json:"response_summary,omitempty"`
}
Processing struct {
AcquirerReferenceNumber string `json:"acquirer_reference_number,omitempty"`
RetrievalReferenceNumber ActionType `json:"retrieval_reference_number,omitempty"`
AcquirerTransactionId string `json:"acquirer_transaction_id,omitempty"`
}
Installments struct {
Count string `json:"count,omitempty"`
}
SenderInformation struct {
Reference string `json:"reference,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Dob string `json:"dob,omitempty"`
Address string `json:"address,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Country common.Country `json:"country,omitempty"`
PostalCode string `json:"postalCode,omitempty"`
SourceOfFunds string `json:"sourceOfFunds,omitempty"`
Purpose string `json:"purpose,omitempty"`
}
DLocalProcessingSettings struct {
Country common.Country `json:"country,omitempty"`
Payer Payer `json:"payer,omitempty"`
Installments *Installments `json:"installments,omitempty"`
}
Product struct {
Name string `json:"name,omitempty"`
Quantity int `json:"quantity,omitempty"`
UnitPrice int `json:"unit_price,omitempty"`
Price int `json:"price,omitempty"`
Reference string `json:"reference,omitempty"`
CommodityCode string `json:"commodity_code,omitempty"`
UnitOfMeasure string `json:"unit_of_measure,omitempty"`
TotalAmount int64 `json:"total_amount,omitempty"`
TaxAmount int64 `json:"tax_amount,omitempty"`
DiscountAmount int64 `json:"discount_amount,omitempty"`
WxpayGoodsId string `json:"wxpay_goods_id,omitempty"`
ImageUrl string `json:"image_url,omitempty"`
Url string `json:"url,omitempty"`
Sku string `json:"sku,omitempty"`
}
BillingInformation struct {
Address *common.Address `json:"address,omitempty"`
Phone *common.Phone `json:"phone,omitempty"`
}
)
// Request
type (
RefundRequest struct {
Amount int64 `json:"amount,omitempty"`
Reference string `json:"reference,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
// Not available on Previous
AmountAllocations []common.AmountAllocations `json:"amount_allocations,omitempty"`
}
VoidRequest struct {
Reference string `json:"reference,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
QueryRequest struct {
Limit int `url:"limit,10"`
Skip int `url:"skip,0"`
Reference string `url:"reference,omitempty"`
}
)
// Response
type (
CaptureResponse struct {
HttpMetadata common.HttpMetadata
ActionId string `json:"action_id,omitempty"`
Reference string `json:"reference,omitempty"`
Links map[string]common.Link `json:"_links"`
}
RefundResponse struct {
HttpMetadata common.HttpMetadata
ActionId string `json:"action_id,omitempty"`
Reference string `json:"reference,omitempty"`
Links map[string]common.Link `json:"_links"`
}
VoidResponse struct {
HttpMetadata common.HttpMetadata
ActionId string `json:"action_id,omitempty"`
Reference string `json:"reference,omitempty"`
Links map[string]common.Link `json:"_links"`
}
ProcessingData struct {
PreferredScheme PreferredSchema `json:"preferred_scheme,omitempty"`
AppId string `json:"app_id,omitempty"`
PartnerCustomerId string `json:"partner_customer_id,omitempty"`
PartnerPaymentId string `json:"partner_payment_id,omitempty"`
TaxAmount int64 `json:"tax_amount,omitempty"`
PurchaseCountry common.Country `json:"purchase_country,omitempty"`
Locale string `json:"locale,omitempty"`
RetrievalReferenceNumber string `json:"retrieval_reference_number,omitempty"`
PartnerOrderId string `json:"partner_order_id,omitempty"`
PartnerStatus string `json:"partner_status,omitempty"`
PartnerTransactionId string `json:"partner_transaction_id,omitempty"`
PartnerErrorCodes string `json:"partner_error_codes,omitempty"`
PartnerErrorMessage string `json:"partner_error_message,omitempty"`
PartnerAuthorizationCode string `json:"partner_authorization_code,omitempty"`
PartnerAuthorizationResponseCode string `json:"partner_authorization_response_code,omitempty"`
FraudStatus string `json:"fraud_status,omitempty"`
ProviderAuthorizedPaymentMethod *ProviderAuthorizedPaymentMethod `json:"provider_authorized_payment_method,omitempty"`
CustomPaymentMethodIds []string `json:"custom_payment_method_ids,omitempty"`
Aft bool `json:"aft,omitempty"`
MerchantCategoryCode string `json:"merchant_category_code,omitempty"`
SchemeMerchantId string `json:"scheme_merchant_id,omitempty"`
}
ProviderAuthorizedPaymentMethod struct {
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
NumberOfInstallments int64 `json:"number_of_installments,omitempty"`
NumberOfDays int64 `json:"number_of_days,omitempty"`
}
)
type (
DestinationTypeMapping struct {
Destination string `json:"destination"`
}
SenderTypeMapping struct {
Sender string `json:"sender"`
}
)