Update Invoice
Change or modify an invoice.
You can modify the invoice when its status is draft.
This method triggers the Invoice Updated Webhook. This webhook contains the same information as the response.
invoice
ID of the invoice you want to update. String starting with invoice_.
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { string invoiceId = "invoice_e722956a315d42c94e93ce49153e7029"; var requestObj = new { days_until_due = 40, metadata = new { merchant_defined = "updated" } }; string request = JsonSerializer.Serialize(requestObj); string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/invoices/{invoiceId}", request); 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 body = { days_until_due: 40 }; const result = await makeRequest( 'POST', '/v1/invoices/invoice_e722956a315d42c94e93ce49153e7029', body ); console.log(result); } catch (error) { console.error('Error completing request', error); } }
PHP
<?php $path .= "/<path-to-your-utility-file>/utilities.php"; include($path); $body = [ "metadata" => array( "merchant_defined" => "updated" ), "days_until_due" => 40 ]; try { $object = make_request('post', "/v1/invoices/invoice_e722956a315d42c94e93ce49153e7029", $body); var_dump($object); } catch(Exception $e) { echo "Error => $e"; } ?>
Python
from pprint import pprint from utilities import make_request invoice = { "metadata": { "merchant_defined": "updated" }, "days_until_due": 40 } result = make_request(method='post', path='/v1/invoices/invoice_e722956a315d42c94e93ce49153e7029', body=invoice) pprint(result)
/v1/invoices/:invoice
Update Invoice
curl -X post https://sandboxapi.rapyd.net/v1/invoices/invoice_5f9980f7355eeca21e1b97931cae6c23 -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' -d '{ "tax_percent" : 10 } '
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "799baea9-ef78-41df-b841-e752d2091538" }, "data": { "id": "invoice_5f9980f7355eeca21e1b97931cae6c23", "attempt_count": 0, "billing": "pay_automatically", "billing_reason": "manual", "created_at": 1702307343, "currency": "USD", "customer": "cus_893a041b7dd251ec894556564298dc13", "description": "", "discount": null, "due_date": 1704899343, "days_until_due": 30, "metadata": {}, "number": 0, "payment_method": "card_4bd5b06ff2ba990676e3b9e8695d790e", "payment": null, "payout": null, "payment_fields": null, "period_end": 0, "period_start": 0, "lines": [], "statement_descriptor": "", "subscription": "", "discount_amount": 0, "subtotal": 0, "tax": 0, "tax_percent": 10, "total": 0, "status": "draft", "payout_fields": null, "type": "payment", "next_payment_attempt": 1702310943, "automatic_attempt_count": 0 } }