From 358c9d42bceaf60e8a71d3ccdf7be80f412720d2 Mon Sep 17 00:00:00 2001 From: Charlie Dibble Date: Mon, 6 Nov 2023 11:07:21 -0800 Subject: [PATCH] rename to connect, move code directly for now --- src/interface/axo.js | 7 ------- src/interface/connect.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) delete mode 100644 src/interface/axo.js create mode 100644 src/interface/connect.js diff --git a/src/interface/axo.js b/src/interface/axo.js deleted file mode 100644 index 1122901ca0..0000000000 --- a/src/interface/axo.js +++ /dev/null @@ -1,7 +0,0 @@ -/* @flow */ -import type { LazyExport } from "../types"; -import { getAxoComponent, type AXOComponent } from "../zoid/axo"; - -export const AXO: LazyExport = { - __get__: getAxoComponent, -}; diff --git a/src/interface/connect.js b/src/interface/connect.js new file mode 100644 index 0000000000..444b43e070 --- /dev/null +++ b/src/interface/connect.js @@ -0,0 +1,39 @@ +/* @flow */ +import type { LazyExport } from "../types"; +import { getAxoComponent, type AXOComponent } from "../zoid/axo"; +import { loadConnectScript } from "@paypal/connect-loader-component"; +import { + getClientID, + getClientMetadataID, + getUserIDToken, +} from "@paypal/sdk-client/src"; + +// eslint-disable-next-line flowtype/no-weak-types +export type AXOComponent = any; + +// TODO: What's the expected structure/approach for this interface. It's not a zoid +// scenario, so what do we return? +// -> Looks like it returns a function that accepts the props +// How do we define the input of merchant params here? +export const AXO: LazyExport = { + __get__: () => { + return async (merchantProps) => { + const cmid = getClientMetadataID(); + const clientID = getClientID(); + const userIdToken = getUserIDToken(); + // TODO: Sort out integration specifics for inputs + try { + const loadResult = await loadConnectScript(); + return window.braintree.connect.create({ + ...loadResult.metadata, + ...merchantProps, + cmid, + clientID, + userIdToken, + }); + } catch (error) { + return new Error(error); + } + }; + }, +};