ArgusDocs
English Türkçe

Card collection in the browser

On this page

Send the card from the customer's browser straight to us, so your server never receives the card number.

Your checkout page reads the card from its own form and sends it with your publishable key. To pass the card through your server instead, see server-to-server card payments. Card payments compares the two ways.

  1. The browser sends the card and your publishable key (pk_…) to POST /v1/payment_methods and gets a pm_… id.
  2. The browser sends the pm_… id to your server.
  3. Your server calls POST /v1/payment_intents with your secret key (sk_…) and the id.

1. Allow your checkout origin

We accept browser calls only from your registered websites. Add the site of your checkout page on the Websites and callbacks tab of Business details.

2. Tokenize the card

Build your own card form and post the fields with your publishable key:

const PUBLISHABLE_KEY = 'pk_sandbox_YOUR_KEY';

export async function tokenizeCard(form) {
  const response = await fetch('https://api.pf.organizer.tr/v1/payment_methods', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${PUBLISHABLE_KEY}`,
      'Content-Type': 'application/json',
      'Idempotency-Key': crypto.randomUUID(),
    },
    body: JSON.stringify({
      type: 'card',
      card: {
        number: form.number.value.replace(/\s+/g, ''),
        exp_month: Number(form.expMonth.value),
        exp_year: Number(form.expYear.value),
        cvc: form.cvc.value,
        holder_name: form.holderName.value,
      },
    }),
  });
  const body = await response.json();
  if (!response.ok) throw new Error(body.error.message);
  return body.id; // pm_…
}

The same request with curl:

curl -X POST https://api.pf.organizer.tr/v1/payment_methods \
  -H "Authorization: Bearer pk_sandbox_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type": "card", "card": {"number": "4109090000000011", "exp_month": 12, "exp_year": 2030, "cvc": "123", "holder_name": "AYSE YILMAZ"}}'
{
  "id": "pm_01J9ZQA2B4C6D8E1F3G5H7J9K2",
  "object": "payment_method",
  "type": "card",
  "customer": null,
  "card": {
    "brand": "visa",
    "bin": "410909",
    "last4": "0011",
    "masked": "410909******0011",
    "fingerprint": "5f1d7c0f9b2a4e6d8c3b1a0f7e9d2c4b",
    "exp_month": 12,
    "exp_year": 2030
  },
  "created": 1795167000
}

Show the customer card.brand and card.last4, so they can see what they entered. The card type (card_type), the issuing bank and the other details of the card are known only when you pay with it, and they appear on the payment. If the card details are incomplete or invalid, the call returns an error. Ask the customer to check them.

3. Charge it from your server

Send the pm_… id to your server. Create the payment there with your secret key, as in card payments:

{
  "amount": 12500,
  "currency": "try",
  "confirm": true,
  "payment_method": "pm_01J9ZQA2B4C6D8E1F3G5H7J9K2",
  "payment_method_data": {
    "billing_details": {
      "name": "Ayşe Yılmaz",
      "address": {"line1": "Caferağa Mah. Moda Cad. No:12", "city": "Kadıköy", "country": "TR"}
    }
  },
  "return_url": "https://modakitabevi.com.tr/odeme/sonuc"
}

A tokenized card is for one checkout, so charge it soon. We delete the card number after 30 minutes by default. We delete the security code once the payment is authorized, and after 15 minutes at most. If the card can no longer be used, ask the customer to enter it again.

To show installment options before the customer pays, send the same pm_… id to the installment preview.

Security of your checkout page

The card never reaches your server, but your page reads it. That keeps the page in scope for the card-data security standard (PCI DSS). An injected script, for example a compromised third-party script, could read the card as the customer types it.

Protect the page against script injection:

Which requirements apply depends on your volume and your agreement. Confirm them with your bank or your assessor.

In the API reference

Next: Pay with the token as Card payments and 3D Secure shows, or show plans with Installments.