#arielbo-Subscription

1 messages · Page 1 of 1 (latest)

pale briar
#

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?

solid tiger
#

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 ?

pale briar
#

the above code and the code in your original message is different. The code in your original message has a recurring section

solid tiger
#

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

#

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?

pale briar
#

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

solid tiger
pale briar
#

Let's think through first

#

which is your price C? and what is your Price A and B?

solid tiger
#

is like this

#

At this moment I have a cart for example with this products:

  1. service A. ebook 1 0 USD one time payment
  2. service B. course 20 USD one time payment
  3. 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

solid tiger
#

??

pale briar
#

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

solid tiger
#

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 ?

pale briar
#

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

solid tiger
#

'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

solid tiger
#

hello ?

inland plaza
#

what part does "not work"? Did you get a specific error message?

solid tiger
#

dont have any error visible but just save in stripe the price_data with 'unit_amount' => 304,

inland plaza
#

what does that mean?

solid tiger
#

you can see here, not save the two price data just one

inland plaza
#

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