transferId that the library gives you.
The V1 API is on https://api.roqqett.com. Authenticate with a Roqqett API key in the X-API-KEY header. Amounts are integers in minor units, so 5499 is £54.99. The full reference is under Roqqett (deprecated) in the v1 tab.
Before you begin
In the Roqqett portal athttps://portal.roqqett.com:
- Go to API keys and create an API key. Treat its secret like a password, and keep it on your server.
- Go to Checkouts and create a checkout. Set its Default return URL, and its Webhook Url to an
httpsendpoint on your server. Keep the checkout’s ID.
How it works
1
Load the library
Your payment page loads the library and creates a Roqqett instance.
2
The payer clicks your Roqqett button
You call
checkout(). The library opens the Roqqett pop-up and gives you a transferId.3
Your server creates a cart
Your page sends the
transferId to your server, which creates a cart with POST /carts. The pop-up then shows the payment.4
The payer pays
The payer approves the payment at their bank, in the pop-up or on their phone.
5
Roqqett tells you the outcome
The library calls your callback in the browser, and Roqqett sends a webhook to your server.
Step 1: Load the library
Add the script to your payment page, and create the Roqqett instance once the page has loaded. Creating the instance adds a hidden 1×1 iframe to the page, which the library uses to talk to Roqqett.Roqqett() takes no arguments. You pass your callbacks to checkout().
Step 2: Add a Roqqett button
Add a button to your payment page for the payer to choose Roqqett, for example:Step 3: Start the checkout
Callcheckout() from your button’s click handler, before any await or network request. The library opens the pop-up as soon as you call it, and browsers block pop-ups that don’t open straight from a click. On a desktop, the pop-up offers a QR code or a text message so the payer can finish on their phone.
checkout(callbacks, isApp) resolves once the pop-up is ready, with:
transferId: the ID to create the cart with.isFresh:truefor a new payment. If the payer clicks again while the pop-up is still open, the library brings the existing pop-up to the front instead. Only create a cart whenisFreshistrue.
Roqqett doesn’t add query parameters to the return URL, so set a
returnUrl on each cart that identifies the order. For a payment that is still pending at the bank, the URL is your return URL with the text success replaced by pending, if it contains it. Either way, confirm the outcome with the webhook before fulfilling the order.
The library doesn’t tell your page when a cart is abandoned. Use the webhook for that.
If your page runs inside your own mobile app’s web view, pass true as isApp. The library then doesn’t dim your page behind the pop-up, and the payer is offered a button back to your return URL at the end.
Step 4: Create the cart
Your server creates the cart with thetransferId. The library must have registered the transferId first, so create the cart only after checkout() resolves.
POST
https://api.roqqett.com/carts
Keep the
cartId with your order. To cancel a cart, for example when the payer empties their basket, use PUT /carts/{cartId}/cancel.
Step 5: Handle the webhook
Roqqett posts a JSON body to the checkout’s webhook URL when a cart ends. Only fulfil the order once you receivecart_completed, not when the payer comes back to your site.
Answer with a
2xx status once you’ve stored the event. Roqqett retries cart events a few times when your endpoint fails, and sends order_refunded once.
Verify the webhook
Each webhook has aDigest header:
publicKey by GET /webhooks.
Authorization: Basic header with the username and password you chose.
The Ping button sends three requests: one validly signed, one unsigned and one with an invalid signature. Your endpoint should answer 200 to the first and 401 to the other two.
Test your integration
V1 carts have a test mode, which takes no money.- In the Roqqett portal, tick Test mode on the checkout. The checkout still takes real payments.
- Create the cart with
"testMode": true. - In the pop-up, choose an outcome, such as paid, cancelled or failed, instead of paying at a bank.
"testMode": true.
Move to the hosted checkout
To move off V1, replace the library andPOST /carts with a checkout session, and redirect the payer to its checkoutUrl. See Migrating from Roqqett V1.