Přejít na hlavní obsah

Typy a enumy

Typy importujte pomocí import type { … } — při kompilaci zmizí a neovlivní runtime bundle.
Balíček exportuje typované modely a enumy pro bezpečnost při kompilaci.

Import typů

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

Import enumů

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

Konfigurace

  • CreateGoPayClientConfig
  • GoPayClientOptions
  • GoPayClientConfigInput
  • GoPayClientConfigNormalized

Platební požadavky

  • CreatePaymentRequest
  • CreateRecurrenceRequest
  • CaptureAuthorizationPartialRequest
  • RefundPaymentRequest

Platební odpovědi

  • PaymentResponse
  • PaymentOperationResponse
  • RefundHistoryItem
  • CardDetailsResponse

Výpisy

  • AccountStatementRequest
  • AccountStatementResponse

Platební metody

  • PaymentInstrumentsResponse
  • PaymentInstrumentsAllResponse
  • PaymentMethodGroups

Chyby

  • GoPayFieldError
  • GoPayErrorBody
  • GoPayErrorResponse
  • GoPayApiError (třída)
  • GoPayConfigError (třída)

Token a transport

  • TokenCache (rozhraní)
  • OAuthToken
  • OAuthTokenResponse
  • HttpTransport
  • HttpTransportRequest
  • HttpMethod
  • ContentType

Hlavní enumy a konstanty

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

Praktický vzor

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);