BINKDocs
HelpDashboard

Wix Integration

/docs/global/integrations/wixGlobal

BINKPAY connects to Wix through a hosted checkout model that requires no server of your own. Your Wix site uses Velo by Wix

— Wix's built-in coding platform — to trigger the BINKPAY checkout overlay directly from a button click. After the customer completes payment, BINKPAY redirects back to a return URL on your site where you confirm the order. Both the Global environment (cards, Apple Pay, Google Pay in USD/AED/EUR/GBP/SAR) and the Egypt environment (Vodafone Cash, InstaPay, Fawry, ValU, MeezaPay in EGP) are supported from a single integration.

Hosted Checkout

Cards · Apple Pay · Google Pay

Refunds sync

No code changes

How the Wix Integration Works

Unlike server-based integrations, the BINKPAY Wix integration uses a hosted checkout flow. Here is what happens end-to-end:

  1. A customer clicks your payment button on the Wix page. Velo frontend code (running in the visitor's browser) constructs a signed BINKPAY checkout URL using your Embed Key and the order parameters (amount, currency, order ID, return URL).
  2. The customer is redirected to (or shown a modal pointing to) the BINKPAY hosted checkout page at pay.binkpay.net/checkout/.... This page is fully hosted and PCI-compliant — your Wix site never touches raw card data.
  3. After the customer completes payment (or abandons), BINKPAY redirects to the return URL you specified, appending ?status=succeeded&session_id=... (or ?status=failed) as query parameters.
  4. Velo code on your return page reads the query parameters, calls the BINKPAY Sessions API to confirm the payment status server-side (optional but recommended), and displays the appropriate confirmation or error message to the customer.

No server required

Because BINKPAY hosts the payment page, you do not need a backend server or any server-side runtime on Wix. All sensitive operations happen on BINKPAY's infrastructure. You only need Velo (frontend JavaScript) to construct the checkout URL and handle the return redirect.

Prerequisites

A Wix site on the Core, Business, or Business Elite plan. Velo is available on all paid Wix plans. Free Wix sites cannot enable Velo.
Velo enabled on your site. In the Wix Editor, go to Tools → Velo Dev Mode → Enable Velo. This unlocks the Velo code panels and the ability to add frontend JavaScript to any page.
A BINKPAY account with at least one active Embed Key. Sign up at dashboard.binkpay.netand retrieve your Embed Key fromIntegrations → Wix → Connection Settings after completing the OAuth connection (see Installation below).
A published Wix site with a custom domain (or a *.wixsite.com subdomain) so that return URLs are stable and reachable by BINKPAY after payment.

Installation

The connection between BINKPAY and your Wix site is established via OAuth. This takes about two minutes and does not require any code changes to complete.

Open the Wix integration in BINKPAY Dashboard

Log in to dashboard.binkpay.net and navigate to Integrations → Wix. Click Connect Wix Site.

Authorize via OAuth

You will be redirected to Wix to authorize the BINKPAY app installation. Log in with your Wix account if prompted, select the site you want to connect, and click Agree & Add to Site. BINKPAY requests read access to your site's basic profile — no write permissions are required for the hosted-checkout flow.

Copy your Embed Key

After authorization, you are redirected back to the BINKPAY Dashboard. On the Wix connection settings page, copy your Embed Key — it looks like embk_live_... (or embk_test_... in test mode). You will use this key in your Velo code. It is safe to include in frontend JavaScript — it can only initiate checkout sessions, not read payment data.

Add the BINKPAY checkout button to your Wix page

In the Wix Editor, add a Button element to the page where you want to collect payment (e.g., a product page or a custom checkout page). Set the button's ID to binkpayCheckoutBtn in the Properties Panel. Then open the Velo code panel for that page and paste the code from the Velo Checkout Code section below.

Velo Checkout Code

Paste the following code into the Page Code panel for the page that contains your payment button. This snippet fires when the button is clicked, builds a signed BINKPAY checkout URL using your Embed Key, and opens the hosted payment page. It also handles the return from BINKPAY and displays a confirmation message.

Page Code (Velo) — checkout-page.js

text
// Wix Velo — BINKPAY hosted checkout integration
// Paste this into the Page Code panel for your checkout page.
// Docs: https://docs.binkpay.net/integrations/wix

import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

// ─── Configuration ────────────────────────────────────────────────────────────
// Replace with your actual Embed Key from Dashboard → Integrations → Wix.
// Use embk_test_... during development, embk_live_... in production.
const BINKPAY_EMBED_KEY = 'embk_live_YOUR_EMBED_KEY_HERE';

// The BINKPAY hosted checkout base URL.
// Use https://pay.binkpay.eg/checkout for Egypt environment (EGP payments).
const BINKPAY_CHECKOUT_BASE = 'https://pay.binkpay.net/checkout';

// The page on your Wix site where customers land after payment.
// Must be a full URL. Wix publishes pages at https://www.yoursite.com/page-path.
const RETURN_URL = 'https://www.yoursite.com/order-confirmation';

// ─── Page ready ───────────────────────────────────────────────────────────────
$w.onReady( function () {
 // Check if the page was loaded as the return URL from BINKPAY.
 // BINKPAY appends ?status=succeeded&session_id=...&order_id=... to the return URL.
 constquery = wixLocation.query; if (query.status === 'succeeded'&& query.session_id) { // Payment succeeded — show confirmation section, hide checkout button.
 $w( '#binkpayCheckoutBtn').hide();
 $w( '#confirmationSection').show();
 $w( '#orderIdText').text = `Order ID: ${query.order_id ?? 'N/A'}`;
 $w( '#sessionIdText').text = `Payment reference: ${query.session_id}`;
 } else if (query.status === 'failed') {
 // Payment failed or was cancelled — show an error message.
 $w( '#errorMessage').show();
 $w( '#errorMessage').text =
 'Payment was not completed. Please try again or choose a different payment method.';
 }

 // Wire up the checkout button click handler.
 $w( '#binkpayCheckoutBtn').onClick(() => {
 initiateCheckout();
 });
}); // ─── Build and redirect to BINKPAY checkout ───────────────────────────────────/**
 * Constructs the BINKPAY hosted checkout URL and redirects the customer.
 *
 * In a real integration, fetch the order details (amount, orderId) fromyour
 * Wix Stores order, a Wix Members area cart, or your own data collection.
 * Hard-coded values are used here for illustration only.
 */ function initiateCheckout() {
 // Replace these with values derived from your actual cart / order.
 constorderDetails = {
 amount: 4999, // Amount in smallest currency unit (e.g. 4999 = $49.99)
 currency: 'USD', // ISO 4217 code. Use 'EGP' for Egypt environment.orderId: generateOrderId(), // Your internal order referencecustomerEmail: getCustomerEmail(),
 description: 'Order from My Wix Store',
 };

 constcheckoutUrl = buildCheckoutUrl(orderDetails); // Navigate the entire page to the BINKPAY checkout.
 // To open in a lightbox instead, use: wixWindow.openLightbox('BinkPayCheckout', { url: checkoutUrl });wixLocation.to(checkoutUrl);
}

/**
 * Builds a BINKPAY hosted checkout URL with the order parameters.
 * All parameters are passed as query strings; BINKPAY validates the Embed Key server-side.
 */ functionbuildCheckoutUrl(order) { const params = newURLSearchParams({
 embed_key: BINKPAY_EMBED_KEY,
 amount: String(order.amount),
 currency: order.currency,
 order_id: order.orderId,
 return_url: RETURN_URL,
 cancel_url: wixLocation.url, // Return to current page on canceldescription: order.description,
 ...(order.customerEmail && { customer_email: order.customerEmail }),
 }); return `${BINKPAY_CHECKOUT_BASE}?${params.toString()}`;
}

/** Generates a unique order ID. Replace with your own ID generation logic. */ function generateOrderId() {
 consttimestamp = Date.now().toString( 36).toUpperCase();
 constrandom = Math.random().toString( 36).substring( 2, 7).toUpperCase();
 return `ORD-${timestamp}-${random}`;
}

/** Retrieves the logged-in Wix member 's email, if available. */
async function getCustomerEmail() {
 try {
 // Requires Wix Members app to be installed on the site.
 const { currentMember } = await import('wix-members ');
 const member = await currentMember.getMember({ fieldsets: ['FULL '] });
 return member?.loginEmail ?? ' ';
 } catch {
 return ''; // Not logged in or Members app not installed
 }
}

Payment Button Configuration

The BINKPAY checkout URL accepts additional metadata that you can use to pre-fill the customer's details, pass product information, or tag the session with your internal references. All metadata is stored on the BINKPAY session and appears in the Dashboard and webhook payloads for reconciliation.

Page Code (Velo) — payment button with full metadata

text
// Extended buildCheckoutUrl with full metadata and billing address pre-fill.
// Useful for stores where you already know the customer's details.

functionbuildCheckoutUrlWithMetadata(order) { const params = new URLSearchParams({
 // Requiredembed_key: BINKPAY_EMBED_KEY,
 amount: String(order.amount), // Integer, smallest currency unitcurrency: order.currency, // 'USD', 'AED', 'EUR', 'GBP', 'SAR', 'EGP'order_id: order.orderId,
 return_url: order.returnUrl,
 cancel_url: order.cancelUrl, // Customer pre-fill — shown on the checkout page; customer can editcustomer_email: order.customer.email,
 customer_name: order.customer.name,
 customer_phone: order.customer.phone, // E.164 format: +201234567890

 // Billing address pre-fill (all optional)billing_address_line1: order.billing.line1,
 billing_address_city: order.billing.city,
 billing_address_country: order.billing.countryCode, // ISO 3166-1 alpha-2

 // Statement descriptor — overrides the account-level default for this session
 statement_descriptor: 'My Wix Store',

 // Metadata — arbitrary key/value pairs (max 20 keys, max 500 chars per value).
 // These appear in Dashboard and webhook payloads under data.metadata.
 'metadata[wix_site_id]': order.wixSiteId,
 'metadata[product_sku]': order.productSku,
 'metadata[campaign_source]': order.utmSource ?? 'direct',

 // Payment method restrictions — leave unset to show all available methods.
 // To restrict to cards only: payment_methods=card
 // To allow cards and Apple Pay: payment_methods=card,apple_pay
 payment_methods: 'card,apple_pay,google_pay',
 });

 return `${BINKPAY_CHECKOUT_BASE}?${params.toString()}`;
}

// Example: build a checkout URL for a 79.99 USD purchase
consturl = buildCheckoutUrlWithMetadata({
 amount: 7999,
 currency: 'USD',
 orderId: 'ORD-WIX-20260511-A1B2C',
 returnUrl: 'https://www.yoursite.com/order-confirmation',
 cancelUrl: 'https://www.yoursite.com/cart',
 customer: {
 email: 'customer@example.com',
 name: 'Jane Smith',
 phone: '+12125550101',
 },
 billing: {
 line1: '123 Main St',
 city: 'New York',
 countryCode: 'US',
 },
 wixSiteId: 'abc123',
 productSku: 'TSHIRT-M-BLK',
 utmSource: 'instagram',
});

wixLocation.to(url);

Return URL Handling

After the customer completes (or abandons) payment, BINKPAY redirects to the return_url you specified, appending the following query parameters:

ParameterValuesDescription
statussucceeded, failed, pendingFinal status of the checkout session
session_idcs_01HXKN...BINKPAY checkout session ID. Use this to retrieve full session details via the Sessions API.
order_idYour order referenceThe order_id you passed when building the checkout URL
payment_idpay_01HXKN... (on success)The BINKPAY payment ID if the session resulted in a successful charge

Always verify payment status server-side

Query parameters in the return URL are for display purposes only — they can be tampered with in the browser. Before fulfilling an order, call the BINKPAY Sessions API to confirm the session status server-side using the session_id. Use a Wix Backend (Velo Web Module) to make this call so your secret key is never exposed in browser code.

Here is how to read the return URL parameters and display an order confirmation in Velo. Add this code to the Page Code of your order confirmation page:

Page Code (Velo) — order-confirmation.js

text
// Velo page code for your order confirmation / return URL page.
// This page is the return_url you pass to BINKPAY at checkout time.

import wixLocation from 'wix-location';

$w.onReady( async function () {
 const{ status, session_id, order_id, payment_id } = wixLocation.query; // Hide all state sections initially
 $w( '#successSection').hide();
 $w( '#pendingSection').hide();
 $w( '#failedSection').hide();
 $w( '#loadingSpinner').show();

 if(!status || !session_id) { // Landed on this page directly (not from a BINKPAY redirect) — show nothing special.
 $w( '#loadingSpinner').hide();
 return;
 }

 // Optional but recommended: verify the payment server-side via a Velo Web Module.
 // Replace with your actual backend module path.
 letverifiedStatus = status;
 try { const{ verifyBinkpaySession } = await import( 'backend/binkpay-verify.jsw');
 const result = awaitverifyBinkpaySession(session_id);
 verifiedStatus = result.status; // Authoritative status from BINKPAY API} catch (err) {
 console.error( 'Could not verify session server-side:', err);
 // Fall back to the URL parameter if the backend call fails.
 // In production, consider blocking the success display until verification succeeds.
 }

 $w( '#loadingSpinner').hide();

 if (verifiedStatus === 'succeeded') {
 $w( '#successSection').show();
 $w( '#successOrderId').text = order_id ? `Order #${order_id}` : 'Your order';
 $w( '#successPaymentId').text = payment_id ? `Ref: ${payment_id}` : '';
 } else if (verifiedStatus === 'pending') {
 // Some payment methods (e.g. Fawry) are pending until the customer pays at the outlet.
 $w( '#pendingSection').show();
 $w( '#pendingMessage').text =
 'Your payment is being processed. You will receive a confirmation email once it is complete.';
 } else {
 $w( '#failedSection').show();
 $w( '#failedMessage').text =
 'Payment was not completed. Please return to the store and try again.';
 }
});

The Velo Backend (Web Module) that verifies the session server-side, so your secret key is never in browser code:

Backend — backend/binkpay-verify.jsw

text
// Velo Web Module — runs on the server, safe to use secret keys here.
// File path: backend/binkpay-verify.jsw
// Expose only the functions you need in the frontend via named exports.

import { getSecret } from 'wix-secrets-backend';
import { fetch } from 'wix-fetch';

/**
 * Verify a BINKPAY checkout session and return its status.
 * Called fromfrontend page code — the secret key never leaves the backend.
 *
 * @param {string} sessionId - The cs_... session ID from the returnURL.
 * @returns {{ status: string, paymentId: string | null }}
 */
export async functionverifyBinkpaySession(sessionId) { if(!sessionId || !sessionId.startsWith( 'cs_')) {
 throw new Error( 'Invalid session ID format');
 }

 // Store your secret key in Wix Secrets Manager (Settings → Secrets Manager)
 // with the name 'BINKPAY_SECRET_KEY'.
 const secretKey = await getSecret( 'BINKPAY_SECRET_KEY');

 const response = await fetch(
 `https://api.binkpay.net/v1/checkout/sessions/${sessionId}`,
 {
 method: 'GET',
 headers: {
 Authorization: `Bearer ${secretKey}`,
 'Content-Type': 'application/json',
 },
 }
 );

 if (!response.ok) {
 const body = awaitresponse.json();
 throw new Error( `BINKPAY API error ${response.status}: ${body?.error?.message ?? 'Unknown error'}`);
 }

 const session = await response.json();

 return{
 status: session.status, // 'succeeded' | 'failed' | 'pending' | 'expired'paymentId: session.payment_id ?? null,
 amount: session.amount,
 currency: session.currency,
 orderId: session.metadata?.order_id ?? null,
 };
}

Mobile Optimization

BINKPAY's hosted checkout is fully responsive and optimized for mobile browsers. However, there are a few Wix-specific considerations to ensure the best mobile experience:

Use full-page redirects on mobile

Avoid opening BINKPAY checkout in a modal or iframe on mobile devices. Mobile browsers restrict cross-origin iframe interactions for security, which can interfere with Apple Pay, Google Pay, and some 3D Secure flows. Use wixLocation.to(checkoutUrl) to perform a full-page redirect on all devices. If you want a modal on desktop only, detect the device type:

Page Code (Velo) — responsive redirect

text
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

async functionopenCheckout(checkoutUrl) { const formFactor = awaitwixWindow.formFactor; if (formFactor === 'Mobile') {
 // Full-page redirect on mobile — best for Apple Pay, Google Pay, and 3DSwixLocation.to(checkoutUrl);
 } else {
 // Open as a lightbox on desktop
 // Requires a Wix Lightbox element named 'BinkPayCheckout' with a web component or iframewixWindow.openLightbox( 'BinkPayCheckout', { url: checkoutUrl });
 }
}

Button sizing and placement

In the Wix Editor, ensure your payment button has a minimum tap target of 44 × 44 pixels on the mobile layout. Wix's Mobile Editor lets you adjust element sizes independently from the desktop layout. A well-placed, full-width button at the bottom of a product description converts better than a small inline button.

Apple Pay on Wix mobile sites

Apple Pay will only appear on the BINKPAY checkout page when:

  • The customer is using Safari on an Apple device (iPhone, iPad, or Mac).
  • The customer has a payment card configured in Apple Wallet.
  • The BINKPAY checkout page's domain (pay.binkpay.net) is Apple Pay verified — this is handled by BINKPAY automatically.

No action is required on your Wix site for Apple Pay domain verification — BINKPAY's hosted checkout domain is pre-verified.

Test Mode

Use test keys during development

Replace your Embed Key with your embk_test_... key in the Velo code to enable test mode. In test mode, BINKPAY routes checkout sessions to the sandbox and no real charges are made. Test sessions appear in the BINKPAY Dashboard under the Test environment toggle.

Use the following test card at the hosted checkout to simulate a successful payment:

Card numberExpiryCVVOutcome
4242 4242 4242 4242Any future dateAny 3 digitsSucceeded
4000 0000 0000 0002Any future dateAny 3 digitsCard declined
4000 0027 6000 3184Any future dateAny 3 digits3DS authentication required

Switch to live keys before publishing

Before publishing your Wix site for real customers, replace embk_test_... with embk_live_... in your Velo code, and similarly update your backend Web Module's secret key in Wix Secrets Manager. Leaving test keys active means no real payments will be processed.

Troubleshooting

Clicking the payment button does nothing — no redirect occurs

Open the Velo Developer Console (F12 in the Wix Editor preview or your browser) and check for JavaScript errors. The most common causes are: (1) a typo in the button ID — confirm the button's ID in the Properties Panel exactly matches the ID used in $w('#binkpayCheckoutBtn'); (2) the Velo code file is attached to the wrong page — in the Velo sidebar, confirm the code is under the correct page, not under "Site" (site-level code); (3) the BINKPAY_EMBED_KEY constant still contains the placeholder text — paste your actual key from the BINKPAY Dashboard.

BINKPAY checkout page shows "Invalid embed key" error

This error means the Embed Key in your Velo code is incorrect, expired, or belongs to a different BINKPAY account. Log in to the BINKPAY Dashboard, go to Integrations → Wix → Connection Settings, and copy the Embed Key again. Note that Embed Keys are environment-specific: embk_test_... only works with the sandbox and embk_live_... only works in live mode. Using a test key on a live checkout URL (or vice versa) will result in this error.

Return URL receives status=succeeded but server-side verification returns status=pending

Some Egypt payment methods — notably Fawry — are asynchronous. When a customer completes the Fawry reference code step on the BINKPAY checkout, they receive a payment reference to pay at a Fawry outlet. At this point, the checkout session closes (so the customer returns to your site) but the underlying payment has not been confirmed yet. The BINKPAY checkout URL will include status=pending in this case. Show the customer a "Your order is pending payment" message and wait for a payment.succeeded webhook event before fulfilling the order. BINKPAY will send this webhook event within minutes of the customer completing the Fawry outlet payment.

Was this page helpful?