zendit developers Logo
Search zendit documentation

Bring Your Own Payments

This guide explains how to use your own payment processor with the Zendit embeddable widget.

Terms Used in this Guide

  • You — the Zendit client. You own the Zendit account and the payment processor.
  • Customer — the person who buys a product in the widget.
  • Transaction ID — the transaction ID that Zendit sends to you in the Payment Request webhook. It is the same ID that the purchase APIs and the product webhooks use.
  • Minor units — the smallest unit of a currency. For USD, 1999 minor units are 19.99 USD. The currency divisor tells you how many minor units are in one major unit (100 for USD).

Overview

With a custom payment processor, Zendit does not connect to your processor. You collect the payment. Zendit delivers the product after you tell Zendit that the payment is successful.

The flow has these steps:

  1. The customer selects Pay in the widget.
  2. Zendit sends a Payment Request webhook to your server.
  3. Your server returns the URL of your payment form and a payment reference.
  4. The widget shows your payment form in an IFRAME.
  5. The customer pays in your form. Your form sends the payment to your processor. Zendit does not see the payment details.
  6. Your form sends an event to the widget. The widget then shows a progress screen.
  7. Your backend sends the payment result to the Zendit API.
  8. If the payment is successful, Zendit debits your wallet and delivers the product.
  9. Zendit sends the usual product webhook to you. It contains a payment object.
  10. The widget shows the result to the customer.

Zendit does not refund a custom payment. If the transaction fails after the customer paid, you must refund the customer in your own payment system. Use the status in the product webhook to decide.

The widget currently sells eSIM products only. The webhook and the API are the same for all future supported product types.

Getting Started

Getting started with Bring Your Own Processor has a few requirements to meet and setup steps as explained in this section.

Recommended Reading

We recommend you familiarize yourself with the Zendit eSIM, Security and Webhook Guides.

Requirements

  • You must use a production wallet. Test Mode (Sandbox) is not supported by Zendit embeddable.
  • You must serve the Payment Request webhook on a whitelisted URL that Zendit may reach.
  • You must host a payment form that the widget can load in an IFRAME on a public URL.
  • Your backend must use the Zendit API with your production API key.

Setup steps

Do these steps in this sequence:

  1. Register the Payment Request webhook. Use the production environment.
  2. Make your payment form and your transaction payment API backend and product webhook ready.
  3. In the client console, open the embeddable Payment Setup screen.
  4. Select Custom as the payment processor.

Currencies

A custom payment processor allows all available currencies. The widget offers each currency that you enabled in your foreign currency (FX) configuration. If FX is disabled for your account, the widget offers your account currency only.

The price that Zendit sends to you is in the currency that the customer selected.

See our Currency Mangement Guide for more information.

Payment Request webhook

Zendit sends this webhook when a customer selects Pay. Your server prepares a payment and returns the URL of your payment form.

Registration

Register the webhook in the client console, on the webhooks screen, with the type Payment Request. The API name of the type is paymentRequest.

  • You can register it for the production environment only.
  • You can add one optional header (name and value). Zendit sends this header with each request. Zendit does not sign the request. Use the header as a shared secret, and check it on your server.
  • Your server must accept HEAD and POST on the same URL.
  • The connectivity check sends HEAD with your optional header. The check is successful only when your server returns HTTP 200. The check stops after 10 seconds.
  • Ensure that the list of IP Addresses to whitelist provided on the setup form are accessible to Zendit to send webhooks.

Once your webhook is registered, it will be available for use for Zendit to call when a customer checks out their purchase.

Request

Zendit sends POST to your URL with these headers:

Content-Type: application/json
Accept: application/json
<your optional header>

Webhook Body

The Payment Request body takes the following form:

{
  "transactionId": "a1b2c3d4",
  "offerId": "ESIM-US-5GB-30D",
  "productType": "ESIM",
  "brand": "ZENDIT-ESIM",
  "brandName": "Zendit eSIM",
  "country": "US",
  "regions": [],
  "subTypes": ["Bundle"],
  "price": 1999,
  "priceCurrency": "USD",
  "priceCurrencyDivisor": 100,
  "ipAddress": "203.0.113.7",
  "createdAt": "2026-09-17T10:04:11.123456789Z",
  "metadata": [
    { "key": "customerRef", "value": "TC-778120" }
  ]
}

The definition of the fields in the webhook are as follows:

FieldTypeDescription
transactionIdstringThe transaction ID. Use it when you send the payment result.
offerIdstringThe Zendit offer ID.
productTypestringESIM, TOPUP, VOUCHER or BILLPAY. The product sent depends on the embeddable. For the eSIM embeddable the product type will be ESIM
brandstringThe brand code of the product.
brandNamestringThe full brand display name.
countrystringThe ISO country code of the product destination. Empty for a regional product.
regionsarray of stringsThe regions of the product. Always present. Can be empty.
priceintegerThe total price that the customer must pay, in minor units. It includes fees. It is the price that the widget shows.
priceCurrencystringThe ISO 4217 code of the price currency. This is the currency that the customer selected.
priceCurrencyDivisorintegerThe currency divisor of priceCurrency.
ipAddressstringThe IP address of the customer. It can be empty.
createdAtstringThe time when Zendit made the transaction. RFC 3339 format, UTC. It can contain fractions of a second.
metadataarray of objectsKey/value pairs from the widget checkout. Not present when the checkout has no metadata. See 3.3.

All fields except metadata are always present.

About Metadata

The widget can send key/value pairs with the checkout. Zendit sends them to you without changes:

  • The sequence stays the same.
  • Duplicate keys stay.
  • Zendit adds nothing and removes nothing.
  • Metadata passed into the widget is not stored in Zendit.

Limits:

  • Maximum 50 pairs.
  • Maximum 2048 bytes in total. Zendit counts the UTF-8 length of all keys and all values.
  • A key cannot be empty. A value can be empty.

If the checkout breaks a limit, Zendit rejects the checkout. Zendit does not send the webhook.

Zendit does not keep the metadata after the Payment Request. The metadata comes from the browser of the customer. Do not use it to identify who pays without a check in your own system.

To add metadata to your embeddable, please see the embedded eSIM Guide for an example.

Response

Return HTTP 200 with a JSON body:

{
  "paymentReference": "PMT-2026-0917-8891",
  "paymentUrl": "https://pay.example.com/form/8891",
  "currency": "USD",
  "paymentAmount": 1999,
  "expiresAt": "2026-09-17T10:19:11Z"
}

The fields in your response explained:

FieldTypeDescription
paymentReferencestringYour reference for this payment. You must send the same value with the payment result.

REQUIRED
paymentUrlstringThe URL of your payment form. It must be an absolute https:// URL.

REQUIRED
currencystringThe currency of the payment. If you send it, it must be the same as priceCurrency in the request.

OPTIONAL
paymentAmountintegerThe amount that you will collect, in minor units. It must be an integer.

OPTIONAL
expiresAtstringThe time when your payment form stops working. RFC 3339 format with a time zone. It must be in the future.

OPTIONAL

Zendit ignores fields that it does not know.

Zendit always debits your wallet for the price that it quoted. paymentAmount does not change the debit. Zendit uses paymentAmount for reporting when your payment result has no usable amount (see 5.4).

Expected Response time

Zendit does not retry the Payment Request. Zendit sends it one time for each checkout.

Return the response as quickly as possible. The customer waits for it. Return it in less than 10 seconds. A slower response can make the checkout fail in the widget.

Failures

Each of these conditions makes the transaction fail immediately:

  • Your server returns a status other than 200. This includes other 2xx statuses, for example 201 or 204.
  • Your server does not return a response in time, or Zendit cannot connect to it.
  • The body is not valid JSON, or a field has the wrong type. For example,paymentAmount is a decimal number or a string, or expiresAt is not in RFC 3339 format.
  • paymentReference or paymentUrl is missing or empty.
  • paymentURL is not an absolute https:// URL.
  • expiresAt is not in the future.
  • currency is different from priceCurrency.

The widget then shows a checkout error. Zendit does not debit your wallet. Zendit sends a product webhook with the status FAILED. That webhook has no payment object.

The transaction error has the code CUSTOM_PAYMENT_FAILED and the description “Failed to collect the custom payment”. The message tells you the cause:

CauseMessage
No response in timeThe Payment Request webhook timed out
Connection failureThe Payment Request webhook is unreachable
Body cannot be decodedThe Payment Request webhook response is not valid JSON
Status other than 200The Payment Request webhook answered [<status>]
No payment referenceThe Payment Request webhook response has no paymentReference
No payment URLThe Payment Request webhook response has no paymentUrl
URL is not httpsThe Payment Request webhook response paymentUrl is not an absolute https URL
Expiry in the pastThe Payment Request webhook returned an expiresAt in the past
Wrong currencyThe Payment Request webhook returned a different currency: <yours>, not the requested <quoted>

The message “not valid JSON” also covers a field with the wrong type.

If no production Payment Request webhook is registered, the transaction fails with the code EMBED_PAYMENT_PROVIDER_NOT_CONFIGURED.

Payment form

The widget loads paymentUrl in an IFRAME. Your form must obey these rules:

  • It must be responsive. It must fit the size of the widget, also on a phone screen.
  • It must do all payment validation.
  • It must send the payment to your payment processor only.
  • Your server must let the widget load the form in an IFRAME. Set the Content-Security-Policy header with frame-ancestors. Do not send X-Frame-Options: Deny or SAMEORIGIN.
    • For the IFRAME integration of the widget, allow https://embed.zendit.io.
    • For the HTML integration, the widget is part of your own page. Allow the origin of that page.
  • For the IFRAME integration, use the latest widget embed code from the client console. It lets your form use Apple Pay, Google Pay and passkey 3-D Secure.

Authentication

The widget loads paymentUrl as you return it. It does not send headers or tokens to your form. If your form needs authentication, put it in paymentUrl. For example, add a single-use token to the query string.

paymentUrl goes to the browser of the customer. Make a token in it short-lived, and limit it to this one payment.

Form events

Your form must tell the widget what happens. Send a message to the parent window with postMessage:

const ZENDIT_ORIGIN = 'https://embed.zendit.io'; // IFRAME integration. For the HTML integration, use the origin of your page.
const zenditEmbedEvents = {
  _send: (type) => window.parent.postMessage(
    { source: 'zendit-custom-processor', type, version: 1 },
    ZENDIT_ORIGIN
  ),
  cancel() { this._send('payment.cancelled'); },
  submit() { this._send('payment.submitted'); },
  expire() { this._send('payment.expired'); }
};

Definitions of the events that the form must expose:

EventWhen to Send ItWhat the Widget Does
payment.cancelledThe customer cancels the payment.It closes the form and shows the checkout page again.

REQUIRED
payment.submittedYour form has sent the payment to your processor.It closes the form and shows a progress screen. It then waits for the transaction result.

REQUIRED
payment.expiredYour payment session has expired.It closes the form and tells the customer that the payment expired. The customer can go back to the checkout.

OPTIONAL

Rules

source must be zendit-custom-processor.

Send the message from the page in the IFRAME. The widget ignores messages from other windows, for example a 3-D Secure popup.

After 3-D Secure, your form can return on a different domain. This is permitted. Send the event from the page that is then in the IFRAME.

The widget uses the first event only. It ignores all events that come after it.

payment.submitted does not tell the widget that the payment is successful. Only your payment result (section 5) tells Zendit the result.

If you return expiresAt, the widget closes the form at that time. It shows the expired message. You do not have to send payment.expired in this case.

If the customer cancels, Zendit does not get a payment result. The transaction expires (see 5.5). A new checkout makes a new transaction.

Payment API

When your processor has finished the payment, your backend sends the result to Zendit.

Request Format

POST https://api.zendit.io/v1/transactions/{transactionId}/payment
Authorization: Bearer <your production API key>
Content-Type: application/json

{transactionId} is the transactionId from the Payment Request webhook.

The usual API rules apply. Use the API key of the wallet that made the transaction. Send the request from a whitelisted IP address. You can send results only for the transactions of your own wallet.

Request body

{
  "paymentReference": "PMT-2026-0917-8891",
  "paymentStatus": "SUCCESS",
  "paymentAmount": 1999,
  "paymentCurrency": "USD",
  "customerReferenceId": "cust-55120"
}

Explanation of fields to include in the request body for the payment call:

FieldTypeDescription
paymentReferencestringThe paymentReference from your Payment Request response. It must be exactly the same, with the same letter case.

REQUIRED
paymentStatusstringSUCCESS or FAILURE. Use capital letters.

REQUIRED
paymentAmountintegerThe amount that the customer paid, in minor units. It cannot be negative.

This value is used if the price was adjusted from the original payment request.

OPTIONAL
paymentCurrencystringThe ISO 4217 code of the currency that the customer paid in.

This value is used if the price was adjusted from the original payment request.

OPTIONAL
customerReferenceIdstringYour own ID for the customer. Zendit sends it back in the product webhook.

OPTIONAL

Send paymentAmount and paymentCurrency together, or do not send them. Zendit ignores fields that it does not know.

Response Codes

StatusMeaningWhat to do
200, empty bodyZendit accepted the report.Stop. Wait for the product webhook.
400 validation_errorThe request is not correct.Do not retry the same request. Correct it.
404 not_foundZendit cannot find the transaction for your wallet.Do not retry. Check the transaction ID and the API key.
401 unauthorized The API Key is not recognizedCorrect your configuration. Then retry.
403 forbiddenIP Address request is from is not whitelistedCorrect your configuration. Then retry.

Requests from IP Addresses not in your whitelist will be blocked.
Other statuses, for example 409 or 5xxZendit did not accept the request.Retry until you get 200.

Zendit returns 200 each time it accepts a report, also when the report does not change the transaction. For example:

You send the same result again.

You send a result after you already sent a different result.

The transaction has already failed or expired.

You send SUCCESS after the payment deadline (see 5.5).

The response does not tell you the transaction result. The product webhook tells you the result.

Error responses have this body:

{ "message": "INVALID_VALUE: paymentStatus: must be one of SUCCESS, FAILURE", "errorCode": "validation_error", "fields": {} }

Zendit returns validation_error (400) for these conditions:

The body is not valid JSON, or a field has the wrong type. For example, paymentAmount is a decimal number.

paymentReference is missing.

paymentStatus is not SUCCESS or FAILURE.

Only one of paymentAmount or paymentCurrency is present.

paymentAmount is negative.

paymentCurrency is not an ISO 4217 code.

The transaction is not paid through a custom payment processor.

paymentReference is not the same as the reference of the transaction.

Result of the Payment API Call

SUCCESS reported on the API Call:

Zendit records the payment as paid. It records your customerReferenceId, if present.

Zendit debits your wallet for the quoted price.

Zendit delivers the product.

The transaction becomes DONE, or FAILED if the delivery fails.

The debit can fail, for example when your wallet balance is too low. The transaction then fails after the customer has paid. You must refund the customer.

FAILURE, reported on the API Call:

Zendit records the payment as failed. It records your customerReferenceId, if present.

The transaction becomes FAILED with the code CUSTOM_PAYMENT_FAILED and the message payment failed. Zendit does not debit your wallet.

Zendit applies only the first result for a transaction. It ignores all results that come after it. The transaction can not be retried for fulfillment and requires a new transaction to be handled if the Zendit transaction has failed.

If your reported currency is different from the quoted currency, Zendit records the payment as paid. Zendit does not reject it, because you have already taken the money. This amount is owed to the customer in a failed Zendit transaction and will be returned on the final webhook.

Reported price

Zendit updates the customer price of the transaction from the payment. This is for reporting only. Your wallet debit does not change. Zendit uses the first of these values that is available:

  1. The paymentAmount in your payment result, when paymentCurrency is the quoted currency.
  2. The paymentAmount in your Payment Request response.
  3. The quoted price.

Payment deadline

If Zendit does not get a result, the transaction expires. The deadline is:

1 hour after the transaction was made, when you do not return expiresAt;

5 minutes after expiresAt, when you return it. The deadline is never more than 1 hour after the transaction was made.

After the deadline:

Zendit ignores a SUCCESS result. It returns 200, but it does not deliver the product.

The transaction becomes FAILED with the code CUSTOM_PAYMENT_FAILED and the message payment expired. The status can change a short time after the deadline.

Product webhooks

Zendit sends the usual product webhooks (eSIM, top-up, voucher, bill pay) for a custom payment transaction. Zendit sends them when the transaction is IN_PROGRESS, DONE or FAILED.

The webhook has a top-level payment object:

"payment": {
  "reference": "PMT-2026-0917-8891",
  "amount": 1999,
  "currency": "USD",
  "currencyDivisor": 100,
  "customerReferenceId": "cust-55120"
}

Explanation of payment node in webhook:

FieldPresentDescription
referenceAlwaysYour paymentReference
amountWhen the payment is paidThe customer price of the transaction in minor units, after the update in reported price.
currencyWhen the payment is paidThe quoted currency.
currencyDivisorWhen the payment is paidThe currency divisor of currency.
customerReferenceIdIf provided by youYour customer ID from the payment result.

What the object contains in each case:

CaseWebhook Statuspayment Object
Payment Request failed at checkoutFAILEDNot present
You reported FAILUREFAILEDreference, and customerReferenceId if sent
The payment expiredFAILEDreference
You reported SUCCESS, then delivery failedFAILEDAll fields
You reported SUCCESS, and the delivery is successfulDONEAll fields

The payment object is only present for purchases made through the Zendit Embeddable.

Refunds

Zendit does not refund a custom payment. Use the product webhook:

DONE — complete the payment in your system.

FAILED with a paid payment (amount is present) — refund the customer.

Purchase API


The purchase APIs also return the payment object, with the same rules. For example: GET /v1/esim/purchases/{transactionId}. The same applies to the top-up, voucher and bill pay purchase APIs.

A custom payment transaction has these statuses:

StatusMeaning
PENDINGZendit waits for your payment result.
AUTHORIZEDYou reported SUCCESS. Zendit debited your wallet.
IN_PROGRESSZendit delivers the product.
DONEThe product is delivered.
FAILEDThe transaction failed. The error object tells you why.

Setting Up Your Payment Processor

Once you have completed all the steps for setting up the Webhooks, you can select the Bring Your Own Payments processor for payments in Zendit Embeddable. You can test your integration in multiple scenarios keeping in mind that a limited amount of test credits can be issued to help with testing since embeddable only works with live product. To setup your payment method, return to the Embedded Payments Setup screen and select the Custom Processor. Selecting the Use Custom Processor will switch to using the webhook and API driven methods with your form for payments.

Register for a Zendit account ->