Skip to main content
This reference covers the customer integration surface in SDK 0.1.0. Load it using the installation guide. The version’s TypeScript declarations provide the exported types; download the companion declaration files with them.

Initialize

For ES modules, import WeGivePay and call WeGivePay.init() instead. publishableKey is required. It must be a key issued to your organization, beginning with pk_test_ or pk_live_. Initialization can throw for an invalid configuration; successful construction alone does not prove the key is active or the current origin is approved. Use the default service configuration. Your integration does not need API-host, processor, or verification-site-key overrides. Never pass a secret key here.

Methods

mountButton() requires an existing target element. It returns immediately and loads branding asynchronously. It does not expose an update method: unmount and remount for new options, or use open() with your form’s current values. open() resolves for checkout outcomes, including cancel and error. Configuration or setup errors can also throw; use try/catch around the call. Other asynchronous methods reject on failure. The ESM export WeGivePayError extends Error and includes an HTTP status when available. Do not rely on exact error wording for business logic or expose raw diagnostic payloads to donors.

Branding

fetchBranding() returns organization information including uuid, name, and optional currency, primaryColor, foregroundColor, logoUrl, and avatarUrl. Use fallbacks for optional values. Branding is presentation data, not donor authentication or proof that a payment succeeded.

Fraud session

createFraudSession() returns an object with string id and expiresAt fields. Its optional argument is { checkoutAttemptId: 'YOUR_SERVER_ATTEMPT_ID' }. Use a server-issued attempt identifier if correlating your own checkout records. This identifier does not replace the processing API’s Idempotency-Key header. See session lifetime.

Attribution

getAttribution(explicit?) returns supported UTM keys with usable values. A nonempty explicit set takes precedence over the current URL as a complete set; the two sets are not merged. Supported keys are utm_source, utm_medium, utm_campaign, utm_term, utm_content, and utm_id. This helper does not persist attribution or access cookies.

Donation options

Both mountButton() and open() accept these options: Recurring cadences: daily, weekly, 1_and_15, bimonthly, monthly, quarterly, semiannual, and yearly. Confirm the displayed schedule with the donor before opening checkout. Button presentation options are logo, hideLogo, className, brand, and theme. See the complete theme reference for color tokens, shape, fonts, languages, string overrides, and form settings.

Result and callbacks

Results are browser notifications. Validate recorded payment state before server-side fulfillment. See result semantics.

Payframes mount options

Use separate, empty containers with a visible height. There are no bank or wallet mount methods on the Payframes SDK surface. tokenize() returns:
Send these values only to your backend over HTTPS. Do not log them, put them in URLs, or store them in browser storage. Treat cardNumber and cardCvv as opaque; do not parse or transform them. Follow the Payframes guide for processing and long-lived form handling.