#shakilkhan496_api

1 messages ยท Page 1 of 1 (latest)

native prismBOT
#

๐Ÿ‘‹ 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/1341409886876995755

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

fallen adder
#

Are you still using apple pay for these trial subscriptions?

terse salmon
#

yes

#

my back end code sample

fallen adder
#

Can you share a sample subscription id?

terse salmon
#

sub_1QtqRnCLTcmkmHRYVh9oXuyE

#

test mode

#

I just need a way to get email on webhook

#

as this is trial so no payment intent

#

so not able to get apple pay email

#

I need to get that apple pay email on webhook when trial starts

fallen adder
terse salmon
#

let me check

#

Can you guide me the process ?

#

I am sending seti_1QtqziCLTcmkmHRYvPR2iVTF_secret_RnRtjY8FswA8pIucC4NQHJuvoYEQoog to front end

#

and it open up apple pay sheet

#

case 'customer.subscription.created': {
const subscription = event.data.object as Stripe.Subscription;
const pendingSetupIntent = subscription.pending_setup_intent;

if (!pendingSetupIntent) {
console.log('No pending_setup_intent available on subscription.');
break;
}

// pending_setup_intent may be a string (ID) or an expanded SetupIntent object
let setupIntent: Stripe.SetupIntent;
if (typeof pendingSetupIntent === 'string') {
setupIntent = await stripe.setupIntents.retrieve(pendingSetupIntent, {
expand: ['payment_method'],
});
} else {
setupIntent = pendingSetupIntent;
}

// The payment_method contains billing details including the email (if provided by Apple Pay)
const paymentMethod = setupIntent.payment_method as Stripe.PaymentMethod | null;
if (paymentMethod && paymentMethod.billing_details?.email) {
const email = paymentMethod.billing_details.email;
console.log('Apple Pay email from pending_setup_intent:', email);
} else {
console.log('Email not found in the payment method billing details.');
}

break;
}

#

is this correct way ??

fallen adder
#

Yeah

#

But that setupintent wasn't completed

#

And it looks like it's from a different subscription

terse salmon
#

yes it is just for a test

#

I mean do I need to use customer subscription update event ?

#

Like after complete payment with apple pay , it will triger customer subscription updated event ?

#

then with that setup intent we can extract apple pay email ?

fallen adder
#

But in above examples you didn't complete it

terse salmon
#

Yeah that was not completed just created for testing

#

Just give me an Idea if I am in correct path ... So when apple pay will triger and user complete that correctly it will call customer subscription updated event ---> then we can get a success full setup intent and retrive the email ?

#

like that code example ..

fallen adder
#

No

#

See the link I shared

#

You'll get a setup_intent.succeeded event

#

That's what you should inspect

terse salmon
#

ok checking

terse salmon
#

{
"id": "evt_1QtrxdCLTcmkmHRYwDrrjwxP",
"object": "event",
"api_version": "2022-11-15",
"created": 1739889585,
"data": {
"object": {
"id": "seti_1QtrxPCLTcmkmHRYkQqd5qOU",
"object": "setup_intent",
"application": null,
"automatic_payment_methods": null,
"cancellation_reason": null,
"client_secret": "seti_1QtrxPCLTcmkmHRYkQqd5qOU_secret_RnStiIXCTemNgPUQhgHFh4iDsZQMcsv",
"created": 1739889571,
"customer": "cus_RnSt8ZtDCyQuap",
"description": null,
"flow_directions": null,
"last_setup_error": null,
"latest_attempt": "setatt_1QtrxdCLTcmkmHRY6zhJMKXS",
"livemode": false,
"mandate": null,
"metadata": {
},
"next_action": null,
"on_behalf_of": null,
"payment_method": "pm_1QtrxcCLTcmkmHRYHRjCtAGl",
"payment_method_configuration_details": null,
"payment_method_options": {
"card": {
"mandate_options": null,
"network": null,
"request_three_d_secure": "automatic"
}
},
"payment_method_types": [
"card",
"link",
"sepa_debit"
],
"single_use_mandate": null,
"status": "succeeded",
"usage": "off_session"
}
},
"livemode": false,
"pending_webhooks": 3,
"request": {
"id": "req_ZIvaPyn9pTEWkb",
"idempotency_key": "80f36928-c65f-47cc-bb51-9e2f79148320"
},
"type": "setup_intent.succeeded"
}

#

This is my event data from successfull setup intent

#

How can I get apple pay email from here ?

#

I can see it on dashboard correctly

fallen adder
#

You'd need to expand or retrieve the pm_ id on that setupIntent: pm_1QtrxcCLTcmkmHRYHRjCtAGl

terse salmon
#

Thanks man all working fine