Create Invoice

This endpoint is used to create invoice details for invoice plugin

Method

POST https://api.ninjapay.me/webextension/api/v1/fiat/invoice/create

Parameters

  • business_logo (string): URL of the business logo.

  • business_name (string, required): Name of the business.

  • phone (string): Contact phone number (without country code).

  • phone_code (string): Country code for the phone number.

  • email (string, required): Contact email address.

  • billing_address (string): Billing address.

  • city (string): City of the business.

  • state (string): State of the business.

  • zipcode (string): Zipcode of the business.

  • country (string): Country of the business.

  • documents (object): Contains document details.

    • doc_1 (object): First document.

      • title (string): Title of the document.

      • value (string): Value of the document.

    • doc_2 (object): Second document.

      • title (string): Title of the document.

      • value (string): Value of the document.

  • default_currency (string): Default currency for transactions.

  • enable_qr (boolean): Enable or disable QR code generation.

  • redirect_url (string): URL to redirect after payment.

  • include_invoice_id (boolean): Include invoice ID in the documentation.

  • webhook_url (string): URL for webhook callbacks.

  • terms_condition_url (string): URL for terms and conditions.

  • custom_thanks_message (string): Custom thank you message.

  • custom_button_text (string): Custom text for the payment button.

  • green_donation_link (string): URL for green donation link.

  • donation_percentage (number): Percentage of donation.

  • donation_message (string): Message regarding donations.

  • tax_details (object): Contains tax details.

    • tax_title (string): Title for tax.

    • tax_percentage (number): Tax percentage.

    • tax_country (string): Country where the tax is applicable.

    • is_all_states (boolean): If tax is applicable to all states.

    • tax_states (array): List of states where tax is applicable (empty if all states).

  • invoice_date (string): Date when the invoice was generated (ISO 8601 format).

  • theme_color (string): Theme color for the invoice.

  • client_details (object): Details of the client.

    • name (string): Name of the client.

    • phone_code (string): Country code for the client's phone number.

    • phone (string): Client's phone number.

    • email (string): Client's email address.

    • website (string): Client's website URL.

    • street_address (string): Street address of the client.

    • state (string): State of the client.

    • city (string): City of the client.

    • country (string): Country of the client.

    • zip_code (string): Zip code of the client.

    • details (array): Additional details of the client.

      • PAN (string): Client's PAN number.

      • GST (string): Client's GST number.

  • product_details * (array): Details of the products or services.

    • name (string): Name of the product.

    • price (string): Price of the product.

    • description (string): Description of the product.

    • logo (string): Logo of the product.

    • product_created_at (string): Date when the product was created (ISO 8601 format).

    • currency (string): Currency for the product price.

    • quantity (number): Quantity of the product.

    • amount (number): Amount for the product (price * quantity).

    • final (number): Final amount after any discounts or taxes.

  • total (number, required): Total amount before any additional charges.

  • total_details (array): Breakdown of additional charges or discounts.

    • title (string): Title for the charge or discount.

    • amount (number): Amount for the charge or discount.

    • percentage (number): Percentage for the charge or discount.

  • net_total (number): Net total after all deductions and additions.

  • allow_partial (boolean): Whether partial payments are allowed.

  • allow_tip (boolean): Whether tips are allowed.

  • due_date (string): Due date for the payment (ISO 8601 format).

  • note_to_customer (string): Note to the customer regarding payment.

  • terms_message (string): Additional terms or messages.

  • tracking_number (string): Tracking number for the shipment.

  • tracking_url (string): URL to track the shipment.

  • extras (object): Additional key-value pairs.

    • key1 (string): Extra key 1.

    • key2 (string): Extra key 2.

  • funding_source (string): Source of funding for the transaction.

Request Body

Body (application/json)
{
    "business_logo": "https://awesomecompany.com", // URL of the business logo
    "business_name": "Awesome Company", // Name of the business
    "phone": "234567890", // Contact phone number (without country code)
    "phone_code": "+1", // Country code for the phone number
    "email": "sample@gmail.com", // Contact email address
    "billing_address": "123 Main Street", // Billing address
    "city": "Hyderabad", // City of the business
    "state": "Telangana", // State of the business
    "zipcode": "12345", // Zipcode of the business
    "country": "USA", // Country of the business
    "documents": {
        "doc_1": {
            "title": "PAN", // Title of the document
            "value": "HG297323" // Value of the document
        },
        "doc_2": {
            "title": "GST", // Title of the document
            "value": "76YHGF67656" // Value of the document
        }
    },
    "default_currency": "USD", // Default currency for transactions
    "enable_qr": true, // Enable or disable QR code generation
    "redirect_url": "", // URL to redirect after payment
    "include_invoice_id": true, // Include invoice ID in the documentation
    "webhook_url": "", // URL for webhook callbacks
    "terms_condition_url": "https://google.com", // URL for terms and conditions
    "custom_thanks_message": "Thank you for your payment!", // Custom thank you message
    "custom_button_text": "", // Custom text for the payment button
    "green_donation_link": "", // URL for green donation link
    "donation_percentage": 0.0, // Percentage of donation
    "donation_message": "", // Message regarding donations
    "tax_details": {
        "tax_title": "GST", // Title for tax
        "tax_percentage": 18, // Tax percentage
        "tax_country": "India", // Country where the tax is applicable
        "is_all_states": true, // If tax is applicable to all states
        "tax_states": [] // List of states where tax is applicable (empty if all states)
    },
    "invoice_date": "2024-08-08T05:55:14.981Z", // Date when the invoice was generated
    "theme_color": "", // Theme color for the invoice
    "client_details": { // Details of the client
        "name": "Aman A", // Name of the client
        "phone_code": "91", // Country code for the client's phone number
        "phone": "9876543211", // Client's phone number
        "email": "aman2@gmail.com", // Client's email address
        "website": "https://amanwebsite.com", // Client's website URL
        "street_address": "1234 Elm Street", // Street address of the client
        "state": "Maharashtra", // State of the client
        "city": "Mumbai", // City of the client
        "country": "India", // Country of the client
        "zip_code": "400001", // Zip code of the client
        "details": [ // Additional details of the client
            {
                "PAN": "ABCDE1234F" // Client's PAN number
            },
            {
                "GST": "27ABCDE1234F1Z5" // Client's GST number
            }
        ]
    },
    "product_details": [ // Details of the products or services
        {
            "name": "Orange Gift Box", // Name of the product
            "price": "599.50", // Price of the product
            "description": "", // Description of the product
            "logo": "", // Logo of the product
            "product_created_at": "2024-08-07T11:53:03.000Z", // Date when the product was created
            "currency": "INR", // Currency for the product price
            "quantity": 1, // Quantity of the product
            "amount": 599.5, // Amount for the product (price * quantity)
            "final": 599.5 // Final amount after any discounts or taxes
        }
    ],
    "total": 599.5, // Total amount before any additional charges
    "total_details": [ // Breakdown of additional charges or discounts
        {
            "title": "Discount", // Title for the discount
            "amount": 0, // Discount amount
            "percentage": 0 // Discount percentage
        },
        {
            "title": "Shipping", // Title for the shipping charge
            "amount": 0, // Shipping amount
            "percentage": 0 // Shipping percentage
        },
        {
            "title": "Total GST", // Title for the GST charge
            "amount": 0, // GST amount
            "percentage": 0 // GST percentage
        },
        {
            "title": "TDS", // Title for the TDS deduction
            "amount": 0, // TDS amount
            "percentage": 0 // TDS percentage
        }
    ],
    "net_total": 599.5, // Net total after all deductions and additions
    "allow_partial": false, // Whether partial payments are allowed
    "allow_tip": false, // Whether tips are allowed
    "due_date": "2024-08-10T05:55:14.981Z", // Due date for the payment
    "note_to_customer": "Kindly pay before due date!", // Note to the customer regarding payment
    "terms_message": "", // Additional terms or messages
    "tracking_number": "", // Tracking number for the shipment
    "tracking_url": "", // URL to track the shipment
    "extras": { // Additional key-value pairs
        "key1": "value1", 
        "key2": "value2"
    },
    "funding_source": "" // Source of funding for the transaction
}

Response

{
    "status": true,
    "data": {
        "invoice_uuid": "89691435"
    },
    "message": "Invoice template and details added successfully"
}

Code Example


const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'API_KEY' //Invoice key required
  },
  body:{
    "business_logo": "https://awesomecompany.com", // URL of the business logo
    "business_name": "Awesome Company", // Name of the business
    "phone": "234567890", // Contact phone number (without country code)
    "phone_code": "+1", // Country code for the phone number
    "email": "sample@gmail.com", // Contact email address
    "billing_address": "123 Main Street", // Billing address
    "city": "Hyderabad", // City of the business
    "state": "Telangana", // State of the business
    "zipcode": "12345", // Zipcode of the business
    "country": "USA", // Country of the business
    "documents": {
        "doc_1": {
            "title": "PAN", // Title of the document
            "value": "HG297323" // Value of the document
        },
        "doc_2": {
            "title": "GST", // Title of the document
            "value": "76YHGF67656" // Value of the document
        }
    },
    "default_currency": "USD", // Default currency for transactions
    "enable_qr": true, // Enable or disable QR code generation
    "redirect_url": "", // URL to redirect after payment
    "include_invoice_id": true, // Include invoice ID in the documentation
    "webhook_url": "", // URL for webhook callbacks
    "terms_condition_url": "https://google.com", // URL for terms and conditions
    "custom_thanks_message": "Thank you for your payment!", // Custom thank you message
    "custom_button_text": "", // Custom text for the payment button
    "green_donation_link": "", // URL for green donation link
    "donation_percentage": 0.0, // Percentage of donation
    "donation_message": "", // Message regarding donations
    "tax_details": {
        "tax_title": "GST", // Title for tax
        "tax_percentage": 18, // Tax percentage
        "tax_country": "India", // Country where the tax is applicable
        "is_all_states": true, // If tax is applicable to all states
        "tax_states": [] // List of states where tax is applicable (empty if all states)
    },
    "invoice_date": "2024-08-08T05:55:14.981Z", // Date when the invoice was generated
    "theme_color": "", // Theme color for the invoice
    "client_details": { // Details of the client
        "name": "Aman A", // Name of the client
        "phone_code": "91", // Country code for the client's phone number
        "phone": "9876543211", // Client's phone number
        "email": "aman2@gmail.com", // Client's email address
        "website": "https://amanwebsite.com", // Client's website URL
        "street_address": "1234 Elm Street", // Street address of the client
        "state": "Maharashtra", // State of the client
        "city": "Mumbai", // City of the client
        "country": "India", // Country of the client
        "zip_code": "400001", // Zip code of the client
        "details": [ // Additional details of the client
            {
                "PAN": "ABCDE1234F" // Client's PAN number
            },
            {
                "GST": "27ABCDE1234F1Z5" // Client's GST number
            }
        ]
    },
    "product_details": [ // Details of the products or services
        {
            "name": "Orange Gift Box", // Name of the product
            "price": "599.50", // Price of the product
            "description": "", // Description of the product
            "logo": "", // Logo of the product
            "product_created_at": "2024-08-07T11:53:03.000Z", // Date when the product was created
            "currency": "INR", // Currency for the product price
            "quantity": 1, // Quantity of the product
            "amount": 599.5, // Amount for the product (price * quantity)
            "final": 599.5 // Final amount after any discounts or taxes
        }
    ],
    "total": 599.5, // Total amount before any additional charges
    "total_details": [ // Breakdown of additional charges or discounts
        {
            "title": "Discount", // Title for the discount
            "amount": 0, // Discount amount
            "percentage": 0 // Discount percentage
        },
        {
            "title": "Shipping", // Title for the shipping charge
            "amount": 0, // Shipping amount
            "percentage": 0 // Shipping percentage
        },
        {
            "title": "Total GST", // Title for the GST charge
            "amount": 0, // GST amount
            "percentage": 0 // GST percentage
        },
        {
            "title": "TDS", // Title for the TDS deduction
            "amount": 0, // TDS amount
            "percentage": 0 // TDS percentage
        }
    ],
    "net_total": 599.5, // Net total after all deductions and additions
    "allow_partial": false, // Whether partial payments are allowed
    "allow_tip": false, // Whether tips are allowed
    "due_date": "2024-08-10T05:55:14.981Z", // Due date for the payment
    "note_to_customer": "Kindly pay before due date!", // Note to the customer regarding payment
    "terms_message": "", // Additional terms or messages
    "tracking_number": "", // Tracking number for the shipment
    "tracking_url": "", // URL to track the shipment
    "extras": { // Additional key-value pairs
        "key1": "value1", 
        "key2": "value2"
    },
    "funding_source": "" // Source of funding for the transaction
}
};

fetch('https://api.ninjapay.me/webextension/api/v1/fiat/invoice/create', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
  

Last updated