Skip to main content
Every Vestrapay payment starts with one call from your server: initialise. It creates a pending transaction and returns the three things you need to take payment: a reference to track it, an access code to authorise checkout calls, and a checkout URL for the hosted pay page. After that you choose how the customer pays.

Choose how the customer pays

Hosted checkout

Redirect the browser to the checkout URL. Vestrapay renders the pay screen, collects card details in processor-hosted fields, runs 3-D Secure and shows transfer details. Least code, fastest to production.

Custom checkout

Build your own pay screen and call the checkout endpoints with the access code. You control every pixel and every state, and you take on the 3-D Secure and countdown handling.

Hosted checkout

  1. Your server sends POST /v1/payment/initialize with your secret key.
  2. You store data.reference on the order and redirect the browser to data.checkoutUrl.
  3. The customer picks a channel and pays. Hosted checkout handles card entry, 3-D Secure, transfer details, retries and expiry.
  4. Vestrapay sends the browser to your callbackUrl and posts a webhook to your server.
  5. You verify the payment and fulfil the order.

Custom checkout

  1. Initialise as above. Keep data.accessCode and data.reference.
  2. For card, create a hosted card session, mount the processor’s fields, then charge. See Pay with card.
  3. For transfer, request a virtual account and show the bank, account number and countdown. See Pay with transfer.
  4. For pay with bank and USSD, see Other channels.
  5. Optionally subscribe to GET /v1/payment/checkout/events so the pay page updates live.
  6. Confirm with a webhook and verify, exactly as for hosted checkout.
Every checkout call after initialise authenticates with the access code in the x-access-code header, never with the secret key. The access code expires after 60 minutes.

What initialise accepts

Send a JSON body to POST /v1/payment/initialize with your secret key. A successful call returns HTTP 201 and the session in the data object:
When you pass a distribution, the response echoes it back in a distribution property so you can confirm what was applied.

The callback query string

When checkout finishes, the customer’s browser is sent to your callback URL with these query parameters added:
The callback page is for the customer’s experience: show a receipt, a failure message or a “we are confirming your payment” screen. It is not a trusted signal. Anyone can type a URL into a browser, so never fulfil from these parameters. Call verify from your server with the reference and decide there.

Metadata

Metadata is your own correlation data. Use it to carry whatever you need to find the order again, such as an order ID, a customer ID or a campaign tag.
Metadata is stored with the payment and returned unchanged on verify and on the collection record. Keep it small and do not put secrets or card data in it. Because verify returns it, you can rebuild your order context from a reference alone.
Metadata on a payment link is different. On a link it defines the form the customer fills in before paying. See Payment links.

Fees and who pays them

Vestrapay charges a fee per collection, and the fee depends on the channel. Initialise tells you the fee for each so you can display totals. The default comes from your payment settings in the dashboard. Pass merchantBearsCost on initialise to override it for one payment.
  • Customer bears the fee (default for most accounts): the customer pays the total. You settle the full amount.
  • You bear the fee: the customer pays the amount. You settle the amount less the fee. Verify reports this as amountSettled.
The fee is charged on the whole collection. It is never divided between split accounts.

Channels

Initialise returns the channels available for this payment: card, bank_transfer, bank_payment and ussd. Hosted checkout shows only the ones enabled for your account. Your enabled set can be narrower than the list the platform supports. If a channel you expect is missing, check your dashboard settings or contact tech@vestrapay.com.

Splitting a payment

If the money from one payment should reach more than one account, add a distribution map to the initialise body. Each key is the service key of a service you have already configured, and each value is the amount to route to that service. Whatever you do not allocate goes to your primary settlement account.
How services, sub-accounts and splits fit together is explained in Services and splits, and the exact allocation rules are in Distribution.

After the customer pays

  1. Receive the signed webhook and the browser callback.
  2. Verify the reference with your secret key.
  3. Fulfil the order once, only on success with a matching amount.
Test every path, including failure and abandonment, in the sandbox first. See Test payments.