#Poulose K Eldho

1 messages · Page 1 of 1 (latest)

digital latchBOT
glossy patrol
#

Hi! Let me help you with this.

#

What's lwc, order record page and apex class?

desert zephyr
#

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

glossy patrol
#

What's lwc, order record page and apex class?

desert zephyr
#

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

glossy patrol
desert zephyr
#

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.

glossy patrol
#

I understand, when one payment is completed you can expire other Checkout Sessions with the API method that I shared

desert zephyr
#

Please explain this process

glossy patrol
#

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.

desert zephyr
#

since the checkout sessions are different each time the apex class is called, how remaining can be expired

digital latchBOT
glossy patrol
#

You need to save it somewhere.

#

Are you with me?