#ahsannajam
1 messages · Page 1 of 1 (latest)
Hello! Looks like you have several threads and individual messages scattered above, can you ask your full question with all details in this thread so we can keep everything all in one place?
Can you show me the request ID with that error? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
{
"add_invoice_items": {
"0": {
"price": "price_1KxWtiIDIaGCKxK2NIk5VtDP",
"quantity": "1"
}
},
"customer": "cus_Letvy0WRxXqNbZ",
"items": {
"0": {
"price": "price_1KxWtiIDIaGCKxK2NIk5VtDP",
"quantity": "1"
}
},
"expand": {
"0": "latest_invoice.payment_intent"
}
}
Request POST body
{
"add_invoice_items": {
"0": {
"price": "price_1KxWtiIDIaGCKxK2NIk5VtDP",
"quantity": "1"
}
},
"customer": "cus_Letvy0WRxXqNbZ",
"items": {
"0": {
"price": "price_1KxWtiIDIaGCKxK2NIk5VtDP",
"quantity": "1"
}
},
"expand": {
"0": "latest_invoice.payment_intent"
}
}
Request query parameters
No query parameters
Response body
{
"error": {
"message": "The price specified is set to type=recurring but this field only accepts prices with type=one_time.",
"param": "add_invoice_items[0][price]",
"type": "invalid_request_error"
}
}
Can you give me the request ID? That ID starting with req_ in the top right corner?
Please do not paste the entire JSON in here.
When creating a Subscription add_invoice_items is used to add one-time items to the first Invoice for the Subscription, but you're trying to add a recurring Price there, which is leading to the error: https://stripe.com/docs/api/subscriptions/create#create_subscription-add_invoice_items
Can you tell me what your goal is? What are you trying to do with this code?
subscribe to a product and charge them annually or monthly
for example: this is a job portal. An employer can buy 180$ subscription for yearly to post jobs.
You should specify recurring Subscription items in the items property: https://stripe.com/docs/api/subscriptions/create#create_subscription-items
It charges automatically every year
May I remove add_invoice_items ?
from this code?
If you don't want any one-time items added to the first Invoice, yes.
Did that work?