Skip to content

Wajub Components

Browser packages that embed Wajub checkout or compose your own payment fields.

Four npm packages put Wajub's payment interface inside your own site. @wajub/js holds everything, and the React, Vue and Svelte packages are thin wrappers over it. All four are published at 1.4.0, ship as ES modules only, and load their runtime from https://js.wajub.com.

Four ways to take a payment

They differ on one question: who draws the pay button.

ModeCallWho draws the pay buttonYou get
Redirectcheckout()WajubThe hosted page, on a Wajub URL
Inline embedmount()WajubThe hosted page inside your own layout
Overlayopen()WajubThe same, in a modal over your page
Payment fieldscomponents()YouIndividual fields you place yourself, then confirmPayment()

The first three run the whole checkout, including coupons, shipping, OTP and 3D Secure. Payment fields give you the layout and hand back the parts Wajub must own, with the limits that come with it.

Start with the inline embed

mount() keeps the customer on your page and costs you nothing in behaviour: the checkout still handles every method, every challenge and every edge case. Move to payment fields when the layout itself is the requirement.

There are five field types: card, mobileMoney, wallet, payment, and address.

A session comes first

Nothing renders without a session token. There are two ways to get one, and they are not equally safe.

Where it is createdWithCost
Your serverA secret key, sk.The amount is decided by code the customer cannot reach
The browserA publishable key, pk.One call, no backend, and the amount comes from the page

POST /payments answers with authorization_url, authorization_token and the transaction. The token is a tok_ value, and it is what the browser calls sessionId.

Packages

The core package holds the loader and the types. Everything else builds on it, and @wajub/js is where its own behaviour is documented.

npm install @wajub/js

A framework wrapper needs the core beside it, because @wajub/js is a peer dependency rather than a bundled one. The three expose the same surface in framework syntax: a WajubProvider, a CheckoutEmbed, and one component per field type.

npm install @wajub/react @wajub/js

Without a bundler, load the script directly. The ESM build is the same runtime with named exports.

From the CDN
<script src="https://js.wajub.com"></script>

<!-- or, as a module -->
<script type="module">
  import { mount } from 'https://js.wajub.com/wajub.mjs';
</script>

The smallest working integration

Create the session on your server, pass the token to the page, mount.

On your server
curl https://api.wajub.com/payments \
  -H "Authorization: sk.kZ3qP8mWvL2xR7tB5nY4hC6dF9jS1aG0eU3i…" \
  -H "Content-Type: application/json" \
  -d '{"amount": 25000, "currency": "XAF", "callback": "https://shop.example.com/return"}'

Send authorization_token to the browser, and nothing else. The token is scoped to that one payment, so it is safe there.

In the browser
import { mount } from '@wajub/js';

await mount('#checkout', {
  sessionId: authorizationToken,
  onSuccess: () => (window.location.href = '/thanks'),
  onError: (error) => showRetry(error),
});

The imported helpers load the runtime themselves. If you would rather hold the runtime, loadWajub() returns { wajub, Wajub, WajubError } and you call rt.wajub.mount(…) on it.

Where the rest is documented

You want toRead
See it working end to endQuickstart
Create and secure the sessionSessions and security
Mount, open or redirect, with every callbackHosted checkout
Build your own layout around the fieldsPayment fields
Change colours, theme and locale from the pageAppearance
Change the logo and the palette for every sessionBranding
Read the full method and type listingAPI reference
Type it correctlyTypeScript
Copy a whole shapeUse cases
Work out why nothing rendersTroubleshooting

What did you think of this content?