Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.usepaykit.dev/llms.txt

Use this file to discover all available pages before exploring further.

npm install @paykit-sdk/gopay

Setup

import { PayKit } from '@paykit-sdk/core';
import { gopay } from '@paykit-sdk/gopay';

export const paykit = new PayKit(gopay());
Required env vars:
GOPAY_CLIENT_ID=140...
GOPAY_CLIENT_SECRET=n6W...
GOPAY_GO_ID=864...
GOPAY_SANDBOX=true
GOPAY_WEBHOOK_URL=https://example.com/api/webhook

Webhooks

GoPay sends webhook notifications via GET requests. Your handler must accept GET, not POST.
const webhook = paykit.webhooks
  .setup({ webhookSecret: '' }) // GoPay does not use a shared secret
  .on('payment.created', async event => { /* ... */ });

await webhook.handle({
  body: '',
  headersAsObject: Object.fromEntries(request.headers),
  fullUrl: request.url, // GoPay passes the payment ID as a query param
});

provider_metadata

GoPay requires amount and currency in provider_metadata on checkout:
await paykit.checkouts.create({
  customer: { email: 'user@example.com' },
  item_id: 'my-product',
  session_type: 'one_time',
  quantity: 1,
  success_url: '...',
  cancel_url: '...',
  provider_metadata: {
    amount: '2900',
    currency: 'CZK',
    lang: 'en',
  },
});