paddle_rust_sdk/
ids.rs

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