ERROR in Integrating stripe One time subscription

536 views
Skip to first unread message

Otong Akan

unread,
Aug 23, 2022, 10:51:11 AM8/23/22
to Stripe API Discussion
I keep having these error messages when I try to create a checkout session:

"error": {
"type": "StripeInvalidRequestError",
"raw": {
"message": "You cannot use `line_items.amount`, `line_items.currency`, `line_items.name`,

Even using the exact code from the stripe documentation viz:
 
const session = await stripe.checkout.sessions.create({ payment_method_types: ['{{ PAYMENT_METHOD_TYPE }}'], 
    line_items: [{ 
                             name: 'T-shirt', description: 'Comfortable cotton t-shirt', 
                             images: ['https://example.com/t-shirt.png'], 
                             amount: 2000, 
                             currency: 'usd', 
                             price_data: { 
                                                    currency: 'usd', 
                                                     unit_amount: 2000, 
                                                              product_data: { 
                                                                                          name: 'T-shirt', 
                                                                                           description: 'Comfortable cotton t-                                                                                                                                               shirt', 
                                                                                  images: ['https://example.com/t-                  shirt.png'], 
                                                                                        },
                                                   }, 
                              quantity: 1, }], 
      mode: 'payment', 
       cancel_url: 'https://example.com/cancel', }); 

Remi J.

unread,
Aug 23, 2022, 10:56:10 AM8/23/22
to api-d...@lists.stripe.com
Hello,

The code you shared is correct and would work. The error you mentioned can only happen if you use the old way of passing line item information which was deprecated back in early 2020 and finally removed completely in the most recent API version 2022-08-01 [1].

The error means you are passing parameters like this:

line_items: [
  {
    amount: 1234,
    currency: 'usd',
    name: 'my random name',
    ...
  }
]

This is not allowed anymore and had been discouraged for a long time before that. And you must still be using that old code when you are testing even though you think you're using the newer code from our docs. You will need to add clear logs to your code to track down what part is and isn't running. You can also look at the Logs for your request in the Dashboard [2] to confirm what exact parameters you are sending.

I'd recommend working with our support team if you have more questions and they can help you more directly. You can contact them here: https://support.stripe.com/contact

Best,
Remi


--
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.

Otong Akan

unread,
Aug 23, 2022, 11:06:26 AM8/23/22
to api-d...@lists.stripe.com
The code i used above was from the documentation, I tried using mine, got same errors, copied from the documentation, I got the same error.
I resolved by running nmp i stripe --save  instead of nmp i stripe 



To unsubscribe from this topic, visit https://groups.google.com/a/lists.stripe.com/d/topic/api-discuss/kHioUKvJ-AY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to api-discuss...@lists.stripe.com.
Reply all
Reply to author
Forward
0 new messages