#ngopi160198gmail.com

1 messages · Page 1 of 1 (latest)

hexed stumpBOT
hybrid basalt
#

hello! how can I help?

dusk salmon
#

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.

hybrid basalt
#

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?

dusk salmon
#

ok.

#

I need to get the recovery URL with the checkout session URL.

hybrid basalt
dusk salmon
#

I already read this document

#

but I didn't get any solution to this.

hybrid basalt
#

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.```
dusk salmon
#

i just created a webhook and connect to the salesforce but it is also showing recovery URL null.

hybrid basalt
dusk salmon
#

yes

hybrid basalt
#

can you share the checkout session id? it'll look like cs_test_xxx

dusk salmon
#

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());
}
}

hybrid basalt
#

can you find the related checkout session id in your Dashboard?

dusk salmon
#

I am sorry i dont get you

hybrid basalt
#

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

dusk salmon
#

This is my account id

hybrid basalt
dusk salmon
#

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());
}
}

hybrid basalt
#

what's your question with regards to the code you've pasted?

dusk salmon
#

i need to get recovery Url

#

but i got it as null

hybrid basalt
#

can you paste the retrieved Checkout Session object in json?

dusk salmon
#

I have a doubt, how i can retrieve the URL from the web hook?

hybrid basalt