Retrieve Subscription
Retrieve the details of a subscription.
subscription
ID of the subscription. String starting with sub_.
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { string subscription = "sub_b3cbb7eba3e4d67e9bf016dd78267b56"; string result = RapydApiRequestSample.Utilities.MakeRequest("GET", $"/v1/payments/subscriptions/{subscription}"); 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( 'GET', '/v1/payments/subscriptions/sub_b3cbb7eba3e4d67e9bf016dd78267b56' ); 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 { $object = make_request('get', '/v1/payments/subscriptions/sub_b3cbb7eba3e4d67e9bf016dd78267b56'); var_dump($object); } catch(Exception $e) { echo "Error: $e"; } ?>
Python
from pprint import pprint from utilities import make_request result = make_request(method='get', path='/v1/payments/subscriptions/sub_b3cbb7eba3e4d67e9bf016dd78267b56') pprint(result)
/v1/payments/subscriptions/:subscription
Retrieve Subscription
curl -X get 'https://sandboxapi.rapyd.net/v1/payments/subscriptions/sub_e38643c5d8d59f4ccd8ae08f8cc61c8d' \ -H 'access_key: your-access-key-here' \ -H 'Content-Type: application/json' \ -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": "bcb8bb7c-e662-4635-b27d-1932fd6102e7" }, "data": { "id": "sub_e38643c5d8d59f4ccd8ae08f8cc61c8d", "billing": "pay_automatically", "billing_cycle_anchor": 1763455667, "created_at": 1763455667, "customer_token": "cus_4e25112ac20e144ad073a614dc46934b", "days_until_due": 30, "metadata": {}, "tax_percent": 0, "cancel_at_period_end": false, "canceled_at": null, "current_period_end": 1766047667, "current_period_start": 1763455667, "discount": null, "ended_at": null, "subscription_items": { "data": [ { "id": "subi_7987dc3af04f7d0b6ba959e54bba24b7", "created": 1763455667, "metadata": null, "quantity": 1, "plan": { "id": "plan_390625a173f599153b5250715d861718", "aggregate_usage": "sum", "amount": 0, "billing_scheme": "tiered", "created_at": 1756282338, "currency": "USD", "interval": "month", "interval_count": 1, "metadata": {}, "product": { "id": "product_fa1b30b1caa6711910f60e758dbe70c6", "active": true, "attributes": [ "quantity" ], "created_at": 1673498178, "description": "Public Transportation Usage", "images": [ "64bit-encoded-image-1" ], "metadata": { "merchant_defined": true }, "name": "Transit Rides", "package_dimensions": { "height": 0, "length": 0, "weight": 0, "width": 0 }, "shippable": false, "skus": [], "statement_descriptor": "Transit Usage", "type": "services", "unit_label": "rides", "updated_at": 1673498178 }, "nickname": "Transit Use", "tiers": [ { "amount": 4, "up_to": 5, "flat_amount": 1 }, { "amount": 3, "up_to": 10, "flat_amount": 0 }, { "amount": 2, "up_to": 20, "flat_amount": 0 }, { "amount": 1, "up_to": "inf", "flat_amount": 0 } ], "tiers_mode": "graduated", "transform_usage": { "divide_by": 1, "round": "up" }, "trial_period_days": 0, "usage_type": "licensed", "active": true } } ], "has_more": false, "total_count": 1, "url": "/v1/subscription_items?subscription=sub_e38643c5d8d59f4ccd8ae08f8cc61c8d" }, "status": "active", "trial_end": null, "trial_start": null, "payment_method": "card_b9548d9b53a565b2315fecdc6c87f158", "payment_fields": null, "payout_fields": null, "type": "payment", "simultaneous_invoice": true } }