Collecting on your own gateway
Your account can be set up to collect scan payments on your own gateway. The widget then asks your page for a checkout, and your server is what settles it. Contact support to have it enabled.
Collecting on your own gateway
By default, when a scan has to be paid for, the widget opens an Oyster checkout and Oyster receives the money. Your account can instead be set up to collect on your own gateway: the customer pays you, through your checkout, and Oyster invoices you for the scans. Contact support to have it enabled.
Nothing changes about who is asked to pay. That is still your configured scan payer.
The flow
- The widget asks Oyster to open a payment and gets back a reference.
- It calls your onCollectPayment handler with that reference.
- You collect however you like.
- Your server confirms to Oyster.
- The widget sees the confirmation and the scan runs.
Registering a handler
const widget = OysterskinWidget.createScanWidget({
publicKey: "YOUR_PUBLIC_KEY",
callback: handleMessage,
onCollectPayment: async ({ reference, amount, currency, email, batchId }) => {
// Create a checkout on your own gateway. Keep `reference` — your
// server needs it to confirm.
const res = await fetch("/my-store/scan-checkout", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ reference, amount, currency, email, batchId }),
});
const { checkoutUrl } = await res.json();
return { status: "redirect", checkoutUrl };
},
});
Without a handler, customers of a vendor on this mode cannot pay — the widget logs an error and tells them collection is unavailable. Register it before asking for this to be enabled.
What you can return
- { status: "redirect", checkoutUrl }: send the customer to your checkout. The widget reuses the window it already opened on their click, so pop-up blockers do not interfere.
- { status: "processing" }: you are collecting another way — your own modal, a card terminal, an account balance. The widget waits for your server.
- { status: "cancelled", reason? }: the customer backed out.
- { status: "failed", reason? }: collection could not start.
Send cancelled or failed rather than staying silent. A handler that never resolves leaves the customer watching a spinner until the widget gives up.
Returning the customer to the widget
After your checkout takes the payment, send the customer to the returnUrl the request carries:
window.location.href = request.returnUrl;
That page closes the payment window and puts the customer back on the widget. Without it they stay on your checkout's confirmation page, because payment pages such as Paystack's cut the window off from the widget, which then cannot close it. It is optional and settles nothing: your server's confirmation is still what admits the scan or books the appointment.
Only your server can complete a payment
Nothing you return from onCollectPayment settles anything. It only decides what the customer sees. The payment counts when your backend calls, with the reference the widget gave you:
POST https://api.oysterskin.com/api/v1/payments/{reference}/external/confirm
Authorization: Bearer <your Oyster API key>
{ "status": "success", "external_reference": "your-order-id" }
This one request confirms every kind of payment: a scan, a booking, or any paid service added later. The reference tells Oyster what was bought, so your server never branches on purpose. The response says what it was (data.purpose) and what it produced (data.produced, such as a booked appointment_number).
Use an API key from your Oyster dashboard with the payments:collect scope. If the Oyster WooCommerce plugin or Shopify app collects for you, it confirms with its own store connection and there is nothing to call. A personal login is refused.
Send { "status": "failed" } the same way when a charge declines or is abandoned, so the customer is told promptly instead of waiting out the timeout.
Retries are safe: confirming an already-settled payment returns replayed: true, changes nothing, and should be treated as success. One collection can never become two scans or two bookings.
The amount you charge is yours to decide. Oyster records what it would have charged for reconciliation and never validates yours against it.
Moving from the per-type confirmations
POST /scan-payments/{reference}/external/confirm and POST /consultation/appointments/reservations/{reference}/external/confirm still answer until the date in their Sunset response header, then stop. Point your confirmation at /payments/{reference}/external/confirm and read data.status as success or failed (the booking endpoint said confirmed). Nothing else in the request changes, and keys that held scans:collect or appointments:collect already have payments:collect.
Collecting bookings on your own gateway
Clinics taking bookings through the widget can collect the booking payment the same way. The customer pays you once, through your checkout, for the appointment, any added services and the skin scan. The appointment fee is yours; Oyster invoices you for the scan taken for the booking. This is set up separately from scan payments. Contact support to have it enabled.
Bookings use the same onCollectPayment handler. Tell the two apart by purpose, which is "appointment" for a booking and "scan" for a scan. A booking request also carries:
- lineItems: how amount breaks down, each { kind, name, amount } with kind one of "appointment", "service" or "scan". Use them for your order lines. Like the amount, they are advisory.
- appointment: { type, date, startTime, endTime }, so your order can describe the booking.
On WooCommerce or Shopify, the Oyster plugin and app handle bookings themselves: the booking becomes an order at your store checkout, with a line for each item, and is confirmed when the order is paid. There is nothing to build. The rest of this section is for your own integration.
Handling a booking
onCollectPayment: async ({ purpose, reference, amount, currency, email, lineItems, appointment }) => {
// One handler for both. Check `purpose` before charging, so a booking is
// never sold as a scan; your server confirms both the same way.
const res = await fetch("/my-store/oyster-checkout", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ purpose, reference, amount, currency, email, lineItems, appointment }),
});
// Your server returns the checkout it already made for this reference, or
// { alreadyPaid: true } once it has been paid, never a second charge.
const { checkoutUrl, alreadyPaid } = await res.json();
if (alreadyPaid) return { status: "processing" };
return { status: "redirect", checkoutUrl };
},
Confirming a booking
The booking is made when your server confirms it, with the same request as a scan, whether or not the customer is still on the page:
POST https://api.oysterskin.com/api/v1/payments/{reference}/external/confirm
Authorization: Bearer <your Oyster API key>
{ "status": "success", "external_reference": "your-order-id" }
The response carries the appointment_number it booked in data.produced. Send { "status": "failed" } when the charge declines or is abandoned: the slot is released at once and the customer is told. A retry returns replayed: true with the same appointment and books nothing new.