+ Create locations to organize your readers. Locations group
+ readers and allow them to automatically download the reader
+ configuration needed for their region of use. You must assign
+ a location to each reader when you register it, which you can
+ do using the API or the Dashboard.
+
+
+
+
+
+
+
+
+ 2.
+ Register a Reader
+
+
+
+
+ Register your reader with Stripe Terminal to enable payment
+ processing.
+
+
+
+
+
+
+
+
Simulate a transaction
+
+
+
+
+
+ 3.
+ Enter the transaction amount and create a PaymentIntent
+
+
+
+
+ Simulate the amount you want to charge by entering it below. Use cents only—skip decimals and commas, since currency separators vary internationally.
+ Use this amount to create a PaymentIntent on your server. A PaymentIntent tracks the customer's payment lifecycle, keeping track of any failed attempts and ensuring they're only charged once.
+
+
+
+
Transaction amount
+
Use cents or the smallest currency unit.
+
+
+ $20.00 USD
+
+
+
+
+
+
+
+
+ 4.
+ Process PaymentIntent on the simulated reader
+
+
+
+
+ Create a PaymentIntent with the specific amount and process the payment on your simulated reader.
+ It prompts the customer to present their card by inserting or tapping it before attempting authorization.
+
+
+
+
+
+
+
+
+ 5.
+ Simulate card presentment by the cardholder
+
+
+
+
+
+ In a real transaction flow, the customer inserts or taps
+ their card on the physical reader. With a simulated reader,
+ you simulate the card presentment step by making another API
+ call.
+
+
+
+
+ This call successfully confirms the PaymentIntent with a test
+ card. You can also try other test cards.
+
+
+
+
+
+
+
+
+
+
Test card numbers
+
+ Payment succeeds
+ 4242 4242 4242 4242
+
+
+
+ Payment is declined
+ 4000 0000 0000 9995
+
+
+
+
+
+
+
+
+
+
+ 6.
+ Capture the PaymentIntent
+
+
+
+
+ Capture the authorized payment to complete the transaction.
+
+
+
+
+
+
+
+
+ 7.
+ View the payment in the Stripe Dashboard
+
+
+
+
View the completed payment in your Stripe Dashboard.
+
+
+
+
+
+
+
+
Logs
+
+ API request
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/stripe python-javascript severless/requirements.txt b/stripe python-javascript severless/requirements.txt
new file mode 100644
index 000000000..0bf4b9178
--- /dev/null
+++ b/stripe python-javascript severless/requirements.txt
@@ -0,0 +1,12 @@
+certifi==2021.5.30
+chardet==4.0.0
+Click==8.0.1
+Flask==2.1.0
+idna==3.2
+itsdangerous==2.0.1
+Jinja2==3.0.1
+MarkupSafe==2.0.1
+requests==2.26.0
+stripe==14.3.0
+toml==0.10.2
+Werkzeug==2.0.1
\ No newline at end of file
diff --git a/stripe python-javascript severless/server.py b/stripe python-javascript severless/server.py
new file mode 100644
index 000000000..57922277e
--- /dev/null
+++ b/stripe python-javascript severless/server.py
@@ -0,0 +1,145 @@
+#! /usr/bin/env python3.10
+
+# Python 3.10 or newer required.
+
+import json
+import os
+import stripe
+
+# This is your test secret API key.
+stripe.api_key = 'rk_test_51REzPYBUxEI2KOLvFD9b0XMfewiQXelHjds8bZ3k6p7dLJYq7B9EIakYL4tscIjfb2vDG7l2PC6jzxQUst53PMUy003d1o8Jn9'
+
+from flask import Flask, jsonify, request, render_template
+
+
+app = Flask(__name__, static_folder='public',
+ static_url_path='', template_folder='public')
+
+@app.route('/')
+def index():
+ return render_template('index.html')
+
+
+@app.route('/create_location', methods=['POST'])
+def create_location():
+ data = json.loads(request.data)
+
+ location = stripe.terminal.Location.create(
+ display_name=data['display_name'],
+ address={
+ 'line1': data['address']['line1'],
+ 'city': data['address']['city'],
+ 'state': data['address']['state'],
+ 'country': data['address']['country'],
+ 'postal_code': data['address']['postal_code'],
+ },
+ )
+
+ return location
+
+@app.route('/register_reader', methods=['POST'])
+def register_reader():
+ data = json.loads(request.data)
+
+ reader = stripe.terminal.Reader.create(
+ location=data['location_id'],
+ label='Quickstart - S700 Simulated Reader',
+ registration_code='simulated-s700'
+ )
+
+ return reader
+
+@app.route('/create_payment_intent', methods=['POST'])
+def secret():
+ data = json.loads(request.data)
+
+ # For Terminal payments, the 'payment_method_types' parameter must include
+ # 'card_present'.
+ # To automatically capture funds when a charge is authorized,
+ # set `capture_method` to `automatic`.
+ intent = stripe.PaymentIntent.create(
+ amount=data['amount'],
+ currency='usd',
+ payment_method_types=[
+ 'card_present',
+ ],
+ capture_method='automatic',
+ payment_method_options={
+ "card_present": {
+ "capture_method": "manual_preferred"
+ }
+ }
+ )
+ return intent
+
+@app.route('/process_payment', methods=['POST'])
+def process_payment():
+ data = json.loads(request.data)
+
+ tries = 3
+ for attempt in range(tries):
+ try:
+ reader = stripe.terminal.Reader.process_payment_intent(
+ data['reader_id'],
+ payment_intent=data['payment_intent_id'],
+ )
+ return reader
+ except stripe.error.InvalidRequestError as e:
+ if e.code == 'terminal_reader_timeout':
+ # Temporary networking blip, automatically retry a few times.
+ if attempt < tries - 1:
+ continue
+ else:
+ return e.json_body
+ elif e.code == 'terminal_reader_offline':
+ # Reader is offline and won't respond to API requests. Make sure the reader is powered on
+ # and connected to the internet before retrying.
+ app.logger.error(e)
+ return e.json_body
+ elif e.code == 'terminal_reader_busy':
+ # Reader is currently busy processing another request, installing updates or changing settings.
+ # Remember to disable the pay button in your point-of-sale application while waiting for a
+ # reader to respond to an API request.
+ app.logger.error(e)
+ return e.json_body
+ elif e.code == 'intent_invalid_state':
+ # Check PaymentIntent status because it's not ready to be processed. It might have been already
+ # successfully processed or canceled.
+ payment_intent = stripe.PaymentIntent.retrieve(data['payment_intent_id'])
+ app.logger.error('PaymentIntent is already in %s state.' % payment_intent.status)
+ return e.json_body
+ else:
+ app.logger.error(e)
+ return e.json_body
+
+@app.route('/simulate_payment', methods=['POST'])
+def simulate_payment():
+ data = json.loads(request.data)
+
+ options = {
+ "card_present": {
+ "number": data['card_number']
+ },
+ "type": "card_present"
+ }
+
+ reader = stripe.terminal.Reader.TestHelpers.present_payment_method(
+ data['reader_id'],
+ **options
+ )
+
+ return reader
+
+
+@app.route('/capture_payment_intent', methods=['POST'])
+def capture():
+ data = json.loads(request.data)
+
+ intent = stripe.PaymentIntent.capture(
+ data['payment_intent_id']
+ )
+
+ return intent
+
+if __name__ == '__main__':
+ app.run()
\ No newline at end of file
diff --git a/test-sandbox.py b/test-sandbox.py
new file mode 100644
index 000000000..2b4987285
--- /dev/null
+++ b/test-sandbox.py
@@ -0,0 +1,31 @@
+
+# Set your secret key. Remember to switch to your live secret key in production.
+# See your keys here: https://dashboard.stripe.com/apikeys
+import stripe
+stripe.api_key = "rk_test_51REzPYBUxEI2KOLvFD9b0XMfewiQXelHjds8bZ3k6p7dLJYq7B9EIakYL4tscIjfb2vDG7l2PC6jzxQUst53PMUy003d1o8Jn9"
+
+location = stripe.terminal.Location.create(
+ display_name="HQ",
+ address={
+ "line1": "1272 Valencia Street",
+ "city": "San Francisco",
+ "state": "CA",
+ "country": "US",
+ "postal_code": "94110",
+ },
+ stripe_account="acct_1REzPYBUxEI2KOLv",
+)
+
+
+
+
+
+
+
+
+
+
+
+
+
+