#binod - iDeal
1 messages ยท Page 1 of 1 (latest)
Im using this code const subscription = await stripe.subscriptions.create({ customer: body.stripe_cus_id, items: [ { body: body.plan_id } ], payment_settings: { payment_method_types: ['card', 'ideal'] }, collection_method: 'send_invoice', payment_behavior: 'default_incomplete', expand: ['latest_invoice.payment_intent'] }); console.log("SUB==>", subscription); return { subscription_id: subscription.id, payment_intent_id: subscription.latest_invoice.payment_intent.id, expiry_date: subscription.current_period_end, clientSecret: subscription.latest_invoice.payment_intent.client_secret };
and get this error Received unknown parameter: items[0][body]
??
hello?
Hello, looking at this again. The server is very busy so responses can get delayed
Instead of
{
body: body.plan_id
}
],```
Try
```items: [
{
price: body.plan_id
}
],```
That call does not take a `body` parameter there
https://stripe.com/docs/api/subscriptions/create#create_subscription-items-price
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
oh okay, that was a silly mistake
Im pulling response in subscription as you can see.
but payment intent is null here i.e. subscription.latest_invoice.payment_intent
๐ hopping in since @placid birch has to head out soon
Do you mind sharing the Invoice ID so I can take a look?
You don't get back a Payment Intent yet because it's still a draft - we don't create a Payment Intent for an Invoice until it's been finalized
I don't understand. Im trying to create subscription payment using iDeal payment
and this is my code const subscription = await stripe.subscriptions.create({ customer: body.stripe_cus_id, items: [ { price: body.plan_id } ], payment_settings: { payment_method_types: ['card', 'ideal'] }, collection_method: 'send_invoice', payment_behavior: 'default_incomplete', expand: ['latest_invoice.payment_intent'], days_until_due: 7 }); console.log("SUB==>", subscription); return { subscription_id: subscription.id, payment_intent_id: subscription.latest_invoice.payment_intent.id, expiry_date: subscription.current_period_end, clientSecret: subscription.latest_invoice.payment_intent.client_secret };
what am I missing?
Backing up for a second here - why do you need the Payment Intent right after you create the Subscription?
Im using PaymentElement in frontend, which needs client_secret
which is inside latest_invoice.payment_intent
It works fine with card payment, having issue with iDeal payment
Is that why you're using 'send_invoice' to create this Subscription (because you're using ideal)? With send_invoice subscription the first invoice isn't automatically finalized like with charge_automatically subscriptions
With ideal you wouldn't use the pattern of using the Payment Element - because you use send_invoice, we'd email your customer and collect payment details from there
it's not possible to use Payment Element with iDeal payment?
You can, but the disconnect here is the type of Subscription that you're working with - you're trying to get around the ideal + charge_automatically restriction by using send_invoice
But send_invoice Subscriptions are meant to work by email the customer a link to a hosted page and won't finalize the invoice immediately
It's in this API https://stripe.com/docs/api/subscriptions/create
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
If I use iDeal payment, I need to specify collection_method as send_invoice
What I want is, I should be able to buy subscription using Card and iDeal payment. what is the best approach to follow?
Yes, and what I'm saying is that using send_invoice + payment element is usually not the approach you want - send_invoice will email the customer EVERY billing cycle. So you won't be able to just collect payment once - your customer will need to provide payment every cycle
you mean send invoice to customer => Customer pays using iDeal => Listen webhoowk => Update aplication data
is this the flow for iDeal payment?
??
Yes, that's the general flow
In test mode we don't sent the email - you have to trigger it manually through the dashboard
how?
Also, subscription is created with status active. isn't it supposed to be incomplete? because customer hasnt paid yet
send_invoice and charge_automatically subscriptions behave VERY differently - because send_invoice subscriptions don't start off with a finalized invoice, there is no payment due immediately so it can transition to active right after being created. In comparison charge_automatically subscriptions will typically have payment due because they are finalized
How did you get to this UI? Did you finalize the invoice before coming here?
I downloaded invoice from dashboard and there was a link which landed me into this UI
Yeah, so you need to be finalized that Invoice BEFORE you go to that link
how do I finalize it?
You can finalize it through the dashboard or the API (https://stripe.com/docs/api/invoices/finalize)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
It says, stripe automatically finalizes invoice. Only need to call API to do it manually
does it finalize automatically in live mode?
It automatically finalizes, after an hour - just like with charge_automatically invoices that are not the first one
okay, API also works.
one last question
can I customize invoice?
I need dynamic title i.e. Nova Automotive B.V
What do you mean by a dynamic title - what would you like to change it to? Is it because connect is involved?
yes, Im working on wordpress like SAAS product
my client needs business name of connected account(express)
Gotcha! So connect is involved here - if you use on_behalf_of when you generate the Invoice, it should use the details from the connect account instead of the platform
It does not accept on_behalf_of parameter
Are you using Subscriptions or Invoices?
subscriptions
Okay so on_behalf_of exists but it's in beta. You will have to contact our support team and they will be able to give you access to the beta for you to use it. You can contact them here: https://support.stripe.com/contact
okay, thanks a lot for the help!