paddle_rust_sdk/
entities.rs

1//! Contains all Paddle entity types.
2
3use std::collections::HashMap;
4
5use chrono::DateTime;
6use chrono::FixedOffset;
7use chrono::Utc;
8use serde::{Deserialize, Serialize};
9use serde_with::skip_serializing_none;
10
11use crate::enums::*;
12use crate::ids::*;
13
14/// Import information for this entity. `null` if this entity is not imported.
15#[derive(Clone, Debug, Serialize, Deserialize)]
16pub struct ImportMeta {
17    /// Reference or identifier for this entity from the solution where it was imported from.
18    pub external_id: Option<String>,
19    /// Name of the platform where this entity was imported from.
20    pub imported_from: String,
21}
22
23/// Represents an address entity.
24#[derive(Clone, Debug, Serialize, Deserialize)]
25pub struct Address {
26    /// Unique Paddle ID for this address entity, prefixed with `add_`.
27    pub id: AddressID,
28    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
29    pub customer_id: CustomerID,
30    /// Memorable description for this address.
31    pub description: Option<String>,
32    /// First line of this address.
33    pub first_line: Option<String>,
34    /// Second line of this address.
35    pub second_line: Option<String>,
36    /// City of this address.
37    pub city: Option<String>,
38    /// ZIP or postal code of this address. Required for some countries.
39    pub postal_code: Option<String>,
40    /// State, county, or region of this address.
41    pub region: Option<String>,
42    /// Supported two-letter ISO 3166-1 alpha-2 country code.
43    pub country_code: CountryCodeSupported,
44    /// Your own structured key-value data.
45    pub custom_data: Option<serde_json::Value>,
46    /// Whether this entity can be used in Paddle.
47    pub status: Status,
48    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
49    pub created_at: DateTime<Utc>,
50    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
51    pub updated_at: DateTime<Utc>,
52    /// Import information for this entity. `null` if this entity is not imported.
53    pub import_meta: Option<ImportMeta>,
54}
55
56/// Represents an address entity when previewing addresses.
57#[derive(Clone, Debug, Serialize, Deserialize)]
58pub struct AddressPreview {
59    /// ZIP or postal code of this address. Include for more accurate tax calculations.
60    pub postal_code: Option<String>,
61    /// Supported two-letter ISO 3166-1 alpha-2 country code.
62    pub country_code: CountryCodeSupported,
63}
64
65/// Breakdown of the total for an adjustment.
66#[derive(Clone, Debug, Serialize, Deserialize)]
67pub struct AdjustmentTotals {
68    /// Total before tax. For tax adjustments, the value is 0.
69    pub subtotal: String,
70    /// Total tax on the subtotal.
71    pub tax: String,
72    /// Total after tax.
73    pub total: String,
74    /// Total fee taken by Paddle for this adjustment.
75    pub fee: String,
76    /// Total earnings. This is the subtotal minus the Paddle fee.
77    /// For tax adjustments, this value is negative, which means a positive effect in the transaction earnings.
78    /// This is because the fee is originally calculated from the transaction total, so if a tax adjustment is made,
79    /// then the fee portion of it is returned.
80    pub earnings: String,
81    /// Supported three-letter ISO 4217 currency code.
82    pub currency_code: CurrencyCode,
83}
84
85/// Chargeback fee before conversion to the payout currency. `null` when the chargeback fee is the same as the payout currency.
86#[derive(Clone, Debug, Serialize, Deserialize)]
87pub struct Original {
88    /// Fee amount for this chargeback in the original currency.
89    pub amount: String,
90    /// Three-letter ISO 4217 currency code for chargeback fees.
91    pub currency_code: CurrencyCodeChargebacks,
92}
93
94/// Chargeback fees incurred for this adjustment. Only returned when the adjustment `action` is `chargeback` or `chargeback_warning`.
95#[derive(Clone, Debug, Serialize, Deserialize)]
96pub struct ChargebackFee {
97    /// Chargeback fee converted into the payout currency.
98    pub amount: String,
99    /// Chargeback fee before conversion to the payout currency. `null` when the chargeback fee is the same as the payout currency.
100    pub original: Option<Original>,
101}
102
103/// Breakdown of how this adjustment affects your payout balance.
104#[derive(Clone, Debug, Serialize, Deserialize)]
105pub struct AdjustmentPayoutTotals {
106    /// Adjustment total before tax and fees.
107    pub subtotal: String,
108    /// Total tax on the adjustment subtotal.
109    pub tax: String,
110    /// Adjustment total after tax.
111    pub total: String,
112    /// Adjusted Paddle fee.
113    pub fee: String,
114    /// Chargeback fees incurred for this adjustment. Only returned when the adjustment `action` is `chargeback` or `chargeback_warning`.
115    pub chargeback_fee: ChargebackFee,
116    /// Adjusted payout earnings. This is the adjustment total plus adjusted Paddle fees, excluding chargeback fees.
117    pub earnings: String,
118    /// Supported three-letter ISO 4217 currency code for payouts from Paddle.
119    pub currency_code: CurrencyCodePayouts,
120}
121
122/// Calculated totals for the tax applied to this adjustment.
123#[derive(Clone, Debug, Serialize, Deserialize)]
124pub struct AdjustmentTaxRateUsedTotals {
125    /// Total before tax. For tax adjustments, the value is 0.
126    pub subtotal: String,
127    /// Total tax on the subtotal.
128    pub tax: String,
129    /// Total after tax.
130    pub total: String,
131}
132
133#[derive(Clone, Debug, Serialize, Deserialize)]
134pub struct AdjustmentTaxRateUsed {
135    /// Rate used to calculate tax for this adjustment.
136    pub tax_rate: String,
137    /// Calculated totals for the tax applied to this adjustment.
138    pub totals: AdjustmentTaxRateUsedTotals,
139}
140
141/// Represents an adjustment entity.
142#[derive(Clone, Debug, Serialize, Deserialize)]
143pub struct Adjustment {
144    /// Unique Paddle ID for this adjustment entity, prefixed with `adj_`.
145    pub id: AdjustmentID,
146    /// How this adjustment impacts the related transaction.
147    pub action: AdjustmentAction,
148    /// Type of adjustment. Use `full` to adjust the grand total for the related transaction. Include an `items` array when creating a `partial` adjustment. If omitted, defaults to `partial`.
149    pub r#type: AdjustmentType,
150    /// Unique Paddle ID for this transaction entity, prefixed with `txn_`.
151    pub transaction_id: TransactionID,
152    /// Paddle ID for the subscription related to this adjustment, prefixed with `sub_`.
153    /// Set automatically by Paddle based on the `subscription_id` of the related transaction.
154    pub subscription_id: Option<SubscriptionID>,
155    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
156    pub customer_id: CustomerID,
157    /// Why this adjustment was created. Appears in the Paddle dashboard. Retained for record-keeping purposes.
158    pub reason: String,
159    /// Whether this adjustment was applied to the related customer's credit balance. Only returned for `credit` adjustments.
160    pub credit_applied_to_balance: Option<bool>,
161    /// Supported three-letter ISO 4217 currency code.
162    pub currency_code: CurrencyCode,
163    /// Status of this adjustment. Set automatically by Paddle.
164    ///
165    /// Most refunds for live accounts are created with the status of `pending_approval` until reviewed by Paddle, but some are automatically approved. For sandbox accounts, Paddle automatically approves refunds every ten minutes.
166    ///
167    /// Credit adjustments don't require approval from Paddle, so they're created as `approved`.
168    pub status: AdjustmentStatus,
169    /// List of items on this adjustment. Required if `type` is not populated or set to `partial`.
170    pub items: Vec<AdjustmentItem>,
171    /// Breakdown of the total for an adjustment.
172    pub totals: AdjustmentTotals,
173    /// Breakdown of how this adjustment affects your payout balance.
174    pub payout_totals: Option<AdjustmentPayoutTotals>,
175    /// List of tax rates applied for this adjustment.
176    pub tax_rates_used: Vec<AdjustmentTaxRateUsed>,
177    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
178    pub created_at: String,
179    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
180    pub updated_at: String,
181}
182
183/// Represents an adjustment entity when creating adjustments.
184#[derive(Clone, Debug, Serialize, Deserialize)]
185pub struct AdjustmentCreate {
186    /// Unique Paddle ID for this adjustment entity, prefixed with `adj_`.
187    pub id: AdjustmentID,
188    /// How this adjustment impacts the related transaction.
189    pub action: AdjustmentAction,
190    /// Type of adjustment. Use `full` to adjust the grand total for the related transaction. Include an `items` array when creating a `partial` adjustment. If omitted, defaults to `partial`.
191    pub r#type: AdjustmentType,
192    /// Unique Paddle ID for this transaction entity, prefixed with `txn_`.
193    pub transaction_id: TransactionID,
194    /// Paddle ID for the subscription related to this adjustment, prefixed with `sub_`.
195    /// Set automatically by Paddle based on the `subscription_id` of the related transaction.
196    pub subscription_id: SubscriptionID,
197    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
198    pub customer_id: CustomerID,
199    /// Why this adjustment was created. Appears in the Paddle dashboard. Retained for recordkeeping purposes.
200    pub reason: String,
201    /// Whether this adjustment was applied to the related customer's credit balance. Only returned for `credit` adjustments.
202    pub credit_applied_to_balance: Option<bool>,
203    /// Supported three-letter ISO 4217 currency code.
204    pub currency_code: CurrencyCode,
205    /// Status of this adjustment. Set automatically by Paddle.
206    ///
207    /// Most refunds for live accounts are created with the status of `pending_approval` until reviewed by Paddle, but some are automatically approved. For sandbox accounts, Paddle automatically approves refunds every ten minutes.
208    ///
209    /// Credit adjustments don't require approval from Paddle, so they're created as `approved`.
210    pub status: AdjustmentStatus,
211    /// List of transaction items to adjust. Required if `type` is not populated or set to `partial`.
212    pub items: Option<Vec<AdjustmentItem>>,
213    /// Breakdown of the total for an adjustment.
214    pub totals: AdjustmentTotals,
215    /// Breakdown of how this adjustment affects your payout balance.
216    pub payout_totals: Option<AdjustmentPayoutTotals>,
217    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
218    pub created_at: String,
219    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
220    pub updated_at: String,
221}
222
223#[derive(Clone, Debug, Serialize, Deserialize)]
224pub struct TimePeriod {
225    /// RFC 3339 datetime string.
226    pub starts_at: DateTime<Utc>,
227    /// RFC 3339 datetime string.
228    pub ends_at: DateTime<Utc>,
229}
230
231/// 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.
232#[derive(Clone, Debug, Serialize, Deserialize)]
233pub struct Proration {
234    /// Rate used to calculate proration.
235    pub rate: String,
236    pub billing_period: TimePeriod,
237}
238
239/// Breakdown of the total for an adjustment item.
240#[derive(Clone, Debug, Serialize, Deserialize)]
241pub struct AdjustmentItemTotals {
242    /// Amount multiplied by quantity.
243    pub subtotal: String,
244    /// Total tax on the subtotal.
245    pub tax: String,
246    /// Total after tax.
247    pub total: String,
248}
249
250#[derive(Clone, Debug, Serialize, Deserialize)]
251pub struct AdjustmentItem {
252    /// Unique Paddle ID for this transaction item, prefixed with `txnitm_`. Used when working with [adjustments](https://developer.paddle.com/build/transactions/create-transaction-adjustments).
253    pub item_id: TransactionItemID,
254    /// Type of adjustment for this transaction item. `tax` adjustments are automatically created by Paddle.
255    /// Include `amount` when creating a `partial` adjustment.
256    pub r#type: AdjustmentItemType,
257    /// Amount adjusted for this transaction item. Required when item type is `partial`.
258    pub amount: Option<String>,
259    /// How proration was calculated for this adjustment item.
260    pub proration: Option<Proration>,
261    /// Breakdown of the total for an adjustment item.
262    pub totals: AdjustmentItemTotals,
263}
264
265/// Represents an adjustment entity when previewing adjustments.
266#[derive(Clone, Debug, Serialize, Deserialize)]
267pub struct AdjustmentPreview {
268    /// Unique Paddle ID for this transaction entity, prefixed with `txn_`.
269    pub transaction_id: TransactionID,
270    /// List of transaction items that this adjustment is for.
271    pub items: Vec<AdjustmentItem>,
272    /// Breakdown of the total for an adjustment.
273    pub totals: AdjustmentTotals,
274}
275
276#[derive(Clone, Debug, Serialize, Deserialize)]
277pub struct Duration {
278    /// Unit of time.
279    pub interval: Interval,
280    /// Amount of time.
281    pub frequency: u64,
282}
283
284/// Details for invoicing. Required if `collection_mode` is `manual`.
285#[derive(Clone, Debug, Serialize, Deserialize)]
286pub struct BillingDetails {
287    /// Whether the related transaction may be paid using Paddle Checkout. If omitted when creating a transaction, defaults to `false`.
288    pub enable_checkout: bool,
289    /// Customer purchase order number. Appears on invoice documents.
290    pub purchase_order_number: String,
291    /// Notes or other information to include on this invoice. Appears on invoice documents.
292    pub additional_information: Option<String>,
293    pub payment_terms: Duration,
294}
295
296/// Details for invoicing. Required if `collection_mode` is `manual`.
297#[derive(Clone, Debug, Serialize, Deserialize)]
298pub struct BillingDetailsUpdate {
299    /// Whether the related transaction may be paid using Paddle Checkout.
300    pub enable_checkout: bool,
301    /// Customer purchase order number. Appears on invoice documents.
302    pub purchase_order_number: String,
303    /// Notes or other information to include on this invoice. Appears on invoice documents.
304    pub additional_information: Option<String>,
305    pub payment_terms: Duration,
306}
307
308#[derive(Clone, Debug, Serialize, Deserialize)]
309pub struct Contact {
310    /// Full name.
311    pub name: String,
312    /// Email address for this entity.
313    pub email: String,
314}
315
316/// Represents a business entity.
317#[derive(Clone, Debug, Serialize, Deserialize)]
318pub struct Business {
319    /// Unique Paddle ID for this business entity, prefixed with `biz_`.
320    pub id: BusinessID,
321    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
322    pub customer_id: CustomerID,
323    /// Full name.
324    pub name: String,
325    /// Company number for this business.
326    pub company_number: Option<String>,
327    /// Tax or VAT Number for this business.
328    pub tax_identifier: Option<String>,
329    /// Whether this entity can be used in Paddle.
330    pub status: Status,
331    /// List of contacts related to this business, typically used for sending invoices.
332    pub contacts: Option<Vec<Contact>>,
333    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
334    pub created_at: DateTime<Utc>,
335    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
336    pub updated_at: DateTime<Utc>,
337    /// Your own structured key-value data.
338    pub custom_data: Option<serde_json::Value>,
339    /// Import information for this entity. `null` if this entity is not imported.
340    pub import_meta: Option<ImportMeta>,
341}
342
343/// Card metadata
344#[derive(Clone, Debug, Serialize, Deserialize)]
345pub struct Card {
346    /// Type of credit or debit card used to pay.
347    pub r#type: CardType,
348    /// Last four digits of the card used to pay.
349    pub last4: String,
350    /// Month of the expiry date of the card used to pay.
351    pub expiry_month: i64,
352    /// Year of the expiry date of the card used to pay.
353    pub expiry_year: i64,
354    /// The name on the card used to pay.
355    pub cardholder_name: String,
356}
357
358#[derive(Clone, Debug, Serialize, Deserialize)]
359pub struct CustomerBalance {
360    /// Total amount of credit available to use.
361    pub available: String,
362    /// Total amount of credit temporarily reserved for `billed` transactions.
363    pub reserved: String,
364    /// Total amount of credit used.
365    pub used: String,
366}
367
368/// Represents a credit balance for a customer.
369#[derive(Clone, Debug, Serialize, Deserialize)]
370pub struct CreditBalance {
371    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
372    pub customer_id: CustomerID,
373    /// Supported three-letter ISO 4217 currency code.
374    pub currency_code: CurrencyCode,
375    pub balance: CustomerBalance,
376}
377
378/// Represents a customer entity.
379#[derive(Clone, Debug, Serialize, Deserialize)]
380pub struct Customer {
381    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
382    pub id: CustomerID,
383    /// Full name of this customer. Required when creating transactions where `collection_mode` is `manual` (invoices).
384    pub name: Option<String>,
385    /// Email address for this entity.
386    pub email: String,
387    /// Whether this customer opted into marketing from you. `false` unless customers check the marketing consent box
388    /// when using Paddle Checkout. Set automatically by Paddle.
389    pub marketing_consent: bool,
390    /// Whether this entity can be used in Paddle.
391    pub status: Status,
392    /// Your own structured key-value data.
393    pub custom_data: Option<serde_json::Value>,
394    /// Valid IETF BCP 47 short form locale tag. If omitted, defaults to `en`.
395    pub locale: String,
396    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
397    pub created_at: DateTime<Utc>,
398    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
399    pub updated_at: DateTime<Utc>,
400    /// Import information for this entity. `null` if this entity is not imported.
401    pub import_meta: Option<ImportMeta>,
402}
403
404/// PayPal metadata
405#[derive(Clone, Debug, Serialize, Deserialize)]
406pub struct PayPal {
407    /// Email address associated with the PayPal account.
408    pub email: String,
409    /// PayPal payment method identifier.
410    pub reference: String,
411}
412
413/// Represents a customer payment method entity.
414#[derive(Clone, Debug, Serialize, Deserialize)]
415pub struct PaymentMethod {
416    /// Unique Paddle ID for this payment method entity, prefixed with `paymtd_`.
417    pub id: PaymentMethodID,
418    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
419    pub customer_id: CustomerID,
420    /// Unique Paddle ID for this address entity, prefixed with `add_`.
421    pub address_id: AddressID,
422    /// Type of payment method saved.
423    pub r#type: SavedPaymentMethodType,
424    /// Information about the credit or debit card saved. `null` unless `type` is `card`.
425    pub card: Option<Card>,
426    /// Information about the PayPal payment method saved. `null` unless `type` is `paypal`.
427    pub paypal: Option<PayPal>,
428    /// Describes how this payment method was saved.
429    pub origin: PaymentMethodOrigin,
430    /// RFC 3339 datetime string of when this entity was saved. Set automatically by Paddle.
431    pub saved_at: DateTime<Utc>,
432    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
433    pub updated_at: DateTime<Utc>,
434}
435
436/// Authenticated customer portal deep links that aren't associated with a specific entity.
437#[derive(Clone, Debug, Serialize, Deserialize)]
438pub struct CustomerPortalSessionGeneralUrls {
439    /// Link to the overview page in the customer portal.
440    pub overview: String,
441}
442
443#[derive(Clone, Debug, Serialize, Deserialize)]
444pub struct CustomerPortalSessionSubscriptionUrls {
445    /// Unique Paddle ID for this subscription entity, prefixed with `sub_`.
446    pub id: SubscriptionID,
447    /// Link to the page for this subscription in the customer portal with the subscription cancellation form pre-opened. Use as part of cancel subscription workflows.
448    pub cancel_subscription: String,
449    /// Link to the page for this subscription in the customer portal with the payment method update form pre-opened. Use as part of workflows to let customers update their payment details.
450    ///
451    /// If a manually-collected subscription, opens the overview page for this subscription.
452    pub update_subscription_payment_method: String,
453}
454
455/// Authenticated customer portal deep links. For security, the `token` appended to each link is temporary. You shouldn't store these links.
456#[derive(Clone, Debug, Serialize, Deserialize)]
457pub struct CustomerPortalSessionUrls {
458    /// Authenticated customer portal deep links that aren't associated with a specific entity.
459    pub general: CustomerPortalSessionGeneralUrls,
460    /// List of generated authenticated customer portal deep links for the subscriptions passed in the `subscription_ids` array in the request.
461    ///
462    /// If subscriptions are paused or canceled, links open the overview page for a subscription.
463    ///
464    /// Empty if no subscriptions passed in the request.
465    pub subscriptions: Vec<CustomerPortalSessionSubscriptionUrls>,
466}
467
468/// Represents a customer portal session.
469#[derive(Clone, Debug, Serialize, Deserialize)]
470pub struct CustomerPortalSession {
471    /// Unique Paddle ID for this customer portal session entity, prefixed with `cpls_`.
472    pub id: CustomerPortalSessionID,
473    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
474    pub customer_id: CustomerID,
475    /// Authenticated customer portal deep links. For security, the `token` appended to each link is temporary. You shouldn't store these links.
476    pub urls: CustomerPortalSessionUrls,
477    /// RFC 3339 datetime string.
478    pub created_at: DateTime<Utc>,
479}
480
481/// Represents a customer authentication token.
482#[derive(Clone, Debug, Serialize, Deserialize)]
483pub struct CustomerAuthenticationToken {
484    /// Authentication token generated by Paddle for this customer. Pass to Paddle.js when opening a checkout to let customers work with saved payment methods.
485    pub customer_auth_token: String,
486    /// RFC 3339 datetime string.
487    pub expires_at: DateTime<Utc>,
488}
489
490/// Represents a discount entity.
491#[derive(Clone, Debug, Serialize, Deserialize)]
492pub struct Discount {
493    /// Unique Paddle ID for this discount, prefixed with `dsc_`.
494    pub id: DiscountID,
495    /// Whether this entity can be used in Paddle.
496    pub status: DiscountStatus,
497    /// Short description for this discount for your reference. Not shown to customers.
498    pub description: String,
499    /// Whether this discount can be redeemed by customers at checkout (`true`) or not (`false`).
500    pub enabled_for_checkout: bool,
501    /// Unique code that customers can use to redeem this discount at checkout. Not case-sensitive.
502    pub code: Option<String>,
503    /// Type of discount. Determines how this discount impacts the checkout or transaction total.
504    pub r#type: DiscountType,
505    /// Amount to discount by. For `percentage` discounts, must be an amount between `0.01` and `100`. For `flat` and `flat_per_seat` discounts, amount in the lowest denomination for a currency.
506    pub amount: String,
507    /// Supported three-letter ISO 4217 currency code. Required where discount type is `flat` or `flat_per_seat`.
508    pub currency_code: Option<CurrencyCode>,
509    /// Whether this discount applies for multiple subscription billing periods (`true`) or not (`false`).
510    pub recur: bool,
511    /// Number of subscription billing periods that this discount recurs for. Requires `recur`. `null` if this discount recurs forever.
512    ///
513    /// Subscription renewals, midcycle changes, and one-time charges billed to a subscription aren't considered a redemption. `times_used` is not incremented in these cases.
514    pub maximum_recurring_intervals: Option<i64>,
515    /// Maximum number of times this discount can be redeemed. This is an overall limit for this discount, rather than a per-customer limit. `null` if this discount can be redeemed an unlimited amount of times.
516    ///
517    /// Paddle counts a usage as a redemption on a checkout, transaction, or the initial application against a subscription. Transactions created for subscription renewals, midcycle changes, and one-time charges aren't considered a redemption.
518    pub usage_limit: Option<i64>,
519    /// Product or price IDs that this discount is for. When including a product ID, all prices for that product can be discounted. `null` if this discount applies to all products and prices.
520    pub restrict_to: Option<Vec<String>>,
521    /// RFC 3339 datetime string of when this discount expires. Discount can no longer be redeemed after this date has elapsed. `null` if this discount can be redeemed forever.
522    ///
523    /// Expired discounts can't be redeemed against transactions or checkouts, but can be applied when updating subscriptions.
524    pub expires_at: Option<DateTime<Utc>>,
525    /// Your own structured key-value data.
526    pub custom_data: Option<serde_json::Value>,
527    /// How many times this discount has been redeemed. Automatically incremented by Paddle.
528    ///
529    /// Paddle counts a usage as a redemption on a checkout, transaction, or subscription. Transactions created for subscription renewals, midcycle changes, and one-time charges aren't considered a redemption.
530    pub times_used: i64,
531    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
532    pub created_at: DateTime<Utc>,
533    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
534    pub updated_at: DateTime<Utc>,
535    /// Import information for this entity. `null` if this entity is not imported.
536    pub import_meta: Option<ImportMeta>,
537}
538
539/// Details of the discount applied to this subscription.
540#[derive(Clone, Debug, Serialize, Deserialize)]
541pub struct SubscriptionDiscountTimePeriod {
542    /// Unique Paddle ID for this discount, prefixed with `dsc_`.
543    pub id: DiscountID,
544    /// RFC 3339 datetime string of when this discount was first applied. `null` for canceled subscriptions where a discount was redeemed but never applied to a transaction.
545    pub starts_at: Option<DateTime<FixedOffset>>,
546    /// RFC 3339 datetime string of when this discount no longer applies. Where a discount has `maximum_recurring_intervals`, this is the date of the last billing period where this discount applies. `null` where a discount recurs forever.
547    pub ends_at: Option<DateTime<FixedOffset>>,
548}
549
550#[derive(Clone, Debug, Serialize, Deserialize)]
551pub struct Errors {
552    /// Field where validation error occurred.
553    pub field: String,
554    /// Information about how the field failed validation.
555    pub message: String,
556}
557
558/// Represents an error.
559#[derive(Clone, Debug, Serialize, Deserialize)]
560pub struct Error {
561    /// Type of error encountered.
562    pub r#type: Type,
563    /// Short snake case string that describes this error. Use to search the error reference.
564    pub code: String,
565    /// Some information about what went wrong as a human-readable string.
566    pub detail: String,
567    /// Link to a page in the error reference for this specific error.
568    pub documentation_url: String,
569    /// List of validation errors. Only returned when there's a validation error.
570    pub errors: Vec<Errors>,
571}
572
573/// Information about this response.
574#[derive(Clone, Debug, Serialize, Deserialize)]
575pub struct Meta {
576    /// Unique ID for the request relating to this response. Provide this when contacting Paddle support about a specific request.
577    pub request_id: String,
578}
579
580#[derive(Clone, Debug, Serialize, Deserialize)]
581pub struct ValidationError {
582    /// Represents an error.
583    pub error: Error,
584    /// Information about this response.
585    pub meta: Meta,
586}
587
588/// Represents an event entity.
589#[derive(Clone, Debug, Serialize, Deserialize)]
590pub struct Event {
591    /// Unique Paddle ID for this event, prefixed with `evt_`.
592    pub event_id: EventID,
593    /// Type of event sent by Paddle, in the format `entity.event_type`.
594    pub event_type: EventTypeName,
595    /// RFC 3339 datetime string.
596    pub occurred_at: String,
597    /// New or changed entity.
598    pub data: HashMap<String, String>,
599}
600
601/// Represents an event type.
602#[derive(Clone, Debug, Serialize, Deserialize)]
603pub struct EventType {
604    /// Type of event sent by Paddle, in the format `entity.event_type`.
605    pub name: EventTypeName,
606    /// Short description of this event type.
607    pub description: String,
608    /// Group for this event type. Typically the entity that this event relates to.
609    pub group: String,
610    /// List of API versions that this event type supports.
611    pub available_versions: Vec<u64>,
612}
613
614/// A base representation of monetary value unformatted in the lowest denomination with currency code.
615#[derive(Clone, Debug, Serialize, Deserialize)]
616pub struct Money {
617    /// Amount in the lowest denomination for the currency, e.g. 10 USD = 1000 (cents). Although represented as a string, this value must be a valid integer.
618    pub amount: String,
619    /// Supported three-letter ISO 4217 currency code.
620    pub currency_code: CurrencyCode,
621}
622
623#[derive(Clone, Debug, Serialize, Deserialize)]
624pub struct UnitPriceOverride {
625    /// Supported two-letter ISO 3166-1 alpha-2 country code. Customers located in the listed countries are charged the override price.
626    pub country_codes: Vec<CountryCodeSupported>,
627    /// A base representation of monetary value unformatted in the lowest denomination with currency code.
628    pub unit_price: Money,
629}
630
631#[derive(Clone, Debug, Serialize, Deserialize)]
632pub struct PriceQuantity {
633    /// Minimum quantity of the product related to this price that can be bought. Required if `maximum` set.
634    pub minimum: u64,
635    /// Maximum quantity of the product related to this price that can be bought. Required if `minimum` set. Must be greater than or equal to the `minimum` value.
636    pub maximum: u64,
637}
638
639/// Represents a price entity.
640#[derive(Clone, Debug, Serialize, Deserialize)]
641pub struct Price {
642    /// Unique Paddle ID for this price, prefixed with `pri_`.
643    pub id: PriceID,
644    /// Unique Paddle ID for this product, prefixed with `pro_`.
645    pub product_id: ProductID,
646    /// Internal description for this price, not shown to customers. Typically notes for your team.
647    pub description: String,
648    /// Type of item. Standard items are considered part of your catalog and are shown on the Paddle dashboard.
649    pub r#type: CatalogType,
650    /// Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills.
651    pub name: Option<String>,
652    /// How often this price should be charged. `null` if price is non-recurring (one-time).
653    pub billing_cycle: Option<Duration>,
654    /// 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`.
655    pub trial_period: Option<Duration>,
656    /// How tax is calculated for this price.
657    pub tax_mode: TaxMode,
658    /// A base representation of monetary value unformatted in the lowest denomination with currency code.
659    pub unit_price: Money,
660    /// List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries.
661    #[serde(default)]
662    pub unit_price_overrides: Vec<UnitPriceOverride>,
663    pub quantity: PriceQuantity,
664    /// Whether this entity can be used in Paddle.
665    pub status: Status,
666    /// Your own structured key-value data.
667    pub custom_data: Option<serde_json::Value>,
668    /// Import information for this entity. `null` if this entity is not imported.
669    pub import_meta: Option<ImportMeta>,
670    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
671    pub created_at: DateTime<Utc>,
672    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
673    pub updated_at: DateTime<Utc>,
674}
675
676/// Represents a product entity.
677#[derive(Clone, Debug, Serialize, Deserialize)]
678pub struct Product {
679    /// Unique Paddle ID for this product, prefixed with `pro_`.
680    pub id: ProductID,
681    /// Name of this product.
682    pub name: String,
683    /// Short description for this product.
684    pub description: Option<String>,
685    /// Type of item. Standard items are considered part of your catalog and are shown on the Paddle dashboard.
686    pub r#type: CatalogType,
687    /// Tax category for this product. Used for charging the correct rate of tax. Selected tax category must be enabled on your Paddle account.
688    pub tax_category: TaxCategory,
689    /// Image for this product. Included in the checkout and on some customer documents.
690    pub image_url: Option<String>,
691    /// Your own structured key-value data.
692    pub custom_data: Option<serde_json::Value>,
693    /// Whether this entity can be used in Paddle.
694    pub status: Status,
695    /// Import information for this entity. `null` if this entity is not imported.
696    pub import_meta: Option<ImportMeta>,
697    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
698    pub created_at: DateTime<Utc>,
699    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
700    pub updated_at: DateTime<Utc>,
701}
702
703/// Represents a subscription item.
704#[derive(Clone, Debug, Serialize, Deserialize)]
705pub struct SubscriptionItem {
706    /// Status of this subscription item. Set automatically by Paddle.
707    pub status: SubscriptionItemStatus,
708    /// Quantity of this item on the subscription.
709    pub quantity: i64,
710    /// Whether this is a recurring item. `false` if one-time.
711    pub recurring: bool,
712    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
713    pub created_at: DateTime<Utc>,
714    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
715    pub updated_at: DateTime<Utc>,
716    /// RFC 3339 datetime string of when this item was last billed.
717    pub previously_billed_at: Option<DateTime<FixedOffset>>,
718    /// RFC 3339 datetime string of when this item is next scheduled to be billed.
719    pub next_billed_at: Option<DateTime<FixedOffset>>,
720    /// Trial dates for this item.
721    pub trial_dates: Option<TimePeriod>,
722    /// Represents a price entity.
723    pub price: Price,
724    /// Represents a product entity.
725    pub product: Product,
726}
727
728/// Keys used for working with paginated results.
729#[derive(Clone, Debug, Serialize, Deserialize)]
730pub struct Pagination {
731    /// Number of entities per page for this response. May differ from the number requested if the requested number is greater than the maximum.
732    pub per_page: i64,
733    /// URL containing the query parameters of the original request, along with the `after` parameter that marks the starting point of the next page. Always returned, even if `has_more` is `false`.
734    pub next: String,
735    /// Whether this response has another page.
736    pub has_more: bool,
737    /// Estimated number of entities for this response.
738    pub estimated_total: i64,
739}
740
741/// Information about this response.
742#[derive(Clone, Debug, Serialize, Deserialize)]
743pub struct MetaPaginated {
744    /// Unique ID for the request relating to this response. Provide this when contacting Paddle support about a specific request.
745    pub request_id: String,
746    /// Keys used for working with paginated results.
747    pub pagination: Pagination,
748}
749
750/// Information about the payment method used for a payment attempt.
751#[derive(Clone, Debug, Serialize, Deserialize)]
752pub struct MethodDetails {
753    /// Type of payment method used for this payment attempt.
754    pub r#type: PaymentMethodType,
755    /// Information about the credit or debit card used to pay. `null` unless `type` is `card`.
756    pub card: Option<Card>,
757}
758
759/// Notification payload. Includes the new or changed event.
760#[derive(Clone, Debug, Serialize, Deserialize)]
761pub struct NotificationPayload {
762    /// Unique Paddle ID for this notification, prefixed with `ntf_`.
763    pub notification_id: NotificationID,
764    /// Unique Paddle ID for this event, prefixed with `evt_`.
765    pub event_id: EventID,
766    /// Type of event sent by Paddle, in the format `entity.event_type`.
767    pub event_type: EventTypeName,
768    /// RFC 3339 datetime string.
769    pub occurred_at: String,
770    /// New or changed entity.
771    pub data: HashMap<String, String>,
772}
773
774/// Represents a notification entity.
775#[derive(Clone, Debug, Serialize, Deserialize)]
776pub struct Notification {
777    /// Unique Paddle ID for this notification, prefixed with `ntf_`.
778    pub id: NotificationID,
779    /// Type of event sent by Paddle, in the format `entity.event_type`.
780    pub r#type: EventTypeName,
781    /// Status of this notification.
782    pub status: NotificationStatus,
783    pub payload: NotificationPayload,
784    /// RFC 3339 datetime string.
785    pub occurred_at: DateTime<FixedOffset>,
786    /// RFC 3339 datetime string of when this notification was delivered. `null` if not yet delivered successfully.
787    pub delivered_at: Option<DateTime<FixedOffset>>,
788    /// RFC 3339 datetime string of when this notification was replayed. `null` if not replayed.
789    pub replayed_at: Option<DateTime<FixedOffset>>,
790    /// Describes how this notification was created.
791    pub origin: NotificationOrigin,
792    /// RFC 3339 datetime string of when this notification was last attempted.
793    pub last_attempt_at: Option<DateTime<FixedOffset>>,
794    /// RFC 3339 datetime string of when this notification is scheduled to be retried.
795    pub retry_at: Option<DateTime<FixedOffset>>,
796    /// How many times delivery of this notification has been attempted. Automatically incremented by Paddle after an attempt.
797    pub times_attempted: i64,
798    /// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
799    pub notification_setting_id: NotificationSettingID,
800}
801
802/// Represents a notification log entity.
803#[derive(Clone, Debug, Serialize, Deserialize)]
804pub struct NotificationLog {
805    /// Unique Paddle ID for this notification log, prefixed with `ntflog_`.
806    pub id: NotificationLogID,
807    /// HTTP code sent by the responding server.
808    pub response_code: i64,
809    /// Content-Type sent by the responding server.
810    pub response_content_type: Option<String>,
811    /// Response body sent by the responding server. Typically empty for success responses.
812    pub response_body: String,
813    /// RFC 3339 datetime string.
814    pub attempted_at: String,
815}
816
817/// Represents a notification destination.
818#[derive(Clone, Debug, Serialize, Deserialize)]
819pub struct NotificationSetting {
820    /// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
821    pub id: NotificationSettingID,
822    /// Short description for this notification destination. Shown in the Paddle dashboard.
823    pub description: String,
824    /// Where notifications should be sent for this destination.
825    pub r#type: NotificationSettingType,
826    /// Webhook endpoint URL or email address.
827    pub destination: String,
828    /// Whether Paddle should try to deliver events to this notification destination.
829    pub active: bool,
830    /// API version that returned objects for events should conform to. Must be a valid version of the Paddle API. Can't be a version older than your account default.
831    pub api_version: i64,
832    /// Whether potentially sensitive fields should be sent to this notification destination.
833    pub include_sensitive_fields: bool,
834    /// Subscribed events for this notification destination.
835    pub subscribed_events: Vec<EventType>,
836    /// Webhook destination secret key, prefixed with `pdl_ntfset_`. Used for signature verification.
837    pub endpoint_secret_key: EndpointSecretKey,
838    /// Whether Paddle should deliver real platform events, simulation events or both to this notification destination.
839    pub traffic_source: TrafficSource,
840}
841
842/// Represents a notification destination when creating notification destinations.
843#[derive(Clone, Debug, Serialize, Deserialize)]
844pub struct NotificationSettingCreate {
845    /// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
846    pub id: NotificationSettingID,
847    /// Short description for this notification destination. Shown in the Paddle Dashboard.
848    pub description: String,
849    /// Where notifications should be sent for this destination.
850    pub r#type: NotificationSettingType,
851    /// Webhook endpoint URL or email address.
852    pub destination: String,
853    /// Whether Paddle should try to deliver events to this notification destination.
854    pub active: bool,
855    /// API version that returned objects for events should conform to. Must be a valid version of the Paddle API. Can't be a version older than your account default. If omitted, defaults to your account default version.
856    pub api_version: i64,
857    /// Whether potentially sensitive fields should be sent to this notification destination. If omitted, defaults to `false`.
858    pub include_sensitive_fields: bool,
859    /// Subscribed events for this notification destination. When creating or updating a notification destination, pass an array of event type names only. Paddle returns the complete event type object.
860    pub subscribed_events: Vec<String>,
861    /// Webhook destination secret key, prefixed with `pdl_ntfset_`. Used for signature verification.
862    pub endpoint_secret_key: EndpointSecretKey,
863    /// Whether Paddle should deliver real platform events, simulation events or both to this notification destination. If omitted, defaults to `platform`.
864    pub traffic_source: TrafficSource,
865}
866
867/// Represents a notification destination when updating notification destinations.
868#[derive(Clone, Debug, Serialize, Deserialize)]
869pub struct NotificationSettingUpdate {
870    /// Short description for this notification destination. Shown in the Paddle Dashboard.
871    pub description: String,
872    /// Webhook endpoint URL or email address.
873    pub destination: String,
874    /// Whether Paddle should try to deliver events to this notification destination.
875    pub active: bool,
876    /// API version that returned objects for events should conform to. Must be a valid version of the Paddle API. Can't be a version older than your account default. Defaults to your account default if omitted.
877    pub api_version: i64,
878    /// Whether potentially sensitive fields should be sent to this notification destination.
879    pub include_sensitive_fields: bool,
880    /// Subscribed events for this notification destination. When creating or updating a notification destination, pass an array of event type names only. Paddle returns the complete event type object.
881    pub subscribed_events: Option<Vec<String>>,
882    /// Whether Paddle should deliver real platform events, simulation events or both to this notification destination.
883    pub traffic_source: TrafficSource,
884}
885
886/// Represents a price preview entity.
887#[derive(Clone, Debug, Serialize, Deserialize)]
888pub struct PricePreview {
889    /// Unique Paddle ID for this price, prefixed with `pri_`.
890    /// The value is null for custom prices being previewed.
891    pub id: Option<PriceID>,
892    /// Paddle ID for the product that this price is for, prefixed with `pro_`.
893    /// The value is null for custom products being previewed.
894    pub product_id: Option<ProductID>,
895    /// Internal description for this price, not shown to customers. Typically notes for your team.
896    pub description: String,
897    /// Type of item. Standard items are considered part of your catalog and are shown on the Paddle dashboard.
898    pub r#type: CatalogType,
899    /// Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills.
900    pub name: Option<String>,
901    /// How often this price should be charged. `null` if price is non-recurring (one-time).
902    pub billing_cycle: Option<Duration>,
903    /// 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`.
904    pub trial_period: Option<Duration>,
905    /// How tax is calculated for this price.
906    pub tax_mode: TaxMode,
907    /// A base representation of monetary value unformatted in the lowest denomination with currency code.
908    pub unit_price: Money,
909    /// List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries.
910    pub unit_price_overrides: Vec<UnitPriceOverride>,
911    pub quantity: PriceQuantity,
912    /// Whether this entity can be used in Paddle.
913    pub status: Status,
914    /// Your own structured key-value data.
915    pub custom_data: Option<serde_json::Value>,
916    /// Import information for this entity. `null` if this entity is not imported.
917    pub import_meta: ImportMeta,
918    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
919    pub created_at: String,
920    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
921    pub updated_at: String,
922}
923
924/// Represents a product (preview) entity.
925#[derive(Clone, Debug, Serialize, Deserialize)]
926pub struct ProductPreview {
927    /// Unique Paddle ID for this product, prefixed with `pro_`.
928    /// The value is null for custom products being previewed.
929    pub id: Option<ProductID>,
930    /// Name of this product.
931    pub name: String,
932    /// Short description for this product.
933    pub description: Option<String>,
934    /// Type of item. Standard items are considered part of your catalog and are shown on the Paddle dashboard.
935    pub r#type: CatalogType,
936    /// Tax category for this product. Used for charging the correct rate of tax. Selected tax category must be enabled on your Paddle account.
937    pub tax_category: TaxCategory,
938    /// Image for this product. Included in the checkout and on some customer documents.
939    pub image_url: Option<String>,
940    /// Your own structured key-value data.
941    pub custom_data: Option<serde_json::Value>,
942    /// Whether this entity can be used in Paddle.
943    pub status: Status,
944    /// Import information for this entity. `null` if this entity is not imported.
945    pub import_meta: Option<ImportMeta>,
946    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
947    pub created_at: DateTime<Utc>,
948    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
949    pub updated_at: DateTime<Utc>,
950}
951
952/// Represents a report entity.
953#[derive(Clone, Debug, Serialize, Deserialize)]
954pub struct ReportBase {
955    /// Unique Paddle ID for this entity.
956    pub id: PaddleID,
957    /// Status of this report. Set automatically by Paddle.
958    ///
959    /// Reports are created as `pending` initially, then move to `ready` when they're available to download.
960    pub status: ReportStatus,
961    /// Number of records in this report. `null` if the report is `pending`.
962    pub rows: Option<i64>,
963    /// RFC 3339 datetime string of when this report expires. The report is no longer available to download after this date.
964    pub expires_at: Option<DateTime<FixedOffset>>,
965    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
966    pub updated_at: DateTime<FixedOffset>,
967    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
968    pub created_at: DateTime<FixedOffset>,
969}
970
971#[derive(Clone, Debug, Serialize, Deserialize)]
972pub enum ReportFilterValue {
973    String(String),
974    Array(Vec<String>),
975}
976
977/// Filter criteria for this report. If omitted when creating, reports are filtered to include data updated in the last 30 days. This means `updated_at` is greater than or equal to (`gte`) the date 30 days ago from the time the report was generated.
978#[derive(Clone, Debug, Serialize, Deserialize)]
979pub struct ReportFilters {
980    /// Field name to filter by.
981    pub name: AdjustmentsReportFilterName,
982    /// Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise.
983    pub operator: Option<FilterOperator>,
984    /// Value to filter by. Check the allowed values descriptions for the `name` field to see valid values for a field.
985    pub value: ReportFilterValue,
986}
987
988/// Information about the request. Sent by Paddle as part of the simulation.
989#[derive(Clone, Debug, Serialize, Deserialize)]
990pub struct SimulationEventRequest {
991    /// Request body sent by Paddle.
992    pub body: String,
993}
994
995/// Information about the response. Sent by the responding server for the notification setting.
996#[derive(Clone, Debug, Serialize, Deserialize)]
997pub struct SimulationEventResponse {
998    /// Response body sent by the responding server. May be empty for success responses.
999    pub body: String,
1000    /// HTTP status code sent by the responding server.
1001    pub status_code: i64,
1002}
1003
1004/// Represents a simulation event.
1005#[derive(Clone, Debug, Serialize, Deserialize)]
1006pub struct SimulationEvent {
1007    /// Unique Paddle ID for this simulation event, prefixed with `ntfsimevt_`.
1008    pub id: SimulationEventID,
1009    /// Status of this simulation run log.
1010    pub status: SimulationEventStatus,
1011    /// Type of event sent by Paddle, in the format `entity.event_type`.
1012    pub event_type: EventTypeName,
1013    /// Simulation payload. Pass a JSON object that matches the schema for an event type to simulate a custom payload. If omitted, Paddle populates with a demo example.
1014    pub payload: serde_json::Value,
1015    /// Information about the request. Sent by Paddle as part of the simulation.
1016    pub request: SimulationEventRequest,
1017    /// Information about the response. Sent by the responding server for the notification setting.
1018    pub response: SimulationEventResponse,
1019    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
1020    pub created_at: String,
1021    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
1022    pub updated_at: String,
1023}
1024
1025/// Represents a simulation run entity for a scenario.
1026#[derive(Clone, Debug, Serialize, Deserialize)]
1027pub struct SimulationRunScenario {
1028    /// Unique Paddle ID for this simulation run, prefixed with `ntfsimrun_`.
1029    pub id: SimulationRunID,
1030    /// Status of this simulation run.
1031    pub status: SimulationRunStatus,
1032    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
1033    pub created_at: String,
1034    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
1035    pub updated_at: String,
1036    /// Scenario for a simulation.
1037    pub r#type: SimulationScenarioType,
1038}
1039
1040/// Represents a simulation run entity for a single event.
1041#[derive(Clone, Debug, Serialize, Deserialize)]
1042pub struct SimulationRunSingleEvent {
1043    /// Unique Paddle ID for this simulation run, prefixed with `ntfsimrun_`.
1044    pub id: SimulationRunID,
1045    /// Status of this simulation run.
1046    pub status: SimulationRunStatus,
1047    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
1048    pub created_at: String,
1049    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
1050    pub updated_at: String,
1051    /// Type of event sent by Paddle, in the format `entity.event_type`.
1052    pub r#type: EventTypeName,
1053}
1054
1055/// Represents a simulation entity for a scenario.
1056#[derive(Clone, Debug, Serialize, Deserialize)]
1057pub struct SimulationScenario {
1058    /// Unique Paddle ID for this simulation, prefixed with `ntfsim_`.
1059    pub id: SimulationID,
1060    /// Whether this entity can be used in Paddle.
1061    pub status: Status,
1062    /// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
1063    pub notification_setting_id: NotificationSettingID,
1064    /// Name of this simulation.
1065    pub name: String,
1066    /// Scenario for a simulation.
1067    pub r#type: SimulationScenarioType,
1068    /// Simulation payload. `null` for scenarios.
1069    pub payload: Option<serde_json::Value>,
1070    /// RFC 3339 datetime string of when this simulation was last run. `null` until run. Set automatically by Paddle.
1071    pub last_run_at: Option<DateTime<FixedOffset>>,
1072    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
1073    pub created_at: String,
1074    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
1075    pub updated_at: String,
1076}
1077
1078/// Represents a simulation entity for a scenario when creating.
1079#[derive(Clone, Debug, Serialize, Deserialize)]
1080pub struct SimulationScenarioCreate {
1081    /// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
1082    pub notification_setting_id: NotificationSettingID,
1083    /// Name of this simulation.
1084    pub name: String,
1085    /// Scenario for a simulation.
1086    pub r#type: SimulationScenarioType,
1087}
1088
1089/// Represents a simulation entity for a scenario when updating.
1090#[derive(Clone, Debug, Serialize, Deserialize)]
1091pub struct SimulationScenarioUpdate {
1092    /// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
1093    pub notification_setting_id: NotificationSettingID,
1094    /// Name of this simulation.
1095    pub name: Option<String>,
1096    /// Whether this entity can be used in Paddle.
1097    pub status: Status,
1098    /// Scenario for a simulation.
1099    pub r#type: SimulationScenarioType,
1100}
1101
1102/// Represents a simulation entity for a single event when creating.
1103#[derive(Clone, Debug, Serialize, Deserialize)]
1104pub struct SimulationSingleEventCreate {
1105    /// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
1106    pub notification_setting_id: NotificationSettingID,
1107    /// Name of this simulation.
1108    pub name: Option<String>,
1109    /// Type of event sent by Paddle, in the format `entity.event_type`.
1110    pub r#type: EventTypeName,
1111    /// Simulation payload. Pass a JSON object that matches the schema for an event type to simulate a custom payload. If omitted, Paddle populates with a demo example.
1112    pub payload: Option<serde_json::Value>,
1113}
1114
1115/// Represents a simulation entity for a single event when updating.
1116#[derive(Clone, Debug, Serialize, Deserialize)]
1117pub struct SimulationSingleEventUpdate {
1118    /// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
1119    pub notification_setting_id: NotificationSettingID,
1120    /// Name of this simulation.
1121    pub name: Option<String>,
1122    /// Whether this entity can be used in Paddle.
1123    pub status: Status,
1124    /// Type of event sent by Paddle, in the format `entity.event_type`.
1125    pub r#type: EventTypeName,
1126    /// Simulation payload. Pass a JSON object that matches the schema for an event type to simulate a custom payload. Set to `null` to clear and populate with a demo example.
1127    pub payload: Option<serde_json::Value>,
1128}
1129
1130/// Represents a simulation type.
1131#[derive(Clone, Debug, Serialize, Deserialize)]
1132pub struct SimulationType {
1133    /// Type of simulation sent by Paddle. Single event simulations are in the format `entity.event_type`; scenario simulations are in `snake_case`.
1134    pub name: String,
1135    /// Descriptive label for this simulation type. Typically gives more context about a scenario. Single event simulations are in the format `entity.event_type`.
1136    pub label: String,
1137    /// Short description of this simulation type.
1138    pub description: String,
1139    /// Group for this simulation type. Typically the entity that this event relates to.
1140    pub group: String,
1141    /// Type of simulation.
1142    pub r#type: SimulationKind,
1143    /// List of events that will be sent for this simulation type.
1144    pub events: Vec<EventTypeName>,
1145}
1146
1147/// Change that's scheduled to be applied to a subscription. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. `null` if no scheduled changes.
1148#[derive(Clone, Debug, Serialize, Deserialize)]
1149pub struct SubscriptionScheduledChange {
1150    /// Kind of change that's scheduled to be applied to this subscription.
1151    pub action: ScheduledChangeAction,
1152    /// RFC 3339 datetime string.
1153    pub effective_at: DateTime<FixedOffset>,
1154    /// RFC 3339 datetime string of when a paused subscription should resume. Only used for `pause` scheduled changes.
1155    pub resume_at: Option<DateTime<FixedOffset>>,
1156}
1157
1158/// Authenticated customer portal deep links for this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links.
1159#[derive(Clone, Debug, Serialize, Deserialize)]
1160pub struct SubscriptionManagementUrls {
1161    /// Link to the page for this subscription in the customer portal with the payment method update form pre-opened. Use as part of workflows to let customers update their payment details. `null` for manually-collected subscriptions.
1162    pub update_payment_method: Option<String>,
1163    /// Link to the page for this subscription in the customer portal with the subscription cancellation form pre-opened. Use as part of cancel subscription workflows.
1164    pub cancel: String,
1165}
1166
1167/// Represents a subscription entity.
1168#[derive(Clone, Debug, Serialize, Deserialize)]
1169pub struct Subscription {
1170    /// Unique Paddle ID for this subscription entity, prefixed with `sub_`.
1171    pub id: SubscriptionID,
1172    /// Status of this subscription. Set automatically by Paddle. Use the pause subscription or cancel subscription operations to change.
1173    pub status: SubscriptionStatus,
1174    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
1175    pub customer_id: CustomerID,
1176    /// Unique Paddle ID for this address entity, prefixed with `add_`.
1177    pub address_id: AddressID,
1178    /// Paddle ID of the business that this subscription is for, prefixed with `biz_`.
1179    pub business_id: Option<BusinessID>,
1180    /// Supported three-letter ISO 4217 currency code.
1181    pub currency_code: CurrencyCode,
1182    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
1183    pub created_at: DateTime<Utc>,
1184    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
1185    pub updated_at: DateTime<Utc>,
1186    /// RFC 3339 datetime string of when this subscription started. This may be different from `first_billed_at` if the subscription started in trial.
1187    pub started_at: Option<DateTime<Utc>>,
1188    /// RFC 3339 datetime string of when this subscription was first billed. This may be different from `started_at` if the subscription started in trial.
1189    pub first_billed_at: Option<DateTime<Utc>>,
1190    /// RFC 3339 datetime string of when this subscription is next scheduled to be billed.
1191    pub next_billed_at: DateTime<Utc>,
1192    /// RFC 3339 datetime string of when this subscription was paused. Set automatically by Paddle when the pause subscription operation is used. `null` if not paused.
1193    pub paused_at: Option<DateTime<Utc>>,
1194    /// RFC 3339 datetime string of when this subscription was canceled. Set automatically by Paddle when the cancel subscription operation is used. `null` if not canceled.
1195    pub canceled_at: Option<DateTime<Utc>>,
1196    /// Details of the discount applied to this subscription.
1197    pub discount: Option<Discount>,
1198    /// How payment is collected. `automatic` for checkout, `manual` for invoices.
1199    pub collection_mode: CollectionMode,
1200    /// Details for invoicing. Required if `collection_mode` is `manual`.
1201    pub billing_details: Option<BillingDetails>,
1202    /// Current billing period for this subscription. Set automatically by Paddle based on the billing cycle. `null` for `paused` and `canceled` subscriptions.
1203    pub current_billing_period: Option<TimePeriod>,
1204    pub billing_cycle: Duration,
1205    /// Change that's scheduled to be applied to a subscription. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. `null` if no scheduled changes.
1206    pub scheduled_change: Option<SubscriptionScheduledChange>,
1207    /// Authenticated customer portal deep links for this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links.
1208    pub management_urls: SubscriptionManagementUrls,
1209    /// List of items on this subscription. Only recurring items are returned.
1210    pub items: Vec<SubscriptionItem>,
1211    /// Your own structured key-value data.
1212    pub custom_data: Option<serde_json::Value>,
1213    /// Import information for this entity. `null` if this entity is not imported.
1214    pub import_meta: Option<ImportMeta>,
1215}
1216
1217#[derive(Clone, Debug, Serialize, Deserialize)]
1218pub enum SubscriptionChargeItem {
1219    /// Add a catalog item to a subscription. In this case, the product and price that you're billing for exist in your product catalog in Paddle.
1220    CatalogItem(SubscriptionItemCreateWithPriceId),
1221    /// Add a non-catalog price for an existing product in your catalog to a subscription. In this case, the product you're billing for is a catalog product, but you charge a specific price for it.
1222    NonCatalogExistingProduct(SubscriptionChargeCreateWithPrice),
1223    /// Add a non-catalog price for a non-catalog product in your catalog to a subscription. In this case, the product and price that you're billing for are specific to this subscription.
1224    NonCatalogPriceAndProduct(SubscriptionChargeCreateWithPriceAndProduct),
1225}
1226
1227/// Represents a one-time charge for a subscription.
1228#[derive(Clone, Debug, Serialize, Deserialize)]
1229pub struct SubscriptionCharge {
1230    /// When this subscription change should take effect from. Defaults to `next_billing_period`, which creates a
1231    /// `scheduled_change` to apply the subscription change at the end of the billing period.
1232    pub effective_from: EffectiveFrom,
1233    /// List of one-time charges to bill for. Only prices where the `billing_cycle` is `null` may be added.
1234    ///
1235    /// You can charge for items that you've added to your catalog by passing the Paddle ID of an existing price entity, or you can charge for non-catalog items by passing a price object.
1236    ///
1237    /// Non-catalog items can be for existing products, or you can pass a product object as part of your price to charge for a non-catalog product.
1238    pub items: Vec<SubscriptionChargeItem>,
1239    /// How Paddle should handle changes made to a subscription or its items if the payment fails during update. If omitted, defaults to `prevent_change`.
1240    pub on_payment_failure: SubscriptionOnPaymentFailure,
1241}
1242
1243/// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1244#[derive(Clone, Debug, Serialize, Deserialize)]
1245pub struct Totals {
1246    /// Subtotal before discount, tax, and deductions. If an item, unit price multiplied by quantity.
1247    pub subtotal: String,
1248    /// Total discount as a result of any discounts applied.
1249    ///
1250    /// Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied.
1251    pub discount: String,
1252    /// Total tax on the subtotal.
1253    pub tax: String,
1254    /// Total after discount and tax.
1255    pub total: String,
1256}
1257
1258#[derive(Clone, Debug, Serialize, Deserialize)]
1259pub struct TaxRatesUsed {
1260    /// Rate used to calculate tax for this transaction preview.
1261    pub tax_rate: String,
1262    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1263    pub totals: Totals,
1264}
1265
1266/// Breakdown of the total for a transaction. These numbers can be negative when dealing with subscription updates that result in credit.
1267#[derive(Clone, Debug, Serialize, Deserialize)]
1268pub struct TransactionTotals {
1269    /// Subtotal before discount, tax, and deductions. If an item, unit price multiplied by quantity.
1270    pub subtotal: String,
1271    /// Total discount as a result of any discounts applied.
1272    ///
1273    /// Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied.
1274    pub discount: String,
1275    /// Total tax on the subtotal.
1276    pub tax: String,
1277    /// Total after discount and tax.
1278    pub total: String,
1279    /// Total credit applied to this transaction. This includes credits applied using a customer's credit balance and adjustments to a `billed` transaction.
1280    pub credit: String,
1281    /// Additional credit generated from negative `details.line_items`. This credit is added to the customer balance.
1282    pub credit_to_balance: String,
1283    /// Total due on a transaction after credits and any payments.
1284    pub balance: String,
1285    /// Total due on a transaction after credits but before any payments.
1286    pub grand_total: String,
1287    /// Total fee taken by Paddle for this transaction. `null` until the transaction is `completed` and the fee is processed.
1288    pub fee: Option<String>,
1289    /// Total earnings for this transaction. This is the total minus the Paddle fee. `null` until the transaction is `completed` and the fee is processed.
1290    pub earnings: Option<String>,
1291    /// Three-letter ISO 4217 currency code of the currency used for this transaction.
1292    pub currency_code: CurrencyCode,
1293}
1294
1295/// SubscriptionTransactionDetailsPreview requires same fields as TransactionLineItemPreview but proration is optional
1296#[derive(Clone, Debug, Serialize, Deserialize)]
1297pub struct SubscriptionTransactionDetailsPreviewItem {
1298    /// Paddle ID for the price related to this transaction line item, prefixed with `pri_`.
1299    /// The value is null for custom prices being previewed.
1300    pub price_id: Option<PriceID>,
1301    /// Quantity of this transaction line item.
1302    pub quantity: i64,
1303    /// Rate used to calculate tax for this transaction line item.
1304    pub tax_rate: String,
1305    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1306    pub unit_totals: Totals,
1307    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1308    pub totals: Totals,
1309    /// Represents a product (preview) entity.
1310    pub product: ProductPreview,
1311    /// How proration was calculated for this item.
1312    pub proration: Option<Proration>,
1313}
1314
1315/// Calculated totals for a transaction preview, including discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction preview.
1316#[derive(Clone, Debug, Serialize, Deserialize)]
1317pub struct SubscriptionTransactionDetailsPreview {
1318    /// List of tax rates applied to this transaction preview.
1319    pub tax_rates_used: Vec<TaxRatesUsed>,
1320    /// Breakdown of the total for a transaction. These numbers can be negative when dealing with subscription updates that result in credit.
1321    pub totals: TransactionTotals,
1322    /// 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.
1323    pub line_items: Vec<SubscriptionTransactionDetailsPreviewItem>,
1324}
1325
1326/// Preview of the next transaction for this subscription. May include prorated charges that aren't yet billed and one-time charges. `null` if the subscription is scheduled to cancel or pause.
1327#[derive(Clone, Debug, Serialize, Deserialize)]
1328pub struct NextTransaction {
1329    pub billing_period: TimePeriod,
1330    /// Calculated totals for a transaction preview, including discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction preview.
1331    pub details: SubscriptionTransactionDetailsPreview,
1332    /// Preview of adjustments for the next transaction.
1333    pub adjustments: Vec<AdjustmentPreview>,
1334}
1335
1336/// Details of the result of credits and charges. Where the total of any credit adjustments is greater than the total charge, the result is a prorated credit; otherwise, the result is a prorated charge.
1337#[derive(Clone, Debug, Serialize, Deserialize)]
1338pub struct UpdateSummaryResult {
1339    /// Whether the subscription change results in a prorated credit or a charge.
1340    pub action: UpdateSummaryResultAction,
1341    /// Amount representing the result of this update, either a charge or a credit.
1342    pub amount: String,
1343    /// Supported three-letter ISO 4217 currency code.
1344    pub currency_code: CurrencyCode,
1345}
1346
1347/// Impact of this subscription change. Includes whether the change results in a charge or credit, and totals for prorated amounts.
1348#[derive(Clone, Debug, Serialize, Deserialize)]
1349pub struct SubscriptionPreviewUpdateSummary {
1350    /// A base representation of monetary value unformatted in the lowest denomination with currency code.
1351    pub credit: Money,
1352    /// A base representation of monetary value unformatted in the lowest denomination with currency code.
1353    pub charge: Money,
1354    /// Details of the result of credits and charges. Where the total of any credit adjustments is greater than the total charge, the result is a prorated credit; otherwise, the result is a prorated charge.
1355    pub result: UpdateSummaryResult,
1356}
1357
1358/// Represents a subscription preview when previewing a subscription.
1359#[derive(Clone, Debug, Serialize, Deserialize)]
1360pub struct SubscriptionPreview {
1361    /// Status of this subscription. Set automatically by Paddle. Use the pause subscription or cancel subscription operations to change.
1362    pub status: SubscriptionStatus,
1363    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
1364    pub customer_id: CustomerID,
1365    /// Unique Paddle ID for this address entity, prefixed with `add_`.
1366    pub address_id: AddressID,
1367    /// Paddle ID of the business that this subscription is for, prefixed with `biz_`.
1368    pub business_id: BusinessID,
1369    /// Supported three-letter ISO 4217 currency code.
1370    pub currency_code: CurrencyCode,
1371    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
1372    pub created_at: DateTime<FixedOffset>,
1373    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
1374    pub updated_at: DateTime<FixedOffset>,
1375    /// RFC 3339 datetime string of when this subscription started. This may be different from `first_billed_at` if the subscription started in trial.
1376    pub started_at: Option<DateTime<FixedOffset>>,
1377    /// RFC 3339 datetime string of when this subscription was first billed. This may be different from `started_at` if the subscription started in trial.
1378    pub first_billed_at: Option<DateTime<FixedOffset>>,
1379    /// RFC 3339 datetime string of when this subscription is next scheduled to be billed.
1380    pub next_billed_at: Option<DateTime<FixedOffset>>,
1381    /// RFC 3339 datetime string of when this subscription was paused. Set automatically by Paddle when the pause subscription operation is used. `null` if not paused.
1382    pub paused_at: Option<DateTime<FixedOffset>>,
1383    /// RFC 3339 datetime string of when this subscription was canceled. Set automatically by Paddle when the cancel subscription operation is used. `null` if not canceled.
1384    pub canceled_at: Option<DateTime<FixedOffset>>,
1385    /// Details of the discount applied to this subscription.
1386    pub discount: Discount,
1387    /// How payment is collected. `automatic` for checkout, `manual` for invoices.
1388    pub collection_mode: CollectionMode,
1389    /// Details for invoicing. Required if `collection_mode` is `manual`.
1390    pub billing_details: BillingDetails,
1391    /// Current billing period for this subscription. Set automatically by Paddle based on the billing cycle. `null` for `paused` and `canceled` subscriptions.
1392    pub current_billing_period: Option<TimePeriod>,
1393    pub billing_cycle: Duration,
1394    /// Change that's scheduled to be applied to a subscription. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. `null` if no scheduled changes.
1395    pub scheduled_change: Option<SubscriptionScheduledChange>,
1396    /// Authenticated customer portal deep links for this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links.
1397    pub management_urls: SubscriptionManagementUrls,
1398    /// List of items on this subscription. Only recurring items are returned.
1399    pub items: Vec<SubscriptionItem>,
1400    /// Your own structured key-value data.
1401    pub custom_data: Option<serde_json::Value>,
1402    /// Preview of the immediate transaction created as a result of changes to the subscription. Returns a complete object where `proration_billing_mode` is `prorated_immediately` or `full_immediately`; `null` otherwise.
1403    pub immediate_transaction: Option<NextTransaction>,
1404    /// Preview of the next transaction for this subscription. Includes charges created where `proration_billing_mode` is `prorated_next_billing_period` or `full_next_billing_period`, as well as one-time charges. `null` if the subscription is scheduled to cancel or pause.
1405    pub next_transaction: NextTransaction,
1406    /// Calculated totals for a transaction preview, including discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction preview.
1407    pub recurring_transaction_details: SubscriptionTransactionDetailsPreview,
1408    pub update_summary: Option<SubscriptionPreviewUpdateSummary>,
1409    /// Import information for this entity. `null` if this entity is not imported.
1410    pub import_meta: ImportMeta,
1411}
1412
1413/// Details of the discount applied to this subscription. Include to add a discount to a subscription. `null` to remove a discount.
1414#[derive(Clone, Debug, Serialize, Deserialize)]
1415pub struct SubscriptionDiscountEffectiveFrom {
1416    /// Unique Paddle ID for this discount, prefixed with `dsc_`.
1417    pub id: DiscountID,
1418    /// When this subscription change should take effect from. Defaults to `next_billing_period`, which creates a
1419    /// `scheduled_change` to apply the subscription change at the end of the billing period.
1420    pub effective_from: EffectiveFrom,
1421}
1422
1423/// Represents a subscription entity when updating subscriptions.
1424#[derive(Clone, Debug, Serialize, Deserialize)]
1425pub struct SubscriptionUpdate {
1426    /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
1427    pub customer_id: CustomerID,
1428    /// Unique Paddle ID for this address entity, prefixed with `add_`.
1429    pub address_id: AddressID,
1430    /// Paddle ID of the business that this subscription is for, prefixed with `biz_`. Include to change the business for a subscription.
1431    pub business_id: BusinessID,
1432    /// Supported three-letter ISO 4217 currency code.
1433    pub currency_code: CurrencyCode,
1434    /// RFC 3339 datetime string.
1435    pub next_billed_at: DateTime<FixedOffset>,
1436    /// Details of the discount applied to this subscription. Include to add a discount to a subscription. `null` to remove a discount.
1437    pub discount: SubscriptionDiscountEffectiveFrom,
1438    /// How payment is collected. `automatic` for checkout, `manual` for invoices.
1439    pub collection_mode: CollectionMode,
1440    /// Details for invoicing. Required if `collection_mode` is `manual`. `null` if changing `collection_mode` to `automatic`.
1441    pub billing_details: BillingDetails,
1442    /// Change that's scheduled to be applied to a subscription. When updating, you may only set to `null` to remove a scheduled change. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes.
1443    pub scheduled_change: Option<()>,
1444    /// List of items on this subscription. Only recurring items may be added. Send the complete list of items that should be on this subscription, including existing items to retain.
1445    pub items: Vec<SubscriptionChargeItem>,
1446    /// Your own structured key-value data.
1447    pub custom_data: Option<serde_json::Value>,
1448    /// How Paddle should handle proration calculation for changes made to a subscription or its items. Required when making
1449    /// changes that impact billing.
1450    ///
1451    /// For automatically-collected subscriptions, responses may take longer than usual if a proration billing mode that
1452    /// collects for payment immediately is used.
1453    pub proration_billing_mode: ProrationBillingMode,
1454    /// How Paddle should handle changes made to a subscription or its items if the payment fails during update. If omitted, defaults to `prevent_change`.
1455    pub on_payment_failure: SubscriptionOnPaymentFailure,
1456}
1457
1458/// Price object for a non-catalog item to bill for. Include a `product_id` to relate this non-catalog price to an existing catalog price.
1459#[derive(Clone, Debug, Serialize, Deserialize)]
1460pub struct SubscriptionChargeCreateWithPricePrice {
1461    /// Unique Paddle ID for this product, prefixed with `pro_`.
1462    pub product_id: ProductID,
1463    /// Internal description for this price, not shown to customers. Typically notes for your team.
1464    pub description: String,
1465    /// Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills.
1466    pub name: Option<String>,
1467    /// How tax is calculated for this price.
1468    pub tax_mode: TaxMode,
1469    /// A base representation of monetary value unformatted in the lowest denomination with currency code.
1470    pub unit_price: Money,
1471    /// List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries.
1472    pub unit_price_overrides: Vec<UnitPriceOverride>,
1473    pub quantity: PriceQuantity,
1474    /// Your own structured key-value data.
1475    pub custom_data: Option<serde_json::Value>,
1476}
1477
1478/// 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.
1479#[derive(Clone, Debug, Serialize, Deserialize)]
1480pub struct SubscriptionChargeCreateWithPriceAndProduct {
1481    /// Internal description for this price, not shown to customers. Typically notes for your team.
1482    pub description: String,
1483    /// Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills.
1484    pub name: Option<String>,
1485    /// How tax is calculated for this price.
1486    pub tax_mode: TaxMode,
1487    /// A base representation of monetary value unformatted in the lowest denomination with currency code.
1488    pub unit_price: Money,
1489    /// List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries.
1490    pub unit_price_overrides: Vec<UnitPriceOverride>,
1491    pub quantity: PriceQuantity,
1492    /// Your own structured key-value data.
1493    pub custom_data: Option<serde_json::Value>,
1494    /// Product object for a non-catalog item to charge for.
1495    pub product: TransactionSubscriptionProductCreate,
1496}
1497
1498#[derive(Clone, Debug, Serialize, Deserialize)]
1499pub struct SubscriptionChargeCreateWithPrice {
1500    /// Quantity to bill for.
1501    pub quantity: i64,
1502    /// Price object for a non-catalog item to bill for. Include a `product_id` to relate this non-catalog price to an existing catalog price.
1503    pub price: SubscriptionChargeCreateWithPricePrice,
1504}
1505
1506#[derive(Clone, Debug, Serialize, Deserialize)]
1507pub struct TransactionPriceCreateWithProductId {
1508    /// Internal description for this price, not shown to customers. Typically notes for your team.
1509    pub description: String,
1510    /// Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills.
1511    pub name: Option<String>,
1512    /// How often this price should be charged. `null` if price is non-recurring (one-time).
1513    pub billing_cycle: Option<Duration>,
1514    /// 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`.
1515    pub trial_period: Option<Duration>,
1516    /// How tax is calculated for this price.
1517    pub tax_mode: TaxMode,
1518    /// A base representation of monetary value unformatted in the lowest denomination with currency code.
1519    pub unit_price: Money,
1520    /// List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries.
1521    pub unit_price_overrides: Vec<UnitPriceOverride>,
1522    pub quantity: PriceQuantity,
1523    /// Your own structured key-value data.
1524    pub custom_data: Option<serde_json::Value>,
1525    /// Paddle ID for the product that this price is for, prefixed with `pro_`.
1526    pub product_id: ProductID,
1527}
1528
1529#[derive(Clone, Debug, Serialize, Deserialize)]
1530pub struct SubscriptionItemCreateWithPrice {
1531    /// Quantity to bill for.
1532    pub quantity: i64,
1533    pub price: TransactionPriceCreateWithProductId,
1534}
1535
1536#[derive(Clone, Debug, Serialize, Deserialize)]
1537pub struct SubscriptionItemCreateWithPriceId {
1538    /// Quantity to bill for.
1539    pub quantity: i64,
1540    /// Unique Paddle ID for this price, prefixed with `pri_`.
1541    pub price_id: PriceID,
1542}
1543
1544#[derive(Clone, Debug, Serialize, Deserialize)]
1545pub struct SubscriptionUpdateItem {
1546    /// Unique Paddle ID for this price, prefixed with `pri_`.
1547    pub price_id: PriceID,
1548    /// Quantity of this item to add to the subscription. If updating an existing item and not changing the quantity, you may omit `quantity`.
1549    pub quantity: i64,
1550}
1551
1552/// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1553#[derive(Clone, Debug, Serialize, Deserialize)]
1554pub struct TotalsWithoutDiscount {
1555    /// Subtotal before tax, and deductions. If an item, unit price multiplied by quantity.
1556    pub subtotal: String,
1557    /// Total tax on the subtotal.
1558    pub tax: String,
1559    /// Total after tax.
1560    pub total: String,
1561}
1562
1563#[derive(Clone, Debug, Serialize, Deserialize)]
1564pub struct TransactionItem {
1565    /// Represents a price entity.
1566    pub price: Price,
1567    /// Quantity of this item on the transaction.
1568    pub quantity: i64,
1569    /// 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.
1570    pub proration: Option<Proration>,
1571}
1572
1573/// Breakdown of the totals for a transaction after adjustments.
1574#[derive(Clone, Debug, Serialize, Deserialize)]
1575pub struct TransactionTotalsAdjusted {
1576    /// Subtotal before discount, tax, and deductions. If an item, unit price multiplied by quantity.
1577    pub subtotal: String,
1578    /// Total tax on the subtotal.
1579    pub tax: String,
1580    /// Total after tax.
1581    pub total: String,
1582    /// Total due after credits but before any payments.
1583    pub grand_total: String,
1584    /// Total fee taken by Paddle for this transaction. `null` until the transaction is `completed` and the fee is processed.
1585    pub fee: Option<String>,
1586    /// Total earnings for this transaction. This is the total minus the Paddle fee.
1587    /// `null` until the transaction is `completed` and the fee is processed.
1588    pub earnings: Option<String>,
1589    /// Supported three-letter ISO 4217 currency code.
1590    pub currency_code: CurrencyCode,
1591}
1592
1593/// Breakdown of the payout total for a transaction after adjustments. `null` until the transaction is `completed`.
1594#[derive(Clone, Debug, Serialize, Deserialize)]
1595pub struct TransactionPayoutTotalsAdjusted {
1596    /// Total before tax and fees.
1597    pub subtotal: String,
1598    /// Total tax on the subtotal.
1599    pub tax: String,
1600    /// Total after tax.
1601    pub total: String,
1602    /// Total fee taken by Paddle for this payout.
1603    pub fee: String,
1604    /// Details of any chargeback fees incurred for this transaction.
1605    pub chargeback_fee: ChargebackFee,
1606    /// Total earnings for this payout. This is the subtotal minus the Paddle fee, excluding chargeback fees.
1607    pub earnings: String,
1608    /// Supported three-letter ISO 4217 currency code for payouts from Paddle.
1609    pub currency_code: CurrencyCodePayouts,
1610}
1611
1612/// Information about line items for this transaction. Different from transaction `items` as they include totals calculated by Paddle. Considered the source of truth for line item totals.
1613#[derive(Clone, Debug, Serialize, Deserialize)]
1614pub struct TransactionLineItemWithId {
1615    /// Unique Paddle ID for this transaction item, prefixed with `txnitm_`.
1616    pub id: TransactionItemID,
1617    /// Unique Paddle ID for this price, prefixed with `pri_`.
1618    pub price_id: PriceID,
1619    /// Quantity of this transaction line item.
1620    pub quantity: i64,
1621    /// 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.
1622    pub proration: Option<Proration>,
1623    /// Rate used to calculate tax for this transaction line item.
1624    pub tax_rate: String,
1625    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1626    pub unit_totals: Totals,
1627    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1628    pub totals: Totals,
1629    /// Represents a product entity.
1630    pub product: Product,
1631}
1632
1633/// Calculated totals for a transaction, including proration, discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction.
1634#[derive(Clone, Debug, Serialize, Deserialize)]
1635pub struct TransactionDetails {
1636    /// List of tax rates applied for this transaction.
1637    pub tax_rates_used: Vec<TaxRatesUsed>,
1638    /// Breakdown of the total for a transaction. These numbers can be negative when dealing with subscription updates that result in credit.
1639    pub totals: TransactionTotals,
1640    /// Breakdown of the totals for a transaction after adjustments.
1641    pub adjusted_totals: TransactionTotalsAdjusted,
1642    /// Breakdown of the payout total for a transaction. `null` until the transaction is `completed`. Returned in your payout currency.
1643    pub payout_totals: Option<TransactionPayoutTotals>,
1644    /// Breakdown of the payout total for a transaction after adjustments. `null` until the transaction is `completed`.
1645    pub adjusted_payout_totals: Option<TransactionPayoutTotalsAdjusted>,
1646    /// Information about line items for this transaction. Different from transaction `items` as they include totals calculated by Paddle. Considered the source of truth for line item totals.
1647    pub line_items: Vec<TransactionLineItemWithId>,
1648}
1649
1650#[derive(Clone, Debug, Serialize, Deserialize)]
1651pub struct TransactionPaymentAttempt {
1652    /// UUID for this payment attempt.
1653    pub payment_attempt_id: String,
1654    /// UUID for the stored payment method used for this payment attempt. Deprecated - use `payment_method_id` instead.
1655    pub stored_payment_method_id: String,
1656    /// Paddle ID of the payment method used for this payment attempt, prefixed with `paymtd_`.
1657    pub payment_method_id: Option<PaymentMethodID>,
1658    /// Amount for collection in the lowest denomination of a currency (e.g. cents for USD).
1659    pub amount: String,
1660    /// Status of this payment attempt.
1661    pub status: PaymentAttemptStatus,
1662    /// Reason why a payment attempt failed. Returns `null` if payment captured successfully.
1663    pub error_code: Option<ErrorCode>,
1664    /// Information about the payment method used for a payment attempt.
1665    pub method_details: MethodDetails,
1666    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
1667    pub created_at: String,
1668    /// RFC 3339 datetime string of when this payment was captured. `null` if `status` is not `captured`.
1669    pub captured_at: Option<DateTime<FixedOffset>>,
1670}
1671
1672/// 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.
1673#[derive(Clone, Debug, Serialize, Deserialize)]
1674pub struct TransactionCheckout {
1675    /// Paddle Checkout URL for this transaction, composed of the URL passed in the request or your default payment URL + `?_ptxn=` and the Paddle ID for this transaction.
1676    pub url: Option<String>,
1677}
1678
1679/// Contains an invoice PDF url for a transaction.
1680#[derive(Clone, Debug, Serialize, Deserialize)]
1681pub struct TransactionInvoice {
1682    /// URL of the requested resource.
1683    pub url: Option<String>,
1684}
1685
1686/// Represents a transaction entity.
1687#[derive(Clone, Debug, Serialize, Deserialize)]
1688pub struct Transaction {
1689    /// Unique Paddle ID for this transaction entity, prefixed with `txn_`.
1690    pub id: TransactionID,
1691    /// 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.
1692    pub status: TransactionStatus,
1693    /// Paddle ID of the customer that this transaction is for, prefixed with `ctm_`.
1694    pub customer_id: Option<CustomerID>,
1695    /// Paddle ID of the address that this transaction is for, prefixed with `add_`.
1696    pub address_id: Option<AddressID>,
1697    /// Paddle ID of the business that this transaction is for, prefixed with `biz_`.
1698    pub business_id: Option<BusinessID>,
1699    /// Your own structured key-value data.
1700    //pub custom_data: Option<serde_json::Value>,
1701    pub custom_data: Option<serde_json::Value>,
1702    /// Supported three-letter ISO 4217 currency code.
1703    pub currency_code: CurrencyCode,
1704    /// Describes how this transaction was created.
1705    pub origin: TransactionOrigin,
1706    /// Paddle ID of the subscription that this transaction is for, prefixed with `sub_`.
1707    pub subscription_id: Option<SubscriptionID>,
1708    /// 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.
1709    pub invoice_id: Option<InvoiceId>,
1710    /// Invoice number for this transaction. Automatically generated by Paddle when you mark a transaction as `billed` where `collection_mode` is `manual`.
1711    pub invoice_number: Option<String>,
1712    /// How payment is collected. `automatic` for checkout, `manual` for invoices.
1713    pub collection_mode: CollectionMode,
1714    /// Paddle ID of the discount applied to this transaction, prefixed with `dsc_`.
1715    pub discount_id: Option<DiscountID>,
1716    /// Details for invoicing. Required if `collection_mode` is `manual`.
1717    pub billing_details: Option<BillingDetails>,
1718    /// Time period that this transaction is for. Set automatically by Paddle for subscription renewals to describe the period that charges are for.
1719    pub billing_period: Option<TimePeriod>,
1720    /// List of items on this transaction. For calculated totals, use `details.line_items`.
1721    pub items: Vec<TransactionItem>,
1722    /// Calculated totals for a transaction, including proration, discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction.
1723    pub details: TransactionDetails,
1724    /// List of payment attempts for this transaction, including successful payments. Sorted by `created_at` in descending order, so most recent attempts are returned first.
1725    pub payments: Vec<TransactionPaymentAttempt>,
1726    /// 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.
1727    pub checkout: TransactionCheckout,
1728    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
1729    pub created_at: DateTime<Utc>,
1730    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
1731    pub updated_at: DateTime<Utc>,
1732    /// RFC 3339 datetime string of when this transaction was marked as `billed`. `null` for transactions that aren't `billed` or `completed`. Set automatically by Paddle.
1733    pub billed_at: Option<DateTime<Utc>>,
1734    /// RFC 3339 datetime string of when a transaction was revised. Revisions describe an update to customer information for a billed or completed transaction. `null` if not revised. Set automatically by Paddle.
1735    pub revised_at: Option<DateTime<Utc>>,
1736}
1737
1738/// Represents a transaction entity when creating transactions.
1739#[derive(Clone, Debug, Serialize, Deserialize)]
1740pub struct TransactionCreate {
1741    /// Unique Paddle ID for this transaction entity, prefixed with `txn_`.
1742    pub id: TransactionID,
1743    /// 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.
1744    pub status: TransactionStatus,
1745    /// Paddle ID of the customer that this transaction is for, prefixed with `ctm_`. If omitted, transaction status is `draft`.
1746    pub customer_id: CustomerID,
1747    /// Paddle ID of the address that this transaction is for, prefixed with `add_`. Requires `customer_id`. If omitted, transaction status is `draft`.
1748    pub address_id: AddressID,
1749    /// Paddle ID of the business that this transaction is for, prefixed with `biz_`. Requires `customer_id`.
1750    pub business_id: BusinessID,
1751    /// Your own structured key-value data.
1752    pub custom_data: Option<serde_json::Value>,
1753    /// Supported three-letter ISO 4217 currency code. Must be `USD`, `EUR`, or `GBP` if `collection_mode` is `manual`.
1754    pub currency_code: CurrencyCode,
1755    /// Describes how this transaction was created.
1756    pub origin: TransactionOrigin,
1757    /// Paddle ID of the subscription that this transaction is for, prefixed with `sub_`.
1758    pub subscription_id: SubscriptionID,
1759    /// 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.
1760    pub invoice_id: InvoiceId,
1761    /// Invoice number for this transaction. Automatically generated by Paddle when you mark a transaction as `billed` where `collection_mode` is `manual`.
1762    pub invoice_number: Option<String>,
1763    /// How payment is collected. `automatic` for checkout, `manual` for invoices.
1764    pub collection_mode: CollectionMode,
1765    /// Paddle ID of the discount applied to this transaction, prefixed with `dsc_`.
1766    pub discount_id: DiscountID,
1767    /// Details for invoicing. Required if `collection_mode` is `manual`.
1768    pub billing_details: BillingDetails,
1769    /// Time period that this transaction is for. Set automatically by Paddle for subscription renewals to describe the period that charges are for.
1770    pub billing_period: Option<TimePeriod>,
1771    /// List of items to charge for. You can charge for items that you've added to your catalog by passing the Paddle ID of an existing price entity, or you can charge for non-catalog items by passing a price object.
1772    ///
1773    /// Non-catalog items can be for existing products, or you can pass a product object as part of your price to charge for a non-catalog product.
1774    pub items: Vec<SubscriptionChargeItem>,
1775    /// Calculated totals for a transaction, including proration, discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction.
1776    pub details: TransactionDetails,
1777    /// List of payment attempts for this transaction, including successful payments. Sorted by `created_at` in descending order, so most recent attempts are returned first.
1778    pub payments: Vec<TransactionPaymentAttempt>,
1779    /// 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`.
1780    pub checkout: TransactionCheckout,
1781    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
1782    pub created_at: DateTime<FixedOffset>,
1783    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
1784    pub updated_at: DateTime<FixedOffset>,
1785    /// RFC 3339 datetime string of when this transaction was marked as `billed`. `null` for transactions that aren't `billed` or `completed`. Set automatically by Paddle.
1786    pub billed_at: Option<DateTime<FixedOffset>>,
1787}
1788
1789/// 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.
1790#[derive(Clone, Debug, Serialize, Deserialize)]
1791pub struct TransactionLineItemPreview {
1792    /// Paddle ID for the price related to this transaction line item, prefixed with `pri_`.
1793    /// The value is null for custom prices being previewed.
1794    pub price_id: Option<PriceID>,
1795    /// Quantity of this transaction line item.
1796    pub quantity: i64,
1797    /// Rate used to calculate tax for this transaction line item.
1798    pub tax_rate: String,
1799    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1800    pub unit_totals: Totals,
1801    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1802    pub totals: Totals,
1803    /// Represents a product (preview) entity.
1804    pub product: ProductPreview,
1805    /// How proration was calculated for this item.
1806    pub proration: Option<Proration>,
1807}
1808
1809/// Calculated totals for a transaction preview, including discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction preview.
1810#[derive(Clone, Debug, Serialize, Deserialize)]
1811pub struct TransactionDetailsPreview {
1812    /// List of tax rates applied to this transaction preview.
1813    pub tax_rates_used: Vec<TaxRatesUsed>,
1814    /// Breakdown of the total for a transaction. These numbers can be negative when dealing with subscription updates that result in credit.
1815    pub totals: TransactionTotals,
1816    /// 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.
1817    pub line_items: Vec<TransactionLineItemPreview>,
1818}
1819
1820/// Represents a transaction entity when previewing transactions.
1821#[derive(Clone, Debug, Serialize, Deserialize)]
1822pub struct TransactionPreview {
1823    /// Paddle ID of the customer that this transaction preview is for, prefixed with `ctm_`.
1824    pub customer_id: Option<CustomerID>,
1825    /// 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.
1826    pub address_id: Option<AddressID>,
1827    /// Paddle ID of the business that this transaction preview is for, prefixed with `biz_`.
1828    pub business_id: Option<BusinessID>,
1829    /// Supported three-letter ISO 4217 currency code.
1830    pub currency_code: CurrencyCode,
1831    /// Paddle ID of the discount applied to this transaction preview, prefixed with `dsc_`.
1832    pub discount_id: Option<DiscountID>,
1833    /// IP address for this transaction preview. Send one of `address_id`, `customer_ip_address`, or the `address` object when previewing.
1834    pub customer_ip_address: Option<String>,
1835    /// Address for this transaction preview. Send one of `address_id`, `customer_ip_address`, or the `address` object when previewing.
1836    pub address: Option<AddressPreview>,
1837    /// Whether trials should be ignored for transaction preview calculations.
1838    ///
1839    /// By default, recurring items with trials are considered to have a zero charge when previewing. Set to `true` to disable this.
1840    pub ignore_trials: bool,
1841    /// List of items to preview transaction calculations for.
1842    pub items: Vec<TransactionItemPreviewBase>,
1843    /// Calculated totals for a transaction preview, including discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction preview.
1844    pub details: TransactionDetailsPreview,
1845    pub available_payment_methods: Vec<PaymentMethodType>,
1846}
1847
1848/// Represents a transaction entity when previewing.
1849#[derive(Clone, Debug, Serialize, Deserialize)]
1850pub struct TransactionPreviewCreate {
1851    /// Paddle ID of the customer that this transaction preview is for, prefixed with `ctm_`.
1852    pub customer_id: CustomerID,
1853    /// Supported three-letter ISO 4217 currency code.
1854    pub currency_code: CurrencyCode,
1855    /// Paddle ID of the discount applied to this transaction preview, prefixed with `dsc_`.
1856    pub discount_id: DiscountID,
1857    /// Whether trials should be ignored for transaction preview calculations.
1858    ///
1859    /// By default, recurring items with trials are considered to have a zero charge when previewing. Set to `true` to disable this.
1860    pub ignore_trials: bool,
1861    /// List of items to preview charging for. You can preview charging for items that you've added to your catalog by passing the Paddle ID of an existing price entity, or you can preview charging for non-catalog items by passing a price object.
1862    ///
1863    /// Non-catalog items can be for existing products, or you can pass a product object as part of your price to preview charging for a non-catalog product.
1864    pub items: Vec<SubscriptionChargeItem>,
1865}
1866
1867/// Represents a price entity.
1868#[derive(Clone, Debug, Serialize, Deserialize)]
1869pub struct TransactionPriceCreateBase {
1870    /// Internal description for this price, not shown to customers. Typically notes for your team.
1871    pub description: String,
1872    /// Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills.
1873    pub name: Option<String>,
1874    /// How often this price should be charged. `null` if price is non-recurring (one-time).
1875    pub billing_cycle: Option<Duration>,
1876    /// 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`.
1877    pub trial_period: Option<Duration>,
1878    /// How tax is calculated for this price.
1879    pub tax_mode: TaxMode,
1880    /// A base representation of monetary value unformatted in the lowest denomination with currency code.
1881    pub unit_price: Money,
1882    /// List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries.
1883    pub unit_price_overrides: Vec<UnitPriceOverride>,
1884    pub quantity: PriceQuantity,
1885    /// Your own structured key-value data.
1886    pub custom_data: Option<serde_json::Value>,
1887}
1888
1889/// Represents a customer information revision for a transaction.
1890#[derive(Clone, Debug, Serialize, Deserialize)]
1891pub struct TransactionRevise {
1892    /// Revised customer information for this transaction.
1893    pub customer: Customer,
1894    /// Revised business information for this transaction.
1895    pub business: Business,
1896    /// Revised address information for this transaction.
1897    pub address: Address,
1898}
1899
1900#[derive(Clone, Debug, Serialize, Deserialize)]
1901pub struct TransactionSubscriptionProductCreate {
1902    /// Name of this product.
1903    pub name: String,
1904    /// Short description for this product.
1905    pub description: Option<String>,
1906    /// Tax category for this product. Used for charging the correct rate of tax. Selected tax category must be enabled on your Paddle account.
1907    pub tax_category: TaxCategory,
1908    /// Image for this product. Included in the checkout and on some customer documents.
1909    pub image_url: Option<String>,
1910    /// Your own structured key-value data.
1911    pub custom_data: Option<serde_json::Value>,
1912}
1913
1914/// Represents a transaction entity when updating transactions.
1915#[derive(Clone, Debug, Serialize, Deserialize)]
1916pub struct TransactionUpdate {
1917    /// Unique Paddle ID for this transaction entity, prefixed with `txn_`.
1918    pub id: TransactionID,
1919    /// 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.
1920    pub status: TransactionStatus,
1921    /// Paddle ID of the customer that this transaction is for, prefixed with `ctm_`.
1922    pub customer_id: CustomerID,
1923    /// Paddle ID of the address that this transaction is for, prefixed with `add_`.
1924    pub address_id: AddressID,
1925    /// Paddle ID of the business that this transaction is for, prefixed with `biz_`.
1926    pub business_id: BusinessID,
1927    /// Your own structured key-value data.
1928    pub custom_data: Option<serde_json::Value>,
1929    /// Supported three-letter ISO 4217 currency code. Must be `USD`, `EUR`, or `GBP` if `collection_mode` is `manual`.
1930    pub currency_code: CurrencyCode,
1931    /// Describes how this transaction was created.
1932    pub origin: TransactionOrigin,
1933    /// Paddle ID of the subscription that this transaction is for, prefixed with `sub_`.
1934    pub subscription_id: SubscriptionID,
1935    /// 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.
1936    pub invoice_id: InvoiceId,
1937    /// Invoice number for this transaction. Automatically generated by Paddle when you mark a transaction as `billed` where `collection_mode` is `manual`.
1938    pub invoice_number: Option<String>,
1939    /// How payment is collected. `automatic` for checkout, `manual` for invoices.
1940    pub collection_mode: CollectionMode,
1941    /// Paddle ID of the discount applied to this transaction, prefixed with `dsc_`.
1942    pub discount_id: DiscountID,
1943    /// Details for invoicing. Required if `collection_mode` is `manual`.
1944    pub billing_details: BillingDetails,
1945    /// Time period that this transaction is for. Set automatically by Paddle for subscription renewals to describe the period that charges are for.
1946    pub billing_period: Option<TimePeriod>,
1947    /// List of items on this transaction.
1948    ///
1949    /// When making a request, each object must contain either a `price_id` or a `price` object, and a `quantity`.
1950    ///
1951    /// Include a `price_id` to charge for an existing catalog item, or a `price` object to charge for a non-catalog item.
1952    pub items: Vec<SubscriptionChargeItem>,
1953    /// Calculated totals for a transaction, including proration, discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction.
1954    pub details: TransactionDetails,
1955    /// List of payment attempts for this transaction, including successful payments. Sorted by `created_at` in descending order, so most recent attempts are returned first.
1956    pub payments: Vec<TransactionPaymentAttempt>,
1957    /// 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`.
1958    pub checkout: TransactionCheckout,
1959    /// RFC 3339 datetime string of when this entity was created. Set automatically by Paddle.
1960    pub created_at: DateTime<FixedOffset>,
1961    /// RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
1962    pub updated_at: DateTime<FixedOffset>,
1963    /// RFC 3339 datetime string of when this transaction was marked as `billed`. `null` for transactions that aren't `billed` or `completed`. Set automatically by Paddle.
1964    pub billed_at: Option<DateTime<FixedOffset>>,
1965}
1966
1967#[derive(Clone, Debug, Serialize, Deserialize)]
1968pub struct TransactionItemCreateBase {
1969    /// Quantity of this item on the transaction.
1970    pub quantity: i64,
1971    /// 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.
1972    pub proration: Proration,
1973}
1974
1975/// Information about line items for this transaction. Different from transaction `items` as they include totals calculated by Paddle. Considered the source of truth for line item totals.
1976#[derive(Clone, Debug, Serialize, Deserialize)]
1977pub struct TransactionLineItem {
1978    /// Unique Paddle ID for this price, prefixed with `pri_`.
1979    pub price_id: PriceID,
1980    /// Quantity of this transaction line item.
1981    pub quantity: i64,
1982    /// 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.
1983    pub proration: Proration,
1984    /// Rate used to calculate tax for this transaction line item.
1985    pub tax_rate: String,
1986    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1987    pub unit_totals: Totals,
1988    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
1989    pub totals: Totals,
1990    /// Represents a product entity.
1991    pub product: Product,
1992}
1993
1994/// Breakdown of the payout total for a transaction. `null` until the transaction is `completed`. Returned in your payout currency.
1995#[derive(Clone, Debug, Serialize, Deserialize)]
1996pub struct TransactionPayoutTotals {
1997    /// Total before tax and fees.
1998    pub subtotal: String,
1999    /// Total discount as a result of any discounts applied.
2000    /// Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied.
2001    pub discount: String,
2002    /// Total tax on the subtotal.
2003    pub tax: String,
2004    /// Total after tax.
2005    pub total: String,
2006    /// Total credit applied to this transaction. This includes credits applied using a customer's credit balance and adjustments to a `billed` transaction.
2007    pub credit: String,
2008    /// Additional credit generated from negative `details.line_items`. This credit is added to the customer balance.
2009    pub credit_to_balance: String,
2010    /// Total due on a transaction after credits and any payments.
2011    pub balance: String,
2012    /// Total due on a transaction after credits but before any payments.
2013    pub grand_total: String,
2014    /// Total fee taken by Paddle for this payout.
2015    pub fee: String,
2016    /// Total earnings for this payout. This is the subtotal minus the Paddle fee.
2017    pub earnings: String,
2018    /// Supported three-letter ISO 4217 currency code for payouts from Paddle.
2019    pub currency_code: CurrencyCodePayouts,
2020}
2021
2022#[derive(Clone, Debug, Serialize, Deserialize)]
2023pub struct TransactionItemPreviewBase {
2024    /// Quantity of this item on the transaction.
2025    pub quantity: i64,
2026    /// Whether this item should be included in totals for this transaction preview. Typically used to exclude one-time charges from calculations.
2027    pub include_in_totals: bool,
2028    /// How proration was calculated for this item. `null` for transaction previews.
2029    pub proration: Option<Proration>,
2030}
2031
2032#[derive(Clone, Debug, Serialize, Deserialize)]
2033pub struct PricePreviewBase {
2034    /// Paddle ID of the customer that this preview is for, prefixed with `ctm_`.
2035    pub customer_id: CustomerID,
2036    /// Paddle ID of the address that this preview is for, prefixed with `add_`. Send one of `address_id`, `customer_ip_address`, or the `address` object when previewing.
2037    pub address_id: AddressID,
2038    /// Paddle ID of the business that this preview is for, prefixed with `biz_`.
2039    pub business_id: BusinessID,
2040    /// Supported three-letter ISO 4217 currency code.
2041    pub currency_code: CurrencyCode,
2042    /// Paddle ID of the discount applied to this preview, prefixed with `dsc_`.
2043    pub discount_id: DiscountID,
2044    /// Address for this preview. Send one of `address_id`, `customer_ip_address`, or the `address` object when previewing.
2045    pub address: Address,
2046    /// IP address for this transaction preview. Send one of `address_id`, `customer_ip_address`, or the `address` object when previewing.
2047    pub customer_ip_address: Option<String>,
2048}
2049
2050/// Array of discounts applied to this preview line item. Empty if no discounts applied.
2051#[derive(Clone, Debug, Serialize, Deserialize)]
2052pub struct PricePreviewDiscounts {
2053    /// Represents a discount entity.
2054    pub discount: Discount,
2055    /// Total amount discounted as a result of this discount.
2056    pub total: String,
2057    /// Total amount discounted as a result of this discount in the format of a given currency. '
2058    pub formatted_total: String,
2059}
2060
2061/// Information about line items for this preview. Includes totals calculated by Paddle. Considered the source of truth for line item totals.
2062#[derive(Clone, Debug, Serialize, Deserialize)]
2063pub struct PricePreviewLineItem {
2064    /// Represents a price entity.
2065    pub price: Price,
2066    /// Quantity of this preview line item.
2067    pub quantity: i64,
2068    /// Rate used to calculate tax for this preview line item.
2069    pub tax_rate: String,
2070    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
2071    pub unit_totals: Totals,
2072    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
2073    pub formatted_unit_totals: Totals,
2074    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
2075    pub totals: Totals,
2076    /// Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD).
2077    pub formatted_totals: Totals,
2078    /// Represents a product entity.
2079    pub product: Product,
2080    pub discounts: Vec<PricePreviewDiscounts>,
2081}
2082
2083/// Calculated totals for a price preview, including discounts, tax, and currency conversion.
2084#[derive(Clone, Debug, Serialize, Deserialize)]
2085pub struct PricePreviewDetails {
2086    pub line_items: Vec<PricePreviewLineItem>,
2087}
2088
2089#[derive(Clone, Debug, Serialize, Deserialize)]
2090pub struct PricePreviewItem {
2091    /// Unique Paddle ID for this price, prefixed with `pri_`.
2092    pub price_id: PriceID,
2093    /// Quantity of the item to preview.
2094    pub quantity: i64,
2095}
2096
2097/// Price object for a non-catalog item to charge for.
2098///
2099/// Can be for existing products, or you can pass a product object as part of your price to charge for a non-catalog product.
2100#[skip_serializing_none]
2101#[derive(Serialize)]
2102pub struct TransactionItemNonCatalogPrice {
2103    description: String,
2104    name: Option<String>,
2105    billing_cycle: Option<Duration>,
2106    trial_period: Option<Duration>,
2107    tax_mode: Option<TaxMode>,
2108    unit_price: Money,
2109    unit_price_overrides: Option<Vec<UnitPriceOverride>>,
2110    quantity: Option<PriceQuantity>,
2111    custom_data: Option<serde_json::Value>,
2112    product_id: Option<ProductID>,
2113    product: Option<TransactionSubscriptionProductCreate>,
2114}
2115
2116impl TransactionItemNonCatalogPrice {
2117    /// Create new price object for non-catalog item.
2118    ///
2119    /// - `description` - Internal description for this price, not shown to customers. Typically notes for your team.
2120    /// - `amount` - Amount in the lowest denomination for the currency, e.g. 10 USD = 1000 (cents). Although represented as a string, this value must be a valid integer.
2121    /// - `currency` - Currency code.
2122    pub fn new(description: impl Into<String>, amount: u64, currency: CurrencyCode) -> Self {
2123        Self {
2124            description: description.into(),
2125            name: None,
2126            billing_cycle: None,
2127            trial_period: None,
2128            tax_mode: None,
2129            unit_price: Money {
2130                amount: amount.to_string(),
2131                currency_code: currency,
2132            },
2133            unit_price_overrides: None,
2134            quantity: None,
2135            custom_data: None,
2136            product_id: None,
2137            product: None,
2138        }
2139    }
2140
2141    /// Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills.
2142    pub fn name(mut self, name: impl Into<String>) -> Self {
2143        self.name = Some(name.into());
2144        self
2145    }
2146
2147    /// How often this price should be charged.
2148    pub fn billing_cycle(mut self, billing_cycle: Duration) -> Self {
2149        self.billing_cycle = Some(billing_cycle);
2150        self
2151    }
2152
2153    /// Trial period for the product related to this price. The billing cycle begins once the trial period is over.
2154    pub fn trial_period(mut self, trial_period: Duration) -> Self {
2155        self.trial_period = Some(trial_period);
2156        self
2157    }
2158
2159    /// How tax is calculated for this price.
2160    pub fn tax_mode(mut self, tax_mode: TaxMode) -> Self {
2161        self.tax_mode = Some(tax_mode);
2162        self
2163    }
2164
2165    /// Use to override the base price with a custom price and currency for a country or group of countries.
2166    /// See [UnitPriceOverride] for more information.
2167    /// See [CountryCodeSupported] for more information.
2168    /// See [Money] for more information.
2169    /// See [CurrencyCode] for more information.
2170    pub fn add_unit_price_override(
2171        mut self,
2172        country_codes: impl IntoIterator<Item = CountryCodeSupported>,
2173        amount: u64,
2174        currency: CurrencyCode,
2175    ) -> Self {
2176        if self.unit_price_overrides.is_none() {
2177            self.unit_price_overrides = Some(vec![]);
2178        }
2179
2180        self.unit_price_overrides
2181            .as_mut()
2182            .unwrap()
2183            .push(UnitPriceOverride {
2184                country_codes: country_codes.into_iter().collect(),
2185                unit_price: Money {
2186                    amount: amount.to_string(),
2187                    currency_code: currency,
2188                },
2189            });
2190
2191        self
2192    }
2193
2194    /// Use to override the base price with a custom price and currency for a country or group of countries.
2195    /// This will replace any existing overrides.
2196    /// Use `add_unit_price_override` to add additional overrides.
2197    /// See [UnitPriceOverride] for more information.
2198    /// See [CountryCodeSupported] for more information.
2199    /// See [Money] for more information.
2200    /// See [CurrencyCode] for more information.
2201    pub fn set_unit_price_overrides(mut self, overrides: Vec<UnitPriceOverride>) -> Self {
2202        self.unit_price_overrides = Some(overrides);
2203        self
2204    }
2205
2206    /// Limits on how many times the related product can be purchased at this price. Useful for discount campaigns. If omitted, defaults to 1-100.
2207    pub fn quantity(mut self, quantity: PriceQuantity) -> Self {
2208        self.quantity = Some(quantity);
2209        self
2210    }
2211
2212    /// Your own structured key-value data.
2213    pub fn custom_data(mut self, custom_data: serde_json::Value) -> Self {
2214        self.custom_data = Some(custom_data);
2215        self
2216    }
2217
2218    /// Paddle ID of the product that this price is for, prefixed with `prd_`.
2219    pub fn product_id(mut self, product_id: impl Into<ProductID>) -> Self {
2220        self.product_id = Some(product_id.into());
2221        self.product = None;
2222        self
2223    }
2224
2225    /// Product object for a non-catalog item to charge for.
2226    ///
2227    /// Setting a non-catalog product to this price will override the catalog product id.
2228    pub fn product(mut self, product: TransactionSubscriptionProductCreate) -> Self {
2229        self.product = Some(product);
2230        self.product_id = None;
2231        self
2232    }
2233}