airwallex-payment-elements
Advanced tools
Comparing version 0.0.19 to 0.0.20
@@ -37,2 +37,3 @@ import { LitElement } from 'lit-element'; | ||
static readonly styles: import("lit-element").CSSResult; | ||
handleEvent(data: any): void; | ||
checkoutEventHandler(event: any): void; | ||
@@ -39,0 +40,0 @@ connectedCallback(): void; |
@@ -27,3 +27,3 @@ import { css, html, LitElement } from 'lit-element'; | ||
width: 100%; | ||
height: 1072px; | ||
height: 1096px; | ||
margin: 4px; | ||
@@ -33,2 +33,10 @@ } | ||
} | ||
handleEvent(data) { | ||
const myEvent = new CustomEvent('airwallex-checkout', { | ||
detail: data, | ||
bubbles: true, | ||
composed: true | ||
}); | ||
this.dispatchEvent(myEvent); | ||
} | ||
checkoutEventHandler(event) { | ||
@@ -39,12 +47,27 @@ if (event.origin === this.gatewayBaseurl && event.isTrusted) { | ||
const parameters = `attemptId=${event.data.attemptId}&instrumentId=${event.data.instrumentId}&transactionId=${event.data.transactionId}`; | ||
window.location.href = | ||
this.successUrl.indexOf('?') === -1 ? `${this.successUrl}?${parameters}` : `${this.successUrl}&${parameters}`; | ||
if (this.successUrl) { | ||
window.location.href = | ||
this.successUrl.indexOf('?') === -1 ? `${this.successUrl}?${parameters}` : `${this.successUrl}&${parameters}`; | ||
} | ||
else { | ||
this.handleEvent(event.data); | ||
} | ||
} | ||
else if (event.data.code === 'AWX_CHECKOUT_CANCEL') { | ||
console.log(`Airwallex Checkout Message: [${JSON.stringify(event.data)}]`); | ||
window.location.href = this.cancelUrl; | ||
if (this.cancelUrl) { | ||
window.location.href = this.cancelUrl; | ||
} | ||
else { | ||
this.handleEvent(event.data); | ||
} | ||
} | ||
else if (event.data.code === 'AWX_CHECKOUT_ERROR') { | ||
console.log(`Airwallex Checkout Message: [${JSON.stringify(event.data)}]`); | ||
window.location.href = this.errorUrl; | ||
if (this.errorUrl) { | ||
window.location.href = this.errorUrl; | ||
} | ||
else { | ||
this.handleEvent(event.data); | ||
} | ||
} | ||
@@ -51,0 +74,0 @@ else { |
@@ -37,2 +37,3 @@ import { LitElement } from 'lit-element'; | ||
static readonly styles: import("lit-element").CSSResult; | ||
handleEvent(data: any): void; | ||
checkoutEventHandler(event: any): void; | ||
@@ -39,0 +40,0 @@ connectedCallback(): void; |
{ | ||
"name": "airwallex-payment-elements", | ||
"version": "0.0.19", | ||
"version": "0.0.20", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.js", |
@@ -35,3 +35,3 @@ import { css, html, LitElement } from 'lit-element'; | ||
width: 100%; | ||
height: 1072px; | ||
height: 1096px; | ||
margin: 4px; | ||
@@ -41,2 +41,9 @@ } | ||
} | ||
handleEvent(data) { | ||
const myEvent = new CustomEvent('airwallex-checkout', { | ||
detail: data, | ||
bubbles: true, | ||
composed: true }); | ||
this.dispatchEvent(myEvent); | ||
} | ||
checkoutEventHandler(event) { | ||
@@ -48,13 +55,25 @@ if (event.origin === this.gatewayBaseurl && event.isTrusted) { | ||
const parameters = `attemptId=${event.data.attemptId}&instrumentId=${event.data.instrumentId}&transactionId=${event.data.transactionId}`; | ||
window.location.href = | ||
if (this.successUrl) { | ||
window.location.href = | ||
this.successUrl.indexOf('?') === -1 ? `${this.successUrl}?${parameters}` : `${this.successUrl}&${parameters}`; | ||
} else if (event.data.code === 'AWX_CHECKOUT_CANCEL') { | ||
} else { | ||
this.handleEvent(event.data); | ||
} | ||
} else if (event.data.code === 'AWX_CHECKOUT_CANCEL') { | ||
// tslint:disable-next-line: no-console | ||
console.log(`Airwallex Checkout Message: [${JSON.stringify(event.data)}]`); | ||
window.location.href = this.cancelUrl; | ||
} else if (event.data.code === 'AWX_CHECKOUT_ERROR') { | ||
if (this.cancelUrl) { | ||
window.location.href = this.cancelUrl; | ||
} else { | ||
this.handleEvent(event.data); | ||
} | ||
} else if (event.data.code === 'AWX_CHECKOUT_ERROR') { | ||
// tslint:disable-next-line: no-console | ||
console.log(`Airwallex Checkout Message: [${JSON.stringify(event.data)}]`); | ||
window.location.href = this.errorUrl; | ||
} else { | ||
if (this.errorUrl) { | ||
window.location.href = this.errorUrl; | ||
} else { | ||
this.handleEvent(event.data); | ||
} | ||
} else { | ||
// ❌Should never get here! | ||
@@ -61,0 +80,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2837639
3021