Zum Inhalt springen

Lösungen

Freelancer & Selbstständige Rechnungen und Belege ohne Shop eBay Verkäufe automatisch abrechnen Shopify Bestellungen direkt aus dem Shop WooCommerce WordPress-Shop anbinden

Authentifizierung

Request

Alle Methoden laufen über denselben Endpunkt. Welche Funktion ausgeführt wird, bestimmt der Header X-Bw-Method. Jeder Aufruf wird als POST mit dem Payload im Request-Body gesendet – auch lesende Methoden wie order.read oder order.list.

Endpunkt

URL https://www.billware.de/api/v1
Methode POST
X-Bw-Method Name der Methode, z. B. order.create
X-Bw-Hmac API-Appid, ein Doppelpunkt und der berechnete HMAC, z. B. appid:hmac
Content-Type application/json

authentication

Jeder API-Aufruf wird mit einem HMAC-Header signiert, der aus dem Payload berechnet wird. Unten siehst du, wie dieser Header entsteht. Die Methode test.connection nutzt denselben Header.

Codebeispiele

# Get your API secret from your billware customer area
API_SECRET="your-api-secret"

# Sign the exact body that will be sent – not a re-encoded copy of it
PAYLOAD='{"foo":"bar"}'

HMAC=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "$API_SECRET" -binary | base64)

# X-Bw-Hmac is the API-Appid, a colon and the HMAC
echo "your-app-id:$HMAC"

test.connection

Du kannst deine Verbindung testen. Rufe die Methode test.connection mit deinem berechneten X-Bw-Hmac-Header auf.

Codebeispiele

# Get your API credentials from your billware customer area
API_APPID="your-app-id"
API_SECRET="your-api-secret"

PAYLOAD='[]'

# The HMAC is calculated over the exact request body that is sent
HMAC=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "$API_SECRET" -binary | base64)

curl -X POST "https://www.billware.de/api/v1" \
  -H "X-Bw-Hmac: $API_APPID:$HMAC" \
  -H "X-Bw-Method: test.connection" \
  -H "Content-Type: application/json" \
  -d "$PAYLOAD"

Beispiel für Postman


// Pre-request Script in Postman

const payload = JSON.stringify({});
const apiAppId = APP_ID; // Replace with your actual API App ID
const apiSecret = API_SECRET; // Replace with your actual API Secret

const encoder = new TextEncoder();
const keyData = encoder.encode(apiSecret);
const data = encoder.encode(payload);

crypto.subtle.importKey(
    'raw',
    keyData,
    { name: 'HMAC', hash: 'SHA-256' },
    false,
    ['sign']
).then(key => {
    return crypto.subtle.sign('HMAC', key, data);
}).then(signature => {
    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));

    pm.request.headers.add({
        key: 'X-Bw-Hmac',
        value: `${apiAppId}:${hmacBase64}`
    });

    pm.request.headers.add({
        key: 'X-Bw-Method',
        value: 'test.connection'
    });

    pm.request.headers.add({
        key: 'Content-Type',
        value: 'application/json'
    });
});

Hinweis

Stelle im Reiter Body den Typ auf raw und wähle JSON als Format. Trage {} als Inhalt ein.

Die Daten im Body müssen genau denen im Pre-request Script entsprechen, sonst passt die HMAC-Signatur nicht.

Antwort

{
    "response": true,
    "data": null,
    "message": "Connection test success"
}