@peakgateway/web-sdk
v0.4.12
Published
Peak Gateway Web SDK - Apple Pay & Google Pay integration for browsers
Readme
@peakgateway/web-sdk
Browser SDK for Peak Gateway checkout sessions, Apple Pay, Google Pay, and gift cards.
This package intentionally does not expose payment tokens to browser callers. Use
mountSecureCardFields for compact, Gateway-hosted secure card entry. Direct CDE
integrations can still submit through an existing session with payWithCard.
Install
npm install @peakgateway/web-sdkSecure card fields
import { mountSecureCardFields } from '@peakgateway/web-sdk'
import type { SecureCardEvent } from '@peakgateway/web-sdk'
const fields = mountSecureCardFields({
container: document.getElementById('card-fields')!,
url: checkoutOrSetupIntentUrl,
onEvent(event: SecureCardEvent) {
if (event.type === 'change') submitButton.disabled = !event.complete
},
})
// Wait for ready before confirming with the authoritative checkout amount.
const result = await fields.confirm({
amount,
currency,
context: { cardHolderName, billingStreet, billingCity, billingState, billingCountry, billingZip },
})
// Setup intents use { context } without checkout amount/currency.
// Dispose when removing the fields from the page.
fields.destroy()Use the Gateway HTTPS checkout or setup-intent URL. The controller mounts a cross-origin Gateway iframe; PAN, expiry, and CVC remain inside that iframe and never appear in merchant inputs or SDK event payloads. The browser package exports the controller, options, style, event, result, brand, and error types from its root.
Card payment
import { PeakGateway } from '@peakgateway/web-sdk'
const peak = new PeakGateway({ sessionId, sessionToken })
const result = await peak.payWithCard({
cardNumber,
expirationDate,
cvv,
cardHolderName,
billingStreet,
billingZip,
})The SDK returns the payment result, never a reusable processor or canonical token.
Apple Pay / Google Pay
See peak.applePay and peak.googlePay.
Gift cards
Use peak.giftCard.balanceCheck() to display the available balance before payment.
Authentication and routing
The browser SDK uses the generated public checkout models from @peakgateway/sdk.
Initialize it with a checkout session and its scoped session token.
Never embed an API key or OAuth client secret in browser code; create sessions on your server
with @peakgateway/sdk instead.
License
MIT: see LICENSE.
