#shainkey

1 messages · Page 1 of 1 (latest)

twin notchBOT
unique vale
#

Hi there,
When creating a Subscription, it represents a recurring payment, so the renewal payement is don automatically.

quick parcel
#

what key we need to pass ?

unique vale
#

If you price_id is monthly recurring price, then every month a payment attempt will be achieved

unique vale
quick parcel
#

Yes that price_id is monthly recurring price.

#

stripe.Subscription.create(
customer="{{CUSTOMER_ID}}",
items=[
{
"price_data": {
"currency": "USD",
"product": "{{PRODUCT_ID}}",
"recurring": {"interval": "month", "interval_count": 3},
"unit_amount": 1000,
},
"quantity": 1,
},
],
)
Like this one we need to pass

unique vale
unique vale
quick parcel
#

okay

#

how we can test in local it is working or not
can i give custom date to expire Subs in 1 hour or something for testing purpose

unique vale
quick parcel
#

okay let me check
Thank you so much

unique vale
#

Np!

quick parcel
#

Hello @unique vale
I have created test clock but not showing when it will expire. I have given 4:10 PST time
Can u please confirm me on this point

tired dawn
#

You're using collection_method: 'send_invoice' so we won't automatically attempt payment(s). Your customer needs to explicitly pay those invoices

quick parcel
#

So which collection_method i need to use to auto payment

tired dawn
#

The default, charge_automatically

quick parcel
#

stripe.Subscription.create(
customer=customer['id'],
items=[
{"price": price_id},
],
payment_behavior="default_incomplete",
collection_method="charge_automatically",
days_until_due=30,
)

#

is it fine ?

tired dawn
quick parcel
#

okay

#

payment_behavior
what does it mean when we passing this key in Subscription creation. If i remove this param it is showing this customer has no attached payment source or default payment method

#

if i pass
payment_behavior="default_incomplete",
Then instead of showing active subscription. It is showing "incomplete" status

tired dawn
#

Well, is there a payment method associated with the customer?

quick parcel
#

Yes

tired dawn
#

Can you share the sub_xxx?

quick parcel
#

sub_1M1q64A1AvSnwwTvkc2VN15G

tired dawn
#

What is it exactly you're trying to test?

tired dawn
#

So there's no way for us to attempt an initial payment

quick parcel
#

Let me explain step-by-step
Lets say i have create three product in stripe that have recurring monthly payment. Now, i want to use this subs from my side. From BE i create payment intent after that create subscription object to check what kind of subs user is taking from FE. for that, i am just sending price id to create subscription in stripe and pass the customer id correct, Now when i pass this object
stripe.Subscription.create(
customer=customer['id'],
items=[
{"price": price_id},
],)
It is showing me error This customer does not no attached payment source or default payment method. But when i pass payment_behavior="default_incomplete",
It is working fine but showing incomplete status in subscription instead of showing Active.But in invoice tab it is showing payment link when i did the payment from here. Then it will show active status. But i need auto payment For resolving this issue, i pass 2 key collection_method="send_invoice",
days_until_due=30,
It is working fine in this case.
But i am not sure it is correct way or not.
for testing purpose i just want to test that subscription will expire after 1 hour or 30mnt.
So, I will update the code on server. That's it i want

#

and it will auto renew as previous subs what the user have

#

?

tired dawn
#

From BE i create payment intent after that create subscription object
Why are you creating a Payment Intent and a Subscription?
It is showing me error This customer does not no attached payment source or default payment method.
Yep, thats' expected: https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior
It is working fine but showing incomplete status in subscription instead of showing Active
Yep, again expected. If there's an initial payment due for the subscription then it will be incomplete until that payment is made. Then it'll transition to active (assuming payment succeeds). Please read: https://stripe.com/docs/billing/subscriptions/overview#subscription-lifecycle

Learn how subscriptions work within Stripe.

quick parcel
tired dawn
#

It is, if you follow the guide I just linked