#arielbo-Subscription
1 messages · Page 1 of 1 (latest)
I think the error message is quite clear
Currency and interval fields must match across all plans on this subscription. Found mismatch in interval field.
What do you don't get from this error?
I want to create one subscription with two items first with recurring and the second item is one time payment, for this purpose I try to use https://stripe.com/docs/api/subscriptions/create#create_subscription-add_invoice_items
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
plesae maybe is bad in my code that this is:
$subscription = $stripe->subscriptions->create([
'customer' => $json_obj->cus,
'items' => [
[
'price' => 'price_1JgiWpHHulAmiNnDavRI80qg',
],
[ 'add_invoice_items' => [
'price_data' => [
['currency' => 'usd'],
['product' => 'prod_KPVrC4nV3rPooT'],
['unit_amount_decimal'] => 999
],
]
]
],
'payment_behavior' => 'default_incomplete',
'expand' => ['latest_invoice.payment_intent.'],
]);
maybe you can check for me which is my error ?
the above code and the code in your original message is different. The code in your original message has a recurring section
yes I see and the correct parameter is add_invoice_items
more early rubeos tell me that: You would specify the Service C as a recurring Price in items.price_data when creating the Subscription: https://stripe.com/docs/api/subscriptions/object#subscription_object-items
A and B would be specified in add_invoice_items.price_data as one-time payments that will be included on the first Invoice the Subscription generates: https://stripe.com/docs/api/subscriptions/create#create_subscription-add_invoice_items
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I try to implement this please maybe you can help, Im very confused in how can I do this, for give your more context of my case Im working y my custom flow with php stripe, I have two type of services A and B are one time payments en the service C is month suscription, both are in my cart, please could you tell me how can I create the subscription in this case?
Yes, as Rubeus said, you will need to include C as a recurring Price, and A and B as one-off Price. The code in your original message is incorrect because it specified price_1JgiWpHHulAmiNnDavRI80qg as a recurring one, and another price_datawhich also has recurring, but the interval of the first Price is Year and the second Price is Day, so it mismatched
The code in your second message looks correct. Let's try that and see how it goes
please I appreciate your help Im very tired and I dont know how write this recommend, with this code I finish my cart
is like this
At this moment I have a cart for example with this products:
- service A. ebook 1 0 USD one time payment
- service B. course 20 USD one time payment
- service C. subscripcion a month to software x 50 USD recurring payment
Total price: 80 USD
_
Button PAY: 80 USD
I have price ID for service C but for service A and B just product ID and I try to create the price dynamically (in line), this is the mainly idea to the cart
??
So yeah, you would want to include Price C as a Price Id, and Price A and B as a Price Data. It's correct direction. it's just your code might be incorrect
hello
I advanced many that the last comunications with your
please at this point I need to know how can I put mulitples product with the same id but with different prices using add_invoice_items, do you understand me?
maybe some like this:
'add_invoice_items'[0] => [[
'price_data' => [
'currency' => 'usd',
'product' => 'prod_KPVrC4nV3rPooT',
'unit_amount' => 204,
'tax_behavior' => 'exclusive',
],
]],
'add_invoice_items'[1] => [ [
'price_data' => [
'currency' => 'usd',
'product' => 'prod_KPVrC4nV3rPooT',
'unit_amount' => 304,
'tax_behavior' => 'exclusive',
],
]],
yes I need to add invoice items with the same product id (ebook) but differents prices this is possibble?
hello ?
Hmm, you would need one product per one price
so you would need 2 items inside the add_invoice_items, each with one price_data, and separated information
'add_invoice_items' => [[
'price_data' => [
'currency' => 'usd',
'product' => 'prod_KPVrC4nV3rPooT',
'unit_amount' => 204,
'tax_behavior' => 'exclusive',
],
'price_data' => [
'currency' => 'usd',
'product' => 'prod_KPZbqYo4QLXRNM',
'unit_amount' => 304,
'tax_behavior' => 'exclusive',
],
]],
not work please could you tell me how can I do? is you software please help me
just save the las with 'unit_amount' => 304, not the first
hello ?
what part does "not work"? Did you get a specific error message?
dont have any error visible but just save in stripe the price_data with 'unit_amount' => 304,
what does that mean?
yep your code is wrong since you aren't passing two
you have the brackets [ ] mixed up
'add_invoice_items' => [
[
'price_data' => [
'currency' => 'usd',
'product' => 'prod_KPVrC4nV3rPooT',
'unit_amount' => 204,
'tax_behavior' => 'exclusive',
],
], // <- close the first item
[. // <- open the second item
'price_data' => [
'currency' => 'usd',
'product' => 'prod_KPZbqYo4QLXRNM',
'unit_amount' => 304,
'tax_behavior' => 'exclusive',
],
]
],