Skip to content

@pesepay/js

Every public export of @pesepay/js, generated from its type declarations. @pesepay/js on npm.

NameDescription
isPesepayErrorNarrows an unknown caught value to a Pesepay error.
loadPesepayLoads the Pesepay runtime and returns a configured instance.
NameDescription
BaseChangeEventSent when the customer changes the input. A field nobody has typed in is empty, not invalid, so you need not show “required” before the customer starts. error is the one message to show.
BaseElementOptionsOptions shared by every element. Events are not options: listen with element.on("change", handler).
CardChangeEventThe card element’s change event.
CardCheckoutWhat opens the provider’s hosted card form.
CardElementCard number, expiry and CVC fields for Visa, in a frame on a Pesepay origin. Pay with confirmCardPayment().
CheckoutChangeEventThe checkout element’s change event: the payment element’s, sent as "checkout".
CheckoutElementThe payment element with its own Pay button. It runs every step itself: the O’mari code, the wait for an EcoCash approval or a scanned code, and the result when the customer comes back from 3-D Secure or the card form. Listen for finished. It is not passed to confirmPayment().
CheckoutFinishedEventSent once, when the checkout element’s payment has ended. Confirm the result on your server before you fulfil the order.
ConfirmCardPaymentDataA card that needs 3-D Secure always navigates the browser to the customer’s bank. Your page never holds the card, so it cannot do that step itself.
ConfirmHostedCardPaymentDataThe hosted card form holds the card, the checkout already fixes the method, and the provider takes no customer details or metadata, so this takes only the element.
ConfirmMobilePaymentDataWhat confirmMobilePayment() takes.
ConfirmPaymentElementDataThe payment element pays with whichever method the customer chose, so it takes no options that only some methods can use.
ConfirmPaymentOptionsMapThe options each element’s payment can use, by element type.
ConfirmScanPaymentDataWhat confirmScanPayment() takes.
ContactChangeEventThe mobile element’s change event.
CustomerDetailsThe customer paying, sent with the payment.
ElementEscapeEventSent when the customer presses Escape inside the element.
ElementFocusEventSent when a field in the element gains focus.
ElementLoadErrorEventSent when the element could not load. Show error, or send the customer to fallbackUrl.
ElementMapThe element each ElementType creates.
ElementOptionsMapThe options each element type takes, by ElementType.
ElementReadyEventSent once the element has rendered and can take input.
ElementsA group of elements that share a theme and fonts.
ElementsOptionsOptions applied to every element in a group.
ElementStatusEventSent by the mobile and payment elements as a mobile money payment progresses.
FontSourceA web font for the card fields.
HandleRedirectOptionsOptions for handleRedirectResult().
HostedCardElementThe card provider’s own form, for Mastercard and Zimswitch. It renders in your page; the card number and CVV stay in the provider’s iframes. One per page: creating a second throws.
HostedCardElementOptionsOptions for elements.create("hostedCard").
LoadOptionsOptions for loadPesepay(): the config, plus where and how long to load the runtime.
MobileElementA phone number field for EcoCash or O’mari. Pay with confirmMobilePayment().
MobileElementOptionsOptions for elements.create("mobile").
PayableAmountWhat the customer pays with the selected method.
PaymentChangeEventempty until the customer picks a method. complete once the method is priced and its fields are filled in.
PaymentElementEvery method the transaction can be paid with, grouped as mobile money, card and scan to pay. The chosen method shows its fields and the total with its fee. Pay with confirmPayment(). It renders in your page; card numbers stay in Pesepay’s or the card provider’s frames.
PaymentElementOptionsOptions for elements.create("payment").
PaymentMethodA payment method Pesepay offers for a transaction’s currency.
PesepayWhat loadPesepay() resolves to.
PesepayConfigOptions for loadPesepay().
PesepayElementBaseWhat every element can do: mount, update, focus, clear and send events. create() does not mount, so you can set an element up before its container exists. Each element’s page lists the events it sends.
PesepayErrorThe shape of result.error. An interface, not a class — the class ships in the CDN runtime. Narrow on code, not instanceof.
PesepayThemeHow elements look. Set it in loadPesepay(), in elements() or on one element: each layer overrides the one before.
RedirectingPaymentDataOptions for a confirm that may need the customer to leave the page.
ScanCodeWhat the customer pays with in the provider’s app.
ScanElementShows the QR code and short code the customer pays with in the InnBucks or PayGo app. It has no input: it is empty until confirmScanPayment() returns the code.
ScanElementOptionsOptions for elements.create("scan").
TransactionA Pesepay transaction, as the SDK reads it.
TransactionAmountA transaction’s amount.
WaitForTransactionOptionsOptions for waitForTransaction().
NameDescription
AnyPesepayElementAny element elements.create() can return.
CardBrandCard brands the SDK can detect. unknown (unmatched BIN, or a partial number) is not an error. Detecting a brand is not being able to charge it — the card element pays Visa only. Mastercard raises use_mastercard_option and the rest raise card_brand_not_supported.
CardCheckoutBrandThe hosted form’s card brand: Mastercard, or Zimswitch’s domestic cards.
CardElementOptionsOptions for elements.create("card"): the options every element takes.
CardFieldThe fields inside a card element, used to scope focus, blur and errors.
CheckoutElementOptionsOptions for elements.create("checkout"): the same as the payment element’s.
CheckoutOutcomeHow a checkout element’s payment ended. unknown is also sent when no answer came in time: the customer may still pay, so don’t let them pay again until your server has the result.
ConfirmableElementAny element confirmPayment() takes: every element but the checkout element, which pays with its own button.
ConfirmPaymentDataWhat confirmPayment() takes. An element typed as a union, such as CardElement | MobileElement, takes only the options every member can use. An option the element’s payment cannot use is refused rather than dropped: redirect with a card or scan element, and anything but signal with a hostedCard or payment element.
ConfirmResultThe transaction, or an error: never both. After if (result.error) return;, TypeScript knows result.transaction is set.
ElementBlurEventSent when a field in the element loses focus.
ElementPaymentStatusWhere a sent mobile money payment stands. After processing, the element shows “Check your phone” and waits for the customer’s approval itself.
ElementTypeThe kind of element elements.create() makes.
LogLevelHow much the SDK writes to the browser console. "silent" writes nothing.
MobileProviderEcoCash approves on the customer’s phone. O’mari sends an SMS code that the customer types into the element, so its payment takes two confirms.
MobileStepWhich input a mobile element shows: the phone number, then O’mari’s SMS code.
NextActionWhat the customer must do before the payment can finish.
PaymentMethodsResultWhat listPaymentMethods() returns: the methods and the amount, or an error.
PesepayErrorCodeEvery code a PesepayError can carry. Branch on these, not on message.
PesepayErrorParamWhich field a validation_error or card_error refers to, when one applies.
PesepayErrorTypeBroad category. Determines how a merchant should react, not what went wrong.
ScanProviderPay-by-code apps. The customer scans a QR code with the provider’s app, or types its short code there. InnBucks pays in USD and PayGo in ZiG (Zimbabwe Gold).
SelectPaymentMethodResultWhat selectPaymentMethod() returns: the priced amount, or an error.
ThemeLabelsWhere field labels go. "hidden" still names each field to screen readers.
ThemePresetA ready-made set of colours, spacing and states. "night" is dark, "flat" is borderless on a tinted fill. Labels and fonts stay yours.
TransactionOutcomeWhat a transaction’s status means for your checkout. Derived from TransactionStatus by one table, so you do not have to keep your own.
TransactionStatusPesepay’s own status for a transaction, exactly as the API reports it.
NameDescription
PESEPAY_ERROR_CODESEvery error code the SDK can return, as an array you can loop over, for example to check that your own messages cover them all.