#SatriaRizali
1 messages · Page 1 of 1 (latest)
Let's head over your Dashboard request log and find the failed request, then inspect its error message
i cant found any error message
$discountvalue = 8;
if ($discountvalue > 0) {
$discount = $stripe->coupons->create([
'percent_off' => $discountvalue
]);
$iddiscount = $discount['id'];
$discountcond = "'discounts' => [[
'coupon' => $iddiscount,
]],";
// print_r($discountcond);
// die;
}
$payment = $stripe->checkout->sessions->create([
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
'line_items' => [
[
'price_data' => [
'unit_amount' => 25000,
'currency' => 'jpy',
'tax_behavior' => 'exclusive',
'product_data' => [
'name' => 'Prefecture custom',
],
],
'quantity' => 1,
],
],
'automatic_tax' => [
'enabled' => true,
],
'mode' => 'payment',
**$discountcond**
]);
i try to make this variable $discountcond , but keep get parameter 0 error
Find here: https://dashboard.stripe.com/test/logs
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I think it's some syntax issue
yup it syntax , the $discountcond variable turn to zero
Can you find the request id? req_xxx
I see you have
'discounts' => [[...]]
This double brackets look problematic
i think for double brackets is ok
$payment = $stripe->checkout->sessions->create([
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
'line_items' => [
[
'price_data' => [
'unit_amount' => 25000,
'currency' => 'jpy',
'tax_behavior' => 'exclusive',
'product_data' => [
'name' => 'Prefecture custom',
],
],
'quantity' => 1,
],
],
'automatic_tax' => [
'enabled' => true,
],
'mode' => 'payment',
'discounts' => [[
'coupon' => $iddiscount,
]]
]);
if i code like this , it can work
but i need dynamic stripecheckout , so if the user not apply any discount then we can apply with no discount syntax
Yeah it's an array of hashes and I suspect it's something with PHP syntax for the type
Similar ask: https://stackoverflow.com/a/67094037/3631795
Hi I am stepping down for the day. If you need further help please ask in the channel!
Generally I think the solution in above link looks promising. You create an array first then push in hash into it.