Dokimantasyon Devlopè

Byenvini sou API Hatexcard la. Gid sa a ap ede w entegre sistèm peman nou an sou sit entènèt ou a nan kèk minit.

1. Otantifikasyon

Pou kominike avèk API nou an, ou dwe voye Kle API ou a (API Key) nan tèt (Header) chak rekèt ou fè. Ou ka jwenn kle sa a nan tablodbò w la.

Authorization: Bearer hx_live_KLE_OU_A_ISIT

2. Kreye yon Peman (Charge)

Pou chaje yon kliyan, fè yon rekèt POST sou adrès sa a.

POST https://hatexcard.com/api/public/payments

// Egzanp JavaScript (Fetch)
const response = await fetch('https://hatexcard.com/api/public/payments', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer hx_live_KLE_OU_A'
  },
  body: JSON.stringify({
    amount: 150.00,
    currency: "HTG",
    order_id: "CMD-99812",
    card_info: {
      number: "0000111122223333",
      exp: "1225", // MWA ak ANE (MMYY)
      cvv: "123"
    }
  })
});

const data = await response.json();
console.log(data);

3. Koute Webhooks yo (Sekirite)

Lè yon peman reyisi, Hatexcard ap voye yon siyal (Webhook) sou adrès ou te konfigire nan tablodbò w la. Ou dwe verifye siyati x-hatex-signature la pou w asire w se vreman nou ki voye l.

// Egzanp Node.js / Express pou verifye siyati a
const crypto = require('crypto');

app.post('/webhook-hatexcard', (req, res) => {
  const signature = req.headers['x-hatex-signature'];
  const webhookSecret = 'whsec_KLE_SEKRE_WEBHOOK_OU_A';

  // Rekreye kripte a pou konpare
  const myHash = crypto
    .createHmac('sha256', webhookSecret)
    .update(JSON.stringify(req.body))
    .digest('hex');

  if (myHash === signature) {
    console.log("Peman an Valide! Debloke pwodwi a.");
    // Ekzekite lojik biznis ou isit la (bay aksè, voye imèl, elatriye)
    res.status(200).send('Resevwa');
  } else {
    console.log("Siyati pa koresponn. Aksè refize.");
    res.status(403).send('Erè Siyati');
  }
});

Si w swiv 3 etap sa yo, sit ou a ap kapab chaje kat Hatexcard otomatikman, an sekirite, 24/7. Si w bezwen plis èd, kontakte sipò teknik nou an.