import crypto from "node:crypto";import { godigitalHeaders } from "./headers.js";const body = JSON.stringify({ requestId: crypto.randomUUID(), merchantId: process.env.MERCHANT_ID, providerCode: "VODACOM", amount: 10000.0, currency: "TZS", msisdn: "255754123456", reference: "INV-1001", callbackUrl: "https://merchant.example.com/api/payment-result", narration: "Invoice INV-1001",});const res = await fetch( "https://api-sandbox.godigital.tz/api/v1/payments/collections/push", { method: "POST", headers: godigitalHeaders({ token: process.env.GD_TOKEN, clientId: process.env.CLIENT_ID, body, }), body, // send exactly the string you hashed },);console.log(await res.json()); // data.transactionStatus: "ROUTED"
Hash and send the exact same string. If you re-serialize the JSON after hashing, the
X-Content-SHA256 value will not match.
5. Receive the result
The customer approves the prompt on their phone. GoDigital then sends the final result to your
callbackUrl. Reply with HTTP 200 quickly. See Callbacks.