diff --git a/package.json b/package.json index 4993ffcc0d..3dade67ad4 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ "@krakenjs/zoid": "^10.3.1", "@paypal/common-components": "^1.0.35", "@paypal/funding-components": "^1.0.31", + "@paypal/connect-loader-component": "^1.0.0", "@paypal/sdk-client": "^4.0.176", "@paypal/sdk-constants": "^1.0.133", "@paypal/sdk-logos": "^2.2.6" diff --git a/src/interface/axo.js b/src/interface/axo.js new file mode 100644 index 0000000000..1122901ca0 --- /dev/null +++ b/src/interface/axo.js @@ -0,0 +1,7 @@ +/* @flow */ +import type { LazyExport } from "../types"; +import { getAxoComponent, type AXOComponent } from "../zoid/axo"; + +export const AXO: LazyExport = { + __get__: getAxoComponent, +}; diff --git a/src/zoid/axo/component.jsx b/src/zoid/axo/component.jsx new file mode 100644 index 0000000000..2d048ceaf2 --- /dev/null +++ b/src/zoid/axo/component.jsx @@ -0,0 +1,20 @@ +/* @flow */ +/** @jsx node */ +/* eslint max-lines: 0 */ + +import { loadConnectScript } from "@paypal/connect-loader-component"; +import { getClientID, getClientMetadataID } from "@paypal/sdk-client/src"; +// eslint-disable-next-line flowtype/no-weak-types +export type AXOComponent = any; + +export function getAxoComponent(): AXOComponent { + const cmid = getClientMetadataID(); + const clientID = getClientID(); + // this will change to whatever options we received + // from the merchant + try { + return loadConnectScript({ cmid, clientID }); + } catch (error) { + return new Error(error); + } +} diff --git a/src/zoid/axo/index.js b/src/zoid/axo/index.js new file mode 100644 index 0000000000..c35c42e094 --- /dev/null +++ b/src/zoid/axo/index.js @@ -0,0 +1,3 @@ +/* @flow */ + +export * from "./component";