Skip to main content

Documentation

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_db73da2fc2a7a3b8451fed8afdbaf46c
    -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": "0d22931f-c478-4a5b-b564-939afcf10723"
        },
        "data": {
            "id": "sub_db73da2fc2a7a3b8451fed8afdbaf46c",
            "billing": "pay_automatically",
            "billing_cycle_anchor": 1700140716,
            "created_at": 1700140716,
            "customer_token": "cus_b306773fc73d23e5a9b4347984606cf7",
            "days_until_due": 30,
            "metadata": {},
            "tax_percent": 0,
            "cancel_at_period_end": false,
            "canceled_at": null,
            "current_period_end": 1702732716,
            "current_period_start": 1700140716,
            "discount": null,
            "ended_at": null,
            "subscription_items": {
                "data": [
                    {
                        "id": "subi_e3cec118feec75e0f270d888a053a410",
                        "created": 1700140716,
                        "metadata": null,
                        "quantity": 5,
                        "plan": {
                            "id": "plan_4feb4cf48e807cd142d7759a58a55d2f",
                            "aggregate_usage": "sum",
                            "amount": 9.99,
                            "billing_scheme": "per_unit",
                            "created_at": 1700140529,
                            "currency": "USD",
                            "interval": "month",
                            "interval_count": 1,
                            "metadata": {},
                            "product": {
                                "id": "product_4ba001c7655c4a0ee4f471dbaccaa305",
                                "active": true,
                                "attributes": [
                                    "location",
                                    "size"
                                ],
                                "created_at": 1673932995,
                                "description": "Unlimited music streaming",
                                "images": [
                                    "64bit-encoded-image-1",
                                    "64bit-encoded-image-2"
                                ],
                                "metadata": {},
                                "name": "Unlimited Music",
                                "package_dimensions": {
                                    "height": 0,
                                    "length": 0,
                                    "weight": 0,
                                    "width": 0
                                },
                                "shippable": false,
                                "skus": [],
                                "statement_descriptor": "Music streaming",
                                "type": "services",
                                "unit_label": "month",
                                "updated_at": 1673932995
                            },
                            "nickname": "Unlimited Plan",
                            "tiers": [],
                            "tiers_mode": "",
                            "transform_usage": {
                                "divide_by": 1,
                                "round": "up"
                            },
                            "trial_period_days": 7,
                            "usage_type": "licensed",
                            "active": true
                        }
                    },
                    {
                        "id": "subi_f0d375617a093d30307adec9ea246b44",
                        "created": 1700140716,
                        "metadata": null,
                        "quantity": 3,
                        "plan": {
                            "id": "plan_26aabd1d48bcfec1ff05dc2bed772aa3",
                            "aggregate_usage": "sum",
                            "amount": 10.99,
                            "billing_scheme": "per_unit",
                            "created_at": 1700140584,
                            "currency": "USD",
                            "interval": "month",
                            "interval_count": 1,
                            "metadata": {},
                            "product": {
                                "id": "product_4ba001c7655c4a0ee4f471dbaccaa305",
                                "active": true,
                                "attributes": [
                                    "location",
                                    "size"
                                ],
                                "created_at": 1673932995,
                                "description": "Unlimited music streaming",
                                "images": [
                                    "64bit-encoded-image-1",
                                    "64bit-encoded-image-2"
                                ],
                                "metadata": {},
                                "name": "Unlimited Music",
                                "package_dimensions": {
                                    "height": 0,
                                    "length": 0,
                                    "weight": 0,
                                    "width": 0
                                },
                                "shippable": false,
                                "skus": [],
                                "statement_descriptor": "Music streaming",
                                "type": "services",
                                "unit_label": "month",
                                "updated_at": 1673932995
                            },
                            "nickname": "Unlimited Plan plus",
                            "tiers": [],
                            "tiers_mode": "",
                            "transform_usage": {
                                "divide_by": 1,
                                "round": "up"
                            },
                            "trial_period_days": 7,
                            "usage_type": "licensed",
                            "active": true
                        }
                    }
                ],
                "has_more": false,
                "total_count": 2,
                "url": "/v1/subscription_items?subscription=sub_db73da2fc2a7a3b8451fed8afdbaf46c"
            },
            "status": "unpaid",
            "trial_end": null,
            "trial_start": null,
            "payment_method": "card_3c000ae5db06762a2c8a00ca514fa336",
            "payment_fields": null,
            "payout_fields": null,
            "type": "payment",
            "simultaneous_invoice": false
        }
    }