Skip to content

Wajub Components

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

Wajub Components put Wajub's payment interface inside your own site: @wajub/js on any page, and @wajub/react, @wajub/vue, @wajub/svelte and @wajub/angular in those frameworks. They ship as ES modules only.

Four ways to take a payment

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

ModeCallWho draws the pay buttonYou getPick it when
Redirectcheckout()WajubThe hosted page, on a Wajub URLYou want the least front end code
Inline embedmount()WajubThe hosted page inside your own layoutThe checkout is the page
Overlayopen()WajubThe same, in a modal over your pageThe checkout interrupts something else
Payment fieldscomponents()YouIndividual fields you place yourself, then confirmPayment()The layout itself is the requirement

The first three run the whole checkout, including OTP and 3D Secure. Coupons and the shipping step are not available on it. 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 seven field types: card, mobileMoney, wallet, bankTransfer, crypto, payment, and address. Each has its own component, CardComponent to CryptoComponent in React, Vue and Svelte, <wajub-card> to <wajub-crypto> in Angular, and ComponentEmbed, <wajub-component> in Angular, mounts any of them by its type.

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. or pk_test.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 what the browser calls sessionId.

Packages

@wajub/js works on any page, with or without a framework.

npm install @wajub/js

A framework package needs @wajub/js installed beside it, as a peer dependency. React, Vue and Svelte give you a WajubProvider, a CheckoutEmbed and one component per field type. Angular gives you provideWajub(), a service, and a standalone component for the checkout and for each field type.

npm install @wajub/react @wajub/js

Without a bundler, load the script directly, or import the module build.

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_test.xxxxxxxxxxxxxxxx…" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 25000,
    "currency": "XAF",
    "email": "buyer@example.com",
    "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),
});

To choose when Wajub.js loads, call loadWajub() instead: it 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 callbackDisplay the 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 listingSDK reference
Type it correctlyTypeScript
Copy a whole shapeUse cases
Work out why nothing rendersTroubleshooting

What did you think of this content?