knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(paddleR)
The paddleR
package provides a complete R interface to the Paddle Billing API, enabling you to manage customers, subscriptions, transactions, invoices, and more directly from R.
Whether you're building internal dashboards, automated billing workflows, or a SaaS application backend, paddle makes it easy to interact with Paddle's RESTful endpoints in a consistent and validated way.
PaddleR
supports two environments:
https://api.paddle.com
) for productionhttps://sandbox-api.paddle.com
) for safe testingBy default, the package uses live mode. You can switch modes using:
# Set sandbox mode for testing set_paddle_mode("sandbox") # Revert back to live mode set_paddle_mode("live")
You can check the current mode and base URL with:
get_paddle_mode() # Returns "live" or "sandbox" get_paddle_url() # Returns full API base URL
To authenticate with the Paddle API, you must set your API key(s) as environment variables. You have two options:
Sys.setenv(PADDLE_KEY = "your-live-or-sandbox-key")
Sys.setenv(PADDLE_KEY_LIVE = "your-live-key") Sys.setenv(PADDLE_KEY_SANDBOX = "your-sandbox-key")
This allows the package to automatically choose the correct key based on the mode selected with set_paddle_mode()
. Please make sure your API has all the necessary permissions for the operations you want to perform.
# Set mode to sandbox for testing set_paddle_mode("sandbox") # List products, subscriptions, or customers products <- paddle_list_products() subscriptions <- paddle_list_subscriptions()
Internally, the package uses a hidden environment to store the current mode and URL:
.paddle_env <- new.env(parent = emptyenv()) .paddle_env$mode <- "live" .paddle_env$base_url <- "https://api.paddle.com"
These are updated dynamically using the exported helpers:
Now that you have paddleR set up, you can start building your Paddle integration:
paddle_list_*()
functions to explore available resources like products, subscriptions, customers, etc.paddle_create_customer()
, paddle_update_customer()
, etc.paddle_create_subscription()
, paddle_update_subscription()
, etc.paddle_list_transactions()
, paddle_get_transaction()
, etc.paddle_list_invoices()
, paddle_get_invoice()
, etc.paddle_list_discounts()
, paddle_create_discount()
, etc.paddle_list_prices()
to explore available prices for productspaddle_create_product()
, paddle_update_product()
, etc.Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.