New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@getblitz/client

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@getblitz/client

Embeddable payment SDK for GetBlitz Payment Gateway - Self-hosted SEPA instant transfers across Europe

latest
Source
npmnpm
Version
0.0.6
Version published
Weekly downloads
8
700%
Maintainers
1
Weekly downloads
 
Created
Source

@getblitz/client

Embeddable payment SDK for GetBlitz Payment Gateway — accept SEPA Instant Transfers across Europe with a lightweight, customizable widget.

npm version License: MIT Bundle Size

Features

  • 🎨 Customizable Widget — Light, dark, and auto themes
  • Real-time Updates — WebSocket-powered instant payment confirmations
  • 📱 EPC QR Code — Bank-scannable QR code for SEPA transfers
  • 🔒 Type-safe — Full TypeScript support
  • 📦 Lightweight — Minimal bundle size with tree-shaking support
  • 🌍 i18n Ready — Locale support for multi-language deployments

Installation

NPM/Yarn/pnpm

npm install @getblitz/client
# or
pnpm add @getblitz/client
# or
yarn add @getblitz/client

CDN

<script src="https://unpkg.com/@getblitz/client/dist/getblitz.umd.cjs"></script>

Quick Start

1. Create a Payment Session (Server-side)

First, create a payment session via the GetBlitz API:

curl -X POST https://pay.yourdomain.com/api/v1/challenge \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 2500,
    "currency": "EUR",
    "merchantReferenceId": "order-456"
  }'

Response:

{
  "sessionId": "550e8400-e29b-41d4-a716-446655440000",
  "clientToken": "ey...",
  "referenceId": "GB-A9F3B2C1",
  "merchantReferenceId": "order-456",
  "paymentUrl": "https://pay.yourdomain.com/pay/550e8400-e29b-41d4-a716-446655440000",
  "expiresAt": "2024-01-15T12:15:00.000Z"
}

Tip: Use merchantReferenceId to link payments to your own system (e.g., order IDs). It must be unique per organization.

2. Mount the Payment Widget (Client-side)

ES Modules

import { GetBlitz } from "@getblitz/client";

const payment = new GetBlitz({
  sessionId: "550e8400-e29b-41d4-a716-446655440000",
  clientToken: "ey...", // From Create Challenge response
  apiUrl: "https://pay.yourdomain.com",
  wssUrl: "wss://wss.yourdomain.com",
  theme: "dark",
});

// Mount the widget to a DOM element
await payment.mount("#payment-container");

// Handle payment events
payment
  .on("onSuccess", (token) => {
    console.log("Payment successful! Token:", token);
    // Redirect to success page or verify payment server-side
    window.location.href = `/order/success?token=${token}`;
  })
  .on("onError", (error) => {
    console.error("Payment failed:", error.message);
  })
  .on("onExpired", () => {
    console.log("Payment session expired");
    // Optionally create a new session
  });

Script Tag (UMD)

<!DOCTYPE html>
<html>
  <head>
    <title>Checkout</title>
  </head>
  <body>
    <div id="payment-container"></div>

    <script src="https://unpkg.com/@getblitz/client/dist/getblitz.umd.cjs"></script>
    <script>
      const payment = new GetBlitz({
        sessionId: "550e8400-e29b-41d4-a716-446655440000",
        clientToken: "ey...",
        apiUrl: "https://pay.yourdomain.com",
        wssUrl: "wss://wss.yourdomain.com",
      });

      payment.mount("#payment-container");

      payment
        .on("onSuccess", function (token) {
          alert("Payment successful!");
        })
        .on("onError", function (error) {
          alert("Payment failed: " + error.message);
        });
    </script>
  </body>
</html>

API Reference

Constructor

new GetBlitz(config: GetBlitzClientConfig)

Configuration Options

OptionTypeRequiredDescription
sessionIdstringPayment session UUID
clientTokenstringAuth token from Challenge response
apiUrlstringAPI base URL (defaults to current origin)
wssUrlstringWebSocket URL (defaults to current origin)
apiKeystringPublic API key (pklive...)
theme"light" | "dark" | "auto"Widget theme (default: system preference)
localestringLocale for i18n (e.g., "de-DE")

Methods

mount(selector: string): Promise<void>

Mounts the payment widget to the specified DOM element. The widget displays:

  • Organization and payment details
  • EPC QR code for bank scanning
  • IBAN for manual transfer
  • Real-time payment status
await payment.mount("#payment-container");

on<K>(event: K, callback: Callback): this

Registers an event callback. Returns this for method chaining.

payment
  .on("onSuccess", (token) => {
    /* ... */
  })
  .on("onError", (error) => {
    /* ... */
  })
  .on("onExpired", () => {
    /* ... */
  })
  .on("onCancel", () => {
    /* ... */
  });

destroy(): void

Cleans up the widget, disconnects WebSocket, and removes event listeners.

payment.destroy();

Events

EventCallback SignatureDescription
onSuccess(token: string) => voidPayment was confirmed successfully
onError(error: Error) => voidPayment failed
onExpired() => voidPayment session expired
onCancel() => voidUser cancelled the payment

How It Works

┌─────────────┐      ┌──────────────┐      ┌───────────────┐
│   Merchant  │      │   GetBlitz   │      │   Customer's  │
│   Website   │      │    Widget    │      │   Bank App    │
└──────┬──────┘      └──────┬───────┘      └───────┬───────┘
       │                    │                      │
       │  1. Create session │                      │
       │───────────────────>│                      │
       │                    │                      │
       │  2. Mount widget   │                      │
       │───────────────────>│                      │
       │                    │                      │
       │                    │  3. Display QR code  │
       │                    │─────────────────────>│
       │                    │                      │
       │                    │  4. Scan & pay       │
       │                    │<─────────────────────│
       │                    │                      │
       │  5. onSuccess(token)                      │
       │<───────────────────│                      │
       │                    │                      │
  • Create Session: Your server creates a payment session via the GetBlitz API
  • Mount Widget: The SDK displays the payment widget with EPC QR code
  • Customer Pays: Customer scans the QR with their banking app
  • Bank Webhook: The bank sends a webhook to GetBlitz confirming payment
  • Real-time Update: WebSocket pushes the confirmation to the widget
  • Callback Fired: Your onSuccess callback receives the payment token

Self-Hosted Configuration

When self-hosting GetBlitz, configure the SDK to point to your infrastructure:

const payment = new GetBlitz({
  sessionId: "...",
  clientToken: "ey...",
  apiUrl: "https://pay.yourdomain.com", // Your Next.js app
  wssUrl: "wss://wss.yourdomain.com", // Your WebSocket server
});

For single-origin deployments where the API and WebSocket server run on the same domain, you can omit these URLs:

const payment = new GetBlitz({
  sessionId: "...",
  clientToken: "ey...",
  // Defaults to window.location.origin
});

TypeScript

Full TypeScript support is included. Import types as needed:

import type {
  GetBlitzClientConfig,
  GetBlitzEventCallbacks,
  PaymentSessionDetails,
} from "@getblitz/client";

For advanced type needs, you can also import from the shared types package:

import type { PaymentEvent } from "@getblitz/shared-types";

Browser Support

  • Chrome 80+
  • Firefox 78+
  • Safari 14+
  • Edge 80+

Requires fetch, WebSocket, and ES2020 features.

License

MIT © GetBlitz

Keywords

payment

FAQs

Package last updated on 28 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts