Skip to content
Browse documentation

Payments

NanoSite ships real payments. Each store brings its own gateway account, configures it per store, and shoppers pay through the provider's own secure flow. Secrets are encrypted at rest and never sent to the browser.

Supported providers

Provider ID Status Flow
Manual / cash manual Built-in Authorizes and captures instantly; no configuration. Great for cash-on-delivery or testing, and always available as a fallback.
Stripe stripe Supported One-time payments via a PaymentIntent + client secret (Stripe Elements); subscriptions via hosted Checkout (mode=subscription) with a redirect.
PayPal paypal Supported Approval-based Orders v2: create order → buyer approves → server captures the payment.
PayFast payfast Supported Redirect to PayFast's hosted page; the ITN (Instant Transaction Notification) webhook finalizes the order.
Pix (manual) pix Supported, BRL only Checkout builds a Pix QR code and copy-paste code for the order total. The order waits as pending until the merchant marks it paid. No webhook.
Mercado Pago mercadopago Supported, BRL only Redirect to Mercado Pago Checkout Pro, where the shopper pays with Pix, boleto or a card in installments. The webhook finalizes the order.

A few provider-specific notes:

  • PayPal requires an explicit capture step after the buyer approves (see below).
  • PayFast refunds are not available through the API. Issue them from the PayFast dashboard.
  • Pix and Mercado Pago only work for stores whose currency is BRL. A store in another currency can't turn them on, and changing the store currency away from BRL turns them off.
  • Pix (manual) refunds are sent back by Pix by the merchant; the order is then marked refunded.
  • Subscriptions are Stripe-only. See Products & subscriptions.

Accept Pix

Manual Pix needs no gateway account. Shoppers pay straight to your Pix key, and you confirm the payment yourself.

  1. In the store admin, open Payments, turn on Pix, and fill in your Pix key (CPF, CNPJ, email, +55 phone or random key), the receiver name registered with that key (up to 25 characters) and your city (up to 15 characters). Save.
  2. At checkout the shopper gets a Pix QR code and a copy-paste code for the order's exact total, on the order confirmation page and in an email with the copy-paste code. The order reference is the Pix transaction id, so you can find the payment in your bank statement.
  3. The order shows as awaiting payment. When the money is in your bank, open the order in Orders and click Mark paid. That confirms the sale, commits the stock and emails the customer.
  4. An order that isn't marked paid within 48 hours is cancelled and its stock is released.

Connect Mercado Pago

With Mercado Pago, shoppers pay on Mercado Pago's page with Pix, boleto or a card in installments ("parcelado"), and the order is confirmed automatically. You need a Mercado Pago account.

  1. In Mercado Pago, open Your integrations, pick (or create) your application, and copy the Access token from its credentials. Use the test credentials first, then the production ones.
  2. In the store admin, open Payments, turn on Mercado Pago, paste the access token and, optionally, set the maximum installments (1 to 36, default 12). Save.
  3. Follow the webhook steps shown on the same screen: in Mercado Pago, go to Your integrations → your application → Webhooks → Configure notifications, paste the endpoint URL from the admin, select the payment topic, save, then copy the secret signature back into the admin.
  4. Orders are marked paid when Mercado Pago tells your store the payment was approved. Pix is usually instant; a boleto can take a few days. An order that isn't paid within 5 days is cancelled and its stock is released.

Refunds for Mercado Pago orders can be issued from the order in the store admin.

Per-store configuration

Payment providers are configured per store from the store admin. Each provider exposes a small set of config fields (secrets are marked as such and encrypted; public fields are exposed to the storefront):

  • Stripe — secretKey (secret), publishableKey (public), webhookSecret (secret; required for subscriptions).
  • PayPal — clientId (public), clientSecret (secret), mode (sandbox/live), optional webhookId.
  • PayFast — merchantId (public), merchantKey (secret), optional passphrase (secret), mode, and the notify/return/cancel URLs.
  • Pix (manual): pixKey, receiverName, receiverCity (none are sent to the browser).
  • Mercado Pago: accessToken (secret), optional maxInstallments, webhookSecret (secret; recommended).
  • Manual — no configuration.

The admin sets which providers are enabled and which is the store's activeProvider. The storefront only ever receives a public view of this config — never a secret.

The checkout flow

Checkout is atomic and provider-aware:

  1. The shopper calls checkout (useCheckout) with their cart and, optionally, a paymentProvider.
  2. The backend reserves inventory atomically, creates a pending order with snapshotted line items, and calls the selected provider to create the payment.
  3. What comes back depends on the provider:
    • Manual captures synchronously — the order becomes paid immediately.
    • Stripe (one-time) returns a clientSecret — confirm it in the browser with Stripe Elements.
    • Stripe (subscription), PayPal, PayFast and Mercado Pago return a redirectUrl: send the shopper there to complete payment.
    • Pix (manual) leaves the order pending. Read the order (useGetStoreOrder) and show order.pix: code (the copy-paste code), reference, expiresAt (ISO time; show it as the "pay by" deadline) and qrCode (a PNG data URL, filled in only on the storefront order read). order.pix is null once the order is no longer pending.
  4. Asynchronous providers finalize the order when their webhook confirms the payment.

If you pass a paymentProvider, it's validated against the store's enabled providers (a shopper can't force manual). Omit it to use the store's activeProvider.

Capturing a PayPal payment

PayPal authorizes on approval and requires a capture:

import { orderAccessRequest, useCaptureOrderPayment } from "@nanosite/ecommerce-sdk";

// accessToken comes back on the checkout result (see Guest order access below)
const capture = useCaptureOrderPayment({ request: orderAccessRequest(accessToken) });
await capture.mutateAsync({ id: orderId });   // POST /store/orders/:id/capture

Guest order access

Reading an order (GET /store/orders/:id, useGetStoreOrder) and capturing it need proof of ownership: the signed-in customer who placed it, or the order's access token in the x-order-token header. The token comes back as accessToken on the checkout, capture and order lookup results, and as ?token= on the hosted-checkout return URL and the confirmation email link. Keep it for the session and pass it with orderAccessRequest(token), which sends nothing when there is no token (a signed-in owner reads by cookie):

import { orderAccessRequest, useGetStoreOrder } from "@nanosite/ecommerce-sdk";

const order = useGetStoreOrder(orderId, { request: orderAccessRequest(token) });

Without either, the API answers 404.

Order & payment status

  • Order status: pending, paid, fulfilled, cancelled, refunded.
  • Payment status: requires_action, authorized, captured, refunded, failed.

Orders finalize (or fail/refund) through the same webhook pipeline described in Webhooks & events.