#arielbo-sub
1 messages · Page 1 of 1 (latest)
hello
I trying to use multiple items with price_data and works good
but now my problem is how can I do to iterate multiple price_data inside the object create subscription some like this
foreach ($d_json as $k => $v)
{
$clase = $v['c'];
$producto_id = $v['p'];
$precio_stripe = $v['a'];
$order_dcarrito .= "[ 'price_data' => [ 'unit_amount' => $precio_stripe, 'currency' => 'usd', 'product' => '$producto_id', 'recurring' => [ 'interval' => 'month', 'interval_count'=> 1, ], 'tax_behavior' => 'exclusive', ], ],";
}
//$order_dcarrito = str_replace('\n','',$order_dcarrito);
$subscription = $stripe->subscriptions->create([
'customer' => $json_obj->cus,
'items' => [
$order_dcarrito
], ....... ```
but not work for me
you can see this req :
req_2FiS1zu5Xq5muE
please
do you understand me Alex?
@elfin garden you would probably want to learn how to create an array/object in php.
Right now you're passing in the entire $order_dcarrito as a string. I'm not that familiar with php but you would probably want to try removing the double quotes that you're enclosing the value of $order_dcarrito with
$order_dcarrito .= [ 'price_data' => [ 'unit_amount' => $precio_stripe, 'currency' => 'usd', 'product' => '$producto_id', 'recurring' => [ 'interval' => 'month', 'interval_count'=> 1, ], 'tax_behavior' => 'exclusive', ], ];