airwallex-payment-elements
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,10 +0,1 @@ | ||
/// <reference types="react" /> | ||
interface IAirwallex { | ||
host: string; | ||
paymentId: string; | ||
successUrl: string; | ||
cancelUrl: string; | ||
errorUrl: string; | ||
} | ||
declare const Index: ({ host, paymentId, successUrl, cancelUrl, errorUrl, }: IAirwallex) => JSX.Element; | ||
export default Index; | ||
export {}; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { | ||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } | ||
return cooked; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = __importDefault(require("react")); | ||
var lit_element_1 = require("lit-element"); | ||
var CHECKOUT_IFRAME_NAME = 'airwallex_checkout_frame'; | ||
@@ -13,6 +27,17 @@ var IframeStyle = { | ||
}; | ||
var Index = function (_a) { | ||
var host = _a.host, paymentId = _a.paymentId, successUrl = _a.successUrl, cancelUrl = _a.cancelUrl, errorUrl = _a.errorUrl; | ||
var src = "https://" + host + "/checkout/" + paymentId + "?origin=" + window.location.origin; | ||
window.addEventListener("message", function (event) { | ||
var Airwallex = (function (_super) { | ||
__extends(Airwallex, _super); | ||
function Airwallex() { | ||
var _this = _super.call(this) || this; | ||
_this.host = _this.paymentId = _this.successUrl = _this.cancelUrl = _this.errorUrl = ''; | ||
return _this; | ||
} | ||
Object.defineProperty(Airwallex, "properties", { | ||
get: function () { | ||
return { host: { type: String }, paymentId: { type: String }, successUrl: { type: String }, cancelUrl: { type: String }, errorUrl: { type: String } }; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Airwallex.prototype.checkoutEventHandler = function (event) { | ||
if (event.origin === window.location.origin) { | ||
@@ -23,9 +48,9 @@ console.info("Iframe Source Name: [" + event.source.name + "]"); | ||
if (event.data === 'AWX_CHECKOUT_SUCCESS') { | ||
window.location.href = successUrl; | ||
window.location.href = this.successUrl; | ||
} | ||
else if (event.data === 'AWX_CHECKOUT_CANCEL') { | ||
window.location.href = cancelUrl; | ||
window.location.href = this.cancelUrl; | ||
} | ||
else if (event.data === 'AWX_CHECKOUT_ERROR') { | ||
window.location.href = errorUrl; | ||
window.location.href = this.errorUrl; | ||
} | ||
@@ -36,6 +61,21 @@ else { | ||
} | ||
}); | ||
return (react_1.default.createElement("iframe", { frameBorder: "0", allowtransparency: "true", importance: "high", scrolling: "no", name: CHECKOUT_IFRAME_NAME, allowpaymentrequest: "true", src: src, title: "Secure airwallex payment frame", style: IframeStyle })); | ||
}; | ||
exports.default = Index; | ||
}; | ||
Airwallex.prototype.connectedCallback = function () { | ||
_super.prototype.connectedCallback.call(this); | ||
window.addEventListener("message", this.checkoutEventHandler); | ||
}; | ||
Airwallex.prototype.disconnectedCallback = function () { | ||
window.removeEventListener("message", this.checkoutEventHandler); | ||
_super.prototype.disconnectedCallback.call(this); | ||
}; | ||
Airwallex.prototype.render = function () { | ||
return lit_element_1.html(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <iframe\n frameBorder=\"0\"\n allowtransparency=\"true\"\n importance=\"high\"\n scrolling=\"no\"\n name=", "\n allowpaymentrequest=\"true\"\n src=\"https://", "/checkout/", "?origin=", "\"\n title=\"Secure airwallex payment frame\"\n style=", "\n />\n "], ["\n <iframe\n frameBorder=\"0\"\n allowtransparency=\"true\"\n importance=\"high\"\n scrolling=\"no\"\n name=", "\n allowpaymentrequest=\"true\"\n src=\"https://", | ||
"/checkout/", | ||
"?origin=", | ||
"\"\n title=\"Secure airwallex payment frame\"\n style=", "\n />\n "])), CHECKOUT_IFRAME_NAME, this.host, this.paymentId, window.location.origin, IframeStyle); | ||
}; | ||
return Airwallex; | ||
}(lit_element_1.LitElement)); | ||
customElements.define('airwallex-element', Airwallex); | ||
var templateObject_1; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "airwallex-payment-elements", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
@@ -15,13 +16,10 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"react": "^16.8.6" | ||
"lit-element": "^2.2.1" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^16.8.23", | ||
"@types/react-dom": "^16.8.5", | ||
"react-dom": "^16.8.6", | ||
"lit-element": "^2.2.1", | ||
"tslint": "^5.18.0", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"tslint-react-hooks": "^2.2.1", | ||
"typescript": "^3.5.3" | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
# awx-payment-elements | ||
# airwallex-payment-elements | ||
TBD | ||
POC TBD |
@@ -9,2 +9,3 @@ { | ||
// "allowJs": true, /* Allow javascript files to be compiled. */ | ||
"skipLibCheck": true, | ||
// "checkJs": true, /* Report errors in .js files. */ | ||
@@ -11,0 +12,0 @@ "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ |
{ | ||
"extends": ["tslint:latest", "tslint-eslint-rules", "tslint-react-hooks"], | ||
"extends": ["tslint:latest", "tslint-eslint-rules"], | ||
"rules": { | ||
@@ -4,0 +4,0 @@ // Disable explicit visibility declarations for class members |
Sorry, the diff of this file is not supported yet
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
15990
4
239
9