Reset Adyen session if it times out.
This commit is contained in:
parent
b357bc8a92
commit
1f7775e67b
1 changed files with 35 additions and 19 deletions
|
|
@ -246,7 +246,7 @@ export default {
|
||||||
console.log(`Price = ${this.amountDue}`);
|
console.log(`Price = ${this.amountDue}`);
|
||||||
console.log(`Adyen Price = ${this.adyenPriceTotal}`);
|
console.log(`Adyen Price = ${this.adyenPriceTotal}`);
|
||||||
|
|
||||||
const requestBody = this.adyenInitRequestInfo;
|
const requestBody = this.getAdyenInitRequestInfo();
|
||||||
|
|
||||||
console.log(`Calling with:`);
|
console.log(`Calling with:`);
|
||||||
console.log(requestBody);
|
console.log(requestBody);
|
||||||
|
|
@ -294,6 +294,15 @@ export default {
|
||||||
|
|
||||||
console.log(checkout);
|
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 = {
|
const configuration = {
|
||||||
paymentMethodsConfiguration: {
|
paymentMethodsConfiguration: {
|
||||||
ideal: {
|
ideal: {
|
||||||
|
|
@ -505,14 +514,26 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
async resetAdyenDropin() {
|
||||||
piaType() {
|
this?.dropinComponent?.unmount();
|
||||||
return this.$store.getters.order.payment.piaType;
|
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 {
|
return {
|
||||||
sourceSystem: this.sourceSystem,
|
sourceSystem: this.sourceSystem,
|
||||||
referralSequenceNumber: this.$store.getters.order.referralSequenceNumber,
|
referralSequenceNumber: this.$store.getters.order.referralSequenceNumber,
|
||||||
|
|
@ -529,9 +550,15 @@ export default {
|
||||||
IP: "127.0.0.1", // TODO
|
IP: "127.0.0.1", // TODO
|
||||||
firstName: this.$store.getters.order.customer.firstName,
|
firstName: this.$store.getters.order.customer.firstName,
|
||||||
lastName: this.$store.getters.order.customer.lastName,
|
lastName: this.$store.getters.order.customer.lastName,
|
||||||
idempotencyKey: this.idempotencyKey,
|
idempotencyKey: this.getIdempotencyKey(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
piaType() {
|
||||||
|
return this.$store.getters.order.payment.piaType;
|
||||||
|
},
|
||||||
|
|
||||||
workOrderNumberLastSixDigits() {
|
workOrderNumberLastSixDigits() {
|
||||||
const workOrderNumber = this.$store.getters.order.workOrderNumber ?? "";
|
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() {
|
sourceSystem() {
|
||||||
return "FMG-2.0";
|
return "FMG-2.0";
|
||||||
},
|
},
|
||||||
|
|
@ -608,7 +624,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
adyenPriceTotal() {
|
adyenPriceTotal() {
|
||||||
return this.amountDue * 100;
|
return Math.round(this.amountDue * 100);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Cart info
|
// Cart info
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue