-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename to connect, move code directly for now
- Loading branch information
Showing
2 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AXOComponent> = { | ||
__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); | ||
} | ||
}; | ||
}, | ||
}; |