#ngopi160198gmail.com
1 messages · Page 1 of 1 (latest)
hello! how can I help?
Does anyone know how to create a checkout session in salesforce and how to get the recovery expired URL?
I just created a checkout session apex callout class. I got the checkout session URL but the recovery URL that getting is null.
we aren't familiar with using Salesforce to create a Checkout Session specifically
but can you share the API calls that you're making in general?
have you taken a look at this guide? https://stripe.com/docs/payments/checkout/abandoned-carts#configure-recovery
it mentioned in the guide that you need to include : after_expiration[recovery][enabled]
and you should
Listen to the checkout.session.expired webhook to be notified when customers abandon Checkout and sessions expire.
When the session expires with recovery enabled, the webhook payload contains after_expiration, which includes a URL denoted by after_expiration.recovery.url that you can embed in cart abandonment emails.```
i just created a webhook and connect to the salesforce but it is also showing recovery URL null.
did you include this parameter when creating the Checkout Session? https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-after_expiration-recovery-enabled
yes
can you share the checkout session id? it'll look like cs_test_xxx
I failed to retrieve that one
public static void getExpiredCheckoutSession(String sessionId)
{
System.debug('getExpiredCheckoutSession');
HttpRequest req = new HttpRequest();
req.setEndpoint('https://api.stripe.com/v1/checkout/sessions/'+sessionId);
req.setHeader('Content-Type','application/x-www-form-urlencoded');
req.setHeader('Authorization','Bearer '+accessToken );
req.setMethod('GET');
Http http = new Http();
HttpResponse res = http.send(req);
if (res.getStatusCode() == 200) {
Map<String, Object> session = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
Boolean isExpired = (Boolean) session.get('livemode');
System.debug('isExpired=='+ isExpired);
if (isExpired) {
Map<String, Object> afterExpiration = (Map<String, Object>) session.get('after_expiration');
Boolean recoveryEnabled = (Boolean) afterExpiration.get('[recovery][enabled]');
if (recoveryEnabled) {
String recoveryUrl = (String) afterExpiration.get('[recovery][url]');
System.debug('Recovery URL: ' + recoveryUrl);
} else {
System.debug('Recovery not enabled');
}
} else {
System.debug('Session has not expired');
}
} else {
System.debug('Failed to retrieve session: ' + res.getStatus());
}
}
can you find the related checkout session id in your Dashboard?
I am sorry i dont get you
can you provide any other object id for me to look at how you've created your Checkout Session?
Or you share your account id? You can find your account id by logging in to https://dashboard.stripe.com/settings/account. It'll be in the upper right hand corner and looks like acct_123 i'll try to find the Checkout Session id
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
This is my account id
https://dashboard.stripe.com/test/events/evt_1N1O7MSJah0e34OpOnAkBZhd - if you look at the event, it does contain the after_expiration.url
public static void getExpiredCheckoutSession(String sessionId)
{
System.debug('getExpiredCheckoutSession');
HttpRequest req = new HttpRequest();
req.setEndpoint('https://api.stripe.com/v1/checkout/sessions/'+sessionId);
req.setHeader('Content-Type','application/x-www-form-urlencoded');
req.setHeader('Authorization','Bearer '+accessToken );
req.setMethod('GET');
Http http = new Http();
HttpResponse res = http.send(req);
if (res.getStatusCode() == 200) {
Map<String, Object> session = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
Boolean isExpired = (Boolean) session.get('livemode');
System.debug('isExpired=='+ isExpired);
if (isExpired) {
Map<String, Object> afterExpiration = (Map<String, Object>) session.get('after_expiration');
Boolean recoveryEnabled = (Boolean) afterExpiration.get('[recovery][enabled]');
if (recoveryEnabled) {
String recoveryUrl = (String) afterExpiration.get('[recovery][url]');
System.debug('Recovery URL: ' + recoveryUrl);
} else {
System.debug('Recovery not enabled');
}
} else {
System.debug('Session has not expired');
}
} else {
System.debug('Failed to retrieve session: ' + res.getStatus());
}
}
what's your question with regards to the code you've pasted?
can you paste the retrieved Checkout Session object in json?
I have a doubt, how i can retrieve the URL from the web hook?
If the webhook event was successfully received by your webhook endpoint, then you would process the event and retrieve the URL from the Checkout Session object
You may want to take a look at these guides :
https://stripe.com/docs/webhooks
https://stripe.com/docs/webhooks/quickstart