diff --git a/package.json b/package.json index fa6b986..d11a81a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "processout.js", - "version": "1.8.1", + "version": "1.8.2", "description": "ProcessOut.js is a JavaScript library for ProcessOut's payment processing API.", "scripts": { "build:processout": "tsc -p src/processout && uglifyjs --compress --keep-fnames --ie8 dist/processout.js -o dist/processout.js", diff --git a/src/dynamic-checkout/payment-methods/apm.ts b/src/dynamic-checkout/payment-methods/apm.ts index ced0cdf..c8fc083 100644 --- a/src/dynamic-checkout/payment-methods/apm.ts +++ b/src/dynamic-checkout/payment-methods/apm.ts @@ -177,6 +177,7 @@ module ProcessOut { payment_method_name: apm.gateway_name, invoice_id: this.paymentConfig.invoiceId, return_url: this.paymentConfig.invoiceDetails.return_url || null, + tab_closed: error.metadata?.reason === "tab_closed", }) } else { this.resetContainerHtml().appendChild( diff --git a/src/dynamic-checkout/utils/events.ts b/src/dynamic-checkout/utils/events.ts index f8098af..6785259 100644 --- a/src/dynamic-checkout/utils/events.ts +++ b/src/dynamic-checkout/utils/events.ts @@ -238,6 +238,7 @@ module ProcessOut { payment_method_name: string invoice_id: string return_url: string | null + tab_closed?: boolean }) { const event = DynamicCheckoutEventsUtils.createEvent( DYNAMIC_CHECKOUT_EVENTS.PAYMENT_CANCELLED, diff --git a/src/processout/actionhandler.ts b/src/processout/actionhandler.ts index 70b2b22..0ae2b3f 100644 --- a/src/processout/actionhandler.ts +++ b/src/processout/actionhandler.ts @@ -347,7 +347,7 @@ module ProcessOut { // The payment window was closed clearInterval(timer) timer = null - error(new Exception("customer.canceled")) + error(new Exception("customer.canceled", undefined, { reason: "tab_closed" })) // Temporary just to investigate the issue telemetryClient.reportWarning({ diff --git a/src/processout/exception.ts b/src/processout/exception.ts index 0f634ea..b693c45 100644 --- a/src/processout/exception.ts +++ b/src/processout/exception.ts @@ -5,15 +5,20 @@ */ module ProcessOut { + export interface ExceptionMetadata { + [key: string]: string | boolean | number; + } + /** * ProcessOut Exception class */ export class Exception extends Error { public code: string; public message: string; + public metadata: ExceptionMetadata; public stack: string; - constructor(code: string, message?: string) { + constructor(code: string, message?: string, metadata?: ExceptionMetadata) { if (! message) message = Translator.translateError(code); @@ -21,6 +26,7 @@ module ProcessOut { this.code = code; this.message = message; + this.metadata = metadata; this.name = "ProcessOutException"; this.stack = ( new Error()).stack;