Skip to content

Subscription Hub

Subscription Hub

The SubscriptionHub is the quickest way to get started with SubscriptionManagement. The SubscriptionHub will render a subscription management widget to the container and manage the entire subscription management and retention workflow.

You can embed the Subscription Hub directly into your application:

renumerate.mountSubscriptionHub("elementId", "sessionId", "classes");
keytypenotes
elementIdstringThe id for the container element
sessionIdstringYour customer’s subscription session id
classesstring | undefinedButton classes (optional)

For React applications, use the SubscriptionHub component for seamless integration:

Basic Setup All Renumerate React components must be wrapped in a RenumerateProvider:

import React from 'react';
import { RenumerateProvider } from '@renumerate/js/react';
function App() {
return (
<RenumerateProvider config={{ publicKey: 'your-public-key' }}>
{/* Default styled subscription hub */}
<SubscriptionHub sessionId={sessionId} />
{/* Or styled subscription hub */}
<SubscriptionHub
sessionId={sessionId}
wrapperClassName="custom-hub-wrapper h-96 w-full border rounded-lg"
iframeClassName="w-full h-full rounded-lg"
/>
</RenumerateProvider>
);
}

Subscription sessions allow you to present the SubscriptionHub widget to your customers to easily manage and view their subscriptions.

Subscription sessions begin with sub_

To generate a customer’s session ID, make a POST request to https://api.renumerate.com/v1/subscription/session from your application’s backend.

Ensure the following:

  1. Include the X-Brand-Key header with your Brand’s private key for authentication. See the Where To Find Private Key section.
  2. Pass the customer’s ID or email in the request body as specified below.

This process securely creates a session ID that grants the customer access to their subscription management portal.

Request Body Parameters:

When generating a SubscriptionHub session, you must include either the customer_id or customer_email (or both). Below is a table of all available parameters:

keytypenotes
subscriptionobject
subscription.customer_idstring | undefinedYour stripe customerId
subscription.customer_emailstring | undefinedThe customer’s email address in stripe
subscription.subscription_idstring | undefinedThe specific subscription id (optional)

Node.js/TypeScript

const privateKey = process.env.RENUMERATE_PRIVATE_KEY;
const requestBody = {
subscription: {
customer_id: "cus_NffrFeUfNV2Hib", // Example stripe id
subscription_id: "sub_1MowQVLkdIwHu7ixeRlqHVzs", // Your specific subscription
},
};
const response = await fetch("https://api.renumerate.com/v1/subscription/session", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Brand-Key": privateKey,
},
body: JSON.stringify(requestBody),
});
const {
session: { id },
} = await response.json();