airwallex-payment-elements
Advanced tools
Comparing version 0.0.17 to 0.0.18
import { LitElement } from 'lit-element'; | ||
export declare class Airwallex extends LitElement { | ||
baseurl: string; | ||
paymentId: string; | ||
gatewayBaseurl: string; | ||
attemptId: string; | ||
successUrl: string; | ||
cancelUrl: string; | ||
errorUrl: string; | ||
options: object; | ||
constructor(); | ||
static readonly properties: { | ||
baseurl: { | ||
gatewayBaseurl: { | ||
type: StringConstructor; | ||
reflect: boolean; | ||
}; | ||
paymentId: { | ||
attemptId: { | ||
type: StringConstructor; | ||
reflect: boolean; | ||
}; | ||
successUrl: { | ||
type: StringConstructor; | ||
reflect: boolean; | ||
}; | ||
cancelUrl: { | ||
type: StringConstructor; | ||
reflect: boolean; | ||
}; | ||
errorUrl: { | ||
type: StringConstructor; | ||
reflect: boolean; | ||
}; | ||
options: { | ||
type: ObjectConstructor; | ||
reflect: boolean; | ||
}; | ||
}; | ||
@@ -26,0 +36,0 @@ static readonly styles: import("lit-element").CSSResult; |
@@ -6,11 +6,13 @@ import { css, html, LitElement } from 'lit-element'; | ||
super(); | ||
this.baseurl = this.paymentId = this.successUrl = this.cancelUrl = this.errorUrl = ''; | ||
this.gatewayBaseurl = this.attemptId = this.successUrl = this.cancelUrl = this.errorUrl = ''; | ||
this.options = {}; | ||
} | ||
static get properties() { | ||
return { | ||
baseurl: { type: String }, | ||
paymentId: { type: String }, | ||
successUrl: { type: String }, | ||
cancelUrl: { type: String }, | ||
errorUrl: { type: String } | ||
gatewayBaseurl: { type: String, reflect: true }, | ||
attemptId: { type: String, reflect: true }, | ||
successUrl: { type: String, reflect: true }, | ||
cancelUrl: { type: String, reflect: true }, | ||
errorUrl: { type: String, reflect: true }, | ||
options: { type: Object, reflect: true } | ||
}; | ||
@@ -32,18 +34,15 @@ } | ||
checkoutEventHandler(event) { | ||
if (event.origin === window.location.origin) { | ||
console.info(`Iframe Source Name: [${event.source.name}]`); | ||
console.info(`Iframe Msg: [${event.data}]`); | ||
if (CHECKOUT_IFRAME_NAME === event.source.name) { | ||
if (event.data === 'AWX_CHECKOUT_SUCCESS') { | ||
window.location.href = this.successUrl; | ||
} | ||
else if (event.data === 'AWX_CHECKOUT_CANCEL') { | ||
window.location.href = this.cancelUrl; | ||
} | ||
else if (event.data === 'AWX_CHECKOUT_ERROR') { | ||
window.location.href = this.errorUrl; | ||
} | ||
else { | ||
} | ||
if (event.origin === this.gatewayBaseurl && event.isTrusted) { | ||
console.log(`Airwallex Checkout Message: [${event.data}]`); | ||
if (event.data === 'AWX_CHECKOUT_SUCCESS') { | ||
window.location.href = this.successUrl; | ||
} | ||
else if (event.data === 'AWX_CHECKOUT_CANCEL') { | ||
window.location.href = this.cancelUrl; | ||
} | ||
else if (event.data === 'AWX_CHECKOUT_ERROR') { | ||
window.location.href = this.errorUrl; | ||
} | ||
else { | ||
} | ||
} | ||
@@ -68,3 +67,3 @@ } | ||
allowpaymentrequest="true" | ||
src="${this.baseurl}/checkout/${this.paymentId}?origin=${window.location.origin}" | ||
src="${this.gatewayBaseurl}/checkout/${this.attemptId}?origin=${window.location.origin}&option=${JSON.stringify(this.options)}" | ||
title="Secure airwallex payment frame" | ||
@@ -71,0 +70,0 @@ /> |
import { LitElement } from 'lit-element'; | ||
export declare class Airwallex extends LitElement { | ||
baseurl: string; | ||
paymentId: string; | ||
gatewayBaseurl: string; | ||
attemptId: string; | ||
successUrl: string; | ||
cancelUrl: string; | ||
errorUrl: string; | ||
options: object; | ||
constructor(); | ||
static readonly properties: { | ||
baseurl: { | ||
gatewayBaseurl: { | ||
type: StringConstructor; | ||
reflect: boolean; | ||
}; | ||
paymentId: { | ||
attemptId: { | ||
type: StringConstructor; | ||
reflect: boolean; | ||
}; | ||
successUrl: { | ||
type: StringConstructor; | ||
reflect: boolean; | ||
}; | ||
cancelUrl: { | ||
type: StringConstructor; | ||
reflect: boolean; | ||
}; | ||
errorUrl: { | ||
type: StringConstructor; | ||
reflect: boolean; | ||
}; | ||
options: { | ||
type: ObjectConstructor; | ||
reflect: boolean; | ||
}; | ||
}; | ||
@@ -26,0 +36,0 @@ static readonly styles: import("lit-element").CSSResult; |
{ | ||
"name": "airwallex-payment-elements", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.js", |
@@ -6,18 +6,21 @@ import { css, html, LitElement } from 'lit-element'; | ||
export class Airwallex extends LitElement { | ||
baseurl: string; | ||
paymentId: string; | ||
gatewayBaseurl: string; | ||
attemptId: string; | ||
successUrl: string; | ||
cancelUrl: string; | ||
errorUrl: string; | ||
options: object; | ||
constructor() { | ||
super(); | ||
this.baseurl = this.paymentId = this.successUrl = this.cancelUrl = this.errorUrl = ''; | ||
this.gatewayBaseurl = this.attemptId = this.successUrl = this.cancelUrl = this.errorUrl = ''; | ||
this.options = {}; | ||
} | ||
static get properties() { | ||
return { | ||
baseurl: { type: String }, | ||
paymentId: { type: String }, | ||
successUrl: { type: String }, | ||
cancelUrl: { type: String }, | ||
errorUrl: { type: String } | ||
gatewayBaseurl: { type: String, reflect: true }, | ||
attemptId: { type: String, reflect: true }, | ||
successUrl: { type: String, reflect: true }, | ||
cancelUrl: { type: String, reflect: true }, | ||
errorUrl: { type: String, reflect: true }, | ||
options: { type: Object, reflect: true } | ||
}; | ||
@@ -39,17 +42,13 @@ } | ||
checkoutEventHandler(event: MessageEvent) { | ||
if (event.origin === window.location.origin) { | ||
// @ts-ignore | ||
console.info(`Iframe Source Name: [${event.source.name}]`); | ||
console.info(`Iframe Msg: [${event.data}]`); | ||
// @ts-ignore | ||
if (CHECKOUT_IFRAME_NAME === event.source.name) { | ||
if (event.data === 'AWX_CHECKOUT_SUCCESS') { | ||
window.location.href = this.successUrl; | ||
} else if (event.data === 'AWX_CHECKOUT_CANCEL') { | ||
window.location.href = this.cancelUrl; | ||
} else if (event.data === 'AWX_CHECKOUT_ERROR') { | ||
window.location.href = this.errorUrl; | ||
} else { | ||
// ❌Should never get here! | ||
} | ||
if (event.origin === this.gatewayBaseurl && event.isTrusted) { | ||
// tslint:disable-next-line: no-console | ||
console.log(`Airwallex Checkout Message: [${event.data}]`); | ||
if (event.data === 'AWX_CHECKOUT_SUCCESS') { | ||
window.location.href = this.successUrl; | ||
} else if (event.data === 'AWX_CHECKOUT_CANCEL') { | ||
window.location.href = this.cancelUrl; | ||
} else if (event.data === 'AWX_CHECKOUT_ERROR') { | ||
window.location.href = this.errorUrl; | ||
} else { | ||
// ❌Should never get here! | ||
} | ||
@@ -75,3 +74,5 @@ } | ||
allowpaymentrequest="true" | ||
src="${this.baseurl}/checkout/${this.paymentId}?origin=${window.location.origin}" | ||
src="${this.gatewayBaseurl}/checkout/${this.attemptId}?origin=${window.location.origin}&option=${JSON.stringify( | ||
this.options | ||
)}" | ||
title="Secure airwallex payment frame" | ||
@@ -78,0 +79,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
2827556
2961