#shainkey

1 messages · Page 1 of 1 (latest)

tough magnetBOT
mystic abyss
#

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?

noble river
#

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

#

and backend i am using python

mystic abyss
#

OK. If can summarize, basically you are asking

  1. How to set up a payment_method for recurring payments
  2. How to use test clocks to test subscription renewal without waiting for a long time.

Is my understanding correct?

noble river
#

Yes correct

#

stuck for last couple of days not able to test properly

mystic abyss
#

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)

noble river
#

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

mystic abyss
#

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?

noble river
#

in_1M29f2A1AvSnwwTvY0CUUV3k

#

I paid it manually by clicking on payment page on invoice

#

on 9th november

shadow vault
#

Hey! Taking over for my colleague. Let me catch up.

noble river
#

sure

shadow vault
noble river
#

Yes

shadow vault
noble river
#

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

noble river
shadow vault
#

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

noble river
#

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?

shadow vault
noble river
#

let me check once

noble river
#

payment_settings={'save_default_payment_method': 'off'},
what does it mean can u please clarify ?
payment_settings={'save_default_payment_method': 'on_subscription'},

shadow vault
#

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 to on_subscription Stripe 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

noble river
#

thanks

#

while creating the simulation in test clock
we need to create new customer. can't use existing one

grave axle
#

Correct

noble river
#

then how we can test from FE ?
is it working or not

grave axle
#

How can you test what from the front-end?

noble river
#

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

grave axle
#

What do you mean by 'expire'?

noble river
#

Subscription is going to finished

grave axle
#

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

noble river
#

okay got it

#

cancel_at=datetime.now() + timedelta(hours=1)
is it fine ?

noble river
#

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

grave axle
#

Looks good to me. Did you try it?

noble river
#

yes

#

that status is fine
it should be cancel at correct ?

#

sub_1M40JEA1AvSnwwTv7FcC7DSn

#

can u please check once

brazen tangle
#

sure, what exactly do you want me to check?

noble river
#

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

brazen tangle
#

it's because the latest_invoice is for a small amount ($0.03) which means we don't actually charge it

noble river
#

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

brazen tangle
#

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".

noble river
#

ohhh okay
So what we need to resolve this issue ?

brazen tangle
#

what issue?

noble river
#

$0.03 issue
need to increase the charge

brazen tangle
#

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?
noble river
#

Yes for only testing purpose i want to do

brazen tangle
#

then you can pass proration_behavior:"none" to the API call creating the subscription