Before you start
- The checkout is registered as a payment location. See Setting up a payment location.
- The customer is checked in at it, so the POS has their
memberId. See Registering at POS. - Server-to-server authentication must be working. See API authentication.
The flow
With confirmation, the customer approves the payment in the app before the POS captures it. This is the flow for card, wallet and subscription payments, and for bonus when you want the customer to confirm. Without confirmation, a payment taken entirely from the customer’s bonus balance is created and captured in two calls.
1
Create the payment
POST /v2/paymentsThe request carries:type, set toPOS.paymentLocation, the checkout.receiptId, the sale.memberId, from check-in.amount, what the customer pays.operationId, unique per attempt. Reuse it only when retrying the same attempt, so a retry cannot create a second payment.requestMemberConfirmation,trueorfalse, explained below.
paymentId.Set requestMemberConfirmation: true to let the customer choose the payment method and confirm in the app. The payment starts in the WaitingMemberConfirmation state. Set it to false only for a payment taken entirely from the customer’s bonus balance. Lobyco then confirms it without the customer, and the payment starts in WaitingPosCapture. The customer must confirm a card or wallet payment.2
Wait for the customer to confirm
GET /v2/payments/{paymentId}Poll the payment every few seconds while itsstate is WaitingMemberConfirmation. The customer sees the amount in the app, picks a method and confirms. The state then changes to WaitingPosCapture. Give the customer a fixed time to confirm, and cancel the payment when it runs out, so the till is not left waiting.3
Capture the payment
POST /v2/payments/{paymentId}/captureCapture once the state isWaitingPosCapture. Send the amount and an operationId. A partial capture is allowed, and Lobyco cancels the remainder. The state becomes Captured, and the money moves. That is the finished payment.If the purchase reaches Lobyco first, with the same amount, Lobyco captures the payment when it loads the purchase. See How the purchase checks the payment.4
[Optional] Cancel the payment
POST /v1/payments/{paymentId}/cancelCancel a payment that has not been captured, because the customer did not confirm in time or the sale was abandoned. The state becomesCanceled.5
[Optional] Refund the payment
POST /v1/payments/{paymentId}/refundRefund a payment that has been captured, for example on a return. A refund is a separate transaction that references the original. It refunds the whole captured amount, on every payment method the payment used. Bonus goes back to the customer’s balance, and a card payment goes back to the card. There is no partial refund. It reportsWaitingRefund while in progress and Refunded when done.How the purchase checks the payment
The purchase you send to the Purchase API is more than the record of the sale. When Lobyco loads a purchase, it looks up the payment under the samereceiptId and compares the two. Record a payment taken through the Payment Coordinator as one entry in paymentMethods, with paymentType LoyaltyApp and the captured amount. What Lobyco then does depends on what it finds:
A purchase with no
LoyaltyApp entry and no payment under its receiptId is an ordinary sale, paid another way. A memberId that differs between the purchase and the payment is logged, and the payment is left as it is. So is more than one payment under the receiptId. A payment whose purchase never arrives is not touched by the check. A nightly job cancels every payment still waiting for confirmation or capture 3 hours after it was created, and completes a refund still in WaitingRefund. Cancel an abandoned payment yourself rather than leave it to the job, so the customer’s balance is released at once.
Payment states
Payment methods and providers
For a POS payment the customer picks the method in the app when confirming. The methods are bonus, a saved or new card, a loyalty subscription, Apple Pay and Google Pay. Which of them a customer sees depends on what is enabled for your programme. Card handling sits behind the Payment Card Provider, Lobyco’s generic card service. The acquirer can change without a change to your integration. Worldline, Rapyd and Moneris are supported today, and Lobyco can add providers. It covers saving a card against the customer’s account for reuse, and paying without storing the card. It also handles Apple Pay and Google Pay, loyalty subscription top-ups, and a web interface for managing saved cards where one is needed. The same service takes e-commerce and scan-and-pay payments. Those usetype: Ecommerce or type: ScanAndPay with a storeId instead of a paymentLocation, and otherwise follow the same states.
Failure and edge cases
If a payment does not reachCaptured, or a call fails, it is one of these.
- A call times out. Retry it with the same
operationId. Lobyco recognises the retry and does not create or capture twice. - The customer never confirms. Cancel the payment when your timeout runs out, so the app stops showing it, then take the payment another way. A payment left waiting is cancelled by the nightly job, as under How the purchase checks the payment.
- Cancel and refund are not interchangeable. Cancel works only before capture, refund only after it. The call for the wrong state fails.
- The POS could not finish. Admin users see every payment in Lobyco Nexus, and can capture, cancel or refund one by hand.
- A captured payment does not record the sale. Send the finished sale to the Purchase API as well, as described in Transaction data.
- The purchase records the app payment under another type. Lobyco cancels the payment, or refunds it if it was captured, when it loads the purchase. Record it as
LoyaltyApp, as under How the purchase checks the payment. - The purchase’s amount differs from the payment. Lobyco logs the mismatch and leaves the payment as it is. Capture or cancel it yourself, and send the purchase with the amount you captured.
API reference
Endpoint documentation: Payment Coordinator.Related
- Registering at POS — the check-in that supplies the
memberIdand the amount the customer can pay from their account. - Transaction data — the call that records the sale. Capturing a payment does not.