-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
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,7 @@ | ||
export interface PayPalHostedButtonsComponentOptions { | ||
hostedButtonId: string; | ||
} | ||
|
||
export interface PayPalHostedButtonsComponent { | ||
render: (container: HTMLElement | string) => Promise<void>; | ||
} |
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
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,28 @@ | ||
import { loadScript } from "../../src/index"; | ||
import type { PayPalNamespace } from "../index"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
async function main() { | ||
let paypal: PayPalNamespace | null; | ||
|
||
try { | ||
paypal = await loadScript({ | ||
clientId: "test", | ||
components: "buttons", | ||
}); | ||
} catch (err) { | ||
throw new Error(`Failed to load the paypal sdk script: ${err}`); | ||
} | ||
|
||
if (!paypal?.HostedButtons) { | ||
throw new Error("Invalid paypal object for buttons component"); | ||
} | ||
|
||
paypal.HostedButtons().render("#container"); | ||
paypal.HostedButtons().render(document.createElement("div")); | ||
paypal | ||
.HostedButtons({ | ||
hostedButtonId: "B123456789", | ||
}) | ||
.render("#container"); | ||
} |