#shainkey
1 messages · Page 1 of 1 (latest)
Hi there, can you tell me more about the After 2 hour it should be expire and auto payment again with out filling the card details part?
Yes
Let me explain again
for ex: I buy subscription today at 02:30 pm and its only valid for 2 hour correct after 2 hour it would be expire after that i need to make auto payment(Auto renewal)
First time i filled the card details and all necessary credentials that is used for payment success but next time it should be auto payment if the available amount is in my bank card whether i made payment previously otherwise it won't happens and payment failed
I created product for monthly basis with recurring payment with some amount but i can't wait till month for auto-renew So, that's why i want to check whether it is happening after 2 hour or 1 hpur for tetsing purpose. i already follow the test clock documents but not getting any success
https://stripe.com/docs/payments/accept-a-payment#add-server-endpoint
using this one in FE IOS app
and backend i am using python
OK. If can summarize, basically you are asking
- How to set up a payment_method for recurring payments
- How to use test clocks to test subscription renewal without waiting for a long time.
Is my understanding correct?
OK. about first one, you set save_default_payment_method to off, this tells Stripe not to use the payment_method for recurring payments. If this is not the desired behaviour, you should set it to on_subscription (https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_settings-save_default_payment_method)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
And for the second one, you can advance the test clock (via Dashboard or API) to the next billing date and see how your subscription handle the renewal https://stripe.com/docs/billing/testing/test-clocks#advance-clock
Previously i made it on_subscription but that time invoices is showing in open state after making payment from FE that's why i changed to off
i created test clock for that subs_id=sub_1M29f2A1AvSnwwTvq40K5jRX
can u please verify its correct or not
Yes this subscription is using a test clock
The invoice should be moved to paid status once the payment is succeeded, can you share with me the invoice ID?
in_1M29f2A1AvSnwwTvY0CUUV3k
I paid it manually by clicking on payment page on invoice
on 9th november
Hey! Taking over for my colleague. Let me catch up.
sure
This invoice is paid now
Yes
why you wanted to pay manually the invoice ?
FE just made one payment for this one
pi_3M3wwkA1AvSnwwTv16iK2sH2
sub_1M3wwkA1AvSnwwTvQTJCtmBM
in_1M3wwkA1AvSnwwTvbD9d5ntk
These all are necessary information
It is working fine but i need to set a clock for that user for recurring auto payment after an hour for testing auto payment
is it possible ?
prod_Md9JesWfXcuy8r
prod_Md9JrLGPpE1ebN
prod_Md9IIbWQe8KVMN
Using these 3 product for subscription
Actually i paid it manually from my side not from FE
This subscription sub_1M3wwkA1AvSnwwTvQTJCtmBM isn't using Test Clock. You need to create a new simulation with a new subscription of these 3 products:
prod_Md9JesWfXcuy8r
prod_Md9JrLGPpE1ebN
prod_Md9IIbWQe8KVMN
okay got it
can i attached some key that expire our payment after an hour in code during subscription create and make auto recurring payment
subscription = stripe.Subscription.create(
customer=customer['id'],
items=[
{"price": price_id},
],
payment_behavior="default_incomplete",
collection_method="charge_automatically",
payment_settings={'save_default_payment_method': 'on_subscription'},
expand=['latest_invoice.payment_intent'],
)
cancel_at or something else?
Yeah you can cancel the subscription using this API endpoint:
https://stripe.com/docs/api/subscriptions/cancel
let me check once
payment_settings={'save_default_payment_method': 'off'},
what does it mean can u please clarify ?
payment_settings={'save_default_payment_method': 'on_subscription'},
payment_settings={'save_default_payment_method': 'off'},
Stripe never sets subscription.default_payment_method.
payment_settings={'save_default_payment_method': 'on_subscription'},
Stripe sets subscription.default_payment_method when a subscription payment succeeds.
In other words, when set toon_subscriptionStripe will save the success payment method as a default payment_method for this subscription and it'll be used for future payment attempts
https://stripe.com/docs/api/subscriptions/object#subscription_object-payment_settings-save_default_payment_method
thanks
while creating the simulation in test clock
we need to create new customer. can't use existing one
Correct
then how we can test from FE ?
is it working or not
How can you test what from the front-end?
how we can test subscription going to expire after an 1 hour or not. there is no option to set time
i created one customer and now set subscription that is already exist now here how can i set start date as today and end date is after an hour
What do you mean by 'expire'?
Subscription is going to finished
You can't set such a granular end time for the subscription via the Dashboard (only at a day level). You'd need to use the API and set cancel_at
subs = stripe.Subscription.create(
customer=customer['id'],
items=[
{"price": price_id},
],
payment_behavior="default_incomplete",
collection_method="charge_automatically",
payment_settings={'save_default_payment_method': 'on_subscription'},
expand=['latest_invoice.payment_intent'],
cancel_at=datetime.now() + timedelta(hours=1)
)
is it fine function
i putted current date + 1 hour
Looks good to me. Did you try it?
yes
that status is fine
it should be cancel at correct ?
sub_1M40JEA1AvSnwwTv7FcC7DSn
can u please check once
sure, what exactly do you want me to check?
AttributeError: 'NoneType' object has no attribute 'id'
subs.latest_invoice.payment_intent.id
why it is showing None here
when i remove cancel_at
it is working fine
it's because the latest_invoice is for a small amount ($0.03) which means we don't actually charge it
there's a minimum amount of about 50c (https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts) if the Invoice is less than that, then there is no payment and no PaymentIntent.
Yes that one is fine
But i am sending price_id= price_1Ltt01A1AvSnwwTvZbq99x2G
here charge is $19.99
why it is showimg $0.03 here
confused
because it's prorated
you create the subscription but say "cancel it after an hour"
so we say "ok, it's $19.99 for a month, but the subscription will only last for one hour, so that is $0.03 when you do the math to divide the monthly price by the time of one hour".
ohhh okay
So what we need to resolve this issue ?
what issue?
$0.03 issue
need to increase the charge
so to clarify:
- you want to create a subscription for a $19.99 per month plan
- you want that subscription to cancel after one hour
- you want the customer to pay the full $19.99 amount regardless?
Yes for only testing purpose i want to do
then you can pass proration_behavior:"none" to the API call creating the subscription