Introduction

Accept in-person card payments with Tap to Pay on iPhone and Android.

The Terminal SDK (@lemonway/terminal) is a React Native library that turns the merchant's phone into a card terminal with Tap to Pay on iPhone and Android. The customer taps their card or wallet on the phone, and the payment goes through a PayGreen Payment Order.

Your app never handles card data and never holds a secret key.

🚧

Beta

The SDK is in beta (0.1.0-beta.x). Its API can still change between beta versions.


Core concepts

ConceptWhat it is
💳 Payment OrderCreated by your backend with source: tap_to_pay. It fixes the amount.
🔑 Object SecretReturned once when the Payment Order is created. Lets the app authorize that Payment Order only, with your public key.
🟢 Public KeyIdentifies your shop in the app (pk_…). Safe to ship in the app.
🔒 Secret KeyUsed by your backend to get a JWT. Never ship it in the app.
📡 Connection tokenShort-lived token that opens a Tap to Pay session. Your backend requests it; the SDK asks your app for it through tokenProvider.
📍 LocationThe shop's Tap to Pay location (tml_…). Returned with the connection token.

Payment flow at a glance

sequenceDiagram
    participant B as Your backend
    participant A as Your app + SDK
    participant P as PayGreen API
    B->>P: Create Payment Order (JWT, source tap_to_pay)
    P-->>B: id + object_secret
    B-->>A: id + object_secret
    A->>P: authorizePaymentOrder() (public key + object_secret)
    P-->>A: authorized payment
    A->>A: collectPayment(): the customer taps
    P-->>B: Webhook payment_order.tap_to_pay.*
  1. Your backend creates the Payment Order. The amount is decided there, never in the app.
  2. The app authorizes it with authorizePaymentOrder(), then collects the card with collectPayment().
  3. Your backend confirms the payment from the webhook. SDK events only drive the UI.

Before you start

👍

Make sure you have:

  • A validated account on app.paygreen.fr with an enabled bank_card payment config. Tap to Pay needs nothing else.
  • Your public key and secret key (Keys page).
  • A React Native app, with Expo (development build) or the React Native CLI.
  • A supported phone: see Device requirements.

Integration steps

  1. Getting Started: install the SDK and set up the native project.
  2. Backend integration: create Payment Orders and serve connection tokens.
  3. Init and connect: initialize the SDK and connect the phone.
  4. Payment Flow: take payments.
  5. Confirm payments: listen to webhooks on your backend.
  6. Error handling and Events: build the UI around them.

Did this page help you?