-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to insert a subscription into stripe wrapper #288
Comments
There are two things:
-- create the subscription table for data insert
create foreign table stripe.subscriptions (
id text,
customer text,
"items[0][price]" text -- column name will be used in API Post request
)
server stripe_server
options (
object 'subscriptions',
rowid_column 'id'
); And then we can insert a subscription: insert into stripe.subscriptions (customer, "items[0][price]")
values ('cus_Na6dX7aXxi11N4', 'price_1MowQULkdIwHu7ixraBm864M'); Note that table can only be used for data insertion, querying on it will need to create another 'normal' foreign table like this.
create function public.insert_stripe_subscription(customer text, price_id text)
returns void
language plpgsql
security definer set search_path = public, extensions, pg_temp
as $$
begin
insert into stripe.subscriptions (customer, "items[0][price]")
values (customer, price_id);
end;
$$; And then call it from the client: const { data, error } = await supabase
.rpc('insert_stripe_subscription', { customer: 'cus_QMxTWax3UG0mYl', price_id: 'price_1Ojb7WJDPojXS6LNxZi0Z4eA' })
if (error) console.error(error)
else console.log(data) |
FWIW, this works as well: insert into stripe.subscriptions (customer,attrs) values ('cus_QUgT45Svmxz0Mt','{"items[0][price]":"price_1PQvBRAKKSGCtBGcJAf3nMHP"}'); Having the ability to |
Bug report
Describe the bug
I am trying to insert into the stripe.subscriptions table by doing this
I also tried directly inserting the data on the sql console
However I am getting the following error.
Please provide more examples on how to insert data into the stripe foreign tables
System information
The text was updated successfully, but these errors were encountered: