Welcome to our documentation!

Keep in mind that if you have any questions, feel free to get in touch with us.

Base url: https://api.invoicetop.com


Create an invoice

/v1/invoice

Method: POST

Type: application/json

export interface IInvoice { title: string; description?: string; amountType: 'fiat' | 'crypto'; amount: number; afterPaymentText?: string; issuerEmail: string; callback?: string; callbackSecret?: string; // if the callback option is set, this is required coin: 'btc' | 'bch' | 'ltc' | 'doge'; issuerAddress: string; multipayment: boolean; expiresIn?: number; // in minutes }

Success response

export interface IInvoiceSucces { url: string; }

Error response

export interface Error { success: false; error: { code: number; info: string; } }

Get invoice

/v1/invoice/:id

Method: GET

Type: application/json

Success response

export interface IInvoiceData { id: string; title: string; description?: string; coin: 'btc' | 'bch' | 'ltc' | 'doge'; expiresAt?: string; // ISO date amount: number; amountType: 'fiat' | 'crypto'; }

Error response

export interface Error { success: false; error: { code: number; info: string; } }

Get payment link

/v1/invoice/pay

Method: POST

Type: application/json

export interface IPayInvoice { id: string; email: number; // customer email. Not invoice's issuer email }

Success response

export interface IPayInvoiceResponse { url: string; }

Error response

export interface Error { success: false; error: { code: number; info: string; } }

Callback

[url is provided by you in the 'callback' param while creating an invoice]

Method: POST

Type: application/json

export interface ICallback { id: string; signature: string; } The method of generation the signature. We hash an invoice id and a secret key which is provided while creating an invoice in the 'callbackSecret' param that separated by ":" using the SHA256 hashing method. For example. We have an invoice with id "12345" and secret key "superKEY54321" (please do not use such simple secret keys). We do: sha256(12345:superKEY54321) and saves it in the 'signature' param. It's required to check the signature when you receive a callback to make sure a request is trusted. Code example: import crypto from 'crypto'; import { Request, Response, NextFunction } from 'express'; export const toSha256Hash = (input: string) => { const hash = crypto.createHash('sha256'); hash.update(input); return hash.digest('hex'); }; export const handler = async ( req: Request, res: Response, next: NextFunction ) => { try { const { id, signature } = req.body; const SECRET_KEY = '0@j7#XWgq&g3DTOzvc4z'; // from your DB const mySignature = toSha256Hash(`${id}:${SECRET_KEY}`); if (mySignature !== signature) { // ⚠️ SIGNATURES DON'T MATCH. REJECT THIS REQUST ⚠️ } // Trusted request. Do your stuff } catch (error) { // handle errors here } };

Any questions? We are always ready to help! Just get in touch with us.