-
Notifications
You must be signed in to change notification settings - Fork 2
/
transactions.go
1279 lines (1110 loc) · 73 KB
/
transactions.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
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
// Code generated by the Paddle SDK Generator; DO NOT EDIT.
package paddle
import (
"context"
"encoding/json"
paddleerr "github.com/PaddleHQ/paddle-go-sdk/v3/pkg/paddleerr"
)
// ErrTransactionImmutable represents a `transaction_immutable` error.
// See https://developer.paddle.com/errors/transactions/transaction_immutable for more information.
var ErrTransactionImmutable = &paddleerr.Error{
Code: "transaction_immutable",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionDiscountNotEligible represents a `transaction_discount_not_eligible` error.
// See https://developer.paddle.com/errors/transactions/transaction_discount_not_eligible for more information.
var ErrTransactionDiscountNotEligible = &paddleerr.Error{
Code: "transaction_discount_not_eligible",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionNotReadyCannotProcessPayment represents a `transaction_not_ready_cannot_process_payment` error.
// See https://developer.paddle.com/errors/transactions/transaction_not_ready_cannot_process_payment for more information.
var ErrTransactionNotReadyCannotProcessPayment = &paddleerr.Error{
Code: "transaction_not_ready_cannot_process_payment",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionDefaultCheckoutURLNotSet represents a `transaction_default_checkout_url_not_set` error.
// See https://developer.paddle.com/errors/transactions/transaction_default_checkout_url_not_set for more information.
var ErrTransactionDefaultCheckoutURLNotSet = &paddleerr.Error{
Code: "transaction_default_checkout_url_not_set",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionCheckoutNotEnabled represents a `transaction_checkout_not_enabled` error.
// See https://developer.paddle.com/errors/transactions/transaction_checkout_not_enabled for more information.
var ErrTransactionCheckoutNotEnabled = &paddleerr.Error{
Code: "transaction_checkout_not_enabled",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionPayoutAccountRequired represents a `transaction_payout_account_required` error.
// See https://developer.paddle.com/errors/transactions/transaction_payout_account_required for more information.
var ErrTransactionPayoutAccountRequired = &paddleerr.Error{
Code: "transaction_payout_account_required",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionCustomerIsRequiredWithAddress represents a `transaction_customer_is_required_with_address` error.
// See https://developer.paddle.com/errors/transactions/transaction_customer_is_required_with_address for more information.
var ErrTransactionCustomerIsRequiredWithAddress = &paddleerr.Error{
Code: "transaction_customer_is_required_with_address",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionCustomerIsRequiredForBusinessValidation represents a `transaction_customer_is_required_for_business_validation` error.
// See https://developer.paddle.com/errors/transactions/transaction_customer_is_required_for_business_validation for more information.
var ErrTransactionCustomerIsRequiredForBusinessValidation = &paddleerr.Error{
Code: "transaction_customer_is_required_for_business_validation",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionPriceDifferentBillingCycle represents a `transaction_price_different_billing_cycle` error.
// See https://developer.paddle.com/errors/transactions/transaction_price_different_billing_cycle for more information.
var ErrTransactionPriceDifferentBillingCycle = &paddleerr.Error{
Code: "transaction_price_different_billing_cycle",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionPriceDifferentTrialPeriod represents a `transaction_price_different_trial_period` error.
// See https://developer.paddle.com/errors/transactions/transaction_price_different_trial_period for more information.
var ErrTransactionPriceDifferentTrialPeriod = &paddleerr.Error{
Code: "transaction_price_different_trial_period",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionItemQuantityOutOfRange represents a `transaction_item_quantity_out_of_range` error.
// See https://developer.paddle.com/errors/transactions/transaction_item_quantity_out_of_range for more information.
var ErrTransactionItemQuantityOutOfRange = &paddleerr.Error{
Code: "transaction_item_quantity_out_of_range",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionBothPriceIDAndObjectFound represents a `transaction_both_price_id_and_object_found` error.
// See https://developer.paddle.com/errors/transactions/transaction_both_price_id_and_object_found for more information.
var ErrTransactionBothPriceIDAndObjectFound = &paddleerr.Error{
Code: "transaction_both_price_id_and_object_found",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionPriceNotFound represents a `transaction_price_not_found` error.
// See https://developer.paddle.com/errors/transactions/transaction_price_not_found for more information.
var ErrTransactionPriceNotFound = &paddleerr.Error{
Code: "transaction_price_not_found",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionProductNotFound represents a `transaction_product_not_found` error.
// See https://developer.paddle.com/errors/transactions/transaction_product_not_found for more information.
var ErrTransactionProductNotFound = &paddleerr.Error{
Code: "transaction_product_not_found",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionCannotBeModifiedAndCanceled represents a `transaction_cannot_be_modified_and_canceled` error.
// See https://developer.paddle.com/errors/transactions/transaction_cannot_be_modified_and_canceled for more information.
var ErrTransactionCannotBeModifiedAndCanceled = &paddleerr.Error{
Code: "transaction_cannot_be_modified_and_canceled",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionDiscountNotFound represents a `transaction_discount_not_found` error.
// See https://developer.paddle.com/errors/transactions/transaction_discount_not_found for more information.
var ErrTransactionDiscountNotFound = &paddleerr.Error{
Code: "transaction_discount_not_found",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionCannotProvideBothDiscountCodeAndID represents a `transaction_cannot_provide_both_discount_code_and_id` error.
// See https://developer.paddle.com/errors/transactions/transaction_cannot_provide_both_discount_code_and_id for more information.
var ErrTransactionCannotProvideBothDiscountCodeAndID = &paddleerr.Error{
Code: "transaction_cannot_provide_both_discount_code_and_id",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionInvalidStatusChange represents a `transaction_invalid_status_change` error.
// See https://developer.paddle.com/errors/transactions/transaction_invalid_status_change for more information.
var ErrTransactionInvalidStatusChange = &paddleerr.Error{
Code: "transaction_invalid_status_change",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionBillingDetailsMustBeNull represents a `transaction_billing_details_must_be_null` error.
// See https://developer.paddle.com/errors/transactions/transaction_billing_details_must_be_null for more information.
var ErrTransactionBillingDetailsMustBeNull = &paddleerr.Error{
Code: "transaction_billing_details_must_be_null",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionBillingDetailsObjectRequired represents a `transaction_billing_details_object_required` error.
// See https://developer.paddle.com/errors/transactions/transaction_billing_details_object_required for more information.
var ErrTransactionBillingDetailsObjectRequired = &paddleerr.Error{
Code: "transaction_billing_details_object_required",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionPaymentTermsObjectRequired represents a `transaction_payment_terms_object_required` error.
// See https://developer.paddle.com/errors/transactions/transaction_payment_terms_object_required for more information.
var ErrTransactionPaymentTermsObjectRequired = &paddleerr.Error{
Code: "transaction_payment_terms_object_required",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionBalanceLessThanChargeLimit represents a `transaction_balance_less_than_charge_limit` error.
// See https://developer.paddle.com/errors/transactions/transaction_balance_less_than_charge_limit for more information.
var ErrTransactionBalanceLessThanChargeLimit = &paddleerr.Error{
Code: "transaction_balance_less_than_charge_limit",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionStatusMustBeReady represents a `transaction_status_must_be_ready` error.
// See https://developer.paddle.com/errors/transactions/transaction_status_must_be_ready for more information.
var ErrTransactionStatusMustBeReady = &paddleerr.Error{
Code: "transaction_status_must_be_ready",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionCustomerNotSuitableForCollectionMode represents a `transaction_customer_not_suitable_for_collection_mode` error.
// See https://developer.paddle.com/errors/transactions/transaction_customer_not_suitable_for_collection_mode for more information.
var ErrTransactionCustomerNotSuitableForCollectionMode = &paddleerr.Error{
Code: "transaction_customer_not_suitable_for_collection_mode",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionAddressNotSuitableForCollectionMode represents a `transaction_address_not_suitable_for_collection_mode` error.
// See https://developer.paddle.com/errors/transactions/transaction_address_not_suitable_for_collection_mode for more information.
var ErrTransactionAddressNotSuitableForCollectionMode = &paddleerr.Error{
Code: "transaction_address_not_suitable_for_collection_mode",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionCurrencyCodeNotValidForManual represents a `transaction_currency_code_not_valid_for_manual` error.
// See https://developer.paddle.com/errors/transactions/transaction_currency_code_not_valid_for_manual for more information.
var ErrTransactionCurrencyCodeNotValidForManual = &paddleerr.Error{
Code: "transaction_currency_code_not_valid_for_manual",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionPreviewAdjustmentSubscriptionConflict represents a `transaction_preview_adjustment_subscription_conflict` error.
// See https://developer.paddle.com/errors/transactions/transaction_preview_adjustment_subscription_conflict for more information.
var ErrTransactionPreviewAdjustmentSubscriptionConflict = &paddleerr.Error{
Code: "transaction_preview_adjustment_subscription_conflict",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionInvalidDiscountCurrency represents a `transaction_invalid_discount_currency` error.
// See https://developer.paddle.com/errors/transactions/transaction_invalid_discount_currency for more information.
var ErrTransactionInvalidDiscountCurrency = &paddleerr.Error{
Code: "transaction_invalid_discount_currency",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionBillingPeriodStartsAtGreaterThanNow represents a `transaction_billing_period_starts_at_greater_than_now` error.
// See https://developer.paddle.com/errors/transactions/transaction_billing_period_starts_at_greater_than_now for more information.
var ErrTransactionBillingPeriodStartsAtGreaterThanNow = &paddleerr.Error{
Code: "transaction_billing_period_starts_at_greater_than_now",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionCheckoutURLDomainIsNotApproved represents a `transaction_checkout_url_domain_is_not_approved` error.
// See https://developer.paddle.com/errors/transactions/transaction_checkout_url_domain_is_not_approved for more information.
var ErrTransactionCheckoutURLDomainIsNotApproved = &paddleerr.Error{
Code: "transaction_checkout_url_domain_is_not_approved",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionRecurringBalanceLessThanChargeLimit represents a `transaction_recurring_balance_less_than_charge_limit` error.
// See https://developer.paddle.com/errors/transactions/transaction_recurring_balance_less_than_charge_limit for more information.
var ErrTransactionRecurringBalanceLessThanChargeLimit = &paddleerr.Error{
Code: "transaction_recurring_balance_less_than_charge_limit",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionDuplicatePriceIDs represents a `transaction_duplicate_price_ids` error.
// See https://developer.paddle.com/errors/transactions/transaction_duplicate_price_ids for more information.
var ErrTransactionDuplicatePriceIDs = &paddleerr.Error{
Code: "transaction_duplicate_price_ids",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionPaymentMethodChangeFieldImmutable represents a `transaction_payment_method_change_field_immutable` error.
// See https://developer.paddle.com/errors/transactions/transaction_payment_method_change_field_immutable for more information.
var ErrTransactionPaymentMethodChangeFieldImmutable = &paddleerr.Error{
Code: "transaction_payment_method_change_field_immutable",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionInvalidStatusToRevise represents a `transaction_invalid_status_to_revise` error.
// See https://developer.paddle.com/errors/transactions/transaction_invalid_status_to_revise for more information.
var ErrTransactionInvalidStatusToRevise = &paddleerr.Error{
Code: "transaction_invalid_status_to_revise",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionRevisedLimitReached represents a `transaction_revised_limit_reached` error.
// See https://developer.paddle.com/errors/transactions/transaction_revised_limit_reached for more information.
var ErrTransactionRevisedLimitReached = &paddleerr.Error{
Code: "transaction_revised_limit_reached",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionAdjustedUnableToRevise represents a `transaction_adjusted_unable_to_revise` error.
// See https://developer.paddle.com/errors/transactions/transaction_adjusted_unable_to_revise for more information.
var ErrTransactionAdjustedUnableToRevise = &paddleerr.Error{
Code: "transaction_adjusted_unable_to_revise",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionImmutableWhileProcessingPayment represents a `transaction_immutable_while_processing_payment` error.
// See https://developer.paddle.com/errors/transactions/transaction_immutable_while_processing_payment for more information.
var ErrTransactionImmutableWhileProcessingPayment = &paddleerr.Error{
Code: "transaction_immutable_while_processing_payment",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionCannotBeRevisedWithInvalidTaxIdentifier represents a `transaction_cannot_be_revised_with_invalid_tax_identifier` error.
// See https://developer.paddle.com/errors/transactions/transaction_cannot_be_revised_with_invalid_tax_identifier for more information.
var ErrTransactionCannotBeRevisedWithInvalidTaxIdentifier = &paddleerr.Error{
Code: "transaction_cannot_be_revised_with_invalid_tax_identifier",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionCannotBeRevisedWithTaxHigherThanGrandTotal represents a `transaction_cannot_be_revised_with_tax_higher_than_grand_total` error.
// See https://developer.paddle.com/errors/transactions/transaction_cannot_be_revised_with_tax_higher_than_grand_total for more information.
var ErrTransactionCannotBeRevisedWithTaxHigherThanGrandTotal = &paddleerr.Error{
Code: "transaction_cannot_be_revised_with_tax_higher_than_grand_total",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionMaximumNumberOfLineItemsReached represents a `transaction_maximum_number_of_line_items_reached` error.
// See https://developer.paddle.com/errors/transactions/transaction_maximum_number_of_line_items_reached for more information.
var ErrTransactionMaximumNumberOfLineItemsReached = &paddleerr.Error{
Code: "transaction_maximum_number_of_line_items_reached",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionNothingToRevise represents a `transaction_nothing_to_revise` error.
// See https://developer.paddle.com/errors/transactions/transaction_nothing_to_revise for more information.
var ErrTransactionNothingToRevise = &paddleerr.Error{
Code: "transaction_nothing_to_revise",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionReviseMissingBusinessName represents a `transaction_revise_missing_business_name` error.
// See https://developer.paddle.com/errors/transactions/transaction_revise_missing_business_name for more information.
var ErrTransactionReviseMissingBusinessName = &paddleerr.Error{
Code: "transaction_revise_missing_business_name",
Type: paddleerr.ErrorTypeRequestError,
}
// ErrTransactionAddressRegionOrCityAlreadySet represents a `transaction_address_region_or_city_already_set` error.
// See https://developer.paddle.com/errors/transactions/transaction_address_region_or_city_already_set for more information.
var ErrTransactionAddressRegionOrCityAlreadySet = &paddleerr.Error{
Code: "transaction_address_region_or_city_already_set",
Type: paddleerr.ErrorTypeRequestError,
}
// AdjustmentTotalsBreakdown: Breakdown of the total adjustments by adjustment action.
type AdjustmentTotalsBreakdown struct {
// Credit: Total amount of credit adjustments.
Credit string `json:"credit,omitempty"`
// Refund: Total amount of refund adjustments.
Refund string `json:"refund,omitempty"`
// Chargeback: Total amount of chargeback adjustments.
Chargeback string `json:"chargeback,omitempty"`
}
// TransactionAdjustmentTotals: Object containing totals for all adjustments on a transaction. Returned when the `include` parameter is used with the `adjustments_totals` value.
type TransactionAdjustmentTotals struct {
// Subtotal: Total before tax.
Subtotal string `json:"subtotal,omitempty"`
// Tax: Total tax on the subtotal.
Tax string `json:"tax,omitempty"`
// Total: Total after tax.
Total string `json:"total,omitempty"`
// Fee: Total fee taken by Paddle.
Fee string `json:"fee,omitempty"`
/*
Earnings: Total earnings. This is the subtotal minus the Paddle fee.
For tax adjustments, this value is negative, which means a positive effect in the transaction earnings.
This is because the fee is originally calculated from the transaction total, so if a tax adjustment is made,
then the fee portion of it is returned.
As a result, the earnings from all the adjustments performed could be either negative, positive or zero.
*/
Earnings string `json:"earnings,omitempty"`
// Breakdown: Breakdown of the total adjustments by adjustment action.
Breakdown AdjustmentTotalsBreakdown `json:"breakdown,omitempty"`
// CurrencyCode: Three-letter ISO 4217 currency code used for adjustments for this transaction.
CurrencyCode CurrencyCode `json:"currency_code,omitempty"`
}
// Transaction: Represents a transaction entity with included entities.
type Transaction struct {
// ID: Unique Paddle ID for this transaction entity, prefixed with `txn_`.
ID string `json:"id,omitempty"`
// Status: Status of this transaction. You may set a transaction to `billed` or `canceled`, other statuses are set automatically by Paddle. Automatically-collected transactions may return `completed` if payment is captured successfully, or `past_due` if payment failed.
Status TransactionStatus `json:"status,omitempty"`
// CustomerID: Paddle ID of the customer that this transaction is for, prefixed with `ctm_`.
CustomerID *string `json:"customer_id,omitempty"`
// AddressID: Paddle ID of the address that this transaction is for, prefixed with `add_`.
AddressID *string `json:"address_id,omitempty"`
// BusinessID: Paddle ID of the business that this transaction is for, prefixed with `biz_`.
BusinessID *string `json:"business_id,omitempty"`
// CustomData: Your own structured key-value data.
CustomData CustomData `json:"custom_data,omitempty"`
// CurrencyCode: Supported three-letter ISO 4217 currency code. Must be `USD`, `EUR`, or `GBP` if `collection_mode` is `manual`.
CurrencyCode CurrencyCode `json:"currency_code,omitempty"`
// Origin: Describes how this transaction was created.
Origin TransactionOrigin `json:"origin,omitempty"`
// SubscriptionID: Paddle ID of the subscription that this transaction is for, prefixed with `sub_`.
SubscriptionID *string `json:"subscription_id,omitempty"`
// InvoiceID: Paddle ID of the invoice that this transaction is related to, prefixed with `inv_`. Used for compatibility with the Paddle Invoice API, which is now deprecated. This field is scheduled to be removed in the next version of the Paddle API.
InvoiceID *string `json:"invoice_id,omitempty"`
// InvoiceNumber: Invoice number for this transaction. Automatically generated by Paddle when you mark a transaction as `billed` where `collection_mode` is `manual`.
InvoiceNumber *string `json:"invoice_number,omitempty"`
// CollectionMode: How payment is collected for this transaction. `automatic` for checkout, `manual` for invoices.
CollectionMode CollectionMode `json:"collection_mode,omitempty"`
// DiscountID: Paddle ID of the discount applied to this transaction, prefixed with `dsc_`.
DiscountID *string `json:"discount_id,omitempty"`
// BillingDetails: Details for invoicing. Required if `collection_mode` is `manual`.
BillingDetails *BillingDetails `json:"billing_details,omitempty"`
// BillingPeriod: Time period that this transaction is for. Set automatically by Paddle for subscription renewals to describe the period that charges are for.
BillingPeriod *TimePeriod `json:"billing_period,omitempty"`
// Items: List of items on this transaction. For calculated totals, use `details.line_items`.
Items []TransactionItem `json:"items,omitempty"`
// Details: Calculated totals for a transaction, including proration, discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction.
Details TransactionDetails `json:"details,omitempty"`
// Payments: List of payment attempts for this transaction, including successful payments. Sorted by `created_at` in descending order, so most recent attempts are returned first.
Payments []TransactionPaymentAttempt `json:"payments,omitempty"`
// Checkout: Paddle Checkout details for this transaction. Returned for automatically-collected transactions and where `billing_details.enable_checkout` is `true` for manually-collected transactions; `null` otherwise.
Checkout *TransactionCheckout `json:"checkout,omitempty"`
// CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
CreatedAt string `json:"created_at,omitempty"`
// UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
UpdatedAt string `json:"updated_at,omitempty"`
// BilledAt: RFC 3339 datetime string of when this transaction was marked as `billed`. `null` for transactions that are not `billed` or `completed`. Set automatically by Paddle.
BilledAt *string `json:"billed_at,omitempty"`
// Address: Address for this transaction. Returned when the `include` parameter is used with the `address` value and the transaction has an `address_id`.
Address Address `json:"address,omitempty"`
// Adjustments: Represents an adjustment entity.
Adjustments []Adjustment `json:"adjustments,omitempty"`
// AdjustmentsTotals: Object containing totals for all adjustments on a transaction. Returned when the `include` parameter is used with the `adjustments_totals` value.
AdjustmentsTotals TransactionAdjustmentTotals `json:"adjustments_totals,omitempty"`
// Business: Business for this transaction. Returned when the `include` parameter is used with the `business` value and the transaction has a `business_id`.
Business Business `json:"business,omitempty"`
// Customer: Customer for this transaction. Returned when the `include` parameter is used with the `customer` value and the transaction has a `customer_id`.
Customer Customer `json:"customer,omitempty"`
// Discount: Discount for this transaction. Returned when the `include` parameter is used with the `discount` value and the transaction has a `discount_id`.
Discount Discount `json:"discount,omitempty"`
// AvailablePaymentMethods: List of available payment methods for this transaction. Returned when the `include` parameter is used with the `available_payment_methods` value.
AvailablePaymentMethods []PaymentMethodType `json:"available_payment_methods,omitempty"`
}
// TransactionItemFromCatalog: Add a catalog item to a transaction. In this case, the product and price that you're billing for exist in your product catalog in Paddle.
type TransactionItemFromCatalog struct {
// Quantity: Quantity of this item on the transaction.
Quantity int `json:"quantity,omitempty"`
// Proration: How proration was calculated for this item. Populated when a transaction is created from a subscription change, where `proration_billing_mode` was `prorated_immediately` or `prorated_next_billing_period`. Set automatically by Paddle.
Proration *Proration `json:"proration,omitempty"`
// PriceID: Paddle ID of an existing catalog price to add to this transaction, prefixed with `pri_`.
PriceID string `json:"price_id,omitempty"`
}
// TransactionItemCreateWithPrice: Add a non-catalog price for an existing product in your catalog to a transaction. In this case, the product you're billing for is a catalog product, but you charge a specific price for it.
type TransactionItemCreateWithPrice struct {
// Quantity: Quantity of this item on the transaction.
Quantity int `json:"quantity,omitempty"`
// Proration: How proration was calculated for this item. Populated when a transaction is created from a subscription change, where `proration_billing_mode` was `prorated_immediately` or `prorated_next_billing_period`. Set automatically by Paddle.
Proration *Proration `json:"proration,omitempty"`
// Price: Price object for a non-catalog item to charge for. Include a `product_id` to relate this non-catalog price to an existing catalog price.
Price TransactionPriceCreateWithProductID `json:"price,omitempty"`
}
// TransactionItemCreateWithProduct: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction.
type TransactionItemCreateWithProduct struct {
// Quantity: Quantity of this item on the transaction.
Quantity int `json:"quantity,omitempty"`
// Proration: How proration was calculated for this item. Populated when a transaction is created from a subscription change, where `proration_billing_mode` was `prorated_immediately` or `prorated_next_billing_period`. Set automatically by Paddle.
Proration *Proration `json:"proration,omitempty"`
// Price: Price object for a non-catalog item to charge for. Include a `product` object to create a non-catalog product for this non-catalog price.
Price TransactionPriceCreateWithProduct `json:"price,omitempty"`
}
// TransactionPreviewItemFromCatalog: Add a catalog item to a transaction. In this case, the product and price that you're billing for exist in your product catalog in Paddle.
type TransactionPreviewItemFromCatalog struct {
// Quantity: Quantity of this item on the transaction.
Quantity int `json:"quantity,omitempty"`
// IncludeInTotals: Whether this item should be included in totals for this transaction preview. Typically used to exclude one-time charges from calculations.
IncludeInTotals bool `json:"include_in_totals,omitempty"`
// Proration: How proration was calculated for this item. `null` for transaction previews.
Proration *Proration `json:"proration,omitempty"`
// PriceID: Paddle ID of an existing catalog price to preview charging for, prefixed with `pri_`.
PriceID string `json:"price_id,omitempty"`
}
// TransactionPreviewItemCreateWithPrice: Add a non-catalog price for an existing product in your catalog to a transaction. In this case, the product you're billing for is a catalog product, but you charge a specific price for it.
type TransactionPreviewItemCreateWithPrice struct {
// Quantity: Quantity of this item on the transaction.
Quantity int `json:"quantity,omitempty"`
// IncludeInTotals: Whether this item should be included in totals for this transaction preview. Typically used to exclude one-time charges from calculations.
IncludeInTotals bool `json:"include_in_totals,omitempty"`
// Proration: How proration was calculated for this item. `null` for transaction previews.
Proration *Proration `json:"proration,omitempty"`
// Price: Price object for a non-catalog item to preview charging for. Include a `product_id` to relate this non-catalog price to an existing catalog price.
Price TransactionPriceCreateWithProductID `json:"price,omitempty"`
}
// TransactionPreviewItemCreateWithProduct: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction.
type TransactionPreviewItemCreateWithProduct struct {
// Quantity: Quantity of this item on the transaction.
Quantity int `json:"quantity,omitempty"`
// IncludeInTotals: Whether this item should be included in totals for this transaction preview. Typically used to exclude one-time charges from calculations.
IncludeInTotals bool `json:"include_in_totals,omitempty"`
// Proration: How proration was calculated for this item. `null` for transaction previews.
Proration *Proration `json:"proration,omitempty"`
// Price: Price object for a non-catalog item to preview charging for. Include a `product` object to create a non-catalog product for this non-catalog price.
Price TransactionPriceCreateWithProduct `json:"price,omitempty"`
}
// NewTransactionPreviewByAddressItemsTransactionPreviewItemFromCatalog takes a TransactionPreviewItemFromCatalog type
// and creates a TransactionPreviewByAddressItems for use in a request.
func NewTransactionPreviewByAddressItemsTransactionPreviewItemFromCatalog(r *TransactionPreviewItemFromCatalog) *TransactionPreviewByAddressItems {
return &TransactionPreviewByAddressItems{TransactionPreviewItemFromCatalog: r}
}
// NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithPrice takes a TransactionPreviewItemCreateWithPrice type
// and creates a TransactionPreviewByAddressItems for use in a request.
func NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithPrice(r *TransactionPreviewItemCreateWithPrice) *TransactionPreviewByAddressItems {
return &TransactionPreviewByAddressItems{TransactionPreviewItemCreateWithPrice: r}
}
// NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithProduct takes a TransactionPreviewItemCreateWithProduct type
// and creates a TransactionPreviewByAddressItems for use in a request.
func NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithProduct(r *TransactionPreviewItemCreateWithProduct) *TransactionPreviewByAddressItems {
return &TransactionPreviewByAddressItems{TransactionPreviewItemCreateWithProduct: r}
}
// TransactionPreviewByAddressItems represents a union request type of the following types:
// - `TransactionPreviewItemFromCatalog`
// - `TransactionPreviewItemCreateWithPrice`
// - `TransactionPreviewItemCreateWithProduct`
//
// The following constructor functions can be used to create a new instance of this type.
// - `NewTransactionPreviewByAddressItemsTransactionPreviewItemFromCatalog()`
// - `NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithPrice()`
// - `NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithProduct()`
//
// Only one of the values can be set at a time, the first non-nil value will be used in the request.
// Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction.
type TransactionPreviewByAddressItems struct {
*TransactionPreviewItemFromCatalog
*TransactionPreviewItemCreateWithPrice
*TransactionPreviewItemCreateWithProduct
}
// MarshalJSON implements the json.Marshaler interface.
func (u TransactionPreviewByAddressItems) MarshalJSON() ([]byte, error) {
if u.TransactionPreviewItemFromCatalog != nil {
return json.Marshal(u.TransactionPreviewItemFromCatalog)
}
if u.TransactionPreviewItemCreateWithPrice != nil {
return json.Marshal(u.TransactionPreviewItemCreateWithPrice)
}
if u.TransactionPreviewItemCreateWithProduct != nil {
return json.Marshal(u.TransactionPreviewItemCreateWithProduct)
}
return nil, nil
}
// TransactionPreviewByAddress: Paddle uses the country and ZIP code (where supplied) to calculate totals.
type TransactionPreviewByAddress struct {
// Address: Address for this transaction preview.
Address AddressPreview `json:"address,omitempty"`
// CustomerID: Paddle ID of the customer that this transaction preview is for, prefixed with `ctm_`.
CustomerID *string `json:"customer_id,omitempty"`
// CurrencyCode: Supported three-letter ISO 4217 currency code.
CurrencyCode CurrencyCode `json:"currency_code,omitempty"`
// DiscountID: Paddle ID of the discount applied to this transaction preview, prefixed with `dsc_`.
DiscountID *string `json:"discount_id,omitempty"`
/*
IgnoreTrials: Whether trials should be ignored for transaction preview calculations.
By default, recurring items with trials are considered to have a zero charge when previewing. Set to `true` to disable this.
*/
IgnoreTrials bool `json:"ignore_trials,omitempty"`
// Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction.
Items []TransactionPreviewByAddressItems `json:"items,omitempty"`
}
// NewTransactionPreviewByIPItemsTransactionPreviewItemFromCatalog takes a TransactionPreviewItemFromCatalog type
// and creates a TransactionPreviewByIPItems for use in a request.
func NewTransactionPreviewByIPItemsTransactionPreviewItemFromCatalog(r *TransactionPreviewItemFromCatalog) *TransactionPreviewByIPItems {
return &TransactionPreviewByIPItems{TransactionPreviewItemFromCatalog: r}
}
// NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithPrice takes a TransactionPreviewItemCreateWithPrice type
// and creates a TransactionPreviewByIPItems for use in a request.
func NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithPrice(r *TransactionPreviewItemCreateWithPrice) *TransactionPreviewByIPItems {
return &TransactionPreviewByIPItems{TransactionPreviewItemCreateWithPrice: r}
}
// NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithProduct takes a TransactionPreviewItemCreateWithProduct type
// and creates a TransactionPreviewByIPItems for use in a request.
func NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithProduct(r *TransactionPreviewItemCreateWithProduct) *TransactionPreviewByIPItems {
return &TransactionPreviewByIPItems{TransactionPreviewItemCreateWithProduct: r}
}
// TransactionPreviewByIPItems represents a union request type of the following types:
// - `TransactionPreviewItemFromCatalog`
// - `TransactionPreviewItemCreateWithPrice`
// - `TransactionPreviewItemCreateWithProduct`
//
// The following constructor functions can be used to create a new instance of this type.
// - `NewTransactionPreviewByIPItemsTransactionPreviewItemFromCatalog()`
// - `NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithPrice()`
// - `NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithProduct()`
//
// Only one of the values can be set at a time, the first non-nil value will be used in the request.
// Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction.
type TransactionPreviewByIPItems struct {
*TransactionPreviewItemFromCatalog
*TransactionPreviewItemCreateWithPrice
*TransactionPreviewItemCreateWithProduct
}
// MarshalJSON implements the json.Marshaler interface.
func (u TransactionPreviewByIPItems) MarshalJSON() ([]byte, error) {
if u.TransactionPreviewItemFromCatalog != nil {
return json.Marshal(u.TransactionPreviewItemFromCatalog)
}
if u.TransactionPreviewItemCreateWithPrice != nil {
return json.Marshal(u.TransactionPreviewItemCreateWithPrice)
}
if u.TransactionPreviewItemCreateWithProduct != nil {
return json.Marshal(u.TransactionPreviewItemCreateWithProduct)
}
return nil, nil
}
// TransactionPreviewByIP: Paddle fetches location using the IP address to calculate totals.
type TransactionPreviewByIP struct {
// CustomerIPAddress: IP address for this transaction preview.
CustomerIPAddress string `json:"customer_ip_address,omitempty"`
// CustomerID: Paddle ID of the customer that this transaction preview is for, prefixed with `ctm_`.
CustomerID *string `json:"customer_id,omitempty"`
// CurrencyCode: Supported three-letter ISO 4217 currency code.
CurrencyCode CurrencyCode `json:"currency_code,omitempty"`
// DiscountID: Paddle ID of the discount applied to this transaction preview, prefixed with `dsc_`.
DiscountID *string `json:"discount_id,omitempty"`
/*
IgnoreTrials: Whether trials should be ignored for transaction preview calculations.
By default, recurring items with trials are considered to have a zero charge when previewing. Set to `true` to disable this.
*/
IgnoreTrials bool `json:"ignore_trials,omitempty"`
// Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction.
Items []TransactionPreviewByIPItems `json:"items,omitempty"`
}
// NewTransactionPreviewByCustomerItemsTransactionPreviewItemFromCatalog takes a TransactionPreviewItemFromCatalog type
// and creates a TransactionPreviewByCustomerItems for use in a request.
func NewTransactionPreviewByCustomerItemsTransactionPreviewItemFromCatalog(r *TransactionPreviewItemFromCatalog) *TransactionPreviewByCustomerItems {
return &TransactionPreviewByCustomerItems{TransactionPreviewItemFromCatalog: r}
}
// NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithPrice takes a TransactionPreviewItemCreateWithPrice type
// and creates a TransactionPreviewByCustomerItems for use in a request.
func NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithPrice(r *TransactionPreviewItemCreateWithPrice) *TransactionPreviewByCustomerItems {
return &TransactionPreviewByCustomerItems{TransactionPreviewItemCreateWithPrice: r}
}
// NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithProduct takes a TransactionPreviewItemCreateWithProduct type
// and creates a TransactionPreviewByCustomerItems for use in a request.
func NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithProduct(r *TransactionPreviewItemCreateWithProduct) *TransactionPreviewByCustomerItems {
return &TransactionPreviewByCustomerItems{TransactionPreviewItemCreateWithProduct: r}
}
// TransactionPreviewByCustomerItems represents a union request type of the following types:
// - `TransactionPreviewItemFromCatalog`
// - `TransactionPreviewItemCreateWithPrice`
// - `TransactionPreviewItemCreateWithProduct`
//
// The following constructor functions can be used to create a new instance of this type.
// - `NewTransactionPreviewByCustomerItemsTransactionPreviewItemFromCatalog()`
// - `NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithPrice()`
// - `NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithProduct()`
//
// Only one of the values can be set at a time, the first non-nil value will be used in the request.
// Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction.
type TransactionPreviewByCustomerItems struct {
*TransactionPreviewItemFromCatalog
*TransactionPreviewItemCreateWithPrice
*TransactionPreviewItemCreateWithProduct
}
// MarshalJSON implements the json.Marshaler interface.
func (u TransactionPreviewByCustomerItems) MarshalJSON() ([]byte, error) {
if u.TransactionPreviewItemFromCatalog != nil {
return json.Marshal(u.TransactionPreviewItemFromCatalog)
}
if u.TransactionPreviewItemCreateWithPrice != nil {
return json.Marshal(u.TransactionPreviewItemCreateWithPrice)
}
if u.TransactionPreviewItemCreateWithProduct != nil {
return json.Marshal(u.TransactionPreviewItemCreateWithProduct)
}
return nil, nil
}
// TransactionPreviewByCustomer: Paddle uses existing customer data to calculate totals. Typically used for logged-in customers.
type TransactionPreviewByCustomer struct {
// AddressID: Paddle ID of the address that this transaction preview is for, prefixed with `add_`. Requires `customer_id`.
AddressID string `json:"address_id,omitempty"`
// BusinessID: Paddle ID of the business that this transaction preview is for, prefixed with `biz_`.
BusinessID *string `json:"business_id,omitempty"`
// CustomerID: Paddle ID of the customer that this transaction preview is for, prefixed with `ctm_`.
CustomerID *string `json:"customer_id,omitempty"`
// CurrencyCode: Supported three-letter ISO 4217 currency code.
CurrencyCode CurrencyCode `json:"currency_code,omitempty"`
// DiscountID: Paddle ID of the discount applied to this transaction preview, prefixed with `dsc_`.
DiscountID *string `json:"discount_id,omitempty"`
/*
IgnoreTrials: Whether trials should be ignored for transaction preview calculations.
By default, recurring items with trials are considered to have a zero charge when previewing. Set to `true` to disable this.
*/
IgnoreTrials bool `json:"ignore_trials,omitempty"`
// Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction.
Items []TransactionPreviewByCustomerItems `json:"items,omitempty"`
}
// TransactionPricePreview: Represents a price preview entity.
type TransactionPricePreview struct {
/*
ID: Unique Paddle ID for this price, prefixed with `pri_`.
The value is null for custom prices being previewed.
*/
ID *string `json:"id,omitempty"`
/*
ProductID: Paddle ID for the product that this price is for, prefixed with `pro_`.
The value is null for custom products being previewed.
*/
ProductID *string `json:"product_id,omitempty"`
// Description: Internal description for this price, not shown to customers. Typically notes for your team.
Description string `json:"description,omitempty"`
// Type: Type of item. Standard items are considered part of your catalog and are shown on the Paddle web app.
Type CatalogType `json:"type,omitempty"`
// Name: Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills.
Name *string `json:"name,omitempty"`
// BillingCycle: How often this price should be charged. `null` if price is non-recurring (one-time).
BillingCycle *Duration `json:"billing_cycle,omitempty"`
// TrialPeriod: Trial period for the product related to this price. The billing cycle begins once the trial period is over. `null` for no trial period. Requires `billing_cycle`.
TrialPeriod *Duration `json:"trial_period,omitempty"`
// TaxMode: How tax is calculated for this price.
TaxMode TaxMode `json:"tax_mode,omitempty"`
// UnitPrice: Base price. This price applies to all customers, except for customers located in countries where you have `unit_price_overrides`.
UnitPrice Money `json:"unit_price,omitempty"`
// UnitPriceOverrides: List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries.
UnitPriceOverrides []UnitPriceOverride `json:"unit_price_overrides,omitempty"`
// Quantity: Limits on how many times the related product can be purchased at this price. Useful for discount campaigns.
Quantity PriceQuantity `json:"quantity,omitempty"`
// Status: Whether this entity can be used in Paddle.
Status Status `json:"status,omitempty"`
// CustomData: Your own structured key-value data.
CustomData CustomData `json:"custom_data,omitempty"`
// ImportMeta: Import information for this entity. `null` if this entity is not imported.
ImportMeta *ImportMeta `json:"import_meta,omitempty"`
// CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
CreatedAt string `json:"created_at,omitempty"`
// UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
UpdatedAt string `json:"updated_at,omitempty"`
}
// TransactionItemPreview: List of items to preview transaction calculations for.
type TransactionItemPreview struct {
// Quantity: Quantity of this item on the transaction.
Quantity int `json:"quantity,omitempty"`
// IncludeInTotals: Whether this item should be included in totals for this transaction preview. Typically used to exclude one-time charges from calculations.
IncludeInTotals bool `json:"include_in_totals,omitempty"`
// Proration: How proration was calculated for this item. `null` for transaction previews.
Proration *Proration `json:"proration,omitempty"`
// Price: Represents a price preview entity.
Price TransactionPricePreview `json:"price,omitempty"`
}
// TransactionLineItemPreview: Information about line items for this transaction preview. Different from transaction preview `items` as they include totals calculated by Paddle. Considered the source of truth for line item totals.
type TransactionLineItemPreview struct {
/*
PriceID: Paddle ID for the price related to this transaction line item, prefixed with `pri_`.
The value is null for custom prices being previewed.
*/
PriceID *string `json:"price_id,omitempty"`
// Quantity: Quantity of this transaction line item.
Quantity int `json:"quantity,omitempty"`
// TaxRate: Rate used to calculate tax for this transaction line item.
TaxRate string `json:"tax_rate,omitempty"`
// UnitTotals: Breakdown of the charge for one unit in the lowest denomination of a currency (e.g. cents for USD).
UnitTotals Totals `json:"unit_totals,omitempty"`
// Totals: Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
Totals Totals `json:"totals,omitempty"`
// Product: Related product entity for this transaction line item price.
Product ProductPreview `json:"product,omitempty"`
}
// TransactionDetailsPreview: Calculated totals for a transaction preview, including discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction preview.
type TransactionDetailsPreview struct {
// TaxRatesUsed: List of tax rates applied to this transaction preview.
TaxRatesUsed []TaxRatesUsed `json:"tax_rates_used,omitempty"`
// Totals: Breakdown of the total for a transaction preview. `fee` and `earnings` always return `null` for transaction previews.
Totals TransactionTotals `json:"totals,omitempty"`
// LineItems: Information about line items for this transaction preview. Different from transaction preview `items` as they include totals calculated by Paddle. Considered the source of truth for line item totals.
LineItems []TransactionLineItemPreview `json:"line_items,omitempty"`
}
// TransactionPreview: Represents a transaction entity when previewing transactions.
type TransactionPreview struct {
// CustomerID: Paddle ID of the customer that this transaction preview is for, prefixed with `ctm_`.
CustomerID *string `json:"customer_id,omitempty"`
// AddressID: Paddle ID of the address that this transaction preview is for, prefixed with `add_`. Send one of `address_id`, `customer_ip_address`, or the `address` object when previewing.
AddressID *string `json:"address_id,omitempty"`
// BusinessID: Paddle ID of the business that this transaction preview is for, prefixed with `biz_`.
BusinessID *string `json:"business_id,omitempty"`
// CurrencyCode: Supported three-letter ISO 4217 currency code.
CurrencyCode CurrencyCode `json:"currency_code,omitempty"`
// DiscountID: Paddle ID of the discount applied to this transaction preview, prefixed with `dsc_`.
DiscountID *string `json:"discount_id,omitempty"`
// CustomerIPAddress: IP address for this transaction preview. Send one of `address_id`, `customer_ip_address`, or the `address` object when previewing.
CustomerIPAddress *string `json:"customer_ip_address,omitempty"`
// Address: Address for this transaction preview. Send one of `address_id`, `customer_ip_address`, or the `address` object when previewing.
Address *AddressPreview `json:"address,omitempty"`
/*
IgnoreTrials: Whether trials should be ignored for transaction preview calculations.
By default, recurring items with trials are considered to have a zero charge when previewing. Set to `true` to disable this.
*/
IgnoreTrials bool `json:"ignore_trials,omitempty"`
// Items: List of items to preview transaction calculations for.
Items []TransactionItemPreview `json:"items,omitempty"`
// Details: Calculated totals for a transaction preview, including discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction preview.
Details TransactionDetailsPreview `json:"details,omitempty"`
// AvailablePaymentMethods: List of available payment methods for Paddle Checkout given the price and location information passed.
AvailablePaymentMethods []PaymentMethodType `json:"available_payment_methods,omitempty"`
}
type TransactionInvoicePDF struct {
// URL: URL of the requested resource.
URL string `json:"url,omitempty"`
}
// TransactionsClient is a client for the Transactions resource.
type TransactionsClient struct {
doer Doer
}
// ListTransactionsRequest is given as an input to ListTransactions.
type ListTransactionsRequest struct {
// After is a query parameter.
// Return entities after the specified Paddle ID when working with paginated endpoints. Used in the `meta.pagination.next` URL in responses for list operations.
After *string `in:"query=after;omitempty" json:"-"`
// BilledAt is a query parameter.
// Return entities billed at a specific time. Pass an RFC 3339 datetime string, or use `[LT]` (less than), `[LTE]` (less than or equal to), `[GT]` (greater than), or `[GTE]` (greater than or equal to) operators. For example, `billed_at=2023-04-18T17:03:26` or `billed_at[LT]=2023-04-18T17:03:26`.
BilledAt *string `in:"query=billed_at;omitempty" json:"-"`
// CollectionMode is a query parameter.
// Return entities that match the specified collection mode.
CollectionMode *string `in:"query=collection_mode;omitempty" json:"-"`
// CreatedAt is a query parameter.
// Return entities created at a specific time. Pass an RFC 3339 datetime string, or use `[LT]` (less than), `[LTE]` (less than or equal to), `[GT]` (greater than), or `[GTE]` (greater than or equal to) operators. For example, `created_at=2023-04-18T17:03:26` or `created_at[LT]=2023-04-18T17:03:26`.
CreatedAt *string `in:"query=created_at;omitempty" json:"-"`
// CustomerID is a query parameter.
// Return entities related to the specified customer. Use a comma-separated list to specify multiple customer IDs.
CustomerID []string `in:"query=customer_id;omitempty" json:"-"`
// ID is a query parameter.
// Return only the IDs specified. Use a comma-separated list to get multiple entities.
ID []string `in:"query=id;omitempty" json:"-"`
// InvoiceNumber is a query parameter.
// Return entities that match the invoice number. Use a comma-separated list to specify multiple invoice numbers.
InvoiceNumber []string `in:"query=invoice_number;omitempty" json:"-"`
// Origin is a query parameter.
// Return entities related to the specified origin. Use a comma-separated list to specify multiple origins.
Origin []string `in:"query=origin;omitempty" json:"-"`
// OrderBy is a query parameter.
/*
Order returned entities by the specified field and direction (`[ASC]` or `[DESC]`). For example, `?order_by=id[ASC]`.
Valid fields for ordering: `billed_at`, `created_at`, `id`, and `updated_at`.
*/
OrderBy *string `in:"query=order_by;omitempty" json:"-"`
// Status is a query parameter.
// Return entities that match the specified status. Use a comma-separated list to specify multiple status values.
Status []string `in:"query=status;omitempty" json:"-"`
// SubscriptionID is a query parameter.
// Return entities related to the specified subscription. Use a comma-separated list to specify multiple subscription IDs. Pass `null` to return entities that are not related to any subscription.
SubscriptionID []string `in:"query=subscription_id;omitempty" json:"-"`
// PerPage is a query parameter.
// Set how many entities are returned per page.
PerPage *int `in:"query=per_page;omitempty" json:"-"`
// UpdatedAt is a query parameter.
// Return entities updated at a specific time. Pass an RFC 3339 datetime string, or use `[LT]` (less than), `[LTE]` (less than or equal to), `[GT]` (greater than), or `[GTE]` (greater than or equal to) operators. For example, `updated_at=2023-04-18T17:03:26` or `updated_at[LT]=2023-04-18T17:03:26`.
UpdatedAt *string `in:"query=updated_at;omitempty" json:"-"`
// IncludeAddress allows requesting the address sub-resource as part of this request.
// If set to true, will be included on the response.
IncludeAddress bool `in:"paddle_include=address" json:"-"`
// IncludeAdjustments allows requesting the adjustment sub-resource as part of this request.
// If set to true, will be included on the response.
IncludeAdjustments bool `in:"paddle_include=adjustment" json:"-"`
// IncludeAdjustmentsTotals allows requesting the adjustments_totals sub-resource as part of this request.
// If set to true, will be included on the response.
IncludeAdjustmentsTotals bool `in:"paddle_include=adjustments_totals" json:"-"`
// IncludeAvailablePaymentMethods allows requesting the available_payment_methods sub-resource as part of this request.
// If set to true, will be included on the response.
IncludeAvailablePaymentMethods bool `in:"paddle_include=available_payment_methods" json:"-"`
// IncludeBusiness allows requesting the business sub-resource as part of this request.
// If set to true, will be included on the response.
IncludeBusiness bool `in:"paddle_include=business" json:"-"`
// IncludeCustomer allows requesting the customer sub-resource as part of this request.
// If set to true, will be included on the response.
IncludeCustomer bool `in:"paddle_include=customer" json:"-"`
// IncludeDiscount allows requesting the discount sub-resource as part of this request.
// If set to true, will be included on the response.
IncludeDiscount bool `in:"paddle_include=discount" json:"-"`
}
// ListTransactions performs the GET operation on a Transactions resource.
func (c *TransactionsClient) ListTransactions(ctx context.Context, req *ListTransactionsRequest) (res *Collection[*Transaction], err error) {
if err := c.doer.Do(ctx, "GET", "/transactions", req, &res); err != nil {
return nil, err
}
return res, nil
}
// NewCreateTransactionItemsTransactionItemFromCatalog takes a TransactionItemFromCatalog type
// and creates a CreateTransactionItems for use in a request.
func NewCreateTransactionItemsTransactionItemFromCatalog(r *TransactionItemFromCatalog) *CreateTransactionItems {
return &CreateTransactionItems{TransactionItemFromCatalog: r}
}
// NewCreateTransactionItemsTransactionItemCreateWithPrice takes a TransactionItemCreateWithPrice type
// and creates a CreateTransactionItems for use in a request.
func NewCreateTransactionItemsTransactionItemCreateWithPrice(r *TransactionItemCreateWithPrice) *CreateTransactionItems {
return &CreateTransactionItems{TransactionItemCreateWithPrice: r}
}
// NewCreateTransactionItemsTransactionItemCreateWithProduct takes a TransactionItemCreateWithProduct type
// and creates a CreateTransactionItems for use in a request.
func NewCreateTransactionItemsTransactionItemCreateWithProduct(r *TransactionItemCreateWithProduct) *CreateTransactionItems {
return &CreateTransactionItems{TransactionItemCreateWithProduct: r}
}
// CreateTransactionItems represents a union request type of the following types:
// - `TransactionItemFromCatalog`
// - `TransactionItemCreateWithPrice`
// - `TransactionItemCreateWithProduct`
//
// The following constructor functions can be used to create a new instance of this type.
// - `NewCreateTransactionItemsTransactionItemFromCatalog()`
// - `NewCreateTransactionItemsTransactionItemCreateWithPrice()`
// - `NewCreateTransactionItemsTransactionItemCreateWithProduct()`
//
// Only one of the values can be set at a time, the first non-nil value will be used in the request.
// Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction.
type CreateTransactionItems struct {
*TransactionItemFromCatalog
*TransactionItemCreateWithPrice
*TransactionItemCreateWithProduct
}
// MarshalJSON implements the json.Marshaler interface.
func (u CreateTransactionItems) MarshalJSON() ([]byte, error) {
if u.TransactionItemFromCatalog != nil {
return json.Marshal(u.TransactionItemFromCatalog)
}
if u.TransactionItemCreateWithPrice != nil {
return json.Marshal(u.TransactionItemCreateWithPrice)
}
if u.TransactionItemCreateWithProduct != nil {
return json.Marshal(u.TransactionItemCreateWithProduct)
}
return nil, nil
}
// CreateTransactionRequest is given as an input to CreateTransaction.
type CreateTransactionRequest struct {
// Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction.
Items []CreateTransactionItems `json:"items,omitempty"`
/*
Status: Status of this transaction. You may set a transaction to `billed` when creating,
or omit to let Paddle set the status. Transactions are created as `ready` if they have
an `address_id`, `customer_id`, and `items`, otherwise they are created as `draft`.
Marking as `billed` when creating is typically used when working with manually-collected
transactions as part of an invoicing workflow. Billed transactions cannot be updated, only canceled.
*/
Status *TransactionStatus `json:"status,omitempty"`
// CustomerID: Paddle ID of the customer that this transaction is for, prefixed with `ctm_`. If omitted, transaction status is `draft`.
CustomerID *string `json:"customer_id,omitempty"`
// AddressID: Paddle ID of the address that this transaction is for, prefixed with `add_`. Requires `customer_id`. If omitted, transaction status is `draft`.
AddressID *string `json:"address_id,omitempty"`
// BusinessID: Paddle ID of the business that this transaction is for, prefixed with `biz_`. Requires `customer_id`.
BusinessID *string `json:"business_id,omitempty"`
// CustomData: Your own structured key-value data.
CustomData CustomData `json:"custom_data,omitempty"`
// CurrencyCode: Supported three-letter ISO 4217 currency code. Must be `USD`, `EUR`, or `GBP` if `collection_mode` is `manual`.
CurrencyCode *CurrencyCode `json:"currency_code,omitempty"`
// CollectionMode: How payment is collected for this transaction. `automatic` for checkout, `manual` for invoices. If omitted, defaults to `automatic`.
CollectionMode *CollectionMode `json:"collection_mode,omitempty"`
// DiscountID: Paddle ID of the discount applied to this transaction, prefixed with `dsc_`.
DiscountID *string `json:"discount_id,omitempty"`
// BillingDetails: Details for invoicing. Required if `collection_mode` is `manual`.
BillingDetails *BillingDetails `json:"billing_details,omitempty"`
// BillingPeriod: Time period that this transaction is for. Set automatically by Paddle for subscription renewals to describe the period that charges are for.
BillingPeriod *TimePeriod `json:"billing_period,omitempty"`
// Checkout: Paddle Checkout details for this transaction. You may pass a URL when creating or updating an automatically-collected transaction, or when creating or updating a manually-collected transaction where `billing_details.enable_checkout` is `true`.
Checkout *TransactionCheckout `json:"checkout,omitempty"`
// IncludeAddress allows requesting the address sub-resource as part of this request.
// If set to true, will be included on the response.
IncludeAddress bool `in:"paddle_include=address" json:"-"`
// IncludeAdjustments allows requesting the adjustment sub-resource as part of this request.
// If set to true, will be included on the response.
IncludeAdjustments bool `in:"paddle_include=adjustment" json:"-"`
// IncludeAdjustmentsTotals allows requesting the adjustments_totals sub-resource as part of this request.
// If set to true, will be included on the response.