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