Skip to main content

Types and enums

Prefer importing types with import type { … } so they erase at compile time and don’t affect your runtime bundle.
The package exports typed models and constant-based enums to keep your integration compile-time safe.

Importing types

import type { CreatePaymentRequest, PaymentResponse, TokenCache } from 'gopay-sdk';

Importing enums

import { Currency, Language, PaymentStatus, TokenScope } from 'gopay-sdk';

Configuration types

  • CreateGoPayClientConfig
  • GoPayClientOptions
  • GoPayClientConfigInput
  • GoPayClientConfigNormalized

Core payment request types

  • CreatePaymentRequest
  • CreateRecurrenceRequest
  • CaptureAuthorizationPartialRequest
  • RefundPaymentRequest

Core payment response types

  • PaymentResponse
  • PaymentOperationResponse
  • RefundHistoryItem
  • CardDetailsResponse

Statement types

  • AccountStatementRequest
  • AccountStatementResponse

Payment methods types

  • PaymentInstrumentsResponse
  • PaymentInstrumentsAllResponse
  • PaymentMethodGroups

Error types

  • GoPayFieldError
  • GoPayErrorBody
  • GoPayErrorResponse
  • GoPayApiError (class)
  • GoPayConfigError (class)

Token and transport abstractions

  • TokenCache (interface)
  • OAuthToken
  • OAuthTokenResponse
  • HttpTransport
  • HttpTransportRequest
  • HttpMethod
  • ContentType

Main enums and constants

  • Currency
  • Language
  • TokenScope
  • PaymentInstrument
  • PaymentMethodGroup
  • PaymentStatus
  • PaymentSubStatusValues
  • RefundState
  • RecurrenceCycle
  • RecurrenceState
  • PreauthorizationState
  • StatementFormat
  • BankSwiftCode
  • ErrorScope
  • ErrorCodeValues

Practical typing pattern

import {
  Currency,
  type CreatePaymentRequest,
  type PaymentResponse,
  createGoPayClient,
} from 'gopay-sdk';

const request: CreatePaymentRequest = {
  amount: 10000,
  currency: Currency.CZK,
  order_number: 'ORD-typed-1',
  payer: {
    contact: { email: 'john.doe@example.com' },
  },
  callback: {
    return_url: 'https://example.com/return',
    notification_url: 'https://example.com/notify',
  },
};

const client = createGoPayClient({
  goid: 8123456789,
  clientId: process.env.GOPAY_CLIENT_ID!,
  clientSecret: process.env.GOPAY_CLIENT_SECRET!,
  gatewayUrl: 'https://gw.sandbox.gopay.com/api',
});

const payment: PaymentResponse = await client.createPayment(request);
console.log(payment.id);