-
Notifications
You must be signed in to change notification settings - Fork 26
feat: new folder structure #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eea7f80
Move oneTimePayment/react to prebuiltPages/react
nbierdeman ba6ee87
Move oneTimePayment and savePayment to paypalPayments and venmoPayments
nbierdeman ef99fbb
Update path in README
nbierdeman 211cbc5
Remove venmo button from paypalPayments
nbierdeman e876f27
Remove paypal buttons from venmoPayments
nbierdeman 381330d
Remove savePayment recommended landing page
nbierdeman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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 hidden or 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 hidden or 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions
21
client/components/venmoPayments/oneTimePayment/html/README.md
This file contains hidden or 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,21 @@ | ||
| # One-Time Payments HTML Sample Integration | ||
|
|
||
| This HTML sample integration uses HTML, JavaScript, and CSS. It does not require a build process to transpile the source code. It's just static files that can be served up by any web server. [Vite](https://vite.dev/) is used for the local web server to provide the following functionality: | ||
|
|
||
| 1. Serve up the static HTML and JavaScript files. | ||
| 2. Proxy the API server so both the client and server are running on port 3000. | ||
|
|
||
| ## How to Run Locally | ||
|
|
||
| ```bash | ||
| npm install | ||
| npm start | ||
| ``` | ||
|
|
||
| ### Sample Integrations | ||
|
|
||
| | Sample Integration | Description | | ||
| | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | [Recommended](src/recommended/index.html) | Start with this recommended sample integration. It displays all buttons supported by the v6 SDK and includes eligibility logic. It uses the "auto" presentation mode which attempts to launch a popup window and then automatically falls back to the modal presentation mode when the browser does not support popups. | | ||
| | [Custom Payment Handler](src/custom/paymentHandler/index.html) | This custom integration uses the experimental "payment-handler" presentation mode. It teaches how to control the fallback logic for presentation modes based on what the browser supports. | | ||
| | [Custom Sandboxed Iframe](src/custom/sandboxedIframe/README.md) | This custom integration demonstrates how a merchant can wrap the v6 SDK integration code into their own iframe and what values need to be passed to the [iframe sandbox attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox). It does require two web servers to demonstrate the use case. Refer to the README in the src/custom/sandboxedIframe directory to learn more. | |
19 changes: 19 additions & 0 deletions
19
client/components/venmoPayments/oneTimePayment/html/package.json
This file contains hidden or 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,19 @@ | ||
| { | ||
| "name": "v6-web-sdk-sample-integration-client-html", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "vite build", | ||
| "preview": "vite preview", | ||
| "start": "vite", | ||
| "format": "prettier . --write", | ||
| "format:check": "prettier . --check", | ||
| "lint": "echo \"eslint is not set up\"" | ||
| }, | ||
| "license": "Apache-2.0", | ||
| "devDependencies": { | ||
| "prettier": "^3.5.3", | ||
| "vite": "^6.2.0" | ||
| } | ||
| } |
97 changes: 97 additions & 0 deletions
97
client/components/venmoPayments/oneTimePayment/html/src/app.js
This file contains hidden or 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,97 @@ | ||
| async function onPayPalLoaded() { | ||
| try { | ||
| const clientToken = await getBrowserSafeClientToken(); | ||
| const sdkInstance = await window.paypal.createInstance({ | ||
| clientToken, | ||
| components: ["venmo-payments"], | ||
| pageType: "checkout", | ||
| }); | ||
|
|
||
| const paymentMethods = await sdkInstance.findEligibleMethods({ | ||
| currencyCode: "USD", | ||
| }); | ||
|
|
||
| if (paymentMethods.isEligible("venmo")) { | ||
| setupVenmoButton(sdkInstance); | ||
| } | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| } | ||
|
|
||
| const paymentSessionOptions = { | ||
| async onApprove(data) { | ||
| console.log("onApprove", data); | ||
| const orderData = await captureOrder({ | ||
| orderId: data.orderId, | ||
| }); | ||
| console.log("Capture result", orderData); | ||
| }, | ||
| onCancel(data) { | ||
| console.log("onCancel", data); | ||
| }, | ||
| onError(error) { | ||
| console.log("onError", error); | ||
| }, | ||
| }; | ||
|
|
||
| async function setupVenmoButton(sdkInstance) { | ||
| const venmoPaymentSession = sdkInstance.createVenmoOneTimePaymentSession( | ||
| paymentSessionOptions, | ||
| ); | ||
| const venmoButton = document.querySelector("#venmo-button"); | ||
| venmoButton.removeAttribute("hidden"); | ||
|
|
||
| venmoButton.addEventListener("click", async () => { | ||
| try { | ||
| await venmoPaymentSession.start( | ||
| { presentationMode: "auto" }, | ||
| createOrder(), | ||
| ); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| async function getBrowserSafeClientToken() { | ||
| const response = await fetch("/paypal-api/auth/browser-safe-client-token", { | ||
| method: "GET", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| }, | ||
| }); | ||
| const { accessToken } = await response.json(); | ||
|
|
||
| return accessToken; | ||
| } | ||
|
|
||
| async function createOrder() { | ||
| const response = await fetch( | ||
| "/paypal-api/checkout/orders/create-with-sample-data", | ||
| { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| }, | ||
| }, | ||
| ); | ||
| const { id } = await response.json(); | ||
|
|
||
| return { orderId: id }; | ||
| } | ||
|
|
||
| async function captureOrder({ orderId }) { | ||
| const response = await fetch( | ||
| `/paypal-api/checkout/orders/${orderId}/capture`, | ||
| { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| }, | ||
| }, | ||
| ); | ||
| const data = await response.json(); | ||
|
|
||
| return data; | ||
| } |
29 changes: 29 additions & 0 deletions
29
client/components/venmoPayments/oneTimePayment/html/src/index.html
This file contains hidden or 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,29 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <title>One-Time Payment - Recommended Integration - PayPal Web SDK</title> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <style> | ||
| .buttons-container { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 12px; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <h1>One-Time Payment Recommended Integration</h1> | ||
|
|
||
| <div class="buttons-container"> | ||
| <venmo-button id="venmo-button" type="pay" hidden></venmo-button> | ||
| </div> | ||
| <script src="app.js"></script> | ||
|
|
||
| <script | ||
| async | ||
| src="https://www.sandbox.paypal.com/web-sdk/v6/core" | ||
| onload="onPayPalLoaded()" | ||
| ></script> | ||
| </body> | ||
| </html> |
17 changes: 17 additions & 0 deletions
17
client/components/venmoPayments/oneTimePayment/html/vite.config.js
This file contains hidden or 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,17 @@ | ||
| import { defineConfig } from "vite"; | ||
|
|
||
| // https://vitejs.dev/config/ | ||
| export default defineConfig({ | ||
| plugins: [], | ||
| root: "src", | ||
| server: { | ||
| port: 3000, | ||
| proxy: { | ||
| "/paypal-api": { | ||
| target: "http://localhost:8080", | ||
| changeOrigin: true, | ||
| secure: false, | ||
| }, | ||
| }, | ||
| }, | ||
| }); |
File renamed without changes.
File renamed without changes.
This file contains hidden or 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why is the
venmo-buttonremoved?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is under
paypalPayments. There's a venmo button example undervenmoPayments.