Update Invoice Item
Change or modify an invoice item.
You can update an invoice item at any time before the corresponding subscription generates an invoice.
This method triggers the Invoice Item Updated webhook. This webhook contains the same information as the response.
invoice_item
ID of the invoice item.
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { string invoiceId = "ii_50f7127dd0f7725c6599697d971af8b8"; var requestObj = new { amount = 50, description = "", discountable = false, metadata = new { merchant_defined = true }, quantity = 0, unit_amount = 0 }; string request = JsonSerializer.Serialize(requestObj); string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/invoice_items/{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 = { amount: 50, description: "", discountable: false, metadata: { merchant_defined: true }, quantity: 0, unit_number: 0 }; const result = await makeRequest( 'POST', '/v1/invoice_items/ii_50f7127dd0f7725c6599697d971af8b8', 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 = [ "amount" => 50, "description" => "", "discountable" => false, "quantity" => 0, "unit_amount" => 0 ]; try { $object = make_request('post', "/v1/invoice_items/ii_50f7127dd0f7725c6599697d971af8b8", $body); var_dump($object); } catch(Exception $e) { echo "Error => $e"; } ?>
Python
from pprint import pprint from utilities import make_request invoice_item = { "amount": 50, "description": "", "discountable": False, "metadata": { "merchant_defined": True }, "quantity": 0, "unit_amount": 0 } result = make_request(method='post', path='/v1/invoice_items/ii_50f7127dd0f7725c6599697d971af8b8', body=invoice_item) pprint(result)
/v1/invoice_items/:invoice_item
Update Invoice Item
curl -X post https://sandboxapi.rapyd.net/v1/invoice_items/ii_50f7127dd0f7725c6599697d971af8b8 -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 '{ "amount": 50, "description": "", "discountable": false, "metadata": { "merchant_defined": true }, "quantity": 0, "unit_amount": 0 } '
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "22ce0b1a-3a3d-40ad-8a40-a30ad82fb384" }, "data": { "id": "ii_50f7127dd0f7725c6599697d971af8b8", "amount": 50, "currency": "USD", "customer": "cus_f4251b4835e51e52d8adf3f1340c3419", "date": 1542974679, "description": "", "discountable": false, "invoice": "", "metadata": { "merchant_defined": true }, "period": { "start": 0, "end": 0 }, "plan": { "product": null, "transform_usage": {} }, "proration": "", "quantity": 0, "subscription": "sub_a19440d43875dd18c58058e722f1dd18", "unit_amount": 0 } }