diff --git a/.devcontainer/advanced-integration/devcontainer.json b/.devcontainer/advanced-integration/devcontainer.json
index 7eb20bdd..2e840f6f 100644
--- a/.devcontainer/advanced-integration/devcontainer.json
+++ b/.devcontainer/advanced-integration/devcontainer.json
@@ -1,44 +1,40 @@
// For more details, see https://aka.ms/devcontainer.json.
{
- "name": "PayPal Advanced Integration",
- "image": "mcr.microsoft.com/devcontainers/javascript-node:20",
- "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/advanced-integration",
- // Use 'onCreateCommand' to run commands when creating the container.
- "onCreateCommand": "bash ../.devcontainer/advanced-integration/welcome-message.sh",
- // Use 'postCreateCommand' to run commands after the container is created.
- "postCreateCommand": "npm install",
- // Use 'postAttachCommand' to run commands when attaching to the container.
- "postAttachCommand": {
- "Start server": "npm start"
- },
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
- "forwardPorts": [
- 8888
- ],
- "portsAttributes": {
- "8888": {
- "label": "Preview of Advanced Checkout Flow",
- "onAutoForward": "openBrowserOnce"
- }
- },
- "secrets": {
- "PAYPAL_CLIENT_ID": {
- "description": "Sandbox client ID of the application.",
- "documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
- },
- "PAYPAL_CLIENT_SECRET": {
- "description": "Sandbox secret of the application.",
- "documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
- }
- },
- "customizations": {
- "vscode": {
- "extensions": [
- "vsls-contrib.codetour"
- ],
- "settings": {
- "git.openRepositoryInParentFolders": "always"
- }
- }
- }
-}
\ No newline at end of file
+ "name": "PayPal Advanced Integration",
+ "image": "mcr.microsoft.com/devcontainers/javascript-node:20",
+ "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/advanced-integration",
+ // Use 'onCreateCommand' to run commands when creating the container.
+ "onCreateCommand": "bash ../.devcontainer/advanced-integration/welcome-message.sh",
+ // Use 'postCreateCommand' to run commands after the container is created.
+ "postCreateCommand": "npm install",
+ // Use 'postAttachCommand' to run commands when attaching to the container.
+ "postAttachCommand": {
+ "Start server": "npm start"
+ },
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
+ "forwardPorts": [8888],
+ "portsAttributes": {
+ "8888": {
+ "label": "Preview of Advanced Checkout Flow",
+ "onAutoForward": "openBrowserOnce"
+ }
+ },
+ "secrets": {
+ "PAYPAL_CLIENT_ID": {
+ "description": "Sandbox client ID of the application.",
+ "documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
+ },
+ "PAYPAL_CLIENT_SECRET": {
+ "description": "Sandbox secret of the application.",
+ "documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
+ }
+ },
+ "customizations": {
+ "vscode": {
+ "extensions": ["vsls-contrib.codetour"],
+ "settings": {
+ "git.openRepositoryInParentFolders": "always"
+ }
+ }
+ }
+}
diff --git a/.devcontainer/standard-integration/devcontainer.json b/.devcontainer/standard-integration/devcontainer.json
index 742d6534..846dd982 100644
--- a/.devcontainer/standard-integration/devcontainer.json
+++ b/.devcontainer/standard-integration/devcontainer.json
@@ -1,44 +1,40 @@
// For more details, see https://aka.ms/devcontainer.json.
{
- "name": "PayPal Standard Integration",
- "image": "mcr.microsoft.com/devcontainers/javascript-node:20",
- "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/standard-integration",
- // Use 'onCreateCommand' to run commands when creating the container.
- "onCreateCommand": "bash ../.devcontainer/standard-integration/welcome-message.sh",
- // Use 'postCreateCommand' to run commands after the container is created.
- "postCreateCommand": "npm install",
- // Use 'postAttachCommand' to run commands when attaching to the container.
- "postAttachCommand": {
- "Start server": "npm start"
- },
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
- "forwardPorts": [
- 8888
- ],
- "portsAttributes": {
- "8888": {
- "label": "Preview of Standard Checkout Flow",
- "onAutoForward": "openBrowserOnce"
- }
- },
- "secrets": {
- "PAYPAL_CLIENT_ID": {
- "description": "Sandbox client ID of the application.",
- "documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
- },
- "PAYPAL_CLIENT_SECRET": {
- "description": "Sandbox secret of the application.",
- "documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
- }
- },
- "customizations": {
- "vscode": {
- "extensions": [
- "vsls-contrib.codetour"
- ],
- "settings": {
- "git.openRepositoryInParentFolders": "always"
- }
- }
- }
-}
\ No newline at end of file
+ "name": "PayPal Standard Integration",
+ "image": "mcr.microsoft.com/devcontainers/javascript-node:20",
+ "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/standard-integration",
+ // Use 'onCreateCommand' to run commands when creating the container.
+ "onCreateCommand": "bash ../.devcontainer/standard-integration/welcome-message.sh",
+ // Use 'postCreateCommand' to run commands after the container is created.
+ "postCreateCommand": "npm install",
+ // Use 'postAttachCommand' to run commands when attaching to the container.
+ "postAttachCommand": {
+ "Start server": "npm start"
+ },
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
+ "forwardPorts": [8888],
+ "portsAttributes": {
+ "8888": {
+ "label": "Preview of Standard Checkout Flow",
+ "onAutoForward": "openBrowserOnce"
+ }
+ },
+ "secrets": {
+ "PAYPAL_CLIENT_ID": {
+ "description": "Sandbox client ID of the application.",
+ "documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
+ },
+ "PAYPAL_CLIENT_SECRET": {
+ "description": "Sandbox secret of the application.",
+ "documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
+ }
+ },
+ "customizations": {
+ "vscode": {
+ "extensions": ["vsls-contrib.codetour"],
+ "settings": {
+ "git.openRepositoryInParentFolders": "always"
+ }
+ }
+ }
+}
diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml
index ca6da048..ba842418 100644
--- a/.github/workflows/validate.yml
+++ b/.github/workflows/validate.yml
@@ -21,7 +21,15 @@ jobs:
node-version: 18
- name: ๐งน Check code formatting with Prettier
- run: find . -name package.json -maxdepth 2 -type f -execdir npm run format:check ';'
+ run: >
+ find . -name package.json -maxdepth 2 -type f | while read -r file; do
+ directory=$(dirname "$file")
+ cd "$directory" && npm run format:check && cd -
+ done
- - name: ๐ Lint Node.js code with ESLint
- run: find . -name package.json -maxdepth 2 -type f -execdir npm run lint ';'
+ - name: ๐ Lint code with ESLint
+ run: >
+ find . -name package.json -maxdepth 2 -type f | while read -r file; do
+ directory=$(dirname "$file")
+ cd "$directory" && npm run lint && cd -
+ done
diff --git a/advanced-integration/client/app.js b/advanced-integration/client/app.js
index 43fb25d9..65f048d7 100644
--- a/advanced-integration/client/app.js
+++ b/advanced-integration/client/app.js
@@ -96,7 +96,7 @@ async function onApproveCallback(data, actions) {
}
}
-paypal
+window.paypal
.Buttons({
createOrder: createOrderCallback,
onApprove: onApproveCallback,
@@ -110,9 +110,9 @@ function resultMessage(message) {
}
// If this returns false or the card fields aren't visible, see Step #1.
-if (paypal.HostedFields.isEligible()) {
+if (window.paypal.HostedFields.isEligible()) {
// Renders card fields
- paypal.HostedFields.render({
+ window.paypal.HostedFields.render({
// Call your server to set up the transaction
createOrder: createOrderCallback,
styles: {
@@ -172,10 +172,9 @@ if (paypal.HostedFields.isEligible()) {
return onApproveCallback(data);
})
.catch((orderData) => {
- const { links, ...errorMessageData } = orderData;
resultMessage(
`Sorry, your transaction could not be processed...
${JSON.stringify(
- errorMessageData,
+ orderData,
)}`,
);
});