Skip to main content

Introduction

SubscriptionManager allows you to retrieve subscription information from a user’s merchant accounts. There are two ways to retrieve subscriptions depending on your use case:
  1. After provisioning your card to the merchant account with CardSwitcher: the user authenticates to the merchant account, their card is provisioned, and their subscription data is returned in the CARD_UPDATED webhook event.
  2. Without provisioning a card: the user authenticates to the merchant account and their subscription data is returned in the NEW_SUBSCRIPTIONS_AVAILABLE webhook event.
SubscriptionManager must be enabled for your account. Reach out to the Knot team to get started.

Getting Started

If you have already integrated CardSwitcher, you can receive subscription data as part of the card switch flow without any additional client-side integration.

Receive Subscription IDs

When a card is successfully updated, the CARD_UPDATED webhook will include subscription IDs in data.subscriptions:
{
  "event": "CARD_UPDATED",
  ...
  "data": {
    "card_id": "123456789",
    "subscriptions": [
      { "id": "ka8sdf0asdfm10as0a0sdfja7ssa8" },
      { "id": "8asdh29qjss923kd0d920skd8sjd8" }
    ]
  }
}

Retrieve Full Subscription Details

Upon receiving the webhook, call Get Subscription By ID for each ID in data.subscriptions to retrieve the full subscription object.

Get Ongoing Updates

New subscriptions

To be notified when new subscriptions are detected on a merchant account, listen to the NEW_SUBSCRIPTIONS_AVAILABLE webhook. You will receive this event each time a new subscription is found on the merchant account. Upon receiving the NEW_SUBSCRIPTIONS_AVAILABLE webhook, make a request to Get Subscription By ID for each ID in data.subscriptions, passing the ID received in the webhook as a path parameter.

Updated subscriptions

Receiving updated subscription information is entirely optional and may not be relevant for your use case.
To be notified about updates to existing subscriptions, listen to the UPDATED_SUBSCRIPTIONS_AVAILABLE webhook. You will receive this event for a merchant account each time there are existing subscriptions for which data has changed (e.g. a price change or status update). Upon receiving the UPDATED_SUBSCRIPTIONS_AVAILABLE webhook, make a request to Get Subscription By ID for each ID in data.subscriptions, passing the ID received in the webhook as a path parameter.

Cancel a Subscription

Once a user has linked a merchant account, they can cancel a subscription or bill associated with that merchant account. Follow the steps below to determine whether cancellation is available and to execute it.
1

Display the subscription in your app

Call Get Merchant Accounts with the user’s external_user_id and merchant_id to check whether cancellation is supported for that merchant account.
curl --request GET \
  --url 'https://development.knotapi.com/accounts/get?external_user_id=15d036d8-0ae5-41bb-84fa-88f839465e5e&merchant_id=45' \
  --header 'Authorization: Basic Y2xpZW50X2lkOnNlY3JldA=='
In the response, check that the merchant account’s connection.scopes array contains an object with "type": "cancel" and that the subscription’s is_cancellable field is true. Only when both conditions are met should you display a cancel button to the user.
// Example connection object from Get Merchant Accounts response
{
  "connection": {
    "status": "connected",
    "scopes": [
      { "type": "update_card" },
      { "type": "cancel" }
    ]
  }
}
2

Call the Cancel Subscription endpoint

When the user taps the cancel button, call Cancel Subscription with the subscription ID to cancel the subscription or bill within seconds. Subscribe to the CANCELLATION_SUCCEEDED and CANCELLATION_FAILED webhooks to be notified of the outcome.

Handle disconnected merchant accounts

If for example a user changes their password to a merchant account, the Get Merchant Accounts endpoint will connection.status: disconnected and you’ll be notified via the ACCOUNT_LOGIN_REQUIRED webhook event. When this occurs, subscription data will not be refreshed (e.g. in case there is a plan or status change) and you will not be able to make requests to Cancel Subscription without the user relinking their merchant account. You’ll want to display a UX in your app to allow users to reconnect their account. For example, you may choose to display a button that says “Reconnect” or “Refresh” depending on the exact UX. When the user clicks the button, call Create Session with type: link and invoke the SDK to allow the user to reconnect their merchant account.
To test this behavior in development, use the Disconnect Account endpoint.

Testing

To test SubscriptionManager in the development environment, use one of the merchants below. The following is a subset of merchants available for testing - it is not the full list of supported merchants.
  • Verizon
  • T-Mobile
  • Spectrum
  • Xfinity Internet
  • Xfinity Mobile
  • Apple
  • Netflix
  • Disney+
  • Hulu
  • Spotify
Via CardSwitcher: Perform a card switch via CardSwitcher with one of the merchants above. Testing docs here. The resulting CARD_UPDATED webhook will include subscription IDs that you can then use to test retrieval of the full subscription details. Without provisioning a card: Create a session with type: link, initialize the SDK with a test merchant, and authenticate using testing credentials user_good/ pass_good. The NEW_SUBSCRIPTIONS_AVAILABLE webhook will fire and include subscription IDs that you can then use to test retrieval.