#Poulose K Eldho
1 messages · Page 1 of 1 (latest)
yes
LWC has a auraenabled method in it. That method contains a method for creation of checkout session in stripe related to a order and the checkout session url is returned to lwc. LWC button contains the value of checkout session url
What's lwc, order record page and apex class?
import { LightningElement, api, wire } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import getHostedInvoiceUrl1 from '@salesforce/apex/StripeCheckoutSessions.createStripeInvoiceLWC';
export default class PayButtonLWC extends NavigationMixin(LightningElement) {
@api recordId;
payNow() {
let invoiceUrl;
getHostedInvoiceUrl1({ invoiceId: this.recordId })
.then(result => {
invoiceUrl = result;
})
.catch(error => {
console.error(error);
})
.finally(() => {
if (invoiceUrl) {
this[NavigationMixin.Navigate]({
type: 'standard__webPage',
attributes: {
url: invoiceUrl,
// target: '_blank'
}
});
}
});
}
}
Coming back to your question. You can programmatically expire a Checkout Session: https://stripe.com/docs/api/checkout/sessions/expire
not that I need.
When same lwc button is clicked multiple times for a partucular order record different checkout session urls are createda nd each contains a checkout session.If pay button of any one of it is clicked and succeeded, other urls should fail.
I understand, when one payment is completed you can expire other Checkout Sessions with the API method that I shared
Please explain this process
You can save all the checkout session IDs somewhere, and when you get a webhook event checkout.session.completed you can expire all the other saved checkout sessions.
since the checkout sessions are different each time the apex class is called, how remaining can be expired