Merge pull request #3043 from Safelite/feature/CASH-2224

Reset Adyen session if it times out.
This commit is contained in:
chloeherdsafelite 2026-02-03 10:00:47 -05:00 committed by GitHub
commit 9d1a07eb97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -246,7 +246,7 @@ export default {
console.log(`Price = ${this.amountDue}`);
console.log(`Adyen Price = ${this.adyenPriceTotal}`);
const requestBody = this.adyenInitRequestInfo;
const requestBody = this.getAdyenInitRequestInfo();
console.log(`Calling with:`);
console.log(requestBody);
@ -294,6 +294,15 @@ export default {
console.log(checkout);
const expiryTime = new Date(checkout.options.expiresAt);
const expiryInterval = expiryTime.getTime() - new Date().getTime();
const handleTimeout = () => {
this.resetAdyenDropin();
};
const timeout = setTimeout(handleTimeout, expiryInterval);
const configuration = {
paymentMethodsConfiguration: {
ideal: {
@ -505,14 +514,26 @@ export default {
return;
}
},
},
computed: {
piaType() {
return this.$store.getters.order.payment.piaType;
async resetAdyenDropin() {
this?.dropinComponent?.unmount();
await this.initializeAdyen();
},
adyenInitRequestInfo() {
// Now a Method so it is always freshly called and not cached.
getIdempotencyKey() {
const currentDateTime = new Date();
const currentHour = currentDateTime.getUTCHours();
const currentDate = currentDateTime.getUTCDate();
const id = this?.$store?.getters?.order?.referralCorrelationId;
const system = this.sourceSystem;
const total = this.adyenPriceTotal;
return `${id}-${system}-${currentDate}-${currentHour}-${total}`;
},
// Now a Method so it is always freshly called and not cached.
getAdyenInitRequestInfo() {
return {
sourceSystem: this.sourceSystem,
referralSequenceNumber: this.$store.getters.order.referralSequenceNumber,
@ -529,9 +550,15 @@ export default {
IP: "127.0.0.1", // TODO
firstName: this.$store.getters.order.customer.firstName,
lastName: this.$store.getters.order.customer.lastName,
idempotencyKey: this.idempotencyKey,
idempotencyKey: this.getIdempotencyKey(),
};
},
},
computed: {
piaType() {
return this.$store.getters.order.payment.piaType;
},
workOrderNumberLastSixDigits() {
const workOrderNumber = this.$store.getters.order.workOrderNumber ?? "";
@ -588,17 +615,6 @@ export default {
};
},
idempotencyKey() {
const currentDateTime = new Date();
const currentHour = currentDateTime.getUTCHours();
const currentDate = currentDateTime.getUTCDate();
const id = this?.$store?.getters?.order?.referralCorrelationId;
const system = this.sourceSystem;
const total = this.adyenPriceTotal;
return `${id}-${system}-${currentDate}-${currentHour}-${total}`;
},
sourceSystem() {
return "FMG-2.0";
},
@ -608,7 +624,7 @@ export default {
},
adyenPriceTotal() {
return this.amountDue * 100;
return Math.round(this.amountDue * 100);
},
// Cart info