#shainkey

1 messages ยท Page 1 of 1 (latest)

hardy crescentBOT
hollow chasm
#

Hi! Let me help you with this.

humble ridge
#

sure thank you

hollow chasm
#

So you want the first invoice to be instantly paid, right?

humble ridge
#

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'],
)

hollow chasm
humble ridge
#

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.

hollow chasm
#

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

humble ridge
#

ok let me check

bright oracle
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

humble ridge
#

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

bright oracle
#

sorry I don't follow, would youmind elaborating more?

humble ridge
#

is there an any way to show success paymnets using apis only not from frontend for testing purpose

bright oracle
#

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

humble ridge
#

okay

bright oracle
#

let me know if you need any more help

humble ridge
#

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

bright oracle
#

no

#

this should be part of stripe.Customer.create

invoice_settings={
 "default_payment_method": "pm_card_visa"
},
humble ridge
#

ohhh okay sorry

humble ridge
#

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'],
)

bright oracle
#

could you please remove this line
payment_settings={'save_default_payment_method': 'off'},

humble ridge
#

okay

bright oracle
#

and instead of the payment_behavior="default_incomplete" use "allow_incomplete"

humble ridge
#

okay sure
default incomplete is used for charge automatically correct

#

for recurring payment

#

It is working now

#

๐Ÿ™‚

bright oracle
humble ridge
#

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

bright oracle
#

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