Skip to main content

Subscriptions

API data

API Gateway
This API is used for payment gateway operations:

Introduction

Subscribing to services and/or products is a common way for companies to retain customers. For example, a fashion or home decor magazine can offer monthly, quarterly, or annual subscriptions—so the customer receives the product (the magazine) every month or each edition. Every subscription is associated with a plan.


Create subscription

To create a subscription, send a POST request as shown below:

POST /v1/recurrences/subscriptions
Notes
  • It’s possible to have different credentials for Gateway and Recurrence. Verify whether your credentials are distinct.
  • To create a vaultId, refer to the gateway Vault documentation: Card Vault.

Via REST request with the following body:

Request
{
"vaultId": "e7fa5a01-90a9-4abc-9bac-d9dbfa7db587",
"orderNumber": "1234567890",
"planId": "e776ab3b-4698-4afa-97d4-a621d70c4a11"
}

Data dictionary - Parameters

PROPERTYDESCRIPTIONTYPELOCATIONREQUIREDMAX SIZE
VaultIdVault identifier.stringbodyyes36
OrderNumberService order / order number.stringbodyyes10
PlanIdPlan identifier.stringbodyyes36
Subscription created successfully
"937d0108-c54c-44f5-9ddc-acdb3dd94cc6"

Data dictionary - Response

PROPERTYDESCRIPTIONTYPE
SubscriptionIdIdentifier of the created subscription.string

Search subscriptions

To search subscriptions, send a GET request as shown below:

GET /v1/recurrences/subscriptions?planName={planName}&status={status}&orderBy={orderBy}&page={page}&limit={limit}

Data dictionary - Query parameters

PROPERTYDESCRIPTIONTYPELOCATIONREQUIRED
PlanNamePlan name.stringquery paramsno
StatusSubscription status filter.stringquery paramsno
OrderByResult ordering.stringquery paramsno
PagePage number.integerquery paramsno
LimitItems per page.integerquery paramsno
Subscriptions found
{
"items": [
{
"vaultId": "fc3c5589-24b1-4bca-b8ab-e57b100c44cd",
"orderNumber": "1234567890",
"status": "Active",
"plan": {
"merchantId": "01700555550000",
"name": "PLANO CUSTOM DO SEU ZÉ",
"description": "PLANO DE RECORRÊNCIA EM 5X",
"amount": 31.000000,
"planType": "Custom",
"trialDays": 0,
"paymentMethod": "CreditCard",
"interval": 30,
"installments": 5,
"status": "Active",
"attempts": 0,
"id": "cef858c4-d0c6-4f27-b009-c303121f3b6e",
"createdDate": "2020-04-14T12:21:23.337"
},
"id": "013c7ec4-62c1-4d78-859d-e8d2a11f681d",
"createdDate": "2020-03-19T15:09:12.203"
},
{
"vaultId": "3a203c6b-553f-4a7c-9cc4-e30897966c2e",
"orderNumber": "1404202015",
"status": "Blocked",
"plan": {
"merchantId": "017005555500000",
"name": "plano - Mensal 1",
"description": "plano - Mensal 1",
"amount": 29.990000,
"planType": "Monthly",
"trialDays": 1,
"paymentMethod": "CreditCard",
"interval": 30,
"installments": 1,
"status": "Active",
"attempts": 0,
"id": "fc7f49da-0510-4884-9cad-ae3e0b2488d9",
"createdDate": "2020-04-14T12:21:23.337"
},
"id": "0405507a-c8d5-440d-bb83-80e45f24b35f",
"createdBy": "[email protected]",
"createdDate": "2020-04-14T15:45:04.73"
}
],
"page": 1,
"limit": 2,
"total": 41
}

Data dictionary - Response

PROPERTYDESCRIPTIONTYPE
VaultIdVault identifier.string
OrderNumberService order / order number.string
StatusSubscription status.string
IdSubscription identifier.string
CreatedByUser responsible for creating the subscription.string
CreatedDateSubscription creation date/time.datetime
Plan.MerchantIdMerchant identifier.string
Plan.NamePlan name.string
Plan.DescriptionPlan description.string
Plan.AmountPlan installment amount.decimal
Plan.PlanTypePlan type.string
Plan.TrialDaysTrial days.integer
Plan.PaymentMethodPayment method.string
Plan.IntervalBilling interval in days.integer
Plan.InstallmentsNumber of installments.integer
Plan.StatusPlan status.string
Plan.AttemptsRetry attempts count.integer
Plan.IdPlan identifier.string
Plan.CreatedDatePlan creation date/time.datetime
PageCurrent page number.integer
LimitItems per page.integer
TotalTotal items found.integer

Get subscription by ID

To retrieve a subscription by ID, send a GET request as shown below:

GET /v1/recurrences/subscriptions/{subscriptionId}

Data dictionary - Parameters

PROPERTYDESCRIPTIONTYPELOCATIONREQUIREDMAX SIZE
SubscriptionIdSubscription identifier.stringpathyes36
Subscription found
{
"vaultId": "fc3c5589-24b1-4bca-b8ab-e57b100c44cd",
"orderNumber": "1234567890",
"status": "Blocked",
"plan": {
"merchantId": "01700555550000",
"name": "PLANO CUSTOM DO SEU ZÉ",
"description": "PLANO DE RECORRÊNCIA EM 5X",
"amount": 31.000000,
"planType": "Custom",
"trialDays": 0,
"paymentMethod": "CreditCard",
"interval": 30,
"installments": 5,
"status": "Active",
"attempts": 0,
"id": "cef858c4-d0c6-4f27-b009-c303121f3b6e",
"createdDate": "2020-04-14T12:21:23.337"
},
"id": "013c7ec4-62c1-4d78-859d-e8d2a11f681d",
"createdDate": "2020-03-19T15:09:12.203"
}

Data dictionary - Response

PROPERTYDESCRIPTIONTYPE
VaultIdVault identifier.string
OrderNumberService order / order number.string
StatusSubscription status.string
IdSubscription identifier.string
CreatedDateSubscription creation date/time.datetime
Plan.MerchantIdMerchant identifier.string
Plan.NamePlan name.string
Plan.DescriptionPlan description.string
Plan.AmountPlan installment amount.decimal
Plan.PlanTypePlan type.string
Plan.TrialDaysTrial days.integer
Plan.PaymentMethodPayment method.string
Plan.IntervalBilling interval in days.integer
Plan.InstallmentsNumber of installments.integer
Plan.StatusPlan status.string
Plan.AttemptsRetry attempts count.integer
Plan.IdPlan identifier.string
Plan.CreatedDatePlan creation date/time.datetime

Update subscription status

To change the subscription status, send a request as shown below:

POST /v1/recurrences/subscriptions/{subscriptionId}/status

Via REST request with the following body:

Request
{
"status": "Actived"
}

Data dictionary - Parameters

PROPERTYDESCRIPTIONTYPELOCATIONREQUIREDMAX SIZE
SubscriptionIdIdentifier of the subscription to update.stringpathyes36
StatusStatus value (Actived, Canceled).stringbodyyesfixed
Status updated successfully
{"id":"0dd23cbd-de75-45a5-b2d1-972191140593"}

Data dictionary - Response

PROPERTYDESCRIPTIONTYPE
idIdentifier of the updated subscription.string

Update vault on a subscription

To change the vault associated with a subscription, send a request as shown below:

POST /v1/recurrences/subscriptions/{subscriptionId}/vault

Via REST request with the following body:

Request
{
"vaultId": "e954a511-f081-42e1-8531-2c4dcdf9a2cf"
}

Data dictionary - Parameters

PROPERTYDESCRIPTIONTYPELOCATIONREQUIREDMAX SIZE
SubscriptionIdSubscription identifier.stringpathyes36
VaultIdVault identifier.stringbodyyes36
Vault updated successfully
{"id":"013c7ec4-62c1-4d78-859d-e8d2a11f681d"}

Data dictionary - Response

PROPERTYDESCRIPTIONTYPE
idIdentifier of the updated subscription.string

Subscription statuses

StatusDescription
ActiveSubscription is active and running normally
CanceledSubscription canceled by the user or the system

For questions or issues, visit the support section in Sopague.