diff --git a/.devcontainer/advanced-integration-v1/devcontainer.json b/.devcontainer/advanced-integration-v1/devcontainer.json index ffb6f41c..9ce61d30 100644 --- a/.devcontainer/advanced-integration-v1/devcontainer.json +++ b/.devcontainer/advanced-integration-v1/devcontainer.json @@ -1,6 +1,6 @@ // For more details, see https://aka.ms/devcontainer.json. { - "name": "PayPal Advanced Integration (v1)", + "name": "advanced-integration-v1", "image": "mcr.microsoft.com/devcontainers/javascript-node:20", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/advanced-integration/v1", // Use 'onCreateCommand' to run commands when creating the container. diff --git a/.devcontainer/advanced-integration-v2-html-dotnet/devcontainer.json b/.devcontainer/advanced-integration-v2-html-dotnet/devcontainer.json new file mode 100644 index 00000000..2ef1ead0 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-dotnet/devcontainer.json @@ -0,0 +1,56 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/html/dotnet", + "image": "mcr.microsoft.com/devcontainers/dotnet:8.0", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-html-dotnet/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Advanced Checkout Flow" + }, + "3000": { + "label": "HTML", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "dotnet", + "VISIBLE_FOLDER_CLIENT": "html", + "VISIBLE_FOLDER_PROJECT": "advanced-integration", + "VISIBLE_FOLDER_VERSION": "v2" + }, + "customizations": { + "vscode": { + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "ms-dotnettools.csharp" + ], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/advanced-integration-v2/welcome-message.sh b/.devcontainer/advanced-integration-v2-html-dotnet/welcome-message.sh similarity index 100% rename from .devcontainer/advanced-integration-v2/welcome-message.sh rename to .devcontainer/advanced-integration-v2-html-dotnet/welcome-message.sh diff --git a/.devcontainer/advanced-integration-v2-html-java/devcontainer.json b/.devcontainer/advanced-integration-v2-html-java/devcontainer.json new file mode 100644 index 00000000..3dcae617 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-java/devcontainer.json @@ -0,0 +1,57 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/html/java", + "image": "mcr.microsoft.com/devcontainers/java:21", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-html-java/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Advanced Checkout Flow" + }, + "3000": { + "label": "HTML", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "java", + "VISIBLE_FOLDER_CLIENT": "html", + "VISIBLE_FOLDER_PROJECT": "advanced-integration", + "VISIBLE_FOLDER_VERSION": "v2" + }, + "customizations": { + "vscode": { + "extensions": ["vsls-contrib.codetour", "PayPal.vscode-paypal"], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "22", + "jdkDistro": "tem", + "installMaven": "true" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} \ No newline at end of file diff --git a/.devcontainer/advanced-integration-v2-html-java/welcome-message.sh b/.devcontainer/advanced-integration-v2-html-java/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-java/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/advanced-integration-v2-html-node/devcontainer.json b/.devcontainer/advanced-integration-v2-html-node/devcontainer.json new file mode 100644 index 00000000..f5f00400 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-node/devcontainer.json @@ -0,0 +1,56 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/html/node", + "image": "mcr.microsoft.com/devcontainers/javascript-node:20", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-html-node/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Advanced Checkout Flow" + }, + "3000": { + "label": "HTML", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "node", + "VISIBLE_FOLDER_CLIENT": "html", + "VISIBLE_FOLDER_PROJECT": "advanced-integration", + "VISIBLE_FOLDER_VERSION": "v2" + }, + "customizations": { + "vscode": { + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "dbaeumer.vscode-eslint" + ], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/advanced-integration-v2-html-node/welcome-message.sh b/.devcontainer/advanced-integration-v2-html-node/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-node/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/advanced-integration-v2-html-php/devcontainer.json b/.devcontainer/advanced-integration-v2-html-php/devcontainer.json new file mode 100644 index 00000000..6afcc17b --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-php/devcontainer.json @@ -0,0 +1,56 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/html/php", + "image": "mcr.microsoft.com/devcontainers/php:8", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-html-php/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Advanced Checkout Flow" + }, + "3000": { + "label": "HTML", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "php", + "VISIBLE_FOLDER_CLIENT": "html", + "VISIBLE_FOLDER_PROJECT": "advanced-integration", + "VISIBLE_FOLDER_VERSION": "v2" + }, + "customizations": { + "vscode": { + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "xdebug.php-debug" + ], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} \ No newline at end of file diff --git a/.devcontainer/advanced-integration-v2-html-php/welcome-message.sh b/.devcontainer/advanced-integration-v2-html-php/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-php/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/advanced-integration-v2-react-dotnet/devcontainer.json b/.devcontainer/advanced-integration-v2-react-dotnet/devcontainer.json new file mode 100644 index 00000000..a4911ab0 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-dotnet/devcontainer.json @@ -0,0 +1,56 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": " advanced-integration-v2/react/dotnet", + "image": "mcr.microsoft.com/devcontainers/dotnet:8.0", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-react-dotnet/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Advanced Checkout Flow" + }, + "3000": { + "label": "React", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "dotnet", + "VISIBLE_FOLDER_CLIENT": "react", + "VISIBLE_FOLDER_PROJECT": "advanced-integration", + "VISIBLE_FOLDER_VERSION": "v2" + }, + "customizations": { + "vscode": { + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "ms-dotnettools.csharp" + ], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/advanced-integration-v2-react-dotnet/welcome-message.sh b/.devcontainer/advanced-integration-v2-react-dotnet/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-dotnet/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/advanced-integration-v2-react-java/devcontainer.json b/.devcontainer/advanced-integration-v2-react-java/devcontainer.json new file mode 100644 index 00000000..e55feb54 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-java/devcontainer.json @@ -0,0 +1,57 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/react/java", + "image": "mcr.microsoft.com/devcontainers/java:21", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-react-java/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Advanced Checkout Flow" + }, + "3000": { + "label": "React", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "java", + "VISIBLE_FOLDER_CLIENT": "react", + "VISIBLE_FOLDER_PROJECT": "advanced-integration", + "VISIBLE_FOLDER_VERSION": "v2" + }, + "customizations": { + "vscode": { + "extensions": ["vsls-contrib.codetour", "PayPal.vscode-paypal"], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "22", + "jdkDistro": "tem", + "installMaven": "true" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} \ No newline at end of file diff --git a/.devcontainer/advanced-integration-v2-react-java/welcome-message.sh b/.devcontainer/advanced-integration-v2-react-java/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-java/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/advanced-integration-v2-react-node/devcontainer.json b/.devcontainer/advanced-integration-v2-react-node/devcontainer.json new file mode 100644 index 00000000..2efab718 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-node/devcontainer.json @@ -0,0 +1,56 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/react/node", + "image": "mcr.microsoft.com/devcontainers/javascript-node:20", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-react-node/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Advanced Checkout Flow" + }, + "3000": { + "label": "React", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "node", + "VISIBLE_FOLDER_CLIENT": "react", + "VISIBLE_FOLDER_PROJECT": "advanced-integration", + "VISIBLE_FOLDER_VERSION": "v2" + }, + "customizations": { + "vscode": { + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "dbaeumer.vscode-eslint" + ], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/advanced-integration-v2-react-node/welcome-message.sh b/.devcontainer/advanced-integration-v2-react-node/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-node/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/advanced-integration-v2-react-php/devcontainer.json b/.devcontainer/advanced-integration-v2-react-php/devcontainer.json new file mode 100644 index 00000000..4980fd30 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-php/devcontainer.json @@ -0,0 +1,56 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/react/php", + "image": "mcr.microsoft.com/devcontainers/php:8", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-react-php/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Advanced Checkout Flow" + }, + "3000": { + "label": "React", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "php", + "VISIBLE_FOLDER_CLIENT": "react", + "VISIBLE_FOLDER_PROJECT": "advanced-integration", + "VISIBLE_FOLDER_VERSION": "v2" + }, + "customizations": { + "vscode": { + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "xdebug.php-debug" + ], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} \ No newline at end of file diff --git a/.devcontainer/advanced-integration-v2-react-php/welcome-message.sh b/.devcontainer/advanced-integration-v2-react-php/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-php/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Advanced Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/post-commands.sh b/.devcontainer/post-commands.sh new file mode 100755 index 00000000..ffdf0fc3 --- /dev/null +++ b/.devcontainer/post-commands.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +WORKSPACE_DIR="$( cd "$SCRIPT_DIR/.." &> /dev/null && pwd )" + +VISIBLE_FOLDER_SERVER="${VISIBLE_FOLDER_SERVER}" +VISIBLE_FOLDER_CLIENT="${VISIBLE_FOLDER_CLIENT}" +VISIBLE_FOLDER_PROJECT="${VISIBLE_FOLDER_PROJECT}" +VISIBLE_FOLDER_VERSION="${VISIBLE_FOLDER_VERSION}" + +# Set up SERVER_DIR & CLIENT_DIR +if [ -z "$VISIBLE_FOLDER_VERSION" ]; then + SERVER_DIR="${WORKSPACE_DIR}/${VISIBLE_FOLDER_PROJECT}/server" + CLIENT_DIR="${WORKSPACE_DIR}/${VISIBLE_FOLDER_PROJECT}/client/${VISIBLE_FOLDER_CLIENT}" +else + SERVER_DIR="${WORKSPACE_DIR}/${VISIBLE_FOLDER_PROJECT}/${VISIBLE_FOLDER_VERSION}/server" + CLIENT_DIR="${WORKSPACE_DIR}/${VISIBLE_FOLDER_PROJECT}/${VISIBLE_FOLDER_VERSION}/client/${VISIBLE_FOLDER_CLIENT}/client" +fi + +# Backend setup functions +setup_backend() { + case "$VISIBLE_FOLDER_SERVER" in + node) + cd "$SERVER_DIR/node" && npm install + ;; + java) + cd "$SERVER_DIR" && cd java && mvn clean install + ;; + dotnet) + cd "$SERVER_DIR/dotnet" && dotnet restore + ;; + php) + cd "$SERVER_DIR" && cd php && composer install + ;; + *) + echo "Unknown server: $VISIBLE_FOLDER_SERVER" + exit 1 + ;; + esac +} + +# Frontend setup functions +setup_frontend() { + cd "$CLIENT_DIR" && npm install +} + +# Backend start functions +start_backend() { + case "$VISIBLE_FOLDER_SERVER" in + node) + cd "$SERVER_DIR/node" && npm start + ;; + java) + cd "$SERVER_DIR/java" && mvn spring-boot:run + ;; + dotnet) + cd "$SERVER_DIR/dotnet" && dotnet run + ;; + php) + cd "$SERVER_DIR/php" && composer start + ;; + *) + echo "Unknown server: $VISIBLE_FOLDER_SERVER" + exit 1 + ;; + esac +} + +# Frontend start functions +start_frontend() { + cd "$CLIENT_DIR" && npm run start --no-analytics +} + +# Post-create commands +post_create() { + echo "Running post-create commands..." + setup_backend + setup_frontend +} + +# Post-attach commands +post_attach() { + echo "Running post-attach commands..." + start_backend & + start_frontend +} + +# Main execution +case "$1" in + post-create) + post_create + ;; + post-attach) + post_attach + ;; + *) + echo "Usage: $0 {post-create|post-attach}" + exit 1 + ;; +esac + +exit 0 \ No newline at end of file diff --git a/.devcontainer/save-payment-method/devcontainer.json b/.devcontainer/save-payment-method/devcontainer.json index ec88eb6c..88b05faa 100644 --- a/.devcontainer/save-payment-method/devcontainer.json +++ b/.devcontainer/save-payment-method/devcontainer.json @@ -1,6 +1,6 @@ // For more details, see https://aka.ms/devcontainer.json. { - "name": "PayPal Save Payment Method", + "name": "save-payment-metthod", "image": "mcr.microsoft.com/devcontainers/javascript-node:20", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/save-payment-method", // Use 'onCreateCommand' to run commands when creating the container. diff --git a/.devcontainer/standard-integration-html-dotnet/devcontainer.json b/.devcontainer/standard-integration-html-dotnet/devcontainer.json new file mode 100644 index 00000000..810ffa39 --- /dev/null +++ b/.devcontainer/standard-integration-html-dotnet/devcontainer.json @@ -0,0 +1,55 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "standard-integration/html/dotnet", + "image": "mcr.microsoft.com/devcontainers/dotnet:8.0", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/standard-integration-html-dotnet/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Standard Checkout Flow" + }, + "3000": { + "label": "HTML", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "dotnet", + "VISIBLE_FOLDER_CLIENT": "html", + "VISIBLE_FOLDER_PROJECT": "standard-integration" + }, + "customizations": { + "vscode": { + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "ms-dotnettools.csharp" + ], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/standard-integration/welcome-message.sh b/.devcontainer/standard-integration-html-dotnet/welcome-message.sh similarity index 100% rename from .devcontainer/standard-integration/welcome-message.sh rename to .devcontainer/standard-integration-html-dotnet/welcome-message.sh diff --git a/.devcontainer/standard-integration-html-java/devcontainer.json b/.devcontainer/standard-integration-html-java/devcontainer.json new file mode 100644 index 00000000..88f7280a --- /dev/null +++ b/.devcontainer/standard-integration-html-java/devcontainer.json @@ -0,0 +1,56 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "standard-integration/html/java", + "image": "mcr.microsoft.com/devcontainers/java:21", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/standard-integration-html-java/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Standard Checkout Flow" + }, + "3000": { + "label": "Html", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "java", + "VISIBLE_FOLDER_CLIENT": "html", + "VISIBLE_FOLDER_PROJECT": "standard-integration" + }, + "customizations": { + "vscode": { + "extensions": ["vsls-contrib.codetour", "PayPal.vscode-paypal"], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "22", + "jdkDistro": "tem", + "installMaven": "true" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} \ No newline at end of file diff --git a/.devcontainer/standard-integration-html-java/welcome-message.sh b/.devcontainer/standard-integration-html-java/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-html-java/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/advanced-integration-v2/devcontainer.json b/.devcontainer/standard-integration-html-node/devcontainer.json similarity index 55% rename from .devcontainer/advanced-integration-v2/devcontainer.json rename to .devcontainer/standard-integration-html-node/devcontainer.json index 6fd991e1..beaa4863 100644 --- a/.devcontainer/advanced-integration-v2/devcontainer.json +++ b/.devcontainer/standard-integration-html-node/devcontainer.json @@ -1,25 +1,22 @@ // For more details, see https://aka.ms/devcontainer.json. { - "name": "PayPal Advanced Integration (v2)", + "name": "standard-integration/html/node", "image": "mcr.microsoft.com/devcontainers/javascript-node:20", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/advanced-integration/v2", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", // Use 'onCreateCommand' to run commands when creating the container. - "onCreateCommand": "bash ../../.devcontainer/advanced-integration-v2/welcome-message.sh", + "onCreateCommand": "bash .devcontainer/standard-integration-html-node/welcome-message.sh", // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": { - "Install Server Packages": "cd server/node && npm install", - "Install Client Packages": "cd client/html && npm install" - }, + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", // Use 'postAttachCommand' to run commands when attaching to the container. - "postAttachCommand": { - "Start server": "cd server/node && npm start", - "Start client": "cd client/html && npm start" - }, + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [3000, 8080], "portsAttributes": { + "8080": { + "label": "Preview of Standard Checkout Flow" + }, "3000": { - "label": "Preview of Advanced Checkout Flow", + "label": "HTML", "onAutoForward": "openBrowserOnce" } }, @@ -33,12 +30,26 @@ "documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox" } }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "node", + "VISIBLE_FOLDER_CLIENT": "html", + "VISIBLE_FOLDER_PROJECT": "standard-integration" + }, "customizations": { "vscode": { - "extensions": ["vsls-contrib.codetour","PayPal.vscode-paypal"], + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "dbaeumer.vscode-eslint" + ], "settings": { "git.openRepositoryInParentFolders": "always" } } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } } } diff --git a/.devcontainer/standard-integration-html-node/welcome-message.sh b/.devcontainer/standard-integration-html-node/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-html-node/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/standard-integration-html-php/devcontainer.json b/.devcontainer/standard-integration-html-php/devcontainer.json new file mode 100644 index 00000000..fc60c8f7 --- /dev/null +++ b/.devcontainer/standard-integration-html-php/devcontainer.json @@ -0,0 +1,55 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "standard-integration/html/php", + "image": "mcr.microsoft.com/devcontainers/php:8", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/standard-integration-html-php/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Standard Checkout Flow" + }, + "3000": { + "label": "HTML", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "php", + "VISIBLE_FOLDER_CLIENT": "html", + "VISIBLE_FOLDER_PROJECT": "standard-integration" + }, + "customizations": { + "vscode": { + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "xdebug.php-debug" + ], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} \ No newline at end of file diff --git a/.devcontainer/standard-integration-html-php/welcome-message.sh b/.devcontainer/standard-integration-html-php/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-html-php/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/standard-integration-react-dotnet/devcontainer.json b/.devcontainer/standard-integration-react-dotnet/devcontainer.json new file mode 100644 index 00000000..d2a2e587 --- /dev/null +++ b/.devcontainer/standard-integration-react-dotnet/devcontainer.json @@ -0,0 +1,55 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "standard-integration/react/dotnet", + "image": "mcr.microsoft.com/devcontainers/dotnet:8.0", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/standard-integration-react-dotnet/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Standard Checkout Flow" + }, + "3000": { + "label": "React", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "dotnet", + "VISIBLE_FOLDER_CLIENT": "react", + "VISIBLE_FOLDER_PROJECT": "standard-integration" + }, + "customizations": { + "vscode": { + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "ms-dotnettools.csharp" + ], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/standard-integration-react-dotnet/welcome-message.sh b/.devcontainer/standard-integration-react-dotnet/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-react-dotnet/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/standard-integration-react-java/devcontainer.json b/.devcontainer/standard-integration-react-java/devcontainer.json new file mode 100644 index 00000000..d9f5d333 --- /dev/null +++ b/.devcontainer/standard-integration-react-java/devcontainer.json @@ -0,0 +1,56 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "standard-integration/react/java", + "image": "mcr.microsoft.com/devcontainers/java:21", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/standard-integration-react-java/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Standard Checkout Flow" + }, + "3000": { + "label": "React", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "java", + "VISIBLE_FOLDER_CLIENT": "react", + "VISIBLE_FOLDER_PROJECT": "standard-integration" + }, + "customizations": { + "vscode": { + "extensions": ["vsls-contrib.codetour", "PayPal.vscode-paypal"], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "22", + "jdkDistro": "tem", + "installMaven": "true" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} \ No newline at end of file diff --git a/.devcontainer/standard-integration-react-java/welcome-message.sh b/.devcontainer/standard-integration-react-java/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-react-java/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/standard-integration/devcontainer.json b/.devcontainer/standard-integration-react-node/devcontainer.json similarity index 55% rename from .devcontainer/standard-integration/devcontainer.json rename to .devcontainer/standard-integration-react-node/devcontainer.json index 508fb74b..fa64ab68 100644 --- a/.devcontainer/standard-integration/devcontainer.json +++ b/.devcontainer/standard-integration-react-node/devcontainer.json @@ -1,25 +1,22 @@ // For more details, see https://aka.ms/devcontainer.json. { - "name": "PayPal Standard Integration", + "name": "standard-integration/react/node", "image": "mcr.microsoft.com/devcontainers/javascript-node:20", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/standard-integration", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", // Use 'onCreateCommand' to run commands when creating the container. - "onCreateCommand": "bash ../.devcontainer/standard-integration/welcome-message.sh", + "onCreateCommand": "bash .devcontainer/standard-integration-react-node/welcome-message.sh", // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": { - "Install Client Packages": "cd client/html && npm install", - "Install Server Packages": "cd server/node && npm install" - }, + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", // Use 'postAttachCommand' to run commands when attaching to the container. - "postAttachCommand": { - "Start client": "cd client/html && npm start", - "Start server": "cd server/node && npm start" - }, + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [3000, 8080], "portsAttributes": { + "8080": { + "label": "Preview of Standard Checkout Flow" + }, "3000": { - "label": "Preview of Standard Checkout Flow", + "label": "React", "onAutoForward": "openBrowserOnce" } }, @@ -33,12 +30,26 @@ "documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox" } }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "node", + "VISIBLE_FOLDER_CLIENT": "react", + "VISIBLE_FOLDER_PROJECT": "standard-integration" + }, "customizations": { "vscode": { - "extensions": ["vsls-contrib.codetour","PayPal.vscode-paypal"], + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "dbaeumer.vscode-eslint" + ], "settings": { "git.openRepositoryInParentFolders": "always" } } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } } } diff --git a/.devcontainer/standard-integration-react-node/welcome-message.sh b/.devcontainer/standard-integration-react-node/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-react-node/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/standard-integration-react-php/devcontainer.json b/.devcontainer/standard-integration-react-php/devcontainer.json new file mode 100644 index 00000000..e5bfcf12 --- /dev/null +++ b/.devcontainer/standard-integration-react-php/devcontainer.json @@ -0,0 +1,55 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "standard-integration/react/php", + "image": "mcr.microsoft.com/devcontainers/php:8", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/standard-integration-react-php/welcome-message.sh", + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "chmod +x .devcontainer/update_settings.sh && .devcontainer/update_settings.sh && chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-create", + // Use 'postAttachCommand' to run commands when attaching to the container. + "postAttachCommand": "chmod +x .devcontainer/post-commands.sh && .devcontainer/post-commands.sh post-attach", + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 8080], + "portsAttributes": { + "8080": { + "label": "Preview of Standard Checkout Flow" + }, + "3000": { + "label": "React", + "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" + } + }, + "containerEnv": { + "VISIBLE_FOLDER_SERVER": "php", + "VISIBLE_FOLDER_CLIENT": "react", + "VISIBLE_FOLDER_PROJECT": "standard-integration" + }, + "customizations": { + "vscode": { + "extensions": [ + "vsls-contrib.codetour", + "PayPal.vscode-paypal", + "xdebug.php-debug" + ], + "settings": { + "git.openRepositoryInParentFolders": "always" + } + } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts" + } + } +} \ No newline at end of file diff --git a/.devcontainer/standard-integration-react-php/welcome-message.sh b/.devcontainer/standard-integration-react-php/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-react-php/welcome-message.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 Once you rename the \".env.example\" file to \".env\" and update \"PAYPAL_CLIENT_ID\" and \"PAYPAL_CLIENT_SECRET\", the checkout page will automatically open in the browser after the server is restarted." + +ALTERNATE_WELCOME_MESSAGE=" +👋 Welcome to the \"PayPal Standard Checkout Integration Example\" + +🛠️ Your environment is fully setup with all the required software. + +🚀 The checkout page will automatically open in the browser after the server is started." + +if [ -n "$PAYPAL_CLIENT_ID" ] && [ -n "$PAYPAL_CLIENT_SECRET" ]; then + WELCOME_MESSAGE="${ALTERNATE_WELCOME_MESSAGE}" +fi + +sudo bash -c "echo \"${WELCOME_MESSAGE}\" > /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/update_settings.sh b/.devcontainer/update_settings.sh new file mode 100755 index 00000000..736b30ff --- /dev/null +++ b/.devcontainer/update_settings.sh @@ -0,0 +1,140 @@ +#!/bin/bash + +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +WORKSPACE_DIR="$( cd "$SCRIPT_DIR/.." &> /dev/null && pwd )" + +VISIBLE_FOLDER_SERVER="$VISIBLE_FOLDER_SERVER" +VISIBLE_FOLDER_CLIENT="$VISIBLE_FOLDER_CLIENT" +VISIBLE_FOLDER_PROJECT="$VISIBLE_FOLDER_PROJECT" +VISIBLE_FOLDER_VERSION="$VISIBLE_FOLDER_VERSION" + +DEVCONTAINER_WORKSPACE="$WORKSPACE_DIR/.devcontainer" +SETTINGS_FILE="$WORKSPACE_DIR/.vscode/settings.json" +PROJECT_WORKSPACE="$WORKSPACE_DIR/$VISIBLE_FOLDER_PROJECT" + + +if [ -z "$VISIBLE_FOLDER_CLIENT" ]; then + echo "Error: VISIBLE_FOLDER_CLIENT is not set, setting it to default" + VISIBLE_FOLDER_CLIENT="DEFAULT" +fi + +if [ -z "$VISIBLE_FOLDER_VERSION" ]; then + SERVER_WORKSPACE="$WORKSPACE_DIR/$VISIBLE_FOLDER_PROJECT/server" + CLIENT_WORKSPACE="$WORKSPACE_DIR/$VISIBLE_FOLDER_PROJECT/client" + VERSION_WORKSPACE="$PROJECT_WORKSPACE" + VISIBLE_FOLDER_DEVCONTAINER="$VISIBLE_FOLDER_PROJECT-$VISIBLE_FOLDER_CLIENT-$VISIBLE_FOLDER_SERVER" + PROJECT_DIR="$VISIBLE_FOLDER_PROJECT" +else + SERVER_WORKSPACE="$WORKSPACE_DIR/$VISIBLE_FOLDER_PROJECT/$VISIBLE_FOLDER_VERSION/server" + CLIENT_WORKSPACE="$WORKSPACE_DIR/$VISIBLE_FOLDER_PROJECT/$VISIBLE_FOLDER_VERSION/client" + VERSION_WORKSPACE="$PROJECT_WORKSPACE/$VISIBLE_FOLDER_VERSION" + VISIBLE_FOLDER_DEVCONTAINER="$VISIBLE_FOLDER_PROJECT-$VISIBLE_FOLDER_VERSION-$VISIBLE_FOLDER_CLIENT-$VISIBLE_FOLDER_SERVER" + PROJECT_DIR="$VISIBLE_FOLDER_PROJECT/$VISIBLE_FOLDER_VERSION" + +fi +echo "SERVER_WORKSPACE:$SERVER_WORKSPACE" +echo "CLIENT_WORKSPACE:$CLIENT_WORKSPACE" +echo "VISIBLE_FOLDER_DEVCONTAINER:$VISIBLE_FOLDER_DEVCONTAINER" +echo "PROJECT_WORKSPACE:$PROJECT_WORKSPACE" + + +echo "Workspace directory: $WORKSPACE_DIR" +echo "Server directory: $SERVER_WORKSPACE" +echo "Visible server folder: $VISIBLE_FOLDER_SERVER" +echo "Visible client folder: $VISIBLE_FOLDER_CLIENT" +echo "Visible project folder: $VISIBLE_FOLDER_PROJECT" +echo "Visible version: $VISIBLE_FOLDER_VERSION" +echo "Visible devcontainer: $DEVCONTAINER_WORKSPACE" +if [ ! -d "$SERVER_WORKSPACE" ]; then + echo "Error: Server directory not found at $SERVER_WORKSPACE" + exit 1 +fi + +if [ ! -d "$DEVCONTAINER_WORKSPACE" ]; then + echo "Error: .devcontainer directory not found at $DEVCONTAINER_WORKSPACE" + exit 1 +fi + +if [ -z "$VISIBLE_FOLDER_SERVER" ]; then + echo "Error: VISIBLE_FOLDER_SERVER is not set" + exit 1 +fi + +mkdir -p "$(dirname "$SETTINGS_FILE")" + +echo "{ + \"files.exclude\": {" > "$SETTINGS_FILE" + +first=true + +for dir in "$WORKSPACE_DIR"/*/ ; do + dir_name=$(basename "$dir") + if [ -d "$dir" ] && [ "$dir_name" != "$VISIBLE_FOLDER_PROJECT" ]; then + if [ "$first" = true ] ; then + first=false + else + echo "," >> "$SETTINGS_FILE" + fi + echo -n " \"**/$dir_name\": true" >> "$SETTINGS_FILE" + fi +done + +if [ -n "$VISIBLE_FOLDER_VERSION" ]; then + for dir in "$PROJECT_WORKSPACE"/*/ ; do + dir_name=$(basename "$dir") + if [ -d "$dir" ] && [ "$dir_name" != "$VISIBLE_FOLDER_VERSION" ]; then + if [ "$first" = true ] ; then + first=false + else + echo "," >> "$SETTINGS_FILE" + fi + echo -n " \"**/$VISIBLE_FOLDER_PROJECT/$dir_name\": true" >> "$SETTINGS_FILE" + fi + done +fi + +for dir in "$DEVCONTAINER_WORKSPACE"/*/ ; do + dir_name=$(basename "$dir") + if [ -d "$dir" ] && [ "$dir_name" != "$VISIBLE_FOLDER_DEVCONTAINER" ]; then + if [ "$first" = true ] ; then + first=false + else + echo "," >> "$SETTINGS_FILE" + fi + echo -n " \"**/.devcontainer/$dir_name\": true" >> "$SETTINGS_FILE" + fi +done + +for dir in "$SERVER_WORKSPACE"/*/ ; do + dir_name=$(basename "$dir") + if [ -d "$dir" ] && [ "$dir_name" != "$VISIBLE_FOLDER_SERVER" ]; then + if [ "$first" = true ] ; then + first=false + else + echo "," >> "$SETTINGS_FILE" + fi + echo -n " \"**/$PROJECT_DIR/server/$dir_name\": true" >> "$SETTINGS_FILE" + fi +done + +for dir in "$CLIENT_WORKSPACE"/*/ ; do + dir_name=$(basename "$dir") + if [ -d "$dir" ] && [ "$dir_name" != "$VISIBLE_FOLDER_CLIENT" ]; then + if [ "$first" = true ] ; then + first=false + else + echo "," >> "$SETTINGS_FILE" + fi + echo -n " \"**/$PROJECT_DIR/client/$dir_name\": true" >> "$SETTINGS_FILE" + fi +done + +echo " + } +}" >> "$SETTINGS_FILE" + +echo "VS Code settings updated to show only $VISIBLE_FOLDER_SERVER and $VISIBLE_FOLDER_CLIENT folder in server directory." +echo "Contents of $SETTINGS_FILE:" +cat "$SETTINGS_FILE" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5df6b051..c889f486 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,10 @@ dist # dotnet *.sln + +# env +*.local + +#Codespace +.vscode/settings.json +.devcontainer/update_settings.sh diff --git a/README.md b/README.md index daf0636c..98fbede3 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,18 @@ These examples will ask you to run commands like `npm install` and `npm start`. You'll need a version of node >= 16 which can be downloaded from the [Node.js website](https://nodejs.org/en/download/). -## PayPal Codespaces +# Running on Codespaces +Follow below steps to use Codespaces. + +1) Click "New with options..." to open a page where you can choose the Dev container to run. +![image](https://github.com/user-attachments/assets/0d4bf202-0c94-42ec-aa2e-d8ccb6da9eb8) + +2) Choose the Dev container to run +![image](https://github.com/user-attachments/assets/b612467d-9fdc-4666-8dfa-0d99af6a2d39) + +3) Client ID and Client Secrets are required for running the application in codespace. +![image](https://github.com/user-attachments/assets/cbbc4521-aa43-403f-9243-e3c555e67f4a) -PayPal codespaces require a client ID and client secret for your app. ### Link to codespaces diff --git a/advanced-integration/v2/client/html/README.md b/advanced-integration/v2/client/html/README.md index 0ebb16ac..a98bb13f 100644 --- a/advanced-integration/v2/client/html/README.md +++ b/advanced-integration/v2/client/html/README.md @@ -20,7 +20,7 @@ This guide will walk you through setting up and running the HTML/JS Advanced Int ### Installation -```sh +```bash npm install ``` @@ -31,7 +31,7 @@ npm install - Rename the .env.example file to .env - Update the following keys with their actual values - - ```sh + ```bash PAYPAL_CLIENT_ID= ``` @@ -61,7 +61,7 @@ npm install - **Start the client**: - ```sh + ```bash npm run dev ``` diff --git a/advanced-integration/v2/client/react/README.md b/advanced-integration/v2/client/react/README.md index 6022519f..70f5f11e 100644 --- a/advanced-integration/v2/client/react/README.md +++ b/advanced-integration/v2/client/react/README.md @@ -20,7 +20,7 @@ This guide will walk you through setting up and running the React Advanced Integ ### Installation -```sh +```bash npm install ``` @@ -31,7 +31,7 @@ npm install - Rename the .env.example file to .env - Update the following keys with their actual values - - ```sh + ```bash PAYPAL_CLIENT_ID= ``` @@ -61,7 +61,7 @@ npm install - **Start the client**: - ```sh + ```bash npm run dev ``` diff --git a/advanced-integration/v2/client/react/client/App.jsx b/advanced-integration/v2/client/react/client/App.jsx index bed59906..fc670070 100644 --- a/advanced-integration/v2/client/react/client/App.jsx +++ b/advanced-integration/v2/client/react/client/App.jsx @@ -9,6 +9,7 @@ import { export default function App() { const [isPaying, setIsPaying] = useState(false); + const [message, setMessage] = useState(""); const initialOptions = { "client-id": import.meta.env.PAYPAL_CLIENT_ID, "enable-funding": "venmo", @@ -126,7 +127,7 @@ export default function App() { setMessage(await onApprove(data))} onError={onError} style={{ shape: "rect", @@ -138,7 +139,7 @@ export default function App() { setMessage(await onApprove(data))} > + ); } @@ -224,7 +226,7 @@ const SubmitPayment = ({ isPaying, setIsPaying, billingAddress }) => { } setIsPaying(true); - cardFieldsForm.submit({ billingAddress }).catch((err) => { + cardFieldsForm.submit({ billingAddress }).finally((err) => { setIsPaying(false); }); }; @@ -238,3 +240,7 @@ const SubmitPayment = ({ isPaying, setIsPaying, billingAddress }) => { ); }; + +const Message = ({ content }) => { + return

{content}

; +}; diff --git a/advanced-integration/v2/server/dotnet/README.md b/advanced-integration/v2/server/dotnet/README.md index 92ac1cc2..52ed7c55 100644 --- a/advanced-integration/v2/server/dotnet/README.md +++ b/advanced-integration/v2/server/dotnet/README.md @@ -1,18 +1,35 @@ # Advanced Integartion .NET Sample + PayPal Advanced Integration sample in .NET ## Running the sample -1. Build the server +1. **Add your API credentials to the environment:** + + - **Windows** + + ```powershell + $env:PAYPAL_CLIENT_ID = "" + $env:PAYPAL_CLIENT_SECRET = "" + ``` + + - **Unix** + + ```bash + export PAYPAL_CLIENT_ID="" + export PAYPAL_CLIENT_SECRET="" + ``` + +2. **Build the server** -~~~ -dotnet restore -~~~ + ```bash + dotnet restore + ``` -2. Run the server +3. **Run the server** -~~~ -dotnet run -~~~ + ```bash + dotnet run + ``` -3. Go to [http://localhost:8080/](http://localhost:8080/) \ No newline at end of file +4. Go to [http://localhost:8080/](http://localhost:8080/) diff --git a/advanced-integration/v2/server/dotnet/Server.cs b/advanced-integration/v2/server/dotnet/Server.cs index c9bab8fc..dcd334fb 100644 --- a/advanced-integration/v2/server/dotnet/Server.cs +++ b/advanced-integration/v2/server/dotnet/Server.cs @@ -23,12 +23,6 @@ public static void Main(string[] args) public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) - .ConfigureAppConfiguration( - (context, config) => - { - config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); - } - ) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseUrls("http://localhost:8080"); @@ -66,11 +60,11 @@ public class CheckoutController : Controller private IConfiguration _configuration { get; } private string _paypalClientId { - get { return _configuration["PAYPAL_CLIENT_ID"]; } + get { return Environment.GetEnvironmentVariable("PAYPAL_CLIENT_ID"); } } private string _paypalClientSecret { - get { return _configuration["PAYPAL_CLIENT_SECRET"]; } + get { return Environment.GetEnvironmentVariable("PAYPAL_CLIENT_SECRET"); } } private readonly string _base = "https://api-m.sandbox.paypal.com"; diff --git a/advanced-integration/v2/server/dotnet/appsettings.json b/advanced-integration/v2/server/dotnet/appsettings.json deleted file mode 100644 index 019194eb..00000000 --- a/advanced-integration/v2/server/dotnet/appsettings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "PAYPAL_CLIENT_ID": "PAYPAL_CLIENT_ID", - "PAYPAL_CLIENT_SECRET": "PAYPAL_CLIENT_SECRET" -} diff --git a/advanced-integration/v2/server/java/README.md b/advanced-integration/v2/server/java/README.md index 578fb9b7..8e330262 100644 --- a/advanced-integration/v2/server/java/README.md +++ b/advanced-integration/v2/server/java/README.md @@ -1,18 +1,35 @@ # Advanced Integartion Java Sample + PayPal Advanced Integration sample in Java ## Running the sample -1. Build the server +1. Add your API credentials to the environment: + + - **Windows** + + ```powershell + $env:PAYPAL_CLIENT_ID = "" + $env:PAYPAL_CLIENT_SECRET = "" + ``` + + - **Unix** + + ```bash + export PAYPAL_CLIENT_ID="" + export PAYPAL_CLIENT_SECRET="" + ``` + +2. Build the server -~~~ -mvn clean install -~~~ + ```bash + mvn clean install + ``` -2. Run the server +3. Run the server -~~~ -mvn spring-boot:run -~~~ + ```bash + mvn spring-boot:run + ``` -3. Go to [http://localhost:8080/](http://localhost:8080/) +4. Go to [http://localhost:8080/](http://localhost:8080/) diff --git a/advanced-integration/v2/server/java/pom.xml b/advanced-integration/v2/server/java/pom.xml index f36d390d..a8c8f8f9 100644 --- a/advanced-integration/v2/server/java/pom.xml +++ b/advanced-integration/v2/server/java/pom.xml @@ -27,7 +27,7 @@ - 22 + 21 diff --git a/advanced-integration/v2/server/java/src/main/resources/application.properties b/advanced-integration/v2/server/java/src/main/resources/application.properties index 88089970..103551b3 100644 --- a/advanced-integration/v2/server/java/src/main/resources/application.properties +++ b/advanced-integration/v2/server/java/src/main/resources/application.properties @@ -1,3 +1,3 @@ spring.application.name=v2-java -PAYPAL_CLIENT_ID= -PAYPAL_CLIENT_SECRET= +PAYPAL_CLIENT_ID=${PAYPAL_CLIENT_ID} +PAYPAL_CLIENT_SECRET=${PAYPAL_CLIENT_SECRET} diff --git a/advanced-integration/v2/server/node/README.md b/advanced-integration/v2/server/node/README.md index 8a3c0250..2a224db8 100644 --- a/advanced-integration/v2/server/node/README.md +++ b/advanced-integration/v2/server/node/README.md @@ -4,16 +4,32 @@ PayPal Advanced Integration sample in Node.js ## Running the sample -1. Install the packages +1. Add your API credentials to the environment: - ```sh - npm install - ``` + - **Windows** -2. Run the server + ```powershell + $env:PAYPAL_CLIENT_ID = "" + $env:PAYPAL_CLIENT_SECRET = "" + ``` - ```sh - npm run start - ``` + - **Unix** -3. Go to [http://localhost:8080/](http://localhost:8080/) + ```bash + export PAYPAL_CLIENT_ID="" + export PAYPAL_CLIENT_SECRET="" + ``` + +2. Install the packages + + ```bash + npm install + ``` + +3. Run the server + + ```bash + npm run start + ``` + +4. Go to [http://localhost:8080/](http://localhost:8080/) diff --git a/advanced-integration/v2/server/php/README.md b/advanced-integration/v2/server/php/README.md index 2f162d42..a789b6bf 100644 --- a/advanced-integration/v2/server/php/README.md +++ b/advanced-integration/v2/server/php/README.md @@ -18,9 +18,23 @@ This sample app demonstrates how to integrate with ACDC using PayPal's REST APIs ## How to Run Locally -1. Replace your Client ID & Client Secret in the server/.env file: -2. Open the `.env` file in a text editor and replace the placeholders with the appropriate values. -3. Follow the below instructions to setup & run server. +1. Add your API credentials to the environment: + + - **Windows** + + ```powershell + $env:PAYPAL_CLIENT_ID = "" + $env:PAYPAL_CLIENT_SECRET = "" + ``` + + - **Unix** + + ```bash + export PAYPAL_CLIENT_ID="" + export PAYPAL_CLIENT_SECRET="" + ``` + +2. Follow the below instructions to setup & run server. ## Install the Composer diff --git a/advanced-integration/v2/server/php/server/.env b/advanced-integration/v2/server/php/server/.env deleted file mode 100644 index 96d3bc76..00000000 --- a/advanced-integration/v2/server/php/server/.env +++ /dev/null @@ -1,2 +0,0 @@ -PAYPAL_CLIENT_ID= -PAYPAL_CLIENT_SECRET= \ No newline at end of file diff --git a/advanced-integration/v2/server/php/server/index.php b/advanced-integration/v2/server/php/server/index.php index 81a25ada..e99a2841 100644 --- a/advanced-integration/v2/server/php/server/index.php +++ b/advanced-integration/v2/server/php/server/index.php @@ -3,17 +3,16 @@ use GuzzleHttp\Client; -$env = parse_ini_file('.env'); - -$PAYPAL_CLIENT_ID = $env['PAYPAL_CLIENT_ID']; -$PAYPAL_CLIENT_SECRET = $env['PAYPAL_CLIENT_SECRET']; +$PAYPAL_CLIENT_ID = getenv('PAYPAL_CLIENT_ID'); +$PAYPAL_CLIENT_SECRET = getenv('PAYPAL_CLIENT_SECRET'); $base = "https://api-m.sandbox.paypal.com"; /** * Generate an OAuth 2.0 access token for authenticating with PayPal REST APIs. * @see https://developer.paypal.com/api/rest/authentication/ */ -function generateAccessToken() { +function generateAccessToken() +{ global $PAYPAL_CLIENT_ID, $PAYPAL_CLIENT_SECRET, $base; if (!$PAYPAL_CLIENT_ID || !$PAYPAL_CLIENT_SECRET) { @@ -21,7 +20,7 @@ function generateAccessToken() { } $auth = base64_encode($PAYPAL_CLIENT_ID . ":" . $PAYPAL_CLIENT_SECRET); - + // Disabling certificate validation for local development $client = new Client(['verify' => false]); $response = $client->post("$base/v1/oauth2/token", [ @@ -41,11 +40,12 @@ function generateAccessToken() { * Create an order to start the transaction. * @see https://developer.paypal.com/docs/api/orders/v2/#orders_create */ -function createOrder($cart) { +function createOrder($cart) +{ global $base; $accessToken = generateAccessToken(); - + // Disabling certificate validation for local development $client = new Client(['verify' => false]); $payload = [ @@ -75,7 +75,8 @@ function createOrder($cart) { * Capture payment for the created order to complete the transaction. * @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture */ -function captureOrder($orderID) { +function captureOrder($orderID) +{ global $base; $accessToken = generateAccessToken(); @@ -92,7 +93,8 @@ function captureOrder($orderID) { return handleResponse($response); } -function handleResponse($response) { +function handleResponse($response) +{ $jsonResponse = json_decode($response->getBody(), true); return [ 'jsonResponse' => $jsonResponse, @@ -101,7 +103,7 @@ function handleResponse($response) { } $endpoint = $_SERVER['REQUEST_URI']; -if($endpoint === '/') { +if ($endpoint === '/') { try { $response = [ "message" => "Server is running" @@ -114,7 +116,7 @@ function handleResponse($response) { } } -if($endpoint === '/api/orders') { +if ($endpoint === '/api/orders') { $data = json_decode(file_get_contents('php://input'), true); $cart = $data['cart']; header('Content-Type: application/json'); @@ -128,7 +130,7 @@ function handleResponse($response) { } -if(str_ends_with($endpoint, '/capture')) { +if (str_ends_with($endpoint, '/capture')) { $urlSegments = explode('/', $endpoint); end($urlSegments); // Will set the pointer to the end of array $orderID = prev($urlSegments); @@ -140,5 +142,4 @@ function handleResponse($response) { echo json_encode(['error' => $e->getMessage()]); http_response_code(500); } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/standard-integration/client/html/README.md b/standard-integration/client/html/README.md index 5c79b001..302fcb42 100644 --- a/standard-integration/client/html/README.md +++ b/standard-integration/client/html/README.md @@ -20,7 +20,7 @@ This guide will walk you through setting up and running the HTML/JS Standard Int ### Installation -```sh +```bash npm install ``` @@ -31,7 +31,7 @@ npm install - Rename the .env.example file to .env - Update the following keys with their actual values - - ```sh + ```bash PAYPAL_CLIENT_ID= ``` @@ -61,7 +61,7 @@ npm install - **Start the client**: - ```sh + ```bash npm run dev ``` diff --git a/standard-integration/client/html/client/app.js b/standard-integration/client/html/client/app.js index 4c70688e..685b2c46 100644 --- a/standard-integration/client/html/client/app.js +++ b/standard-integration/client/html/client/app.js @@ -42,7 +42,7 @@ window.paypal throw new Error(errorMessage); } catch (error) { console.error(error); - // resultMessage(`Could not initiate PayPal Checkout...

${error}`); + resultMessage(`Could not initiate PayPal Checkout...

${error}`); } }, @@ -98,3 +98,9 @@ window.paypal }, }) .render("#paypal-button-container"); + +// Example function to show a result to the user. Your site's UI library can be used instead. +function resultMessage(message) { + const container = document.querySelector("#result-message"); + container.innerHTML = message; +} diff --git a/standard-integration/client/react/README.md b/standard-integration/client/react/README.md index fdf7d214..da8ec278 100644 --- a/standard-integration/client/react/README.md +++ b/standard-integration/client/react/README.md @@ -20,7 +20,7 @@ This guide will walk you through setting up and running the React Standard Integ ### Installation -```sh +```bash npm install ``` @@ -31,7 +31,7 @@ npm install - Rename the .env.example file to .env - Update the following keys with their actual values - - ```sh + ```bash PAYPAL_CLIENT_ID= ``` @@ -61,7 +61,7 @@ npm install - **Start the client**: - ```sh + ```bash npm run dev ``` diff --git a/standard-integration/server/dotnet/README.md b/standard-integration/server/dotnet/README.md index 9dca45c3..d1f5fd91 100644 --- a/standard-integration/server/dotnet/README.md +++ b/standard-integration/server/dotnet/README.md @@ -1,18 +1,35 @@ # Standard Integartion .NET Sample + PayPal Standard Integration sample in .NET ## Running the sample -1. Build the server +1. **Add your API credentials to the environment:** + + - **Windows** + + ```powershell + $env:PAYPAL_CLIENT_ID = "" + $env:PAYPAL_CLIENT_SECRET = "" + ``` + + - **Unix** + + ```bash + export PAYPAL_CLIENT_ID="" + export PAYPAL_CLIENT_SECRET="" + ``` + +2. **Build the server** -~~~ -dotnet restore -~~~ + ```bash + dotnet restore + ``` -2. Run the server +3. **Run the server** -~~~ -dotnet run -~~~ + ```bash + dotnet run + ``` -3. Go to [http://localhost:8080/](http://localhost:8080/) \ No newline at end of file +4. Go to [http://localhost:8080/](http://localhost:8080/) diff --git a/standard-integration/server/dotnet/Server.cs b/standard-integration/server/dotnet/Server.cs index eb24f0e8..9be4f5e5 100644 --- a/standard-integration/server/dotnet/Server.cs +++ b/standard-integration/server/dotnet/Server.cs @@ -23,12 +23,6 @@ public static void Main(string[] args) public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) - .ConfigureAppConfiguration( - (context, config) => - { - config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); - } - ) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseUrls("http://localhost:8080"); @@ -66,11 +60,11 @@ public class CheckoutController : Controller private IConfiguration _configuration { get; } private string _paypalClientId { - get { return _configuration["PAYPAL_CLIENT_ID"]; } + get { return Environment.GetEnvironmentVariable("PAYPAL_CLIENT_ID"); } } private string _paypalClientSecret { - get { return _configuration["PAYPAL_CLIENT_SECRET"]; } + get { return Environment.GetEnvironmentVariable("PAYPAL_CLIENT_SECRET"); } } private readonly string _base = "https://api-m.sandbox.paypal.com"; diff --git a/standard-integration/server/dotnet/appsettings.json b/standard-integration/server/dotnet/appsettings.json deleted file mode 100644 index 019194eb..00000000 --- a/standard-integration/server/dotnet/appsettings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "PAYPAL_CLIENT_ID": "PAYPAL_CLIENT_ID", - "PAYPAL_CLIENT_SECRET": "PAYPAL_CLIENT_SECRET" -} diff --git a/standard-integration/server/java/README.md b/standard-integration/server/java/README.md index 343200e7..a9fcce21 100644 --- a/standard-integration/server/java/README.md +++ b/standard-integration/server/java/README.md @@ -1,18 +1,35 @@ # Standard Integartion Java Sample + PayPal Standard Integration sample in Java ## Running the sample -1. Build the server +1. Add your API credentials to the environment: + + - **Windows** + + ```powershell + $env:PAYPAL_CLIENT_ID = "" + $env:PAYPAL_CLIENT_SECRET = "" + ``` + + - **Unix** + + ```bash + export PAYPAL_CLIENT_ID="" + export PAYPAL_CLIENT_SECRET="" + ``` + +2. Build the server -~~~ -mvn clean install -~~~ + ```bash + mvn clean install + ``` -2. Run the server +3. Run the server -~~~ -mvn spring-boot:run -~~~ + ```bash + mvn spring-boot:run + ``` -3. Go to [http://localhost:8080/](http://localhost:8080/) +4. Go to [http://localhost:8080/](http://localhost:8080/) diff --git a/standard-integration/server/java/pom.xml b/standard-integration/server/java/pom.xml index 48e7a01c..ab4c30bc 100644 --- a/standard-integration/server/java/pom.xml +++ b/standard-integration/server/java/pom.xml @@ -27,7 +27,7 @@ - 22 + 21 diff --git a/standard-integration/server/java/src/main/resources/application.properties b/standard-integration/server/java/src/main/resources/application.properties index 88089970..103551b3 100644 --- a/standard-integration/server/java/src/main/resources/application.properties +++ b/standard-integration/server/java/src/main/resources/application.properties @@ -1,3 +1,3 @@ spring.application.name=v2-java -PAYPAL_CLIENT_ID= -PAYPAL_CLIENT_SECRET= +PAYPAL_CLIENT_ID=${PAYPAL_CLIENT_ID} +PAYPAL_CLIENT_SECRET=${PAYPAL_CLIENT_SECRET} diff --git a/standard-integration/server/node/README.md b/standard-integration/server/node/README.md index a9ddb604..0fce05d5 100644 --- a/standard-integration/server/node/README.md +++ b/standard-integration/server/node/README.md @@ -4,16 +4,32 @@ PayPal Standard Integration sample in Node.js ## Running the sample -1. Install the packages +1. Add your API credentials to the environment: - ```sh - npm install - ``` + - **Windows** -2. Run the server + ```powershell + $env:PAYPAL_CLIENT_ID = "" + $env:PAYPAL_CLIENT_SECRET = "" + ``` - ```sh - npm run start - ``` + - **Unix** -3. Go to [http://localhost:8080/](http://localhost:8080/) + ```bash + export PAYPAL_CLIENT_ID="" + export PAYPAL_CLIENT_SECRET="" + ``` + +2. Install the packages + + ```bash + npm install + ``` + +3. Run the server + + ```bash + npm run start + ``` + +4. Go to [http://localhost:8080/](http://localhost:8080/) diff --git a/standard-integration/server/php/README.md b/standard-integration/server/php/README.md index 5c5b5ed6..53284b42 100644 --- a/standard-integration/server/php/README.md +++ b/standard-integration/server/php/README.md @@ -18,9 +18,23 @@ This sample app demonstrates how to integrate with ACDC using PayPal's REST APIs ## How to Run Locally -1. Replace your Client ID & Client Secret in the server/.env file: -2. Open the `.env` file in a text editor and replace the placeholders with the appropriate values. -3. Follow the below instructions to setup & run server. +1. Add your API credentials to the environment: + + - **Windows** + + ```powershell + $env:PAYPAL_CLIENT_ID = "" + $env:PAYPAL_CLIENT_SECRET = "" + ``` + + - **Unix** + + ```bash + export PAYPAL_CLIENT_ID="" + export PAYPAL_CLIENT_SECRET="" + ``` + +2. Follow the below instructions to setup & run server. ## Install the Composer diff --git a/standard-integration/server/php/server/.env b/standard-integration/server/php/server/.env deleted file mode 100644 index 96d3bc76..00000000 --- a/standard-integration/server/php/server/.env +++ /dev/null @@ -1,2 +0,0 @@ -PAYPAL_CLIENT_ID= -PAYPAL_CLIENT_SECRET= \ No newline at end of file diff --git a/standard-integration/server/php/server/index.php b/standard-integration/server/php/server/index.php index 81a25ada..e99a2841 100644 --- a/standard-integration/server/php/server/index.php +++ b/standard-integration/server/php/server/index.php @@ -3,17 +3,16 @@ use GuzzleHttp\Client; -$env = parse_ini_file('.env'); - -$PAYPAL_CLIENT_ID = $env['PAYPAL_CLIENT_ID']; -$PAYPAL_CLIENT_SECRET = $env['PAYPAL_CLIENT_SECRET']; +$PAYPAL_CLIENT_ID = getenv('PAYPAL_CLIENT_ID'); +$PAYPAL_CLIENT_SECRET = getenv('PAYPAL_CLIENT_SECRET'); $base = "https://api-m.sandbox.paypal.com"; /** * Generate an OAuth 2.0 access token for authenticating with PayPal REST APIs. * @see https://developer.paypal.com/api/rest/authentication/ */ -function generateAccessToken() { +function generateAccessToken() +{ global $PAYPAL_CLIENT_ID, $PAYPAL_CLIENT_SECRET, $base; if (!$PAYPAL_CLIENT_ID || !$PAYPAL_CLIENT_SECRET) { @@ -21,7 +20,7 @@ function generateAccessToken() { } $auth = base64_encode($PAYPAL_CLIENT_ID . ":" . $PAYPAL_CLIENT_SECRET); - + // Disabling certificate validation for local development $client = new Client(['verify' => false]); $response = $client->post("$base/v1/oauth2/token", [ @@ -41,11 +40,12 @@ function generateAccessToken() { * Create an order to start the transaction. * @see https://developer.paypal.com/docs/api/orders/v2/#orders_create */ -function createOrder($cart) { +function createOrder($cart) +{ global $base; $accessToken = generateAccessToken(); - + // Disabling certificate validation for local development $client = new Client(['verify' => false]); $payload = [ @@ -75,7 +75,8 @@ function createOrder($cart) { * Capture payment for the created order to complete the transaction. * @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture */ -function captureOrder($orderID) { +function captureOrder($orderID) +{ global $base; $accessToken = generateAccessToken(); @@ -92,7 +93,8 @@ function captureOrder($orderID) { return handleResponse($response); } -function handleResponse($response) { +function handleResponse($response) +{ $jsonResponse = json_decode($response->getBody(), true); return [ 'jsonResponse' => $jsonResponse, @@ -101,7 +103,7 @@ function handleResponse($response) { } $endpoint = $_SERVER['REQUEST_URI']; -if($endpoint === '/') { +if ($endpoint === '/') { try { $response = [ "message" => "Server is running" @@ -114,7 +116,7 @@ function handleResponse($response) { } } -if($endpoint === '/api/orders') { +if ($endpoint === '/api/orders') { $data = json_decode(file_get_contents('php://input'), true); $cart = $data['cart']; header('Content-Type: application/json'); @@ -128,7 +130,7 @@ function handleResponse($response) { } -if(str_ends_with($endpoint, '/capture')) { +if (str_ends_with($endpoint, '/capture')) { $urlSegments = explode('/', $endpoint); end($urlSegments); // Will set the pointer to the end of array $orderID = prev($urlSegments); @@ -140,5 +142,4 @@ function handleResponse($response) { echo json_encode(['error' => $e->getMessage()]); http_response_code(500); } -} -?> \ No newline at end of file +} \ No newline at end of file