-
Notifications
You must be signed in to change notification settings - Fork 303
Expand file tree
/
Copy pathtypes.go
More file actions
1624 lines (1447 loc) · 65.1 KB
/
Copy pathtypes.go
File metadata and controls
1624 lines (1447 loc) · 65.1 KB
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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package paypal
import (
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
"sync"
"time"
)
const (
// APIBaseSandBox points to the sandbox (for testing) version of the API
APIBaseSandBox = "https://api-m.sandbox.paypal.com"
// APIBaseLive points to the live version of the API
APIBaseLive = "https://api-m.paypal.com"
// RequestNewTokenBeforeExpiresIn is used by SendWithAuth and try to get new Token when it's about to expire
RequestNewTokenBeforeExpiresIn = time.Duration(60) * time.Second
)
// Possible values for `no_shipping` in InputFields
//
// https://developer.paypal.com/docs/api/payment-experience/#definition-input_fields
const (
NoShippingDisplay uint = 0
NoShippingHide uint = 1
NoShippingBuyerAccount uint = 2
)
// Possible values for `address_override` in InputFields
//
// https://developer.paypal.com/docs/api/payment-experience/#definition-input_fields
const (
AddrOverrideFromFile uint = 0
AddrOverrideFromCall uint = 1
)
// Possible values for `landing_page_type` in FlowConfig
//
// https://developer.paypal.com/docs/api/payment-experience/#definition-flow_config
const (
LandingPageTypeBilling string = "Billing"
LandingPageTypeLogin string = "Login"
)
// Possible value for `allowed_payment_method` in PaymentOptions
//
// https://developer.paypal.com/docs/api/payments/#definition-payment_options
const (
AllowedPaymentUnrestricted string = "UNRESTRICTED"
AllowedPaymentInstantFundingSource string = "INSTANT_FUNDING_SOURCE"
AllowedPaymentImmediatePay string = "IMMEDIATE_PAY"
)
// Possible value for `intent` in CreateOrder
//
// https://developer.paypal.com/docs/api/orders/v2/#orders_create
const (
OrderIntentCapture string = "CAPTURE"
OrderIntentAuthorize string = "AUTHORIZE"
)
// Possible value for `status` in GetOrder
//
// https://developer.paypal.com/docs/api/orders/v2/#orders-get-response
const (
OrderStatusCreated string = "CREATED"
OrderStatusSaved string = "SAVED"
OrderStatusApproved string = "APPROVED"
OrderStatusVoided string = "VOIDED"
OrderStatusCompleted string = "COMPLETED"
)
// Possible values for `category` in Item
//
// https://developer.paypal.com/docs/api/orders/v2/#definition-item
const (
ItemCategoryDigitalGood string = "DIGITAL_GOODS"
ItemCategoryPhysicalGood string = "PHYSICAL_GOODS"
)
// Possible values for `shipping_preference` in ApplicationContext
//
// https://developer.paypal.com/docs/api/orders/v2/#definition-application_context
const (
EventCheckoutOrderApproved string = "CHECKOUT.ORDER.APPROVED"
EventPaymentCaptureCompleted string = "PAYMENT.CAPTURE.COMPLETED"
EventPaymentCaptureDenied string = "PAYMENT.CAPTURE.DENIED"
EventPaymentCaptureRefunded string = "PAYMENT.CAPTURE.REFUNDED"
EventMerchantOnboardingCompleted string = "MERCHANT.ONBOARDING.COMPLETED"
EventMerchantPartnerConsentRevoked string = "MERCHANT.PARTNER-CONSENT.REVOKED"
)
const (
OperationAPIIntegration string = "API_INTEGRATION"
ProductExpressCheckout string = "EXPRESS_CHECKOUT"
IntegrationMethodPayPal string = "PAYPAL"
IntegrationTypeThirdParty string = "THIRD_PARTY"
ConsentShareData string = "SHARE_DATA_CONSENT"
)
const (
FeaturePayment string = "PAYMENT"
FeatureRefund string = "REFUND"
FeatureFuturePayment string = "FUTURE_PAYMENT"
FeatureDirectPayment string = "DIRECT_PAYMENT"
FeaturePartnerFee string = "PARTNER_FEE"
FeatureDelayFunds string = "DELAY_FUNDS_DISBURSEMENT"
FeatureReadSellerDispute string = "READ_SELLER_DISPUTE"
FeatureUpdateSellerDispute string = "UPDATE_SELLER_DISPUTE"
FeatureDisputeReadBuyer string = "DISPUTE_READ_BUYER"
FeatureUpdateCustomerDispute string = "UPDATE_CUSTOMER_DISPUTES"
)
// https://developer.paypal.com/docs/api/payments.payouts-batch/v1/?mark=recipient_type#definition-recipient_type
const (
EmailRecipientType string = "EMAIL" // An unencrypted email — string of up to 127 single-byte characters.
PaypalIdRecipientType string = "PAYPAL_ID" // An encrypted PayPal account number.
PhoneRecipientType string = "PHONE" // An unencrypted phone number.
// Note: The PayPal sandbox doesn't support type PHONE
)
// https://developer.paypal.com/docs/api/payments.payouts-batch/v1/?mark=recipient_wallet#definition-recipient_wallet
const (
PaypalRecipientWallet string = "PAYPAL"
VenmoRecipientWallet string = "VENMO"
)
// Possible value for `batch_status` in GetPayout
//
// https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#definition-batch_status
const (
BatchStatusDenied string = "DENIED"
BatchStatusPending string = "PENDING"
BatchStatusProcessing string = "PROCESSING"
BatchStatusSuccess string = "SUCCESS"
BatchStatusCanceled string = "CANCELED"
)
const (
LinkRelSelf string = "self"
LinkRelActionURL string = "action_url"
)
const (
AncorTypeApplication string = "APPLICATION"
AncorTypeAccount string = "ACCOUNT"
)
type (
// JSONTime overrides MarshalJson method to format in ISO8601
JSONTime time.Time
// Address struct
Address struct {
Line1 string `json:"line1,omitempty"`
Line2 string `json:"line2,omitempty"`
City string `json:"city,omitempty"`
CountryCode string `json:"country_code,omitempty"`
PostalCode string `json:"postal_code,omitempty"`
State string `json:"state,omitempty"`
Phone string `json:"phone,omitempty"`
}
// AgreementDetails struct
AgreementDetails struct {
OutstandingBalance AmountPayout `json:"outstanding_balance"`
CyclesRemaining int `json:"cycles_remaining,string"`
CyclesCompleted int `json:"cycles_completed,string"`
NextBillingDate time.Time `json:"next_billing_date"`
LastPaymentDate time.Time `json:"last_payment_date"`
LastPaymentAmount AmountPayout `json:"last_payment_amount"`
FinalPaymentDate time.Time `json:"final_payment_date"`
FailedPaymentCount int `json:"failed_payment_count,string"`
}
// Amount struct
Amount struct {
Currency string `json:"currency"`
Total string `json:"total"`
Details Details `json:"details,omitempty"`
}
// AmountPayout struct
AmountPayout struct {
Currency string `json:"currency"`
Value string `json:"value"`
}
// ApplicationContext struct
// Doc: https://developer.paypal.com/docs/api/orders/v2/#definition-application_context
ApplicationContext struct {
BrandName string `json:"brand_name,omitempty"`
Locale string `json:"locale,omitempty"`
ShippingPreference ShippingPreference `json:"shipping_preference,omitempty"`
UserAction UserAction `json:"user_action,omitempty"`
PaymentMethod PaymentMethod `json:"payment_method,omitempty"`
LandingPage string `json:"landing_page,omitempty"`
ReturnURL string `json:"return_url,omitempty"`
CancelURL string `json:"cancel_url,omitempty"`
}
// Invoicing relates structures
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#invoices_generate-next-invoice-number
InvoiceNumber struct {
InvoiceNumberValue string `json:"invoice_number"`
}
// used in InvoiceAmountWithBreakdown
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-custom_amount
CustomAmount struct {
Label string `json:"label"`
Amount Money `json:"amount,omitempty"`
}
// Used in AggregatedDiscount
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-discount
InvoicingDiscount struct {
DiscountAmount Money `json:"amount,omitempty"`
Percent string `json:"percent,omitempty"`
}
// Used in InvoiceAmountWithBreakdown
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-aggregated_discount
AggregatedDiscount struct {
InvoiceDiscount InvoicingDiscount `json:"invoice_discount,omitempty"`
ItemDiscount *Money `json:"item_discount,omitempty"`
}
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-tax
InvoiceTax struct {
Name string `json:"name,omitempty"`
Percent string `json:"percent,omitempty"`
ID string `json:"id,omitempty"` // not mentioned here, but is still returned in response payload, when invoice is requested by ID.
Amount Money `json:"amount,omitempty"`
}
// Used in InvoiceAmountWithBreakdown struct
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-shipping_cost
InvoiceShippingCost struct {
Amount Money `json:"amount,omitempty"`
Tax InvoiceTax `json:"tax,omitempty"`
}
// Used in AmountSummaryDetail
// Doc: https://developer.paypal.com/docs/api/payments/v2/#definition-nrp-nrr_attributes
InvoiceAmountWithBreakdown struct {
Custom CustomAmount `json:"custom,omitempty"` // The custom amount to apply to an invoice.
Discount AggregatedDiscount `json:"discount,omitempty"`
ItemTotal Money `json:"item_total,omitempty"` // The subtotal for all items.
Shipping InvoiceShippingCost `json:"shipping,omitempty"` // The shipping fee for all items. Includes tax on shipping.
TaxTotal Money `json:"tax_total,omitempty"`
}
// Invoice AmountSummary
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-amount_summary_detail
AmountSummaryDetail struct {
Breakdown InvoiceAmountWithBreakdown `json:"breakdown,omitempty"`
Currency string `json:"currency_code,omitempty"`
Value string `json:"value,omitempty"`
}
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-partial_payment
InvoicePartialPayment struct {
AllowPartialPayment bool `json:"allow_partial_payment,omitempty"`
MinimumAmountDue Money `json:"minimum_amount_due,omitempty"` // Valid only when allow_partial_payment is true.
}
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-configuration
InvoiceConfiguration struct {
AllowTip bool `json:"allow_tip,omitempty"`
PartialPayment InvoicePartialPayment `json:"partial_payment,omitempty"`
TaxCalculatedAfterDiscount bool `json:"tax_calculated_after_discount,omitempty"`
TaxInclusive bool `json:"tax_inclusive,omitempty"`
TemplateId string `json:"template_id,omitempty"`
}
// used in InvoiceDetail structure
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-file_reference
InvoiceFileReference struct {
ContentType string `json:"content_type,omitempty"`
CreateTime string `json:"create_time,omitempty"`
ID string `json:"id,omitempty"`
URL string `json:"reference_url,omitempty"`
Size string `json:"size,omitempty"`
}
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-metadata
InvoiceAuditMetadata struct {
CreateTime string `json:"create_time,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
LastUpdateTime string `json:"last_update_time,omitempty"`
LastUpdatedBy string `json:"last_updated_by,omitempty"`
CancelTime string `json:"cancel_time,omitempty"`
CancellledTimeBy string `json:"cancelled_by,omitempty"`
CreatedByFlow string `json:"created_by_flow,omitempty"`
FirstSentTime string `json:"first_sent_time,omitempty"`
InvoicerViewUrl string `json:"invoicer_view_url,omitempty"`
LastSentBy string `json:"last_sent_by,omitempty"`
LastSentTime string `json:"last_sent_time,omitempty"`
RecipientViewUrl string `json:"recipient_view_url,omitempty"`
}
// used in InvoiceDetail struct
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-invoice_payment_term
InvoicePaymentTerm struct {
TermType string `json:"term_type,omitempty"`
DueDate string `json:"due_date,omitempty"`
}
// used in Invoice struct
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-invoice_detail
InvoiceDetail struct {
CurrencyCode string `json:"currency_code"` // required, hence omitempty not used
Attachments []InvoiceFileReference `json:"attachments,omitempty"`
Memo string `json:"memo,omitempty"`
Note string `json:"note,omitempty"`
Reference string `json:"reference,omitempty"`
TermsAndConditions string `json:"terms_and_conditions,omitempty"`
InvoiceDate string `json:"invoice_date,omitempty"`
InvoiceNumber string `json:"invoice_number,omitempty"`
Metadata InvoiceAuditMetadata `json:"metadata,omitempty"` // The audit metadata.
PaymentTerm InvoicePaymentTerm `json:"payment_term,omitempty"` // payment due date for the invoice. Value is either but not both term_type or due_date.
}
// used in InvoicerInfo struct
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-phone_detail
InvoicerPhoneDetail struct {
CountryCode string `json:"country_code"`
NationalNumber string `json:"national_number"`
ExtensionNumber string `json:"extension_number,omitempty"`
PhoneType string `json:"phone_type,omitempty"`
}
// used in Invoice struct
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-invoicer_info
InvoicerInfo struct {
AdditionalNotes string `json:"additional_notes,omitempty"`
EmailAddress string `json:"email_address,omitempty"`
LogoUrl string `json:"logo_url,omitempty"`
Phones []InvoicerPhoneDetail `json:"phones,omitempty"`
TaxId string `json:"tax_id,omitempty"`
Website string `json:"website,omitempty"`
}
// Used in Invoice struct
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-item
InvoiceItem struct {
Name string `json:"name"`
Quantity string `json:"quantity"`
UnitAmount Money `json:"unit_amount"`
Description string `json:"description,omitempty"`
InvoiceDiscount InvoicingDiscount `json:"discount,omitempty"`
ID string `json:"id,omitempty"`
ItemDate string `json:"item_date,omitempty"`
Tax InvoiceTax `json:"tax,omitempty"`
UnitOfMeasure string `json:"unit_of_measure,omitempty"`
}
// used in InvoiceAddressPortable
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-address_details
InvoiceAddressDetails struct {
BuildingName string `json:"building_name,omitempty"`
DeliveryService string `json:"delivery_service,omitempty"`
StreetName string `json:"street_name,omitempty"`
StreetNumber string `json:"street_number,omitempty"`
StreetType string `json:"street_type,omitempty"`
SubBuilding string `json:"sub_building,omitempty"`
}
// used in InvoiceContactInfo
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-address_portable
InvoiceAddressPortable struct {
CountryCode string `json:"country_code"`
AddressDetails InvoiceAddressDetails `json:"address_details,omitempty"`
AddressLine1 string `json:"address_line_1,omitempty"`
AddressLine2 string `json:"address_line_2,omitempty"`
AddressLine3 string `json:"address_line_3,omitempty"`
AdminArea1 string `json:"admin_area_1,omitempty"`
AdminArea2 string `json:"admin_area_2,omitempty"`
AdminArea3 string `json:"admin_area_3,omitempty"`
AdminArea4 string `json:"admin_area_4,omitempty"`
PostalCode string `json:"postal_code,omitempty"`
}
// used in InvoicePaymentDetails
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-contact_information
InvoiceContactInfo struct {
BusinessName string `json:"business_name,omitempty"`
RecipientAddress InvoiceAddressPortable `json:"address,omitempty"` // address of the recipient.
RecipientName Name `json:"name,omitempty"` // The first and Last name of the recipient.
}
// used in InvoicePayments struct
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-payment_detail
InvoicePaymentDetails struct {
Method string `json:"method"`
Amount Money `json:"amount,omitempty"`
Note string `json:"note,omitempty"`
PaymentDate string `json:"payment_date,omitempty"`
PaymentID string `json:"payment_id,omitempty"`
ShippingInfo InvoiceContactInfo `json:"shipping_info,omitempty"` // The recipient's shipping information.
Type string `json:"type,omitempty"`
}
// used in Invoice
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-payments
InvoicePayments struct {
PaidAmount Money `json:"paid_amount,omitempty"`
Transactions []InvoicePaymentDetails `json:"transactions,omitempty"`
}
// used in InvoiceRecipientInfo
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-billing_info
InvoiceBillingInfo struct {
AdditionalInfo string `json:"additional_info,omitempty"`
EmailAddress string `json:"email_address,omitempty"`
Language string `json:"language,omitempty"`
Phones []InvoicerPhoneDetail `json:"phones,omitempty"` // invoice recipient's phone numbers.
}
// used in Invoice struct
// Doc:
InvoiceRecipientInfo struct {
BillingInfo InvoiceBillingInfo `json:"billing_info,omitempty"` // billing information for the invoice recipient.
ShippingInfo InvoiceContactInfo `json:"shipping_info,omitempty"` // recipient's shipping information.
}
// used in InvoiceRefund struct
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-refund_detail
InvoiceRefundDetails struct {
Method string `json:"method"`
RefundAmount Money `json:"amount,omitempty"`
RefundDate string `json:"refund_date,omitempty"`
RefundID string `json:"refund_id,omitempty"`
RefundType string `json:"type,omitempty"`
}
// used in Invoice struct
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-refunds
InvoiceRefund struct {
RefundAmount Money `json:"refund_amount,omitempty"`
RefundDetails []InvoiceRefundDetails `json:"transactions,omitempty"`
}
// used in Invoice struct
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#definition-email_address
InvoiceEmailAddress struct {
EmailAddress string `json:"email_address,omitempty"`
}
// to contain Invoice related fields
// Doc: https://developer.paypal.com/docs/api/invoicing/v2/#invoices_get
Invoice struct {
AdditionalRecipients []InvoiceEmailAddress `json:"additional_recipients,omitempty"` // An array of one or more CC: emails to which notifications are sent.
AmountSummary AmountSummaryDetail `json:"amount,omitempty"`
Configuration InvoiceConfiguration `json:"configuration,omitempty"`
Detail InvoiceDetail `json:"detail,omitempty"`
DueAmount Money `json:"due_amount,omitempty"` // balance amount outstanding after payments.
Gratuity Money `json:"gratuity,omitempty"` // amount paid by the payer as gratuity to the invoicer.
ID string `json:"id,omitempty"`
Invoicer InvoicerInfo `json:"invoicer,omitempty"`
Items []InvoiceItem `json:"items,omitempty"`
Links []Link `json:"links,omitempty"`
ParentID string `json:"parent_id,omitempty"`
Payments InvoicePayments `json:"payments,omitempty"`
PrimaryRecipients []InvoiceRecipientInfo `json:"primary_recipients,omitempty"`
Refunds InvoiceRefund `json:"refunds,omitempty"` // List of refunds against this invoice.
Status string `json:"status,omitempty"`
}
// Doc: https://developer.paypal.com/api/orders/v2/#definition-payment_method
PaymentMethod struct {
PayeePreferred PayeePreferred `json:"payee_preferred,omitempty"`
StandardEntryClassCode StandardEntryClassCode `json:"standard_entry_class_code,omitempty"`
}
// Authorization struct
Authorization struct {
ID string `json:"id,omitempty"`
CustomID string `json:"custom_id,omitempty"`
InvoiceID string `json:"invoice_id,omitempty"`
Status string `json:"status,omitempty"`
StatusDetails *CaptureStatusDetails `json:"status_details,omitempty"`
Amount *PurchaseUnitAmount `json:"amount,omitempty"`
SellerProtection *SellerProtection `json:"seller_protection,omitempty"`
CreateTime *time.Time `json:"create_time,omitempty"`
UpdateTime *time.Time `json:"update_time,omitempty"`
ExpirationTime *time.Time `json:"expiration_time,omitempty"`
Links []Link `json:"links,omitempty"`
}
AuthorizeOrderResponse struct {
CreateTime *time.Time `json:"create_time,omitempty"`
UpdateTime *time.Time `json:"update_time,omitempty"`
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Intent string `json:"intent,omitempty"`
PurchaseUnits []PurchaseUnit `json:"purchase_units,omitempty"`
Payer *PayerWithNameAndPhone `json:"payer,omitempty"`
}
// AuthorizeOrderRequest - https://developer.paypal.com/docs/api/orders/v2/#orders_authorize
AuthorizeOrderRequest struct {
PaymentSource *PaymentSource `json:"payment_source,omitempty"`
ApplicationContext ApplicationContext `json:"application_context,omitempty"`
}
// https://developer.paypal.com/docs/api/payments/v2/#definition-platform_fee
PlatformFee struct {
Amount *Money `json:"amount,omitempty"`
Payee *PayeeForOrders `json:"payee,omitempty"`
}
// https://developer.paypal.com/docs/api/payments/v2/#definition-payment_instruction
PaymentInstruction struct {
PlatformFees []PlatformFee `json:"platform_fees,omitempty"`
DisbursementMode string `json:"disbursement_mode,omitempty"`
}
// https://developer.paypal.com/docs/api/payments/v2/#authorizations_capture
PaymentCaptureRequest struct {
InvoiceID string `json:"invoice_id,omitempty"`
NoteToPayer string `json:"note_to_payer,omitempty"`
SoftDescriptor string `json:"soft_descriptor,omitempty"`
Amount *Money `json:"amount,omitempty"`
FinalCapture bool `json:"final_capture,omitempty"`
}
SellerProtection struct {
Status string `json:"status,omitempty"`
DisputeCategories []string `json:"dispute_categories,omitempty"`
}
// https://developer.paypal.com/docs/api/payments/v2/#definition-capture_status_details
CaptureStatusDetails struct {
Reason string `json:"reason,omitempty"`
}
PaymentCaptureResponse struct {
Status string `json:"status,omitempty"`
StatusDetails *CaptureStatusDetails `json:"status_details,omitempty"`
ID string `json:"id,omitempty"`
Amount *Money `json:"amount,omitempty"`
InvoiceID string `json:"invoice_id,omitempty"`
FinalCapture bool `json:"final_capture,omitempty"`
DisbursementMode string `json:"disbursement_mode,omitempty"`
Links []Link `json:"links,omitempty"`
}
// https://developer.paypal.com/docs/api/payments/v2/#captures_get
CaptureDetailsResponse struct {
Status string `json:"status,omitempty"`
StatusDetails *CaptureStatusDetails `json:"status_details,omitempty"`
ID string `json:"id,omitempty"`
Amount *Money `json:"amount,omitempty"`
InvoiceID string `json:"invoice_id,omitempty"`
CustomID string `json:"custom_id,omitempty"`
SellerProtection *SellerProtection `json:"seller_protection,omitempty"`
FinalCapture bool `json:"final_capture,omitempty"`
SellerReceivableBreakdown *SellerReceivableBreakdown `json:"seller_receivable_breakdown,omitempty"`
DisbursementMode string `json:"disbursement_mode,omitempty"`
Links []Link `json:"links,omitempty"`
UpdateTime *time.Time `json:"update_time,omitempty"`
CreateTime *time.Time `json:"create_time,omitempty"`
}
// CaptureOrderRequest - https://developer.paypal.com/docs/api/orders/v2/#orders_capture
CaptureOrderRequest struct {
PaymentSource *PaymentSource `json:"payment_source"`
}
// CaptureOrderMockResponse - https://developer.paypal.com/docs/api-basics/sandbox/request-headers/#test-api-error-handling-routines
CaptureOrderMockResponse struct {
MockApplicationCodes string `json:"mock_application_codes"`
}
// RefundOrderRequest - https://developer.paypal.com/docs/api/payments/v2/#captures_refund
RefundCaptureRequest struct {
Amount *Money `json:"amount,omitempty"`
InvoiceID string `json:"invoice_id,omitempty"`
NoteToPayer string `json:"note_to_payer,omitempty"`
}
// BatchHeader struct
BatchHeader struct {
Amount *AmountPayout `json:"amount,omitempty"`
Fees *AmountPayout `json:"fees,omitempty"`
PayoutBatchID string `json:"payout_batch_id,omitempty"`
BatchStatus string `json:"batch_status,omitempty"`
TimeCreated *time.Time `json:"time_created,omitempty"`
TimeCompleted *time.Time `json:"time_completed,omitempty"`
SenderBatchHeader *SenderBatchHeader `json:"sender_batch_header,omitempty"`
}
// Plan struct
Plan struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
CreateTime string `json:"create_time,omitempty"`
UpdateTime string `json:"update_time,omitempty"`
PaymentDefinitions []PaymentDefinition `json:"payment_definitions,omitempty"`
}
// BillingInfo struct
BillingInfo struct {
OutstandingBalance AmountPayout `json:"outstanding_balance,omitempty"`
CycleExecutions []CycleExecutions `json:"cycle_executions,omitempty"`
LastPayment LastPayment `json:"last_payment,omitempty"`
NextBillingTime time.Time `json:"next_billing_time,omitempty"`
FailedPaymentsCount int `json:"failed_payments_count,omitempty"`
}
// BillingPlan struct
BillingPlan struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
PaymentDefinitions []PaymentDefinition `json:"payment_definitions,omitempty"`
MerchantPreferences *MerchantPreferences `json:"merchant_preferences,omitempty"`
}
// Capture struct
Capture struct {
ID string `json:"id,omitempty"`
Amount *Amount `json:"amount,omitempty"`
State string `json:"state,omitempty"`
ParentPayment string `json:"parent_payment,omitempty"`
TransactionFee string `json:"transaction_fee,omitempty"`
IsFinalCapture bool `json:"is_final_capture"`
CreateTime *time.Time `json:"create_time,omitempty"`
UpdateTime *time.Time `json:"update_time,omitempty"`
Links []Link `json:"links,omitempty"`
}
// ChargeModel struct
ChargeModel struct {
Type string `json:"type,omitempty"`
Amount AmountPayout `json:"amount,omitempty"`
}
// Client represents a Paypal REST API Client
Client struct {
// sync.Mutex
mu sync.Mutex
Client *http.Client
ClientID string
Secret string
APIBase string
Log io.Writer // If user set log file name all requests will be logged there
Token *TokenResponse
tokenExpiresAt time.Time
returnRepresentation bool
}
// CreditCard struct
CreditCard struct {
ID string `json:"id,omitempty"`
PayerID string `json:"payer_id,omitempty"`
ExternalCustomerID string `json:"external_customer_id,omitempty"`
Number string `json:"number"`
Type string `json:"type"`
ExpireMonth string `json:"expire_month"`
ExpireYear string `json:"expire_year"`
CVV2 string `json:"cvv2,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
BillingAddress *Address `json:"billing_address,omitempty"`
State string `json:"state,omitempty"`
ValidUntil string `json:"valid_until,omitempty"`
}
// CreditCards GET /v1/vault/credit-cards
CreditCards struct {
Items []CreditCard `json:"items"`
SharedListResponse
}
// CreditCardToken struct
CreditCardToken struct {
CreditCardID string `json:"credit_card_id"`
PayerID string `json:"payer_id,omitempty"`
Last4 string `json:"last4,omitempty"`
ExpireYear string `json:"expire_year,omitempty"`
ExpireMonth string `json:"expire_month,omitempty"`
}
// CreditCardsFilter struct
CreditCardsFilter struct {
PageSize int
Page int
}
// CreditCardField PATCH /v1/vault/credit-cards/credit_card_id
CreditCardField struct {
Operation string `json:"op"`
Path string `json:"path"`
Value string `json:"value"`
}
// Currency struct
Currency struct {
Currency string `json:"currency,omitempty"`
Value string `json:"value,omitempty"`
}
// CycleExecutions struct
CycleExecutions struct {
TenureType string `json:"tenure_type,omitempty"`
Sequence int `json:"sequence,omitempty"`
CyclesCompleted int `json:"cycles_completed,omitempty"`
CyclesRemaining int `json:"cycles_remaining,omitempty"`
TotalCycles int `json:"total_cycles,omitempty"`
}
// LastPayment struct
LastPayment struct {
Amount Money `json:"amount,omitempty"`
Time time.Time `json:"time,omitempty"`
}
// Details structure used in Amount structures as optional value
Details struct {
Subtotal string `json:"subtotal,omitempty"`
Shipping string `json:"shipping,omitempty"`
Tax string `json:"tax,omitempty"`
HandlingFee string `json:"handling_fee,omitempty"`
ShippingDiscount string `json:"shipping_discount,omitempty"`
Insurance string `json:"insurance,omitempty"`
GiftWrap string `json:"gift_wrap,omitempty"`
}
// ErrorResponseDetail struct
ErrorResponseDetail struct {
Field string `json:"field"`
Value string `json:"value"`
Location string `json:"location"`
Issue string `json:"issue"`
Description string `json:"description"`
Links []Link `json:"link"`
}
// ErrorResponse https://developer.paypal.com/docs/api/errors/
ErrorResponse struct {
Response *http.Response `json:"-"`
Name string `json:"name"`
DebugID string `json:"debug_id"`
Message string `json:"message"`
InformationLink string `json:"information_link"`
Details []ErrorResponseDetail `json:"details"`
Links []Link `json:"link"`
}
// ExecuteAgreementResponse struct
ExecuteAgreementResponse struct {
ID string `json:"id"`
State string `json:"state"`
Description string `json:"description,omitempty"`
Payer Payer `json:"payer"`
Plan BillingPlan `json:"plan"`
StartDate time.Time `json:"start_date"`
ShippingAddress ShippingAddress `json:"shipping_address"`
AgreementDetails AgreementDetails `json:"agreement_details"`
Links []Link `json:"links"`
}
// ExecuteResponse struct
ExecuteResponse struct {
ID string `json:"id"`
Links []Link `json:"links"`
State string `json:"state"`
Payer PaymentPayer `json:"payer"`
Transactions []Transaction `json:"transactions,omitempty"`
}
// FundingInstrument struct
FundingInstrument struct {
CreditCard *CreditCard `json:"credit_card,omitempty"`
CreditCardToken *CreditCardToken `json:"credit_card_token,omitempty"`
}
// Item struct
Item struct {
Name string `json:"name"`
UnitAmount *Money `json:"unit_amount,omitempty"`
Tax *Money `json:"tax,omitempty"`
Quantity string `json:"quantity"`
Description string `json:"description,omitempty"`
SKU string `json:"sku,omitempty"`
Category string `json:"category,omitempty"`
URL string `json:"url,omitempty"`
ImageURL string `json:"image_url,omitempty"`
}
// ItemList struct
ItemList struct {
Items []Item `json:"items,omitempty"`
ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
}
// Link struct
Link struct {
Href string `json:"href"`
Rel string `json:"rel,omitempty"`
Method string `json:"method,omitempty"`
Description string `json:"description,omitempty"`
Enctype string `json:"enctype,omitempty"`
}
// PurchaseUnitAmount struct
PurchaseUnitAmount struct {
Currency string `json:"currency_code"`
Value string `json:"value"`
Breakdown *PurchaseUnitAmountBreakdown `json:"breakdown,omitempty"`
}
// PurchaseUnitAmountBreakdown struct
PurchaseUnitAmountBreakdown struct {
ItemTotal *Money `json:"item_total,omitempty"`
Shipping *Money `json:"shipping,omitempty"`
Handling *Money `json:"handling,omitempty"`
TaxTotal *Money `json:"tax_total,omitempty"`
Insurance *Money `json:"insurance,omitempty"`
ShippingDiscount *Money `json:"shipping_discount,omitempty"`
Discount *Money `json:"discount,omitempty"`
}
// Money struct
//
// https://developer.paypal.com/docs/api/orders/v2/#definition-money
Money struct {
Currency string `json:"currency_code"`
Value string `json:"value"`
}
PurchaseUnit struct {
ReferenceID string `json:"reference_id"`
Amount *PurchaseUnitAmount `json:"amount,omitempty"`
Payee *PayeeForOrders `json:"payee,omitempty"`
Payments *CapturedPayments `json:"payments,omitempty"`
PaymentInstruction *PaymentInstruction `json:"payment_instruction,omitempty"`
Description string `json:"description,omitempty"`
CustomID string `json:"custom_id,omitempty"`
InvoiceID string `json:"invoice_id,omitempty"`
ID string `json:"id,omitempty"`
SoftDescriptor string `json:"soft_descriptor,omitempty"`
Shipping *ShippingDetail `json:"shipping,omitempty"`
Items []Item `json:"items,omitempty"`
}
// TaxInfo used for orders.
TaxInfo struct {
TaxID string `json:"tax_id,omitempty"`
TaxIDType string `json:"tax_id_type,omitempty"`
}
// PhoneWithTypeNumber struct for PhoneWithType
PhoneWithTypeNumber struct {
NationalNumber string `json:"national_number,omitempty"`
}
// PhoneWithType struct used for orders
PhoneWithType struct {
PhoneType string `json:"phone_type,omitempty"`
PhoneNumber *PhoneWithTypeNumber `json:"phone_number,omitempty"`
}
// CreateOrderPayerName create order payer name
CreateOrderPayerName struct {
GivenName string `json:"given_name,omitempty"`
Surname string `json:"surname,omitempty"`
}
// CreateOrderPayer used with create order requests
CreateOrderPayer struct {
Name *CreateOrderPayerName `json:"name,omitempty"`
EmailAddress string `json:"email_address,omitempty"`
PayerID string `json:"payer_id,omitempty"`
Phone *PhoneWithType `json:"phone,omitempty"`
BirthDate string `json:"birth_date,omitempty"`
TaxInfo *TaxInfo `json:"tax_info,omitempty"`
Address *ShippingDetailAddressPortable `json:"address,omitempty"`
}
// PurchaseUnitRequest struct
PurchaseUnitRequest struct {
ReferenceID string `json:"reference_id,omitempty"`
Amount *PurchaseUnitAmount `json:"amount"`
Payee *PayeeForOrders `json:"payee,omitempty"`
Description string `json:"description,omitempty"`
CustomID string `json:"custom_id,omitempty"`
InvoiceID string `json:"invoice_id,omitempty"`
SoftDescriptor string `json:"soft_descriptor,omitempty"`
Items []Item `json:"items,omitempty"`
Shipping *ShippingDetail `json:"shipping,omitempty"`
PaymentInstruction *PaymentInstruction `json:"payment_instruction,omitempty"`
}
// MerchantPreferences struct
MerchantPreferences struct {
SetupFee *AmountPayout `json:"setup_fee,omitempty"`
ReturnURL string `json:"return_url,omitempty"`
CancelURL string `json:"cancel_url,omitempty"`
AutoBillAmount string `json:"auto_bill_amount,omitempty"`
InitialFailAmountAction string `json:"initial_fail_amount_action,omitempty"`
MaxFailAttempts string `json:"max_fail_attempts,omitempty"`
}
// Order struct
Order struct {
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Intent string `json:"intent,omitempty"`
Payer *PayerWithNameAndPhone `json:"payer,omitempty"`
PurchaseUnits []PurchaseUnit `json:"purchase_units,omitempty"`
Links []Link `json:"links,omitempty"`
CreateTime *time.Time `json:"create_time,omitempty"`
UpdateTime *time.Time `json:"update_time,omitempty"`
}
// ExchangeRate struct
//
// https://developer.paypal.com/docs/api/orders/v2/#definition-exchange_rate
ExchangeRate struct {
SourceCurrency string `json:"source_currency"`
TargetCurrency string `json:"target_currency"`
Value string `json:"value"`
}
// SellerReceivableBreakdown has the detailed breakdown of the capture activity.
SellerReceivableBreakdown struct {
GrossAmount *Money `json:"gross_amount,omitempty"`
PaypalFee *Money `json:"paypal_fee,omitempty"`
PaypalFeeInReceivableCurrency *Money `json:"paypal_fee_in_receivable_currency,omitempty"`
NetAmount *Money `json:"net_amount,omitempty"`
ReceivableAmount *Money `json:"receivable_amount,omitempty"`
ExchangeRate *ExchangeRate `json:"exchange_rate,omitempty"`
PlatformFees []PlatformFee `json:"platform_fees,omitempty"`
}
// CaptureAmount struct
CaptureAmount struct {
Status string `json:"status,omitempty"`
ID string `json:"id,omitempty"`
CustomID string `json:"custom_id,omitempty"`
Amount *PurchaseUnitAmount `json:"amount,omitempty"`
SellerProtection *SellerProtection `json:"seller_protection,omitempty"`
SellerReceivableBreakdown *SellerReceivableBreakdown `json:"seller_receivable_breakdown,omitempty"`
}
// CapturedPayments has the amounts for a captured order
CapturedPayments struct {
Authorizations []Authorization `json:"authorizations,omitempty"`
Captures []CaptureAmount `json:"captures,omitempty"`
}
// CapturedPurchaseItem are items for a captured order
CapturedPurchaseItem struct {
Quantity string `json:"quantity"`
Name string `json:"name"`
SKU string `json:"sku,omitempty"`
Description string `json:"description,omitempty"`
}
// CapturedPurchaseUnit are purchase units for a captured order
CapturedPurchaseUnit struct {
Items []CapturedPurchaseItem `json:"items,omitempty"`
ReferenceID string `json:"reference_id"`
Shipping CapturedPurchaseUnitShipping `json:"shipping,omitempty"`
Payments *CapturedPayments `json:"payments,omitempty"`
}
CapturedPurchaseUnitShipping struct {
Address ShippingDetailAddressPortable `json:"address,omitempty"`
}
// PayerWithNameAndPhone struct
PayerWithNameAndPhone struct {
Name *CreateOrderPayerName `json:"name,omitempty"`
EmailAddress string `json:"email_address,omitempty"`
Phone *PhoneWithType `json:"phone,omitempty"`
PayerID string `json:"payer_id,omitempty"`
BirthDate string `json:"birth_date,omitempty"`
TaxInfo *TaxInfo `json:"tax_info,omitempty"`
Address *ShippingDetailAddressPortable `json:"address,omitempty"`
}
// CaptureOrderResponse is the response for capture order
CaptureOrderResponse struct {
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Payer *PayerWithNameAndPhone `json:"payer,omitempty"`
Address *Address `json:"address,omitempty"`
PurchaseUnits []CapturedPurchaseUnit `json:"purchase_units,omitempty"`
}
// Payer struct
Payer struct {
PaymentMethod string `json:"payment_method"`
FundingInstruments []FundingInstrument `json:"funding_instruments,omitempty"`
PayerInfo *PayerInfo `json:"payer_info,omitempty"`
Status string `json:"payer_status,omitempty"`
}
// PayerInfo struct