Skip to main content
Use this page when you need the exact browser SDK contract for Payment Element v3.

Load the SDK

The script exposes window.Pagou.
Supported environments:

Initialize Elements

Options: You can update an existing instance before submit:

Create and mount the card field

elements.create("card") creates one hosted card field. If a card field already exists on the same elements instance, the SDK unmounts it before creating the new one. Card options:

Card events

Supported events: Remove handlers during component teardown when the same card instance can stay alive:

Submit a payment

elements.submit(...) is the main SDK action. It creates an Element session, tokenizes the hosted card field, calls your createTransaction callback, completes any card authentication the payment requires, and resolves the final result.
createTransaction receives:
Only send token to your backend as the payment credential. Treat brand, last4, exp_month, and exp_year as display or bookkeeping metadata.

Submit result

Possible status values include: Do not fulfill an order from the browser status alone. Use webhook delivery or server-side reconciliation as the final source of truth.

3D Secure

elements.submit(...) completes card authentication for you when the payment requires it, using the buyer and products your server already sends when it creates the transaction. You collect nothing extra in the browser. See 3D Secure. Return your transaction payload from the backend unchanged. If it asks for further action, the SDK detects it and continues the flow. If you already created the transaction server-side and only need the SDK to finish an action it reported, pass that action straight through:
Or pass the transaction to an Elements instance:

Resume after a reload

If the page reloads or the buyer navigates away mid-payment, resume the same transaction instead of starting a new checkout attempt. resume() recreates the Element session from your public key, so it works even after a full page load.
resume() returns the same result shape as submit(). It picks up an outstanding action when one is still pending, returns the terminal status when the payment already finished, and returns processing when the outcome has not arrived yet. Persist the transaction id before the buyer can navigate away so you have it on the way back.

Card re-entry (auto-heal)

A payment that was waiting on card authentication (pre-charge 3DS) was bound to the Element session that captured the card; a reload starts a new session and the original challenge can no longer run. resume() self-heals this by default — the element/SDK owns the whole recovery, identical for hosted checkout and raw integrators. Your only responsibility: keep a CardElement mounted and call resume().
On a stale-session pre-charge challenge, resume() asks the buyer to re-enter the card in the mounted element, re-tokenizes it under the current session, supersedes the stale challenge, runs the fresh one, and resolves to a terminal status. No new transaction is created.
Only the same card can supersede the payment — a different card is refused. With no card element mounted, or if the buyer does not re-enter within the timeout, resume() resolves to a clear terminal result telling the buyer to start a new payment attempt. It never loops or hangs.

Token mode

Pass a mode to submit to declare the caller’s intent and select the resulting token type:

Cleanup

Unmount a card field when leaving the checkout screen:
Destroy the Elements instance when the entire payment flow is gone:

Production rules

  • Use pk_test_* only with Pagou.setEnvironment("sandbox").
  • Use pk_live_* with the default production environment.
  • Never send raw card data to your backend.
  • Never log pgct_* or pgpm_* tokens, or card data.
  • Disable duplicate submits while elements.submit(...) is running.
  • Persist the transaction id so you can resume(...) after a reload.
  • Return your transaction payload from the backend without removing id, status, or next_action.
  • Treat browser status as provisional until webhook or reconciliation confirms the final payment state.