Finalize Invoice
Finalize an invoice.
Invoices are initially created with a draft status, and this is the only state in which an invoice can be finalized. When an invoice is ready to be paid, finalize it. This sets its status to open.
Subscriptions automatically create draft invoices during each billing cycle, which are then automatically finalized.
When an invoice is finalized, it can no longer be deleted and its final status can be one of the following:
paid
uncollectible
void
An invoice can be finalized only one time. This method triggers the Invoice Finalized Webhook. This webhook contains the same information as the response.
The following asynchronous webhooks provide information about later changes to the invoice:
invoice
ID of the invoice you want to finalize. String starting with invoice_.
Code Samples
.NET
using System; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { string invoice = "invoice_1785fecf9748e66319ce0848e6501072"; string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/invoices/{invoice}/finalize"); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Error completing request: " + e.Message); } } } }
JavaScript
const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest; async function main() { try { const result = await makeRequest( 'POST', '/v1/invoices/invoice_1785fecf9748e66319ce0848e6501072/finalize' ); console.log(result); } catch (error) { console.error('Error completing request', error); } }
PHP
<?php $path .= "/<path-to-your-utility-file>/utilities.php"; include($path); try { $object = make_request('post', "/v1/invoices/invoice_1785fecf9748e66319ce0848e6501072/finalize"); var_dump($object); } catch(Exception $e) { echo "Error => $e"; } ?>
Python
from pprint import pprint from utilities import make_request result = make_request(method='post', path='/v1/invoices/invoice_1785fecf9748e66319ce0848e6501072/finalize') pprint(result)
/v1/invoices/:invoice/finalize
Finalize Invoice
curl -X post https://sandboxapi.rapyd.net/v1/invoices/invoice_d021dc5aadaae5c810ed076a64065699/finalize -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here'
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "449e772d-b6a4-407e-9574-9e3e46a7d473" }, "data": { "id": "invoice_d021dc5aadaae5c810ed076a64065699", "attempt_count": 1, "billing": "pay_automatically", "billing_reason": "subscription_create", "created_at": 1702305351, "currency": "USD", "customer": "cus_893a041b7dd251ec894556564298dc13", "description": "", "discount": null, "due_date": 1704897351, "days_until_due": 30, "metadata": { "merchant_defined": true }, "failure_code": "", "failure_message": "", "paid": true, "paid_at": 1702305377, "dispute": null, "refunds": null, "order": null, "outcome": null, "visual_codes": {}, "textual_codes": {}, "instructions": [], "ewallet_id": "ewallet_8d09667ac2a0d4ba57d2765c497491fd", "ewallets": [ { "ewallet_id": "ewallet_8d09667ac2a0d4ba57d2765c497491fd", "amount": 9.99, "percent": 100, "refunded_amount": 0 } ], "payment_method_options": {}, "payment_method_type": "at_visa_card", "payment_method_type_category": "card", "fx_rate": 1, "merchant_requested_currency": null, "merchant_requested_amount": null, "fixed_side": "", "payment_fees": null, "invoice": "invoice_d021dc5aadaae5c810ed076a64065699", "escrow": null, "group_payment": "", "cancel_reason": null, "initiation_type": "customer_present", "mid": "mid_f79561a67d79c6e0162bf22f3ccd1292", "next_action": "not_applicable", "error_code": "", "remitter_information": {} }, "payout": null, "payment_fields": null, "period_end": 1704983751, "period_start": 1702305351, "lines": [], "statement_descriptor": "", "subscription": "sub_4febac6e4554b387ae7e0ee2d933abed", "discount_amount": 0, "subtotal": 9.99, "tax": 0, "tax_percent": 0, "total": 9.99, "status": "paid", "payout_fields": null, "type": "payment", "next_payment_attempt": 1702308951, "automatic_attempt_count": 0 } }