pub struct Paddle { /* private fields */ }
Expand description
Paddle API client
This struct is used to create a new Paddle client instance.
Implementations§
Source§impl Paddle
impl Paddle
pub const PRODUCTION: &'static str = "https://api.paddle.com"
pub const SANDBOX: &'static str = "https://sandbox-api.paddle.com"
Sourcepub fn new(
api_key: impl Into<String>,
base_url: impl IntoUrl,
) -> Result<Self, Error>
pub fn new( api_key: impl Into<String>, base_url: impl IntoUrl, ) -> Result<Self, Error>
Creates a new Paddle client instance.
Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
Sourcepub fn products_list(&self) -> ProductsList<'_>
pub fn products_list(&self) -> ProductsList<'_>
Returns a request builder for fetching products. Use the after method to page through results.
By default, Paddle returns products that are active. Use the status method to return products that are archived. Use the include method to include related price entities in the response.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let products = client.products_list().send().await.unwrap();
Sourcepub fn product_create(
&self,
name: impl Into<String>,
tax_category: TaxCategory,
) -> ProductCreate<'_>
pub fn product_create( &self, name: impl Into<String>, tax_category: TaxCategory, ) -> ProductCreate<'_>
Returns a request builder for creating a new product.
§Example:
use paddle::Paddle;
use paddle::enums::TaxCategory;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let product = client.products_create("My Product", TaxCategory::Standard).send().await.unwrap();
Sourcepub fn product_get(&self, product_id: impl Into<ProductID>) -> ProductGet<'_>
pub fn product_get(&self, product_id: impl Into<ProductID>) -> ProductGet<'_>
Returns a request builder for fetching a specific product.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let product = client.product_get("pro_01jqx9rd...").send().await.unwrap();
Sourcepub fn product_update(
&self,
product_id: impl Into<ProductID>,
) -> ProductUpdate<'_>
pub fn product_update( &self, product_id: impl Into<ProductID>, ) -> ProductUpdate<'_>
Returns a request builder for updating a specific product.
§Example:
use paddle::Paddle;
use paddle::enums::TaxCategory;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let product = client.product_update("pro_01jqx9rd...").name("My New Name").send().await.unwrap();
Sourcepub fn prices_list(&self) -> PricesList<'_>
pub fn prices_list(&self) -> PricesList<'_>
Returns a request builder listing prices
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let prices = client.prices_list().send().await.unwrap();
Sourcepub fn price_create(
&self,
product_id: impl Into<ProductID>,
description: impl Into<String>,
amount: u64,
currency: CurrencyCode,
) -> PricesCreate<'_>
pub fn price_create( &self, product_id: impl Into<ProductID>, description: impl Into<String>, amount: u64, currency: CurrencyCode, ) -> PricesCreate<'_>
Returns a request builder for creating a new price.
product_id
- Paddle ID for the product that this price is for.description
- Internal description for this price, not shown to customers. Typically notes for your team.amount
- Amount of the price in the smallest unit of the currency (e.g. 1000 cents for 10 USD).currency
- Currency code for the price. Use the CurrencyCode enum to specify the currency.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let price = client.price_create("pro_01jqx9rd...", "Low price", 19.99, CurrencyCode::USD).send().await.unwrap();
Sourcepub fn price_get(&self, price_id: impl Into<PriceID>) -> PriceGet<'_>
pub fn price_get(&self, price_id: impl Into<PriceID>) -> PriceGet<'_>
Returns a request builder for fetching a specific price by id.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let price = client.price_get("price_01jqx9rd...").send().await.unwrap();
Sourcepub fn price_update(&self, price_id: impl Into<PriceID>) -> PriceUpdate<'_>
pub fn price_update(&self, price_id: impl Into<PriceID>) -> PriceUpdate<'_>
Returns a request builder for updating a specific price.
§Example:
use paddle::Paddle;
use paddle::enums::TaxCategory;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let price = client.price_update("pri_01jqxv...").name("Updated Name").send().await.unwrap();
Sourcepub fn discounts_list(&self) -> DiscountsList<'_>
pub fn discounts_list(&self) -> DiscountsList<'_>
Returns a request builder for fetching discounts.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let discounts = client.discounts_list().send().await.unwrap();
Sourcepub fn discount_create(
&self,
amount: impl Into<String>,
description: impl Into<String>,
discount_type: DiscountType,
) -> DiscountCreate<'_>
pub fn discount_create( &self, amount: impl Into<String>, description: impl Into<String>, discount_type: DiscountType, ) -> DiscountCreate<'_>
Returns a request builder for creating discounts.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let discount = client.discount_create("15", "Winter Holidays", DiscountType::Percentage).send().await.unwrap();
Sourcepub fn discount_get(
&self,
discount_id: impl Into<DiscountID>,
) -> DiscountGet<'_>
pub fn discount_get( &self, discount_id: impl Into<DiscountID>, ) -> DiscountGet<'_>
Returns a request builder for fetching a specific discount by id.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let discount = client.discount_get("dsc_01jqzpbmnq...").send().await.unwrap();
Sourcepub fn discount_update(
&self,
discount_id: impl Into<DiscountID>,
) -> DiscountUpdate<'_>
pub fn discount_update( &self, discount_id: impl Into<DiscountID>, ) -> DiscountUpdate<'_>
Returns a request builder for creating discounts.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let discount = client.discount_update("dsc_01jqzpbmnq...").amount("18").send().await.unwrap();
Sourcepub fn customers_list(&self) -> CustomersList<'_>
pub fn customers_list(&self) -> CustomersList<'_>
Returns a request builder for fetching customers. Use the after method to page through results.
By default, Paddle returns customers that are active
. Use the status query parameter to return customers that are archived.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let customers = client.customers_list().send().await.unwrap();
Sourcepub fn customer_create(&self, email: impl Into<String>) -> CustomerCreate<'_>
pub fn customer_create(&self, email: impl Into<String>) -> CustomerCreate<'_>
Returns a request builder for creating a new customer.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let customers = client.customer_create("test@example.com").send().await.unwrap();
Sourcepub fn customer_get(
&self,
customer_id: impl Into<CustomerID>,
) -> CustomerGet<'_>
pub fn customer_get( &self, customer_id: impl Into<CustomerID>, ) -> CustomerGet<'_>
Returns a request builder for fetching a specific customer by id.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let discount = client.customer_get("ctm_01jqztc78e1xfdgwhcgjzdrvgd").send().await.unwrap();
Sourcepub fn customer_update(
&self,
customer_id: impl Into<CustomerID>,
) -> CustomerUpdate<'_>
pub fn customer_update( &self, customer_id: impl Into<CustomerID>, ) -> CustomerUpdate<'_>
Returns a request builder for updating customer data.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let discount = client.customer_update("ctm_01jqztc78e1xfdgwhcgjzdrvgd").email("new_email@example.com").send().await.unwrap();
Sourcepub fn customer_credit_balances(
&self,
customer_id: impl Into<CustomerID>,
) -> CustomerCreditBalances<'_>
pub fn customer_credit_balances( &self, customer_id: impl Into<CustomerID>, ) -> CustomerCreditBalances<'_>
Returns a request builder for fetching a list of credit balances for each currency for a customer.
Each balance has three totals:
available
- total available to use.reserved
- total temporarily reserved for billed transactions.used
- total amount of credit used.
Credit is added to the available total initially. When used, it moves to the used total.
The reserved total is used when a credit balance is applied to a transaction that’s marked as billed, like when working with an issued invoice. It’s not available for other transactions at this point, but isn’t considered used until the transaction is completed. If a billed transaction is canceled, any reserved credit moves back to available.
Credit balances are created automatically by Paddle when you take an action that results in Paddle creating a credit for a customer, like making prorated changes to a subscription. An empty data array is returned where a customer has no credit balances.
The response is not paginated.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let discount = client.customer_credit_balances("ctm_01jqztc78e1xfdgwhcgjzdrvgd").send().await.unwrap();
Sourcepub async fn generate_auth_token(
&self,
customer_id: impl Display,
) -> Result<SuccessResponse<CustomerAuthenticationToken>, Error>
pub async fn generate_auth_token( &self, customer_id: impl Display, ) -> Result<SuccessResponse<CustomerAuthenticationToken>, Error>
Generates an authentication token for a customer.
You can pass a generated authentication token to Paddle.js when opening a checkout to let customers work with saved payment methods.
Authentication tokens are temporary and shouldn’t be cached. They’re valid until the expires_at date returned in the response.
Sourcepub fn addresses_list(
&self,
customer_id: impl Into<CustomerID>,
) -> AddressesList<'_>
pub fn addresses_list( &self, customer_id: impl Into<CustomerID>, ) -> AddressesList<'_>
Returns a request builder for fetching customers addresses.
By default, Paddle returns addresses that are active
. Use the status query parameter to return addresses that are archived.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let customers = client.addresses_list("ctm_01jqztc78e1xfdgwhcgjzdrvgd").send().await.unwrap();
Sourcepub fn address_create(
&self,
customer_id: impl Into<CustomerID>,
country_code: CountryCodeSupported,
) -> AddressCreate<'_>
pub fn address_create( &self, customer_id: impl Into<CustomerID>, country_code: CountryCodeSupported, ) -> AddressCreate<'_>
Returns a request builder for creating a new customer address.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let customers = client.address_create("ctm_01jqztc78e1xfdgwhcgjzdrvgd", CountryCodeSupported::US).send().await.unwrap();
Sourcepub fn address_get(
&self,
customer_id: impl Into<CustomerID>,
address_id: impl Into<AddressID>,
) -> AddressGet<'_>
pub fn address_get( &self, customer_id: impl Into<CustomerID>, address_id: impl Into<AddressID>, ) -> AddressGet<'_>
Returns a request builder for getting an address for a customer using its ID and related customer ID.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let customers = client.address_get("ctm_01jqztc78e1xfdgwhcgjzdrvgd", "add_01hv8gwdfkw5z6d1yy6pa3xyrz").send().await.unwrap();
Sourcepub fn address_update(
&self,
customer_id: impl Into<CustomerID>,
address_id: impl Into<AddressID>,
) -> AddressUpdate<'_>
pub fn address_update( &self, customer_id: impl Into<CustomerID>, address_id: impl Into<AddressID>, ) -> AddressUpdate<'_>
Returns a request builder for updating an address for a customer using its ID and related customer ID.
§Example:
use paddle::Paddle;
let client = Paddle::new("your_api_key", Paddle::SANDBOX).unwrap();
let customers = client.address_update("add_01hv8gwdfkw5z6d1yy6pa3xyrz", "add_01hv8gwdfkw5z6d1yy6pa3xyrz").first_line("Test").send().await.unwrap();