#shainkey
1 messages ยท Page 1 of 1 (latest)
Hi! Let me help you with this.
sure thank you
So you want the first invoice to be instantly paid, right?
yes and payment status is also success not incomplete
how we can pass the default card details in subs create function to make payment success
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': 'off'},
expand=['latest_invoice.payment_intent'],
)
You can use payment_behavior="allow_incomplete", to charge the customer instantly. You can read more here: https://stripe.com/docs/billing/subscriptions/overview#subscription-payment-behavior
pi_3M566UA1AvSnwwTv0cQcXXA6
getting error
please check once
This customer has no attached payment source or default payment method. Please consider adding a default payment method.
This is expected, your customer needs to have a payment method in order to pay the invoice instantly.
You can attach the payment method to the customer in the dashboard or via API.
Otherwise, you can create the subscription the way you did that before, with payment_behavior="default_incomplete", and then complete the payment method collection on the frontend. You can find more here: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
ok let me check
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
sure
if anything related to webhhok events that i can consider after hitting this api So we don't need Frontend to test this one
sorry I don't follow, would youmind elaborating more?
is there an any way to show success paymnets using apis only not from frontend for testing purpose
what do you mean by showing?
I went back through the thread I think I know what you mean
basically what you can do is create a customer with payment_method="pm_card_visa" and invoice_settings={ default_payment_method: "pm_card_visa"} and use that customer to create the subscription
this would automatically pay the subscription's first invoice
okay
let me know if you need any more help
No
subscription = stripe.Subscription.create(
customer=customer['id'],
items=[
{"price": price_id},
],
payment_method="pm_card_visa",
invoice_settings={
"default_payment_method": "pm_card_visa"
},
payment_behavior="default_incomplete",
collection_method="charge_automatically",
payment_settings={'save_default_payment_method': 'off'},
expand=['latest_invoice.payment_intent'],
)
is it fine ?
Please confirm me once
no
this should be part of stripe.Customer.create
invoice_settings={
"default_payment_method": "pm_card_visa"
},
ohhh okay sorry
did the same but still showing incomplete
pi_3M56ejA1AvSnwwTv1iOalgHE
customer = stripe.Customer.create(
email=self.request.user,
name=self.request.user.first_name + ' ' + self.request.user.last_name,
payment_method="pm_card_visa",
invoice_settings={
"default_payment_method": "pm_card_visa"
},
)
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': 'off'},
expand=['latest_invoice.payment_intent'],
)
could you please remove this line
payment_settings={'save_default_payment_method': 'off'},
okay
and instead of the payment_behavior="default_incomplete" use "allow_incomplete"
okay sure
default incomplete is used for charge automatically correct
for recurring payment
It is working now
๐
default_incomplete means that the payment will default to incomplete
save_default_payment_method
payment_behavior
why we use these parameters in recurring payment ?
Please explain these 2 points only
is it necessary to use when use recurring payment
when you're creating a subscription for a customer with no previously saved invoice_settings.default_payment_method you want the subscription to "default to incomplete" will you collect the payment details, and then you can choose to "save the default payment method" on the subscription
for future payments