diff --git a/src/layouts/payment-adyen/payment-adyen.vue b/src/layouts/payment-adyen/payment-adyen.vue index f8abc12b7..cddb2189c 100644 --- a/src/layouts/payment-adyen/payment-adyen.vue +++ b/src/layouts/payment-adyen/payment-adyen.vue @@ -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