Skip to content

Commit 926df23

Browse files
CopilotburmeciaCopilot
authored
docs(stripe): clarify api_key_id vs api_key_name vault options (supabase#595)
* Initial plan * Improve Stripe FDW docs: clarify api_key_id and api_key_name vault options usage Agent-Logs-Url: https://github.com/supabase/wrappers/sessions/57afec13-50a3-4077-86e8-cc23196407f6 Co-authored-by: burmecia <[email protected]> * Fix stripe docs: revert tab split, add descriptions inside existing With Vault tab Agent-Logs-Url: https://github.com/supabase/wrappers/sessions/84fc15a3-8220-4d92-83a6-641528a1b1b3 Co-authored-by: burmecia <[email protected]> * Update docs/catalog/stripe.md Co-authored-by: Copilot <[email protected]> * docs(stripe): show two separate create server examples for api_key_id vs api_key_name Agent-Logs-Url: https://github.com/supabase/wrappers/sessions/bd13c673-32e0-4c55-9ffd-ff4e43c3832a Co-authored-by: burmecia <[email protected]> * docs(stripe): use consistent 'secret id' terminology and alias query result to key_id Agent-Logs-Url: https://github.com/supabase/wrappers/sessions/84b96a3b-ebb1-46a0-9b6f-2255ba7bf03a Co-authored-by: burmecia <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: burmecia <[email protected]> Co-authored-by: Bo Lu <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 52a0442 commit 926df23

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

docs/catalog/stripe.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,48 @@ create foreign data wrapper stripe_wrapper
4040
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](https://supabase.com/docs/guides/database/vault), which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.
4141

4242
```sql
43-
-- Save your Stripe API key in Vault and retrieve the created `key_id`
43+
-- Save your Stripe API key in Vault and retrieve the secret id (UUID) used for api_key_id
4444
select vault.create_secret(
4545
'<Stripe API key>',
46-
'stripe',
47-
'Stripe API key for Wrappers'
46+
'stripe', -- key name, used for api_key_name option
47+
'Stripe API key for Wrappers' -- key description
4848
);
4949
```
5050

51+
The `vault.create_secret` function returns the secret id (UUID) used for the `api_key_id` option. You can also retrieve this id later:
52+
53+
```sql
54+
select id as key_id from vault.secrets where name = 'stripe';
55+
```
56+
5157
### Connecting to Stripe
5258

5359
We need to provide Postgres with the credentials to connect to Stripe, and any additional options. We can do this using the `create server` command:
5460

5561

5662
=== "With Vault"
5763

64+
You can connect using either `api_key_id` or `api_key_name` — only one is required. If both are provided, `api_key_id` takes precedence.
65+
66+
**Option 1: using `api_key_id`** (the UUID returned by `vault.create_secret`)
67+
68+
```sql
69+
create server stripe_server
70+
foreign data wrapper stripe_wrapper
71+
options (
72+
api_key_id '<key_id>', -- UUID returned by vault.create_secret, or retrieved via: select id from vault.secrets where name = 'stripe'
73+
api_url 'https://api.stripe.com/v1/', -- Stripe API base URL, optional. Default is 'https://api.stripe.com/v1/'
74+
api_version '2024-06-20' -- Stripe API version, optional. Default is your Stripe account’s default API version.
75+
);
76+
```
77+
78+
**Option 2: using `api_key_name`** (the name given to the secret, i.e. the second argument to `vault.create_secret`)
79+
5880
```sql
5981
create server stripe_server
6082
foreign data wrapper stripe_wrapper
6183
options (
62-
api_key_id '<key_ID>', -- The Key ID from above, required if api_key_name is not specified.
63-
api_key_name '<key_Name>', -- The Key Name from above, required if api_key_id is not specified.
84+
api_key_name 'stripe', -- name used when creating the secret via vault.create_secret
6485
api_url 'https://api.stripe.com/v1/', -- Stripe API base URL, optional. Default is 'https://api.stripe.com/v1/'
6586
api_version '2024-06-20' -- Stripe API version, optional. Default is your Stripe account’s default API version.
6687
);

0 commit comments

Comments
 (0)