paddle_rust_sdk/ids.rs
1//! Unique Paddle IDs
2
3use std::fmt::Display;
4
5use serde::{Deserialize, Serialize};
6
7macro_rules! paddle_id {
8 ($(#[$attr:meta])* $name:ident) => {
9 $(#[$attr])*
10 #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
11 pub struct $name(pub String);
12
13 impl<T: Display> From<T> for $name {
14 fn from(value: T) -> Self {
15 $name(value.to_string())
16 }
17 }
18
19 impl Into<String> for $name {
20 fn into(self) -> String {
21 self.0
22 }
23 }
24
25 impl AsRef<str> for $name {
26 fn as_ref(&self) -> &str {
27 &self.0
28 }
29 }
30 };
31 ($($(#[$attr:meta])* $name:ident,)*) => {
32 $(
33 paddle_id! {
34 $(#[$attr])*
35 $name
36 }
37 )*
38 };
39}
40
41paddle_id! {
42 /// Unique Paddle ID for this address entity, prefixed with `add_`.
43 AddressID,
44
45 /// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
46 CustomerID,
47
48 /// Unique Paddle ID for this adjustment entity, prefixed with `adj_`.
49 AdjustmentID,
50
51 /// Unique Paddle ID for this transaction entity, prefixed with `txn_`.
52 TransactionID,
53
54 /// Unique Paddle ID for this subscription entity, prefixed with `sub_`.
55 SubscriptionID,
56
57 /// Unique Paddle ID for this transaction item, prefixed with `txnitm_`. Used when working with [adjustments](https://developer.paddle.com/build/transactions/create-transaction-adjustments).
58 TransactionItemID,
59
60 /// Unique Paddle ID for this adjustment item, prefixed with `adjitm_`.
61 AdjustmentItemID,
62
63 /// Unique Paddle ID for this business entity, prefixed with `biz_`.
64 BusinessID,
65
66 /// Unique Paddle ID for this payment method entity, prefixed with `paymtd_`.
67 PaymentMethodID,
68
69 /// Unique Paddle ID for this customer portal session entity, prefixed with `cpls_`.
70 CustomerPortalSessionID,
71
72 /// Unique Paddle ID for this discount, prefixed with `dsc_`.
73 DiscountID,
74
75 /// Unique code that customers can use to apply this discount at checkout. Use letters and numbers only, up to 16 characters. Not case-sensitive.
76 DiscountCode,
77
78 /// Unique Paddle ID for this event, prefixed with `evt_`.
79 EventID,
80
81 /// Unique Paddle ID for this price, prefixed with `pri_`.
82 PriceID,
83
84 /// Unique Paddle ID for this product, prefixed with `pro_`.
85 ProductID,
86
87 /// Unique Paddle ID for API keys, prefixed with `apikey_`.
88 ApiKeyID,
89
90 /// Unique Paddle ID for payouts, prefixed with `payout_`.
91 PayoutID,
92
93 /// Unique Paddle ID for this notification, prefixed with `ntf_`.
94 NotificationID,
95
96 /// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
97 NotificationSettingID,
98
99 /// Unique Paddle ID for this notification log, prefixed with `ntflog_`.
100 NotificationLogID,
101
102 /// Webhook destination secret key, prefixed with `pdl_ntfset_`. Used for signature verification.
103 EndpointSecretKey,
104
105 /// Just a Paddle ID. I've noticed this used in some places.
106 PaddleID,
107
108 /// Unique Paddle ID for this simulation event, prefixed with `ntfsimevt_`.
109 SimulationEventID,
110
111 /// Unique Paddle ID for this simulation run, prefixed with `ntfsimrun_`.
112 SimulationRunID,
113
114 /// Unique Paddle ID for this simulation, prefixed with `ntfsim_`.
115 SimulationID,
116
117 /// 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.
118 InvoiceId,
119}