#sarvesh3742_api

1 messages ¡ Page 1 of 1 (latest)

trim walrusBOT
#

👋 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.

vast finchBOT
#

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.

round ibex
#

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",

rose reef
#

Can you share the evt_xxx ID of the event?

round ibex
#

"coupon": {
"id": "DfwacB1y",

#

"id": "evt_1Ove6bHw3iz1Brlc4Z1njg6z",

#

"id": "evt_1Ove6aHw3iz1Brlc0OC9HZfM",

rose reef
#

Meaning it'll only apply a discount for the first period

round ibex
#

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

rose reef
#

Then what is unexpected with the payload?

round ibex
#
  1. Why it showing $2.50 in draft mode on 1st payment of $5.00 on 26 March (using test clock)
  2. Why "customer.subscription.updated" webhook event sent amount 500 ($5) instead of $2.5 here?
rose reef
round ibex
#

ok but how I will get the discounted amount in webhook in amount field?

rose reef
#

It'll be in the discounts field

round ibex
#

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",

rose reef
#

Again, what is unexpected? That is the customer.subscription.updated event that fires when the subscriptions transitions into a new period without the discount

round ibex
#

but why it is without discount here? as it was the first actual payment after free 7 days are over

rose reef
#

The items.data[]price will never reflect the discounted amount

round ibex
#

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",

rose reef
# round ibex but why it is without discount here? as it was the first actual payment after fr...

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

round ibex
#

ok, let me check agian by disabling the trial period

round ibex
#

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?

lime bone
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

lime bone
round ibex
#

var paymentIntentClientSecret = '';

lime bone
#

Are you providing the client secret from $subscription?

round ibex
#

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

lime bone
#

Are you taking the secret from latest_invoice.payment_intent or pending_setup_intent?

round ibex
#

yes, sorry my fault, I was taking it from pending_setup_intent