Update Subscription Item
Change or modify a subscription item.
This method triggers the Customer Subscription Item Updated webhook. This webhook contains the same information as the response.
subscription_item
ID of the subscription item. String starting with subi_.
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { string subscriptionItem = "subi_e5dbbf84c68e5bb7db761625158d4262"; var requestObj = new { quantity = 2, metadata = new { merchant_defined = true } }; string request = JsonSerializer.Serialize(requestObj); string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/subscription_items/{subscriptionItem}", 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 = { quantity: 2 }; const result = await makeRequest( 'POST', '/v1/subscription_items/subi_e5dbbf84c68e5bb7db761625158d4262', body ); console.log(result); } catch (error) { console.error('Error completing request', error); } }
PHP
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/<path-to-your-utility-file>/utilities.php"; include($path); try { $body = [ "metadata" => array( "merchant_defined" => "updated" ), "quantity" => 2 ]; $object = make_request('post', '/v1/subscription_items/subi_e5dbbf84c68e5bb7db761625158d4262', $body); var_dump($object); } catch(Exception $e) { echo "Error: $e"; } ?>
Python
from pprint import pprint from utilities import make_request subscription_item = { "metadata": { "merchant_defined": 'updated' }, "quantity": 2 } result = make_request(method='post', path='/v1/subscription_items/subi_e5dbbf84c68e5bb7db761625158d4262', body=subscription_item) pprint(result)
/v1/subscription_items/:subscription_item
Update Subscription Item
curl -X post https://sandboxapi.rapyd.net/v1/subscription_items/subi_e5dbbf84c68e5bb7db761625158d4262 -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 '{ "metadata": { "merchant_defined": "updated" }, "quantity": 2 } '
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "65056f31-505e-4a75-802a-aea3cdf8226d" }, "data": { "id": "subi_e5dbbf84c68e5bb7db761625158d4262", "created": 1560329454, "metadata": { "merchant_defined": "updated" }, "quantity": 2, "subscription_id": "sub_0de9c79c1e2beee09499dc8220493d59", "plan": { "id": "plan_dad429f5e16c41499c9c23356a5e8dea", "aggregate_usage": "sum", "amount": 0, "billing_scheme": "per_unit", "created_at": 1559803170, "currency": "USD", "interval": "month", "interval_count": 1, "metadata": {}, "product": "product_97f34708270f13d95d9c505eb785e3c5", "nickname": "", "tiers": [], "tiers_mode": "", "transform_usage": { "divide_by": 0, "round": "" }, "trial_period_days": 0, "usage_type": "metered" } } }