#sarvesh3742_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1219243827345227776
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- sarvesh3742_api, 52 minutes ago, 16 messages
- sarvesh3742_api, 4 days ago, 21 messages
subscription ID: sub_1OvdobHw3iz1BrlctpU6sCy4
show $2.50 in daft mode only and in
webhook type: "customer.subscription.updated" shows
"status": "active",
"amount": 500,
"amount_decimal": "500",
Can you share the evt_xxx ID of the event?
"coupon": {
"id": "DfwacB1y",
"id": "evt_1Ove6bHw3iz1Brlc4Z1njg6z",
"id": "evt_1Ove6aHw3iz1Brlc0OC9HZfM",
Well that's because the discount has been removed from the subscription as the Coupon applied had duration: 'once': https://dashboard.stripe.com/test/logs/req_tSqgwrOl7rrTng
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Meaning it'll only apply a discount for the first period
yes, we need to apply the discount only for 1st payment and then recurring payments will be charge with full amount and intial it was trial period subscription with 0 amount
Then what is unexpected with the payload?
- Why it showing $2.50 in draft mode on 1st payment of $5.00 on 26 March (using test clock)
- Why "customer.subscription.updated" webhook event sent amount 500 ($5) instead of $2.5 here?
- Because you applied a 50% discount
- That event fires for the new billing period when the discount was removed (you can see it in the
previous_attributeshash)
ok but how I will get the discounted amount in webhook in amount field?
It'll be in the discounts field
let me test it again with another subscription
created another subscription now and received webhook event type: customer.subscription.updated
"id": "evt_1OvefMHw3iz1BrlcijNC1l3E",
subscription "id": "sub_1Oveb7Hw3iz1BrlcE6aJggFg",
"amount": 500,
"previous_attributes": {
"discount": {
"id": "di_1Oveb7Hw3iz1Brlcx7uMfZXH",
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Again, what is unexpected? That is the customer.subscription.updated event that fires when the subscriptions transitions into a new period without the discount
This is the customer.subscription.created event where the discount is applied: https://dashboard.stripe.com/test/events/evt_1Oveb8Hw3iz1Brlcooukezec
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
but why it is without discount here? as it was the first actual payment after free 7 days are over
The items.data[]price will never reflect the discounted amount
ok but atleast in the discount object I should get the discuscount amount for apply the coupon of 50% to store in our database
"discount": {
"id": "di_1Oveb7Hw3iz1Brlcx7uMfZXH",
"object": "discount",
Because you created the subscription with the coupon and the initial free trial. The discount will apply to the first period (the trial) regardless: https://dashboard.stripe.com/test/logs/req_pFvGgb2uncU8tD
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
ok, let me check agian by disabling the trial period
This customer has no attached payment source or default payment method.
getting this error on subscription payment method page
$subscription = $stripe->subscriptions->create([
'customer' => $stripe_customer_id,
'items' => [[
'price' => $stripePriceId,
]],
'metadata' => $metaData,
////'trial_end' => strtotime($freeTrialDays.' days'), // Adjust trial period as needed
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent', 'pending_setup_intent'],
'expand' => ['latest_invoice.payment_intent'],
'coupon' => $couponId
]);
only commented out the trial_end to remove the free trial from the subscription
what more needs to adjust in this to work subscription without trial period but apply 50% discount on first subscription payment only?
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
What error are you getting exactly?
Are you providing the client secret from $subscription?
yes
it is getting broken after I commented out the line
//'trial_end' => strtotime($freeTrialDays.' days'),
from the subscription object I am creating via API
Are you taking the secret from latest_invoice.payment_intent or pending_setup_intent?
yes, sorry my fault, I was taking it from pending_setup_intent