From 2bc51dde71fa11d39857a3037e1150c02cab471e Mon Sep 17 00:00:00 2001 From: Shraddha Shah Date: Fri, 22 Nov 2024 19:19:22 -0800 Subject: [PATCH 1/3] add fastlane 3ds support --- dist/ui.js | 42 ++++++++++++++------------- dist/ui.min.js | 2 +- src/constants.js | 8 +++++ src/three-domain-secure/component.jsx | 32 +++++++++++--------- 4 files changed, 50 insertions(+), 34 deletions(-) create mode 100644 src/constants.js diff --git a/dist/ui.js b/dist/ui.js index 42b8d653..dd68fb76 100644 --- a/dist/ui.js +++ b/dist/ui.js @@ -216,37 +216,39 @@ module.exports = function(modules) { var child = firstChild.render(function(opts) { void 0 === opts && (opts = {}); var _opts$doc = opts.doc, doc = void 0 === _opts$doc ? document : _opts$doc; - return function domRenderer(node) { - if ("component" === node.type) return node.renderComponent(domRenderer); + var _xmlNamespaceDomRenderer = function(node, xmlNamespace) { + if ("component" === node.type) return node.renderComponent((function(childNode) { + return _xmlNamespaceDomRenderer(childNode, xmlNamespace); + })); + if ("text" === node.type) return createTextElement(doc, node); + if ("element" === node.type) { + var el = function(doc, node, xmlNamespace) { + return doc.createElementNS(xmlNamespace, node.name); + }(doc, node, xmlNamespace); + addProps(el, node); + addChildren(el, node, doc, (function(childNode) { + return _xmlNamespaceDomRenderer(childNode, xmlNamespace); + })); + return el; + } + throw new TypeError("Unhandleable node"); + }; + var _domRenderer = function(node) { + if ("component" === node.type) return node.renderComponent(_domRenderer); if ("text" === node.type) return createTextElement(doc, node); if ("element" === node.type) { var xmlNamespace = ELEMENT_DEFAULT_XML_NAMESPACE[node.name.toLowerCase()]; - if (xmlNamespace) return function xmlNamespaceDomRenderer(node, xmlNamespace) { - if ("component" === node.type) return node.renderComponent((function(childNode) { - return xmlNamespaceDomRenderer(childNode, xmlNamespace); - })); - if ("text" === node.type) return createTextElement(doc, node); - if ("element" === node.type) { - var el = function(doc, node, xmlNamespace) { - return doc.createElementNS(xmlNamespace, node.name); - }(doc, node, xmlNamespace); - addProps(el, node); - addChildren(el, node, doc, (function(childNode) { - return xmlNamespaceDomRenderer(childNode, xmlNamespace); - })); - return el; - } - throw new TypeError("Unhandleable node"); - }(node, xmlNamespace); + if (xmlNamespace) return _xmlNamespaceDomRenderer(node, xmlNamespace); var el = function(doc, node) { return node.props.el ? node.props.el : doc.createElement(node.name); }(doc, node); addProps(el, node); - addChildren(el, node, doc, domRenderer); + addChildren(el, node, doc, _domRenderer); return el; } throw new TypeError("Unhandleable node"); }; + return _domRenderer; }({ doc: doc })); diff --git a/dist/ui.min.js b/dist/ui.min.js index 6399e172..42e4a06b 100644 --- a/dist/ui.min.js +++ b/dist/ui.min.js @@ -1 +1 @@ -module.exports=function(n){var e={};function t(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return n[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var i in n)t.d(r,i,function(e){return n[e]}.bind(null,i));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return{}.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";function r(n,e){for(var t=[],r=0;r1?new o(e):void 0}(this.component(this.props,this.children));if(e)return e.render(n)},e.render=function(n){return n(this)},e.renderChildren=function(n){return r(this.children,n)},n}();function d(n){for(var e=[],t=0;t2?t-2:0),o=2;o1?new o(e):void 0}(this.component(this.props,this.children));if(e)return e.render(n)},e.render=function(n){return n(this)},e.renderChildren=function(n){return r(this.children,n)},n}();function d(n){for(var e=[],t=0;t2?t-2:0),o=2;o void, onError: (mixed) => void, sdkMeta: string, + go_to: string, content?: void | {| windowMessage?: string, continueMessage?: string, @@ -74,6 +75,7 @@ export function getThreeDomainSecureComponent(): TDSComponent { /> ).render(dom({ doc })); }, + domain: getPayPalDomainRegex(), props: { action: { @@ -86,11 +88,6 @@ export function getThreeDomainSecureComponent(): TDSComponent { queryParam: true, value: () => "1", }, - flow: { - type: "string", - queryParam: true, - value: () => "3ds", - }, createOrder: { type: "function", queryParam: "cart_id", @@ -117,8 +114,10 @@ export function getThreeDomainSecureComponent(): TDSComponent { alias: "onContingencyResult", decorate: ({ props, value, onError }) => { return (err, result) => { + if (props?.userType === "FASTLANE") { + return value(result); + } const isCardFieldFlow = props?.userType === "UNBRANDED_GUEST"; - // HostedFields ONLY rejects when the err object is not null. The below implementation ensures that CardFields follows the same pattern. const hasError = isCardFieldFlow @@ -144,6 +143,13 @@ export function getThreeDomainSecureComponent(): TDSComponent { type: "object", required: false, }, + go_to: { + type: "string", + queryParam: true, + // $FlowFixMe + value: ({ value }) => value, + required: false, + }, userType: { type: "string", required: false, From 6f9b7fc90a1e9b380d51dd260712366e75b6edf5 Mon Sep 17 00:00:00 2001 From: Shraddha Shah Date: Sat, 23 Nov 2024 23:30:34 -0800 Subject: [PATCH 2/3] make devOnly export --- src/interface.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/interface.js b/src/interface.js index ebe8788d..e8909059 100644 --- a/src/interface.js +++ b/src/interface.js @@ -1,8 +1,9 @@ /* @flow */ -import { isPayPalDomain } from "@paypal/sdk-client/src"; +import { isPayPalDomain, getEnv } from "@paypal/sdk-client/src"; // eslint-disable-next-line import/no-namespace import * as postRobotModule from "@krakenjs/post-robot/src"; +import { ENV } from "@paypal/sdk-constants/src"; import { getThreeDomainSecureComponent, @@ -23,8 +24,18 @@ function protectedExport(xport: T): ?T { } } +// $FlowIssue +export const devEnvOnlyExport = (unprotectedExport) => { + const env = getEnv(); + if (env === ENV.LOCAL || env === ENV.STAGE) { + return unprotectedExport; + } else { + return undefined; + } +}; + export const ThreeDomainSecure: LazyProtectedExport = { - __get__: () => protectedExport(getThreeDomainSecureComponent()), + __get__: () => devEnvOnlyExport(getThreeDomainSecureComponent()), }; export const postRobot: LazyProtectedExport = { From 2028a84ab281955d42a3a7a877f95c03e2b5058e Mon Sep 17 00:00:00 2001 From: Shraddha Shah Date: Sun, 24 Nov 2024 00:55:41 -0800 Subject: [PATCH 3/3] fix karma test --- src/interface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interface.js b/src/interface.js index e8909059..b7108fe8 100644 --- a/src/interface.js +++ b/src/interface.js @@ -27,7 +27,7 @@ function protectedExport(xport: T): ?T { // $FlowIssue export const devEnvOnlyExport = (unprotectedExport) => { const env = getEnv(); - if (env === ENV.LOCAL || env === ENV.STAGE) { + if (env === ENV.LOCAL || env === ENV.STAGE || env === ENV.TEST) { return unprotectedExport; } else { return undefined;