Website without WordPress: embed script
A simple website that can show an amount and run one script needs neither the plugin nor any development. The script reads the amount, currency and reference from your page and shows the QR code in inline mode.
data-site |
The address of your website as you added it in the app. Without it the address of the page itself is used. |
|---|---|
data-location |
The ID of your Stripe Terminal Location, it starts with tml_. |
data-amount |
CSS selector of the element that holds the amount, for example #order-total. The currency can be part of its text (CZK, Kč, €). |
data-reference |
CSS selector of the element that holds the order number or another reference, 1 to 64 characters. |
data-target |
CSS selector of the element where the QR code appears. Without it the QR code appears right after the script. |
data-currency, data-description, data-merchant |
Optional selectors for the currency, the description and the merchant name. Add -value for a fixed value (data-currency-value) or -attr to read an attribute instead of the text (data-amount-attr). |
data-ttl |
How long the QR code is valid, in seconds. The default is 300. |
Prepare Stripe: get key C (see the article on Stripe keys) and create the Terminal Location by hand (Terminal → Locations, copy the tml_ ID). You need no webhook and no key A or B.
Upload qr2stripe.js to your website and add the code from the example after the elements that hold the values. Host the file yourself, do not load a payment script from a third party.
In the phone app do the same as for inline mode: add the website, switch on Pay from data inside the QR (not verified by the website) and enter key C.
Take a payment: open the page, scan the QR with the app, check the amount on the phone and let the customer tap their card. When the amount on the page changes, the QR code changes within a second.
The page does not change to Paid, because no server confirms the payment. The phone shows Payment successful once Stripe has confirmed the card payment and keeps the payment in the list Payments on this phone. You can also check payments in the Stripe Dashboard: the metadata of the payment contain source = qr2stripe-inline and reservation_id with your reference.
This is inline mode: the amount is not signed, so anyone who can edit the page in their own browser can change it. Check the amount on the phone every time and use the script only when you are present at the payment. For unattended payments use API mode with the WordPress plugin.
<div id="payment-qr"></div>
<script src="/js/qr2stripe.js"
data-site="https://www.example.com"
data-location="tml_xxxxxxxx"
data-amount="#order-total"
data-reference="#order-number"
data-target="#payment-qr"></script>