> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zabcik.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Platby

> Vytváření a dotazování plateb s typovanými modely.

# Platby

<Tip>
  Po `createPayment` přesměrujte zákazníka na **`gw_url`**. Notifikace a návrat z prohlížeče berěte jako **nápovědu** — stav vždy ověřte na serveru pomocí **`getPayment`**.
</Tip>

Základní operace vytvoření platby a načtení detailu.

## Vytvoření platby

```ts theme={null}
import { Currency, createGoPayClient } from 'gopay-sdk';

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 = await client.createPayment({
  amount: 15900,
  currency: Currency.CZK,
  order_number: 'ORDER-15900',
  order_description: 'Premium subscription',
  payer: {
    contact: {
      email: 'buyer@example.com',
      first_name: 'John',
      last_name: 'Doe',
    },
  },
  callback: {
    return_url: 'https://example.com/payment/return',
    notification_url: 'https://example.com/payment/notify',
  },
});
```

### Výchozí hodnoty ze SDK

Pokud vynecháte, SDK doplní:

* `target: { type: 'ACCOUNT', goid: <nakonfigurované goid> }`
* `lang: <nakonfigurovaný jazyk klienta>`

## Detail platby

```ts theme={null}
const details = await client.getPayment(payment.id!);

console.log({
  id: details.id,
  state: details.state,
  subState: details.sub_state,
  amount: details.amount,
  currency: details.currency,
});
```

## Karty — detail a smazání

```ts theme={null}
const card = await client.getCardDetails(123456);
console.log(card.status, card.card_brand, card.card_expiration);

await client.deleteCard(123456);
```

## Embed.js

Pro vložení GoPay UI se stejným prostředím brány:

```ts theme={null}
const embedJsUrl = client.getEmbedJsUrl();
// https://gw.sandbox.gopay.com/gp-gw/js/embed.js
```

## Použité typy

Z exportu `gopay-sdk`:

* `CreatePaymentRequest`
* `PaymentResponse`
* `CardDetailsResponse`
* `Currency`, `Language`, `PaymentInstrument` a další enumy
