From cc6131c749cbf7dd9fedf40a7f9d55dc45c1100f Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Fri, 27 Sep 2024 14:31:50 -0400 Subject: [PATCH 01/13] Add virtual env dir & .env to gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c889f486..734b2c38 100644 --- a/.gitignore +++ b/.gitignore @@ -108,4 +108,4 @@ dist #Codespace .vscode/settings.json -.devcontainer/update_settings.sh +.devcontainer/update_settings.sh \ No newline at end of file From b4e24b052db2d5bd68a27d7d4d5833ddc55484cf Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Fri, 27 Sep 2024 14:33:03 -0400 Subject: [PATCH 02/13] Add pycache to gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 734b2c38..513c3b5b 100644 --- a/.gitignore +++ b/.gitignore @@ -103,9 +103,15 @@ dist # dotnet *.sln + # env *.local +# Python +.venv +__pycache__ + + #Codespace .vscode/settings.json .devcontainer/update_settings.sh \ No newline at end of file From 7f91ddc5fe58048c81be9fce5bbc107595bd40fe Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Fri, 27 Sep 2024 14:34:14 -0400 Subject: [PATCH 03/13] Add flask app using paypal-server-sdk@0.5.1 --- .../server/python/.env.example | 5 ++ .../server/python/src/__init__.py | 87 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 standard-integration/server/python/.env.example create mode 100644 standard-integration/server/python/src/__init__.py diff --git a/standard-integration/server/python/.env.example b/standard-integration/server/python/.env.example new file mode 100644 index 00000000..2251fbbb --- /dev/null +++ b/standard-integration/server/python/.env.example @@ -0,0 +1,5 @@ +# Create an application to obtain credentials at +# https://developer.paypal.com/dashboard/applications/sandbox + +PAYPAL_CLIENT_ID=YOUR_CLIENT_ID_GOES_HERE +PAYPAL_CLIENT_SECRET=YOUR_SECRET_GOES_HERE diff --git a/standard-integration/server/python/src/__init__.py b/standard-integration/server/python/src/__init__.py new file mode 100644 index 00000000..c5dcf8b7 --- /dev/null +++ b/standard-integration/server/python/src/__init__.py @@ -0,0 +1,87 @@ +import logging +import os + +from dotenv import load_dotenv +from flask import Flask, request +from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials +from paypalserversdk.logging.configuration.api_logging_configuration import LoggingConfiguration, \ + RequestLoggingConfiguration, ResponseLoggingConfiguration +from paypalserversdk.paypalserversdk_client import PaypalserversdkClient +from paypalserversdk.controllers.orders_controller import OrdersController +from paypalserversdk.models.amount_with_breakdown import AmountWithBreakdown +from paypalserversdk.models.checkout_payment_intent import CheckoutPaymentIntent +from paypalserversdk.models.order_request import OrderRequest +from paypalserversdk.models.purchase_unit_request import PurchaseUnitRequest +from paypalserversdk.api_helper import ApiHelper + +app = Flask(__name__) + +load_dotenv() + +paypal_client: PaypalserversdkClient = PaypalserversdkClient( + client_credentials_auth_credentials=ClientCredentialsAuthCredentials( + o_auth_client_id=os.getenv('PAYPAL_CLIENT_ID'), + o_auth_client_secret=os.getenv('PAYPAL_CLIENT_SECRET') + ), + logging_configuration=LoggingConfiguration( + log_level=logging.INFO, + # Disable masking of sensitive headers for Sandbox testing. + # This should be set to True (the default if unset)in production. + mask_sensitive_headers=False, + request_logging_config=RequestLoggingConfiguration( + log_headers=True, + log_body=True + ), + response_logging_config=ResponseLoggingConfiguration( + log_headers=True, + log_body=True + ) + ) +) + +''' +Health check +''' +@app.route('/', methods=['GET']) +def index(): + return {"message": "Server is running"} + +orders_controller: OrdersController = paypal_client.orders + +''' +Create an order to start the transaction. + +@see https://developer.paypal.com/docs/api/orders/v2/#orders_create +''' +@app.route('/api/orders', methods=['POST']) +def create_order(): + request_body = request.get_json() + # use the cart information passed from the front-end to calculate the order amount detals + cart = request_body['cart'] + order = orders_controller.orders_create({ + "body": OrderRequest( + intent=CheckoutPaymentIntent.CAPTURE, + purchase_units=[ + PurchaseUnitRequest( + AmountWithBreakdown( + currency_code='USD', + value='100.00' + ) + ) + ] + )} + ) + return ApiHelper.json_serialize(order.body) + +''' + Capture payment for the created order to complete the transaction. + + @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture +''' +@app.route('/api/orders//capture', methods=['POST']) +def capture_order(order_id): + order = orders_controller.orders_capture({ + 'id': order_id, + 'prefer': 'return=representation' + }) + return ApiHelper.json_serialize(order.body) \ No newline at end of file From fe893dd197ffc48c90a91c950ffaf113e00413fb Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Fri, 27 Sep 2024 14:41:56 -0400 Subject: [PATCH 04/13] Add Python standard readme --- standard-integration/server/python/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/standard-integration/server/python/README.md b/standard-integration/server/python/README.md index de523758..024410d0 100644 --- a/standard-integration/server/python/README.md +++ b/standard-integration/server/python/README.md @@ -35,7 +35,7 @@ PayPal Standard Integration sample in Python using Flask 1. **Run the server** ```sh - flask --app server run + flask --app server run --port 8080 ``` -1. Go to [http://localhost:8080/](http://localhost:8080/) +1. Go to [http://localhost:8080/](http://localhost:8080/) \ No newline at end of file From 956d2feab9d9b5ab25aec43e2f224b919efa8adb Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Fri, 27 Sep 2024 16:51:04 -0400 Subject: [PATCH 05/13] Rename src -> server to match other languages --- standard-integration/server/python/{src => server}/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename standard-integration/server/python/{src => server}/__init__.py (100%) diff --git a/standard-integration/server/python/src/__init__.py b/standard-integration/server/python/server/__init__.py similarity index 100% rename from standard-integration/server/python/src/__init__.py rename to standard-integration/server/python/server/__init__.py From 56be8b8dbc11888686c35e69e725820d7a5f96d0 Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Fri, 27 Sep 2024 21:56:48 -0400 Subject: [PATCH 06/13] Explicitly request full orders response on create --- standard-integration/server/python/server/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/standard-integration/server/python/server/__init__.py b/standard-integration/server/python/server/__init__.py index c5dcf8b7..05ab4b08 100644 --- a/standard-integration/server/python/server/__init__.py +++ b/standard-integration/server/python/server/__init__.py @@ -69,7 +69,9 @@ def create_order(): ) ) ] - )} + ), + "prefer": 'return=representation' + } ) return ApiHelper.json_serialize(order.body) From f919846b87370b502b2414fab583d7db9e8ccd78 Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Fri, 27 Sep 2024 21:57:13 -0400 Subject: [PATCH 07/13] Add sinatra app using paypal-server-sdk@0.5.1 --- standard-integration/server/ruby/.env.example | 5 + standard-integration/server/ruby/Gemfile | 4 +- standard-integration/server/ruby/Gemfile.lock | 118 ++++++++++++++++++ standard-integration/server/ruby/README.md | 2 +- 4 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 standard-integration/server/ruby/.env.example create mode 100644 standard-integration/server/ruby/Gemfile.lock diff --git a/standard-integration/server/ruby/.env.example b/standard-integration/server/ruby/.env.example new file mode 100644 index 00000000..2251fbbb --- /dev/null +++ b/standard-integration/server/ruby/.env.example @@ -0,0 +1,5 @@ +# Create an application to obtain credentials at +# https://developer.paypal.com/dashboard/applications/sandbox + +PAYPAL_CLIENT_ID=YOUR_CLIENT_ID_GOES_HERE +PAYPAL_CLIENT_SECRET=YOUR_SECRET_GOES_HERE diff --git a/standard-integration/server/ruby/Gemfile b/standard-integration/server/ruby/Gemfile index a5b31725..64f65682 100644 --- a/standard-integration/server/ruby/Gemfile +++ b/standard-integration/server/ruby/Gemfile @@ -2,7 +2,9 @@ source "https://rubygems.org" -gem "paypal-server-sdk", "~> 0.5.2" + +gem "dotenv", "~> 3.1" +gem "paypal-server-sdk", "~> 0.5.1" gem "puma", "~> 6.4" gem "rackup", "~> 2.1" gem "sinatra", "~> 4.0" diff --git a/standard-integration/server/ruby/Gemfile.lock b/standard-integration/server/ruby/Gemfile.lock new file mode 100644 index 00000000..d66a7748 --- /dev/null +++ b/standard-integration/server/ruby/Gemfile.lock @@ -0,0 +1,118 @@ +GEM + remote: https://rubygems.org/ + specs: + apimatic_core (0.3.10) + apimatic_core_interfaces (~> 0.2.0) + certifi (~> 2018.1, >= 2018.01.18) + faraday-multipart (~> 1.0) + nokogiri (~> 1.10, >= 1.10.10) + apimatic_core_interfaces (0.2.1) + apimatic_faraday_client_adapter (0.1.4) + apimatic_core_interfaces (~> 0.2.0) + certifi (~> 2018.1, >= 2018.01.18) + faraday (~> 2.0, >= 2.0.1) + faraday-follow_redirects (~> 0.2) + faraday-gzip (~> 1.0) + faraday-http-cache (~> 2.2) + faraday-multipart (~> 1.0) + faraday-net_http_persistent (~> 2.0) + faraday-retry (~> 2.0) + base64 (0.2.0) + certifi (2018.01.18) + connection_pool (2.4.1) + dotenv (3.1.4) + faraday (2.12.0) + faraday-net_http (>= 2.0, < 3.4) + json + logger + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) + faraday-gzip (1.0.0) + faraday (>= 1.0) + zlib (~> 2.1) + faraday-http-cache (2.5.1) + faraday (>= 0.8) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (3.3.0) + net-http + faraday-net_http_persistent (2.2.0) + faraday (~> 2.5) + net-http-persistent (>= 4.0.4, < 5) + faraday-retry (2.2.1) + faraday (~> 2.0) + json (2.7.2) + logger (1.6.1) + multi_json (1.15.0) + multipart-post (2.4.1) + mustermann (3.0.3) + ruby2_keywords (~> 0.0.1) + net-http (0.4.1) + uri + net-http-persistent (4.0.4) + connection_pool (~> 2.2) + nio4r (2.7.3) + nokogiri (1.16.7-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86-linux) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-linux) + racc (~> 1.4) + paypal-server-sdk (0.5.1) + apimatic_core (~> 0.3.9) + apimatic_core_interfaces (~> 0.2.1) + apimatic_faraday_client_adapter (~> 0.1.4) + puma (6.4.3) + nio4r (~> 2.0) + racc (1.8.1) + rack (3.1.7) + rack-protection (4.0.0) + base64 (>= 0.1.0) + rack (>= 3.0.0, < 4) + rack-session (2.0.0) + rack (>= 3.0.0) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + ruby2_keywords (0.0.5) + sinatra (4.0.0) + mustermann (~> 3.0) + rack (>= 3.0.0, < 4) + rack-protection (= 4.0.0) + rack-session (>= 2.0.0, < 3) + tilt (~> 2.0) + sinatra-contrib (4.0.0) + multi_json (>= 0.0.2) + mustermann (~> 3.0) + rack-protection (= 4.0.0) + sinatra (= 4.0.0) + tilt (~> 2.0) + tilt (2.4.0) + uri (0.13.1) + webrick (1.8.2) + zlib (2.1.1) + +PLATFORMS + aarch64-linux + arm-linux + arm64-darwin + x86-linux + x86_64-darwin + x86_64-linux + +DEPENDENCIES + dotenv (~> 3.1) + paypal-server-sdk (~> 0.5.1) + puma (~> 6.4) + rackup (~> 2.1) + sinatra (~> 4.0) + sinatra-contrib (~> 4.0) + +BUNDLED WITH + 2.5.16 diff --git a/standard-integration/server/ruby/README.md b/standard-integration/server/ruby/README.md index 6ad18fe2..6188a5c2 100644 --- a/standard-integration/server/ruby/README.md +++ b/standard-integration/server/ruby/README.md @@ -34,4 +34,4 @@ PayPal Standard Integration sample in Ruby using Sinatra bundle exec ruby server.rb ``` -1. Go to [http://localhost:8080/](http://localhost:8080/) +1. Go to [http://localhost:8080/](http://localhost:8080/) \ No newline at end of file From b9f568d15af910be9183454d8ae9741f966e8956 Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Fri, 27 Sep 2024 22:31:44 -0400 Subject: [PATCH 08/13] Add python flask based advanced-integration --- .../v2/server/python/.env.example | 5 ++ .../v2/server/python/README.md | 20 ++--- .../v2/server/python/server/__init__.py | 89 +++++++++++++++++++ 3 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 advanced-integration/v2/server/python/.env.example create mode 100644 advanced-integration/v2/server/python/server/__init__.py diff --git a/advanced-integration/v2/server/python/.env.example b/advanced-integration/v2/server/python/.env.example new file mode 100644 index 00000000..2251fbbb --- /dev/null +++ b/advanced-integration/v2/server/python/.env.example @@ -0,0 +1,5 @@ +# Create an application to obtain credentials at +# https://developer.paypal.com/dashboard/applications/sandbox + +PAYPAL_CLIENT_ID=YOUR_CLIENT_ID_GOES_HERE +PAYPAL_CLIENT_SECRET=YOUR_SECRET_GOES_HERE diff --git a/advanced-integration/v2/server/python/README.md b/advanced-integration/v2/server/python/README.md index de523758..6188a5c2 100644 --- a/advanced-integration/v2/server/python/README.md +++ b/advanced-integration/v2/server/python/README.md @@ -1,19 +1,15 @@ -# Standard Integration Python Flask Sample +# Standard Integration Ruby Sinatra Sample -PayPal Standard Integration sample in Python using Flask +PayPal Standard Integration sample in Ruby using Sinatra ## Running the sample -1. **Setup a virtual environment** - - ```sh - python3 -m venv .venv - ``` +1. **Ensure you have a supported Ruby version installed**: [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/) 1. **Install the dependencies** - ```sh - pip install -r requirements.txt + ```bash + bundle install ``` 1. **Add your API credentials to the environment:** @@ -34,8 +30,8 @@ PayPal Standard Integration sample in Python using Flask 1. **Run the server** - ```sh - flask --app server run + ```bash + bundle exec ruby server.rb ``` -1. Go to [http://localhost:8080/](http://localhost:8080/) +1. Go to [http://localhost:8080/](http://localhost:8080/) \ No newline at end of file diff --git a/advanced-integration/v2/server/python/server/__init__.py b/advanced-integration/v2/server/python/server/__init__.py new file mode 100644 index 00000000..05ab4b08 --- /dev/null +++ b/advanced-integration/v2/server/python/server/__init__.py @@ -0,0 +1,89 @@ +import logging +import os + +from dotenv import load_dotenv +from flask import Flask, request +from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials +from paypalserversdk.logging.configuration.api_logging_configuration import LoggingConfiguration, \ + RequestLoggingConfiguration, ResponseLoggingConfiguration +from paypalserversdk.paypalserversdk_client import PaypalserversdkClient +from paypalserversdk.controllers.orders_controller import OrdersController +from paypalserversdk.models.amount_with_breakdown import AmountWithBreakdown +from paypalserversdk.models.checkout_payment_intent import CheckoutPaymentIntent +from paypalserversdk.models.order_request import OrderRequest +from paypalserversdk.models.purchase_unit_request import PurchaseUnitRequest +from paypalserversdk.api_helper import ApiHelper + +app = Flask(__name__) + +load_dotenv() + +paypal_client: PaypalserversdkClient = PaypalserversdkClient( + client_credentials_auth_credentials=ClientCredentialsAuthCredentials( + o_auth_client_id=os.getenv('PAYPAL_CLIENT_ID'), + o_auth_client_secret=os.getenv('PAYPAL_CLIENT_SECRET') + ), + logging_configuration=LoggingConfiguration( + log_level=logging.INFO, + # Disable masking of sensitive headers for Sandbox testing. + # This should be set to True (the default if unset)in production. + mask_sensitive_headers=False, + request_logging_config=RequestLoggingConfiguration( + log_headers=True, + log_body=True + ), + response_logging_config=ResponseLoggingConfiguration( + log_headers=True, + log_body=True + ) + ) +) + +''' +Health check +''' +@app.route('/', methods=['GET']) +def index(): + return {"message": "Server is running"} + +orders_controller: OrdersController = paypal_client.orders + +''' +Create an order to start the transaction. + +@see https://developer.paypal.com/docs/api/orders/v2/#orders_create +''' +@app.route('/api/orders', methods=['POST']) +def create_order(): + request_body = request.get_json() + # use the cart information passed from the front-end to calculate the order amount detals + cart = request_body['cart'] + order = orders_controller.orders_create({ + "body": OrderRequest( + intent=CheckoutPaymentIntent.CAPTURE, + purchase_units=[ + PurchaseUnitRequest( + AmountWithBreakdown( + currency_code='USD', + value='100.00' + ) + ) + ] + ), + "prefer": 'return=representation' + } + ) + return ApiHelper.json_serialize(order.body) + +''' + Capture payment for the created order to complete the transaction. + + @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture +''' +@app.route('/api/orders//capture', methods=['POST']) +def capture_order(order_id): + order = orders_controller.orders_capture({ + 'id': order_id, + 'prefer': 'return=representation' + }) + return ApiHelper.json_serialize(order.body) \ No newline at end of file From 2fc2818e13d44842891f7fa8cd7d065cd5a3871b Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Fri, 27 Sep 2024 22:32:10 -0400 Subject: [PATCH 09/13] Add ruby sinatra based advanced-integration --- .../v2/server/ruby/.env.example | 5 + advanced-integration/v2/server/ruby/Gemfile | 4 +- .../v2/server/ruby/Gemfile.lock | 118 ++++++++++++++++++ advanced-integration/v2/server/ruby/README.md | 2 +- 4 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 advanced-integration/v2/server/ruby/.env.example create mode 100644 advanced-integration/v2/server/ruby/Gemfile.lock diff --git a/advanced-integration/v2/server/ruby/.env.example b/advanced-integration/v2/server/ruby/.env.example new file mode 100644 index 00000000..2251fbbb --- /dev/null +++ b/advanced-integration/v2/server/ruby/.env.example @@ -0,0 +1,5 @@ +# Create an application to obtain credentials at +# https://developer.paypal.com/dashboard/applications/sandbox + +PAYPAL_CLIENT_ID=YOUR_CLIENT_ID_GOES_HERE +PAYPAL_CLIENT_SECRET=YOUR_SECRET_GOES_HERE diff --git a/advanced-integration/v2/server/ruby/Gemfile b/advanced-integration/v2/server/ruby/Gemfile index a5b31725..64f65682 100644 --- a/advanced-integration/v2/server/ruby/Gemfile +++ b/advanced-integration/v2/server/ruby/Gemfile @@ -2,7 +2,9 @@ source "https://rubygems.org" -gem "paypal-server-sdk", "~> 0.5.2" + +gem "dotenv", "~> 3.1" +gem "paypal-server-sdk", "~> 0.5.1" gem "puma", "~> 6.4" gem "rackup", "~> 2.1" gem "sinatra", "~> 4.0" diff --git a/advanced-integration/v2/server/ruby/Gemfile.lock b/advanced-integration/v2/server/ruby/Gemfile.lock new file mode 100644 index 00000000..d66a7748 --- /dev/null +++ b/advanced-integration/v2/server/ruby/Gemfile.lock @@ -0,0 +1,118 @@ +GEM + remote: https://rubygems.org/ + specs: + apimatic_core (0.3.10) + apimatic_core_interfaces (~> 0.2.0) + certifi (~> 2018.1, >= 2018.01.18) + faraday-multipart (~> 1.0) + nokogiri (~> 1.10, >= 1.10.10) + apimatic_core_interfaces (0.2.1) + apimatic_faraday_client_adapter (0.1.4) + apimatic_core_interfaces (~> 0.2.0) + certifi (~> 2018.1, >= 2018.01.18) + faraday (~> 2.0, >= 2.0.1) + faraday-follow_redirects (~> 0.2) + faraday-gzip (~> 1.0) + faraday-http-cache (~> 2.2) + faraday-multipart (~> 1.0) + faraday-net_http_persistent (~> 2.0) + faraday-retry (~> 2.0) + base64 (0.2.0) + certifi (2018.01.18) + connection_pool (2.4.1) + dotenv (3.1.4) + faraday (2.12.0) + faraday-net_http (>= 2.0, < 3.4) + json + logger + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) + faraday-gzip (1.0.0) + faraday (>= 1.0) + zlib (~> 2.1) + faraday-http-cache (2.5.1) + faraday (>= 0.8) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (3.3.0) + net-http + faraday-net_http_persistent (2.2.0) + faraday (~> 2.5) + net-http-persistent (>= 4.0.4, < 5) + faraday-retry (2.2.1) + faraday (~> 2.0) + json (2.7.2) + logger (1.6.1) + multi_json (1.15.0) + multipart-post (2.4.1) + mustermann (3.0.3) + ruby2_keywords (~> 0.0.1) + net-http (0.4.1) + uri + net-http-persistent (4.0.4) + connection_pool (~> 2.2) + nio4r (2.7.3) + nokogiri (1.16.7-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86-linux) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-linux) + racc (~> 1.4) + paypal-server-sdk (0.5.1) + apimatic_core (~> 0.3.9) + apimatic_core_interfaces (~> 0.2.1) + apimatic_faraday_client_adapter (~> 0.1.4) + puma (6.4.3) + nio4r (~> 2.0) + racc (1.8.1) + rack (3.1.7) + rack-protection (4.0.0) + base64 (>= 0.1.0) + rack (>= 3.0.0, < 4) + rack-session (2.0.0) + rack (>= 3.0.0) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + ruby2_keywords (0.0.5) + sinatra (4.0.0) + mustermann (~> 3.0) + rack (>= 3.0.0, < 4) + rack-protection (= 4.0.0) + rack-session (>= 2.0.0, < 3) + tilt (~> 2.0) + sinatra-contrib (4.0.0) + multi_json (>= 0.0.2) + mustermann (~> 3.0) + rack-protection (= 4.0.0) + sinatra (= 4.0.0) + tilt (~> 2.0) + tilt (2.4.0) + uri (0.13.1) + webrick (1.8.2) + zlib (2.1.1) + +PLATFORMS + aarch64-linux + arm-linux + arm64-darwin + x86-linux + x86_64-darwin + x86_64-linux + +DEPENDENCIES + dotenv (~> 3.1) + paypal-server-sdk (~> 0.5.1) + puma (~> 6.4) + rackup (~> 2.1) + sinatra (~> 4.0) + sinatra-contrib (~> 4.0) + +BUNDLED WITH + 2.5.16 diff --git a/advanced-integration/v2/server/ruby/README.md b/advanced-integration/v2/server/ruby/README.md index 6ad18fe2..6188a5c2 100644 --- a/advanced-integration/v2/server/ruby/README.md +++ b/advanced-integration/v2/server/ruby/README.md @@ -34,4 +34,4 @@ PayPal Standard Integration sample in Ruby using Sinatra bundle exec ruby server.rb ``` -1. Go to [http://localhost:8080/](http://localhost:8080/) +1. Go to [http://localhost:8080/](http://localhost:8080/) \ No newline at end of file From 8b31385fdb41a4b5ae909f2b13b36be49dd7cd16 Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Mon, 30 Sep 2024 11:18:10 -0400 Subject: [PATCH 10/13] Remove Gemfile.lock --- .../v2/server/ruby/Gemfile.lock | 118 ------------------ standard-integration/server/ruby/Gemfile.lock | 118 ------------------ 2 files changed, 236 deletions(-) delete mode 100644 advanced-integration/v2/server/ruby/Gemfile.lock delete mode 100644 standard-integration/server/ruby/Gemfile.lock diff --git a/advanced-integration/v2/server/ruby/Gemfile.lock b/advanced-integration/v2/server/ruby/Gemfile.lock deleted file mode 100644 index d66a7748..00000000 --- a/advanced-integration/v2/server/ruby/Gemfile.lock +++ /dev/null @@ -1,118 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - apimatic_core (0.3.10) - apimatic_core_interfaces (~> 0.2.0) - certifi (~> 2018.1, >= 2018.01.18) - faraday-multipart (~> 1.0) - nokogiri (~> 1.10, >= 1.10.10) - apimatic_core_interfaces (0.2.1) - apimatic_faraday_client_adapter (0.1.4) - apimatic_core_interfaces (~> 0.2.0) - certifi (~> 2018.1, >= 2018.01.18) - faraday (~> 2.0, >= 2.0.1) - faraday-follow_redirects (~> 0.2) - faraday-gzip (~> 1.0) - faraday-http-cache (~> 2.2) - faraday-multipart (~> 1.0) - faraday-net_http_persistent (~> 2.0) - faraday-retry (~> 2.0) - base64 (0.2.0) - certifi (2018.01.18) - connection_pool (2.4.1) - dotenv (3.1.4) - faraday (2.12.0) - faraday-net_http (>= 2.0, < 3.4) - json - logger - faraday-follow_redirects (0.3.0) - faraday (>= 1, < 3) - faraday-gzip (1.0.0) - faraday (>= 1.0) - zlib (~> 2.1) - faraday-http-cache (2.5.1) - faraday (>= 0.8) - faraday-multipart (1.0.4) - multipart-post (~> 2) - faraday-net_http (3.3.0) - net-http - faraday-net_http_persistent (2.2.0) - faraday (~> 2.5) - net-http-persistent (>= 4.0.4, < 5) - faraday-retry (2.2.1) - faraday (~> 2.0) - json (2.7.2) - logger (1.6.1) - multi_json (1.15.0) - multipart-post (2.4.1) - mustermann (3.0.3) - ruby2_keywords (~> 0.0.1) - net-http (0.4.1) - uri - net-http-persistent (4.0.4) - connection_pool (~> 2.2) - nio4r (2.7.3) - nokogiri (1.16.7-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.7-arm-linux) - racc (~> 1.4) - nokogiri (1.16.7-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.7-x86-linux) - racc (~> 1.4) - nokogiri (1.16.7-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) - racc (~> 1.4) - paypal-server-sdk (0.5.1) - apimatic_core (~> 0.3.9) - apimatic_core_interfaces (~> 0.2.1) - apimatic_faraday_client_adapter (~> 0.1.4) - puma (6.4.3) - nio4r (~> 2.0) - racc (1.8.1) - rack (3.1.7) - rack-protection (4.0.0) - base64 (>= 0.1.0) - rack (>= 3.0.0, < 4) - rack-session (2.0.0) - rack (>= 3.0.0) - rackup (2.1.0) - rack (>= 3) - webrick (~> 1.8) - ruby2_keywords (0.0.5) - sinatra (4.0.0) - mustermann (~> 3.0) - rack (>= 3.0.0, < 4) - rack-protection (= 4.0.0) - rack-session (>= 2.0.0, < 3) - tilt (~> 2.0) - sinatra-contrib (4.0.0) - multi_json (>= 0.0.2) - mustermann (~> 3.0) - rack-protection (= 4.0.0) - sinatra (= 4.0.0) - tilt (~> 2.0) - tilt (2.4.0) - uri (0.13.1) - webrick (1.8.2) - zlib (2.1.1) - -PLATFORMS - aarch64-linux - arm-linux - arm64-darwin - x86-linux - x86_64-darwin - x86_64-linux - -DEPENDENCIES - dotenv (~> 3.1) - paypal-server-sdk (~> 0.5.1) - puma (~> 6.4) - rackup (~> 2.1) - sinatra (~> 4.0) - sinatra-contrib (~> 4.0) - -BUNDLED WITH - 2.5.16 diff --git a/standard-integration/server/ruby/Gemfile.lock b/standard-integration/server/ruby/Gemfile.lock deleted file mode 100644 index d66a7748..00000000 --- a/standard-integration/server/ruby/Gemfile.lock +++ /dev/null @@ -1,118 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - apimatic_core (0.3.10) - apimatic_core_interfaces (~> 0.2.0) - certifi (~> 2018.1, >= 2018.01.18) - faraday-multipart (~> 1.0) - nokogiri (~> 1.10, >= 1.10.10) - apimatic_core_interfaces (0.2.1) - apimatic_faraday_client_adapter (0.1.4) - apimatic_core_interfaces (~> 0.2.0) - certifi (~> 2018.1, >= 2018.01.18) - faraday (~> 2.0, >= 2.0.1) - faraday-follow_redirects (~> 0.2) - faraday-gzip (~> 1.0) - faraday-http-cache (~> 2.2) - faraday-multipart (~> 1.0) - faraday-net_http_persistent (~> 2.0) - faraday-retry (~> 2.0) - base64 (0.2.0) - certifi (2018.01.18) - connection_pool (2.4.1) - dotenv (3.1.4) - faraday (2.12.0) - faraday-net_http (>= 2.0, < 3.4) - json - logger - faraday-follow_redirects (0.3.0) - faraday (>= 1, < 3) - faraday-gzip (1.0.0) - faraday (>= 1.0) - zlib (~> 2.1) - faraday-http-cache (2.5.1) - faraday (>= 0.8) - faraday-multipart (1.0.4) - multipart-post (~> 2) - faraday-net_http (3.3.0) - net-http - faraday-net_http_persistent (2.2.0) - faraday (~> 2.5) - net-http-persistent (>= 4.0.4, < 5) - faraday-retry (2.2.1) - faraday (~> 2.0) - json (2.7.2) - logger (1.6.1) - multi_json (1.15.0) - multipart-post (2.4.1) - mustermann (3.0.3) - ruby2_keywords (~> 0.0.1) - net-http (0.4.1) - uri - net-http-persistent (4.0.4) - connection_pool (~> 2.2) - nio4r (2.7.3) - nokogiri (1.16.7-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.7-arm-linux) - racc (~> 1.4) - nokogiri (1.16.7-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.7-x86-linux) - racc (~> 1.4) - nokogiri (1.16.7-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) - racc (~> 1.4) - paypal-server-sdk (0.5.1) - apimatic_core (~> 0.3.9) - apimatic_core_interfaces (~> 0.2.1) - apimatic_faraday_client_adapter (~> 0.1.4) - puma (6.4.3) - nio4r (~> 2.0) - racc (1.8.1) - rack (3.1.7) - rack-protection (4.0.0) - base64 (>= 0.1.0) - rack (>= 3.0.0, < 4) - rack-session (2.0.0) - rack (>= 3.0.0) - rackup (2.1.0) - rack (>= 3) - webrick (~> 1.8) - ruby2_keywords (0.0.5) - sinatra (4.0.0) - mustermann (~> 3.0) - rack (>= 3.0.0, < 4) - rack-protection (= 4.0.0) - rack-session (>= 2.0.0, < 3) - tilt (~> 2.0) - sinatra-contrib (4.0.0) - multi_json (>= 0.0.2) - mustermann (~> 3.0) - rack-protection (= 4.0.0) - sinatra (= 4.0.0) - tilt (~> 2.0) - tilt (2.4.0) - uri (0.13.1) - webrick (1.8.2) - zlib (2.1.1) - -PLATFORMS - aarch64-linux - arm-linux - arm64-darwin - x86-linux - x86_64-darwin - x86_64-linux - -DEPENDENCIES - dotenv (~> 3.1) - paypal-server-sdk (~> 0.5.1) - puma (~> 6.4) - rackup (~> 2.1) - sinatra (~> 4.0) - sinatra-contrib (~> 4.0) - -BUNDLED WITH - 2.5.16 From cdbac46f71635e76096859d42775d56c8e7d5ffa Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Mon, 30 Sep 2024 11:22:11 -0400 Subject: [PATCH 11/13] Simplify directory structure for Python apps --- .../v2/server/python/server/__init__.py | 89 ------------------- .../server/python/server/__init__.py | 89 ------------------- 2 files changed, 178 deletions(-) delete mode 100644 advanced-integration/v2/server/python/server/__init__.py delete mode 100644 standard-integration/server/python/server/__init__.py diff --git a/advanced-integration/v2/server/python/server/__init__.py b/advanced-integration/v2/server/python/server/__init__.py deleted file mode 100644 index 05ab4b08..00000000 --- a/advanced-integration/v2/server/python/server/__init__.py +++ /dev/null @@ -1,89 +0,0 @@ -import logging -import os - -from dotenv import load_dotenv -from flask import Flask, request -from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials -from paypalserversdk.logging.configuration.api_logging_configuration import LoggingConfiguration, \ - RequestLoggingConfiguration, ResponseLoggingConfiguration -from paypalserversdk.paypalserversdk_client import PaypalserversdkClient -from paypalserversdk.controllers.orders_controller import OrdersController -from paypalserversdk.models.amount_with_breakdown import AmountWithBreakdown -from paypalserversdk.models.checkout_payment_intent import CheckoutPaymentIntent -from paypalserversdk.models.order_request import OrderRequest -from paypalserversdk.models.purchase_unit_request import PurchaseUnitRequest -from paypalserversdk.api_helper import ApiHelper - -app = Flask(__name__) - -load_dotenv() - -paypal_client: PaypalserversdkClient = PaypalserversdkClient( - client_credentials_auth_credentials=ClientCredentialsAuthCredentials( - o_auth_client_id=os.getenv('PAYPAL_CLIENT_ID'), - o_auth_client_secret=os.getenv('PAYPAL_CLIENT_SECRET') - ), - logging_configuration=LoggingConfiguration( - log_level=logging.INFO, - # Disable masking of sensitive headers for Sandbox testing. - # This should be set to True (the default if unset)in production. - mask_sensitive_headers=False, - request_logging_config=RequestLoggingConfiguration( - log_headers=True, - log_body=True - ), - response_logging_config=ResponseLoggingConfiguration( - log_headers=True, - log_body=True - ) - ) -) - -''' -Health check -''' -@app.route('/', methods=['GET']) -def index(): - return {"message": "Server is running"} - -orders_controller: OrdersController = paypal_client.orders - -''' -Create an order to start the transaction. - -@see https://developer.paypal.com/docs/api/orders/v2/#orders_create -''' -@app.route('/api/orders', methods=['POST']) -def create_order(): - request_body = request.get_json() - # use the cart information passed from the front-end to calculate the order amount detals - cart = request_body['cart'] - order = orders_controller.orders_create({ - "body": OrderRequest( - intent=CheckoutPaymentIntent.CAPTURE, - purchase_units=[ - PurchaseUnitRequest( - AmountWithBreakdown( - currency_code='USD', - value='100.00' - ) - ) - ] - ), - "prefer": 'return=representation' - } - ) - return ApiHelper.json_serialize(order.body) - -''' - Capture payment for the created order to complete the transaction. - - @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture -''' -@app.route('/api/orders//capture', methods=['POST']) -def capture_order(order_id): - order = orders_controller.orders_capture({ - 'id': order_id, - 'prefer': 'return=representation' - }) - return ApiHelper.json_serialize(order.body) \ No newline at end of file diff --git a/standard-integration/server/python/server/__init__.py b/standard-integration/server/python/server/__init__.py deleted file mode 100644 index 05ab4b08..00000000 --- a/standard-integration/server/python/server/__init__.py +++ /dev/null @@ -1,89 +0,0 @@ -import logging -import os - -from dotenv import load_dotenv -from flask import Flask, request -from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials -from paypalserversdk.logging.configuration.api_logging_configuration import LoggingConfiguration, \ - RequestLoggingConfiguration, ResponseLoggingConfiguration -from paypalserversdk.paypalserversdk_client import PaypalserversdkClient -from paypalserversdk.controllers.orders_controller import OrdersController -from paypalserversdk.models.amount_with_breakdown import AmountWithBreakdown -from paypalserversdk.models.checkout_payment_intent import CheckoutPaymentIntent -from paypalserversdk.models.order_request import OrderRequest -from paypalserversdk.models.purchase_unit_request import PurchaseUnitRequest -from paypalserversdk.api_helper import ApiHelper - -app = Flask(__name__) - -load_dotenv() - -paypal_client: PaypalserversdkClient = PaypalserversdkClient( - client_credentials_auth_credentials=ClientCredentialsAuthCredentials( - o_auth_client_id=os.getenv('PAYPAL_CLIENT_ID'), - o_auth_client_secret=os.getenv('PAYPAL_CLIENT_SECRET') - ), - logging_configuration=LoggingConfiguration( - log_level=logging.INFO, - # Disable masking of sensitive headers for Sandbox testing. - # This should be set to True (the default if unset)in production. - mask_sensitive_headers=False, - request_logging_config=RequestLoggingConfiguration( - log_headers=True, - log_body=True - ), - response_logging_config=ResponseLoggingConfiguration( - log_headers=True, - log_body=True - ) - ) -) - -''' -Health check -''' -@app.route('/', methods=['GET']) -def index(): - return {"message": "Server is running"} - -orders_controller: OrdersController = paypal_client.orders - -''' -Create an order to start the transaction. - -@see https://developer.paypal.com/docs/api/orders/v2/#orders_create -''' -@app.route('/api/orders', methods=['POST']) -def create_order(): - request_body = request.get_json() - # use the cart information passed from the front-end to calculate the order amount detals - cart = request_body['cart'] - order = orders_controller.orders_create({ - "body": OrderRequest( - intent=CheckoutPaymentIntent.CAPTURE, - purchase_units=[ - PurchaseUnitRequest( - AmountWithBreakdown( - currency_code='USD', - value='100.00' - ) - ) - ] - ), - "prefer": 'return=representation' - } - ) - return ApiHelper.json_serialize(order.body) - -''' - Capture payment for the created order to complete the transaction. - - @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture -''' -@app.route('/api/orders//capture', methods=['POST']) -def capture_order(order_id): - order = orders_controller.orders_capture({ - 'id': order_id, - 'prefer': 'return=representation' - }) - return ApiHelper.json_serialize(order.body) \ No newline at end of file From 31e8d0ebacdc8025e5c9c9386266f4a936c50d4d Mon Sep 17 00:00:00 2001 From: Tim Martinak Date: Wed, 9 Oct 2024 15:36:58 -0400 Subject: [PATCH 12/13] Remove dotenv & prefer pre-set shell env var; bump sdk version --- .gitignore | 2 +- .../v2/server/python/.env.example | 5 ----- .../v2/server/python/README.md | 20 +++++++++++-------- .../v2/server/ruby/.env.example | 5 ----- advanced-integration/v2/server/ruby/Gemfile | 4 +--- .../server/python/.env.example | 5 ----- standard-integration/server/ruby/.env.example | 5 ----- standard-integration/server/ruby/Gemfile | 4 +--- 8 files changed, 15 insertions(+), 35 deletions(-) delete mode 100644 advanced-integration/v2/server/python/.env.example delete mode 100644 advanced-integration/v2/server/ruby/.env.example delete mode 100644 standard-integration/server/python/.env.example delete mode 100644 standard-integration/server/ruby/.env.example diff --git a/.gitignore b/.gitignore index 513c3b5b..d9fd284a 100644 --- a/.gitignore +++ b/.gitignore @@ -114,4 +114,4 @@ __pycache__ #Codespace .vscode/settings.json -.devcontainer/update_settings.sh \ No newline at end of file +.devcontainer/update_settings.sh diff --git a/advanced-integration/v2/server/python/.env.example b/advanced-integration/v2/server/python/.env.example deleted file mode 100644 index 2251fbbb..00000000 --- a/advanced-integration/v2/server/python/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -# Create an application to obtain credentials at -# https://developer.paypal.com/dashboard/applications/sandbox - -PAYPAL_CLIENT_ID=YOUR_CLIENT_ID_GOES_HERE -PAYPAL_CLIENT_SECRET=YOUR_SECRET_GOES_HERE diff --git a/advanced-integration/v2/server/python/README.md b/advanced-integration/v2/server/python/README.md index 6188a5c2..37e6a15b 100644 --- a/advanced-integration/v2/server/python/README.md +++ b/advanced-integration/v2/server/python/README.md @@ -1,15 +1,19 @@ -# Standard Integration Ruby Sinatra Sample +# Standard Integration Python Flask Sample -PayPal Standard Integration sample in Ruby using Sinatra +PayPal Standard Integration sample in Python using Flask ## Running the sample -1. **Ensure you have a supported Ruby version installed**: [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/) +1. **Setup a virtual environment** + + ```sh + python3 -m venv .venv + ``` 1. **Install the dependencies** - ```bash - bundle install + ```sh + pip install -r requirements.txt ``` 1. **Add your API credentials to the environment:** @@ -30,8 +34,8 @@ PayPal Standard Integration sample in Ruby using Sinatra 1. **Run the server** - ```bash - bundle exec ruby server.rb + ```sh + flask --app server run --port 8080 ``` -1. Go to [http://localhost:8080/](http://localhost:8080/) \ No newline at end of file +1. Go to [http://localhost:8080/](http://localhost:8080/) \ No newline at end of file diff --git a/advanced-integration/v2/server/ruby/.env.example b/advanced-integration/v2/server/ruby/.env.example deleted file mode 100644 index 2251fbbb..00000000 --- a/advanced-integration/v2/server/ruby/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -# Create an application to obtain credentials at -# https://developer.paypal.com/dashboard/applications/sandbox - -PAYPAL_CLIENT_ID=YOUR_CLIENT_ID_GOES_HERE -PAYPAL_CLIENT_SECRET=YOUR_SECRET_GOES_HERE diff --git a/advanced-integration/v2/server/ruby/Gemfile b/advanced-integration/v2/server/ruby/Gemfile index 64f65682..a5b31725 100644 --- a/advanced-integration/v2/server/ruby/Gemfile +++ b/advanced-integration/v2/server/ruby/Gemfile @@ -2,9 +2,7 @@ source "https://rubygems.org" - -gem "dotenv", "~> 3.1" -gem "paypal-server-sdk", "~> 0.5.1" +gem "paypal-server-sdk", "~> 0.5.2" gem "puma", "~> 6.4" gem "rackup", "~> 2.1" gem "sinatra", "~> 4.0" diff --git a/standard-integration/server/python/.env.example b/standard-integration/server/python/.env.example deleted file mode 100644 index 2251fbbb..00000000 --- a/standard-integration/server/python/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -# Create an application to obtain credentials at -# https://developer.paypal.com/dashboard/applications/sandbox - -PAYPAL_CLIENT_ID=YOUR_CLIENT_ID_GOES_HERE -PAYPAL_CLIENT_SECRET=YOUR_SECRET_GOES_HERE diff --git a/standard-integration/server/ruby/.env.example b/standard-integration/server/ruby/.env.example deleted file mode 100644 index 2251fbbb..00000000 --- a/standard-integration/server/ruby/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -# Create an application to obtain credentials at -# https://developer.paypal.com/dashboard/applications/sandbox - -PAYPAL_CLIENT_ID=YOUR_CLIENT_ID_GOES_HERE -PAYPAL_CLIENT_SECRET=YOUR_SECRET_GOES_HERE diff --git a/standard-integration/server/ruby/Gemfile b/standard-integration/server/ruby/Gemfile index 64f65682..a5b31725 100644 --- a/standard-integration/server/ruby/Gemfile +++ b/standard-integration/server/ruby/Gemfile @@ -2,9 +2,7 @@ source "https://rubygems.org" - -gem "dotenv", "~> 3.1" -gem "paypal-server-sdk", "~> 0.5.1" +gem "paypal-server-sdk", "~> 0.5.2" gem "puma", "~> 6.4" gem "rackup", "~> 2.1" gem "sinatra", "~> 4.0" From ee0e6ce430ce703a5039e985d91ba63a689839be Mon Sep 17 00:00:00 2001 From: Umar Nafeez Abdul Phatip Date: Tue, 15 Oct 2024 11:24:43 +0530 Subject: [PATCH 13/13] Adding devcontianer files for Ruby and Python for module Advanced and Standard Integration --- .../devcontainer.json | 52 +++++++++++++++++++ .../welcome-message.sh | 23 ++++++++ .../devcontainer.json | 52 +++++++++++++++++++ .../welcome-message.sh | 23 ++++++++ .../devcontainer.json | 52 +++++++++++++++++++ .../welcome-message.sh | 23 ++++++++ .../devcontainer.json | 52 +++++++++++++++++++ .../welcome-message.sh | 23 ++++++++ .devcontainer/post-commands.sh | 12 +++++ .../devcontainer.json | 51 ++++++++++++++++++ .../welcome-message.sh | 23 ++++++++ .../devcontainer.json | 51 ++++++++++++++++++ .../welcome-message.sh | 23 ++++++++ .../devcontainer.json | 51 ++++++++++++++++++ .../welcome-message.sh | 23 ++++++++ .../devcontainer.json | 51 ++++++++++++++++++ .../welcome-message.sh | 23 ++++++++ .gitignore | 10 ++-- .../v2/server/python/README.md | 4 +- 19 files changed, 614 insertions(+), 8 deletions(-) create mode 100644 .devcontainer/advanced-integration-v2-html-python/devcontainer.json create mode 100644 .devcontainer/advanced-integration-v2-html-python/welcome-message.sh create mode 100644 .devcontainer/advanced-integration-v2-html-ruby/devcontainer.json create mode 100644 .devcontainer/advanced-integration-v2-html-ruby/welcome-message.sh create mode 100644 .devcontainer/advanced-integration-v2-react-python/devcontainer.json create mode 100644 .devcontainer/advanced-integration-v2-react-python/welcome-message.sh create mode 100644 .devcontainer/advanced-integration-v2-react-ruby/devcontainer.json create mode 100644 .devcontainer/advanced-integration-v2-react-ruby/welcome-message.sh create mode 100644 .devcontainer/standard-integration-html-python/devcontainer.json create mode 100644 .devcontainer/standard-integration-html-python/welcome-message.sh create mode 100644 .devcontainer/standard-integration-html-ruby/devcontainer.json create mode 100644 .devcontainer/standard-integration-html-ruby/welcome-message.sh create mode 100644 .devcontainer/standard-integration-react-python/devcontainer.json create mode 100644 .devcontainer/standard-integration-react-python/welcome-message.sh create mode 100644 .devcontainer/standard-integration-react-ruby/devcontainer.json create mode 100644 .devcontainer/standard-integration-react-ruby/welcome-message.sh diff --git a/.devcontainer/advanced-integration-v2-html-python/devcontainer.json b/.devcontainer/advanced-integration-v2-html-python/devcontainer.json new file mode 100644 index 00000000..4efa388c --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-python/devcontainer.json @@ -0,0 +1,52 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/html/python", + "image": "mcr.microsoft.com/devcontainers/python:3.12", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-html-python/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": "python", + "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/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/advanced-integration-v2-html-python/welcome-message.sh b/.devcontainer/advanced-integration-v2-html-python/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-python/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-ruby/devcontainer.json b/.devcontainer/advanced-integration-v2-html-ruby/devcontainer.json new file mode 100644 index 00000000..4fabbaf4 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-ruby/devcontainer.json @@ -0,0 +1,52 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/html/ruby", + "image": "mcr.microsoft.com/devcontainers/ruby:3.3", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-html-ruby/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": "ruby", + "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/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/advanced-integration-v2-html-ruby/welcome-message.sh b/.devcontainer/advanced-integration-v2-html-ruby/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-html-ruby/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-python/devcontainer.json b/.devcontainer/advanced-integration-v2-react-python/devcontainer.json new file mode 100644 index 00000000..ed284272 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-python/devcontainer.json @@ -0,0 +1,52 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/react/python", + "image": "mcr.microsoft.com/devcontainers/python:3.12", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-react-python/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": "python", + "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/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/advanced-integration-v2-react-python/welcome-message.sh b/.devcontainer/advanced-integration-v2-react-python/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-python/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-ruby/devcontainer.json b/.devcontainer/advanced-integration-v2-react-ruby/devcontainer.json new file mode 100644 index 00000000..89e2a064 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-ruby/devcontainer.json @@ -0,0 +1,52 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "advanced-integration-v2/react/ruby", + "image": "mcr.microsoft.com/devcontainers/ruby:3.3", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/advanced-integration-v2-react-ruby/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": "ruby", + "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/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/advanced-integration-v2-react-ruby/welcome-message.sh b/.devcontainer/advanced-integration-v2-react-ruby/welcome-message.sh new file mode 100644 index 00000000..ae9a72f9 --- /dev/null +++ b/.devcontainer/advanced-integration-v2-react-ruby/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 index 505bdf50..69b269be 100755 --- a/.devcontainer/post-commands.sh +++ b/.devcontainer/post-commands.sh @@ -34,6 +34,12 @@ setup_backend() { php) cd "$SERVER_DIR" && cd php && composer install ;; + python) + cd "$SERVER_DIR" && cd python && python -m venv .venv && pip install -r requirements.txt + ;; + ruby) + cd "$SERVER_DIR" && cd ruby && bundle install + ;; *) echo "Unknown server: $VISIBLE_FOLDER_SERVER" exit 1 @@ -61,6 +67,12 @@ start_backend() { php) cd "$SERVER_DIR/php" && composer start ;; + python) + cd "$SERVER_DIR" && cd python && flask --app server run --port 8080 + ;; + ruby) + cd "$SERVER_DIR" && cd ruby && bundle exec ruby server.rb + ;; *) echo "Unknown server: $VISIBLE_FOLDER_SERVER" exit 1 diff --git a/.devcontainer/standard-integration-html-python/devcontainer.json b/.devcontainer/standard-integration-html-python/devcontainer.json new file mode 100644 index 00000000..70dabad3 --- /dev/null +++ b/.devcontainer/standard-integration-html-python/devcontainer.json @@ -0,0 +1,51 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "standard-integration/html/python", + "image": "mcr.microsoft.com/devcontainers/python:3.12", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/standard-integration-html-python/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": "python", + "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/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/standard-integration-html-python/welcome-message.sh b/.devcontainer/standard-integration-html-python/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-html-python/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-ruby/devcontainer.json b/.devcontainer/standard-integration-html-ruby/devcontainer.json new file mode 100644 index 00000000..1d6cb8a7 --- /dev/null +++ b/.devcontainer/standard-integration-html-ruby/devcontainer.json @@ -0,0 +1,51 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "standard-integration/html/ruby", + "image": "mcr.microsoft.com/devcontainers/ruby:3.3", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/standard-integration-html-ruby/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": "ruby", + "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/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/standard-integration-html-ruby/welcome-message.sh b/.devcontainer/standard-integration-html-ruby/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-html-ruby/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-python/devcontainer.json b/.devcontainer/standard-integration-react-python/devcontainer.json new file mode 100644 index 00000000..395f8f62 --- /dev/null +++ b/.devcontainer/standard-integration-react-python/devcontainer.json @@ -0,0 +1,51 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "standard-integration/react/python", + "image": "mcr.microsoft.com/devcontainers/python:3.12", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/standard-integration-react-python/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": "python", + "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/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/standard-integration-react-python/welcome-message.sh b/.devcontainer/standard-integration-react-python/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-react-python/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-ruby/devcontainer.json b/.devcontainer/standard-integration-react-ruby/devcontainer.json new file mode 100644 index 00000000..2037d401 --- /dev/null +++ b/.devcontainer/standard-integration-react-ruby/devcontainer.json @@ -0,0 +1,51 @@ +// For more details, see https://aka.ms/devcontainer.json. +{ + "name": "standard-integration/react/ruby", + "image": "mcr.microsoft.com/devcontainers/ruby:3.3", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + // Use 'onCreateCommand' to run commands when creating the container. + "onCreateCommand": "bash .devcontainer/standard-integration-react-ruby/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": "ruby", + "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/node:1": { + "version": "lts" + } + } +} diff --git a/.devcontainer/standard-integration-react-ruby/welcome-message.sh b/.devcontainer/standard-integration-react-ruby/welcome-message.sh new file mode 100644 index 00000000..78cce216 --- /dev/null +++ b/.devcontainer/standard-integration-react-ruby/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/.gitignore b/.gitignore index d9fd284a..734d3368 100644 --- a/.gitignore +++ b/.gitignore @@ -103,15 +103,13 @@ dist # dotnet *.sln - # env *.local -# Python -.venv -__pycache__ - - #Codespace .vscode/settings.json .devcontainer/update_settings.sh + +# Python +.venv +__pycache__ diff --git a/advanced-integration/v2/server/python/README.md b/advanced-integration/v2/server/python/README.md index 37e6a15b..024410d0 100644 --- a/advanced-integration/v2/server/python/README.md +++ b/advanced-integration/v2/server/python/README.md @@ -35,7 +35,7 @@ PayPal Standard Integration sample in Python using Flask 1. **Run the server** ```sh - flask --app server run --port 8080 + flask --app server run --port 8080 ``` -1. Go to [http://localhost:8080/](http://localhost:8080/) \ No newline at end of file +1. Go to [http://localhost:8080/](http://localhost:8080/) \ No newline at end of file