Integrazioni
Creare una fattura (Checkout)
Per creare una fattura, è necessario prima ottenere l'ID del metodo di pagamento.
- Se usi sempre lo stesso metodo di pagamento, richiedilo al team di supporto.
- Se usi metodi diversi, invia una richiesta all'endpoint qui sotto.
Endpoint: /v1/payment-method/list
Metodo: GET
Esempio di risposta:
{
"data": [
{
"id": "11111",
"title": "Cards International",
"countries": ["US", "GB", "FR"],
"currencies": ["USD", "EUR"],
"icon": "",
"fields": [
{
"name": "cardNumber",
"title": "card number"
},
{
"name": "holderName",
"title": "holder name"
}
]
},
{
"id": "11117",
"title": "Alipay",
"countries": ["CN"],
"currencies": ["CNY"],
"icon": "",
"fields": []
}
]
}
Utilizza il valore di id come payment_method quando crei una fattura.
Creare una fattura
Endpoint: /v1/payment/create
Metodo: POST
Richiesta (parametri minimi):
{
"amount": "10.03",
"currency": "USD",
"payment_method": "11111",
"save_card": "1",
"customer": {
"email": "[email protected]",
"name": "John Doe",
"ip": "192.168.1.1"
},
"urls": {
"success": "https://example.com/success",
"fail": "https://example.com/fail",
"notification": "https://example.com/notification"
},
"reference": "3d7d949e-94fb-4b8b-bc32-7c7f46bcd638",
"metadata": {
"key1": "value1",
"key2": "value2"
}
}
Richiesta con carta salvata:
{
"amount": "10.03",
"currency": "USD",
"payment_method": "11111",
"customer": {
"email": "[email protected]",
"name": "John Doe",
"ip": "192.168.1.1"
},
"urls": {
"success": "https://example.com/success",
"fail": "https://example.com/fail",
"notification": "https://example.com/notification"
},
"reference": "3d7d949e-94fb-4b8b-bc32-7c7f46bcd638",
"card": {
"cardId": "050159eb-6af3-407c-84c0-ca1680711a77"
},
"metadata": {
"key1": "value1",
"key2": "value2"
}
}
Risposta:
{
"data": {
"payment_id": "...",
"amount": "10.03",
"currency": "USD",
"status": "pending",
"reference": "...",
"url": "https://api.beezyycashier.com/process/...",
"method": "get"
}
}
Reindirizza il cliente all'url.
Aggiornare informazioni di pagamento
Per ID pagamento
Endpoint: /v1/payment/{payment_id}
Metodo: GET
Per riferimento
Endpoint: /v1/payment/by-reference/{reference}
Metodo: GET
Esempio di risposta
{
"data": {
"payment_id": "...",
"amount": "10.03",
"status": "success",
"transactions": [ ... ]
}
}
Rimborsi
Endpoint: /v1/refund/create
Metodo: POST
{
"reference": "...",
"payment_id": "...",
"amount": "10.03",
"currency": "USD"
}
Risposta:
{
"data": {
"refund_id": "...",
"amount": "10.03",
"status": "success",
"message": "Rimborso accettato"
}
}
Salvare una carta
Endpoint: /v1/client/card/save
Metodo: POST
{
"payment_method": "11111",
"customer": {
"email": "[email protected]",
"name": "John Doe",
"ip": "192.168.1.1"
},
"urls": {
"success": "https://example.com/success",
"fail": "https://example.com/fail",
"notification": "https://example.com/notification"
},
"reference": "...",
"metadata": {
"key1": "value1"
}
}
Informazioni del cliente
Per email:
GET: /v1/client/[email protected]
Per ID carta:
GET: /v1/client/card/{card_id}
Azioni sulla carta
- Disattivare:
GET /v1/client/card/deactivate/{card_id} - Attivare:
GET /v1/client/card/activate/{card_id}
Prelievi
Singolo:
POST: /v1/withdrawal/create
{
"reference": "...",
"amount": "10.03",
"currency": "USD",
"withdrawal_method_id": "22222",
"receiver": {
"cardNumber": "...",
"name": "John Doe",
"email": "[email protected]"
},
"urls": {
"notification": "https://example.com/notify"
}
}
Multipli:
POST: /v1/withdrawal/create-mass
Corpo: array di oggetti di prelievo
Per ID stack:
GET: /v1/withdrawal/{stack_id}
Firma della notifica
Puoi verificare le notifiche tramite l'header della firma.
- Algoritmo:
HMAC-SHA512 - Firma:
hash_hmac('sha512', raw_request_body, project_key) - Header:
signature - Per le notifiche di prelievo, utilizza la chiave di prelievo del progetto invece della chiave di pagamento.
- Applica l'hash al corpo JSON grezzo esattamente come ricevuto — non ricodificarlo né riformattarlo prima dell'hashing.
Esempi di generazione della firma
Tutti gli snippet seguenti producono lo stesso output hex in minuscolo per gli stessi raw_body e project_key.
PHP
$signature = hash_hmac('sha512', $rawBody, $projectKey);
Python
import hmac
import hashlib
signature = hmac.new(
project_key.encode('utf-8'),
raw_body.encode('utf-8'),
hashlib.sha512
).hexdigest()
Go
import (
"crypto/hmac"
"crypto/sha512"
"encoding/hex"
)
mac := hmac.New(sha512.New, []byte(projectKey))
mac.Write([]byte(rawBody))
signature := hex.EncodeToString(mac.Sum(nil))
Java
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
Mac mac = Mac.getInstance("HmacSHA512");
mac.init(new SecretKeySpec(
projectKey.getBytes(StandardCharsets.UTF_8),
"HmacSHA512"
));
byte[] hash = mac.doFinal(rawBody.getBytes(StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
for (byte b : hash) sb.append(String.format("%02x", b));
String signature = sb.toString();
Importante: raw_body deve essere esattamente la sequenza di byte letta dal corpo della richiesta HTTP, prima di qualsiasi json_decode / json.loads. Se prima si effettua il parsing del JSON e poi lo si riserializza, cambieranno spazi e ordine delle chiavi, e la verifica della firma fallirà.