#mbillah21-coupon
1 messages ยท Page 1 of 1 (latest)
Yes, of course
I have created one coupon using php api
and added two products as "Applicable Products"
and it is showing okay on dashboard but not when I tried to retrieve them
as you can see, there are two products under "Applicable Products"
so the problem is $stripe->coupons->all(); this code not returning those two products
Ah okay!
Let me take a quick look
Thank you
You'd need to expand applies_to property to get a list of products here
https://stripe.com/docs/api/coupons/object#coupon_object-applies_to
In PHP it should look something like $stripe->coupons->all([], [ 'expand' => ['data.applies_to'] ]);
creating coupon with products apply is not the problem
the problem is to retrieve them
Yup I understand.
I'm suggesting that you'd need to expand the property while retrieving the coupons
Got unexpected keys in options array: expand
try this
$stripe->coupons->all([ 'expand' => ['data.applies_to'] ]);
Great! ๐
Would you please help me again to update coupon with all data like duration, max_redemptions, duration_in_months, percent_off, applies_to?
Hello! Not sure what you mean, can you provide more details?
I want to update duration, max_redemptions, duration_in_months, percent_off, applies_to these data
on coupon
Okay, what have you tried so far?
$coupon = $stripe->coupons->update(
'tmCe2fEb',
'name' => '20%',
'duration' => 'repeating',
'max_redemptions' => 1,
'duration_in_months' => 1,
'percent_off' => 20,
'applies_to' => array(
'products' => array(
'prod_LMzhBVqZM4CyQQ',
'prod_LN0CphtkTdmbya',
'prod_LN0OcfLHdK7LAk',
)
)
);
this is what I tried but got an error Received unknown parameters: duration, max_redemptions, duration_in_months, percent_off
Ah, I see. You're trying to update a Coupon there, but the only things you can update on a Coupon are the metadata and name: https://stripe.com/docs/api/coupons/update
Oh Okay