Paddle
Paddle is a merchant of record that acts to provide a payment infrastructure to thousands of software companies around the world.
The Paddle Wrapper is a WebAssembly(Wasm) foreign data wrapper which allows you to read and write data from Paddle within your Postgres database.
Warning
Restoring a logical backup of a database with a materialized view using a foreign table can fail. For this reason, either do not use foreign tables in materialized views or use them in databases with physical backups enabled.
Supported Data Types
Postgres Data Type | Paddle Data Type |
---|---|
boolean | Boolean |
smallint | Money |
integer | Money |
bigint | Money |
real | Money |
double precision | Money |
numeric | Money |
text | Text |
date | Dates and time |
timestamp | Dates and time |
timestamptz | Dates and time |
The Paddle API uses JSON formatted data, please refer to Paddle docs for more details.
Available Versions
Version | Wasm Package URL | Checksum |
---|---|---|
0.1.1 | https://github.com/supabase/wrappers/releases/download/wasm_paddle_fdw_v0.1.1/paddle_fdw.wasm |
c5ac70bb2eef33693787b7d4efce9a83cde8d4fa40889d2037403a51263ba657 |
0.1.0 | https://github.com/supabase/wrappers/releases/download/wasm_paddle_fdw_v0.1.0/paddle_fdw.wasm |
7d0b902440ac2ef1af85d09807145247f14d1d8fd4d700227e5a4d84c8145409 |
Preparation
Before you get started, make sure the wrappers
extension is installed on your database:
1 |
|
and then create the Wasm foreign data wrapper:
1 2 3 |
|
Secure your credentials (optional)
By default, Postgres stores FDW credentials inside pg_catalog.pg_foreign_server
in plain text. Anyone with access to this table will be able to view these credentials. Wrappers is designed to work with Vault, which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.
1 2 3 4 5 6 7 |
|
Connecting to Paddle
We need to provide Postgres with the credentials to access Paddle, and any additional options. We can do this using the create server
command:
1 2 3 4 5 6 7 8 9 10 |
|
1 2 3 4 5 6 7 8 9 10 |
|
Note the fdw_package_*
options are required, which specify the Wasm package metadata. You can get the available package version list from above.
Create a schema
We recommend creating a schema to hold all the foreign tables:
1 |
|
Creating Foreign Tables
The Paddle Wrapper supports data reads and writes from Paddle.
Integration | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
Paddle | ✅ | ✅ | ✅ | ❌ | ❌ |
For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Foreign table options
The full list of foreign table options are below:
object
- Object name in Paddle, required.
Supported objects are listed below:
Object name |
---|
products |
prices |
discounts |
customers |
transactions |
reports |
notification-settings |
notifications |
rowid_column
- Primary key column name, optional for data scan, required for data modify
Query Pushdown Support
This FDW supports where
clause pushdown with id
as the filter. For example,
1 |
|
Examples
Below are Some examples on how to use Paddle foreign tables.
Basic example
This example will create a "foreign table" inside your Postgres database and query its data. First, we can create a schema to hold all the Paddle foreign tables.
1 |
|
Then create the foreign table and query it, for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
attrs
is a special column which stores all the object attributes in JSON format, you can extract any attributes needed or its associated sub objects from it. See more examples below.
Query JSON attributes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
Data modify example
This example will modify data in a "foreign table" inside your Postgres database, note that rowid_column
option is mandatory for data modify:
1 2 3 4 5 6 7 8 |
|