#Léonard
1 messages · Page 1 of 1 (latest)
Thanks for the thread
When canceling the subscription, I would like to specify the invoice_now and prorate parameters but always have a invalid http request error
Here is a extract of my plpgsql function
select
content::jsonb
from http((
'DELETE',
'https://api.stripe.com/v1/subscriptions/' || _subscription_id,
ARRAY[http_header('Authorization','Bearer ' || _api_key)],
'application/x-www-form-urlencoded',
null -- here is the error when adding something different than null!
))
I have tried multiple things like
select
content::jsonb
from http((
'DELETE',
'https://api.stripe.com/v1/subscriptions/' || _subscription_id,
ARRAY[http_header('Authorization','Bearer ' || _api_key)],
'application/x-www-form-urlencoded',
'invoice_now=' || urlencode('true') || '&prorate=' || urlencode('true')
))
but it does not work
everything works in python though
import stripe
stripe.api_key = api_key
stripe.Subscription.delete(
sub_id,
invoice_now = True,
prorate = True
)
(The reason why I want to proceed this way is to ensure people are being invoice straight away !)
I'm not very familiar with PostgresSQL and making HTTP calls with it. What's the exact error?
It sounds like you're trying to run a query and you're not allowed to access HTTP request metadata from within a query function.
I don't have a lot of context on this unfortunately, as this server is mostly catered to solving Stripe-related issues, but this is a Postgresql error
I hate giving that answer, but you're probably more informed on what to do here than I
for the record, here is another request I am using that is wokring perfectly fine
select
content::jsonb->>'url'
from
http((
'POST',
'https://api.stripe.com/v1/checkout/sessions',
ARRAY[http_header('Authorization','Bearer ' || _api_key)],
'application/x-www-form-urlencoded',
'success_url=' || urlencode(_success_url) ||
'&cancel_url=' || urlencode(_cancel_url) ||
'&mode=' || urlencode('subscription') ||
'&line_items[0][price]=' || urlencode(_stripe_price_id) ||
'&customer=' || urlencode(_stripe_customer_id)
)::http_request)
into _stripe_checkout_session_url;