Skip to main content

Plans

API data

API Gateway
This API is used for payment gateway operations:

Introduction

Plans are offers presented by businesses to potential customers. For example, a gym can offer monthly, quarterly, or annual plans, allowing the customer to choose the plan that best fits their needs.


Create plan

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

POST /v1/recurrences/plans

Via REST request with the following body:

Request
{
"merchantId": "01700555550000",
"name": "Jornal do Bairro - assinatura mensal",
"description": "Jornal com notícias locais do bairro.",
"amount": 5.99,
"planType": "Monthly",
"trialDays": 7,
"paymentMethod": "CreditCard",
"interval": 30,
"installments": 12,
"attempts": 3
}

Data dictionary - Parameters

PROPERTYDESCRIPTIONTYPELOCATIONREQUIREDMAX SIZE
MerchantIdMerchant identifier.stringbodyNo (captured from authentication)20
NamePlan name.stringbodyyes255
DescriptionPlan description.stringbodyyes255
AmountPlan installment amount.decimalbodyyes12 integers and 6 decimals
PlanTypePlan type (Monthly, Bimonthly, Quarterly, Semesterly, Yearly, Custom).stringbodyyesfixed
TrialDaysTrial days.integerbodynoN/A
PaymentMethodPayment method (CreditCard).stringbodyyesfixed
IntervalBilling interval in days.integerbodyconditionalGreater than 20
InstallmentsNumber of installments.integerbodyconditionalN/A
AttemptsRetry attempts ("Teimosinha") count (up to 4).integerbodyconditional4
Plan types

Monthly = Monthly
For the "Monthly" plan, billings happen every 30 days. There is no end date until the subscription is canceled, or the transaction is declined by the issuer/brand.

Bimonthly = Every two months
Quarterly = Quarterly
Semesterly = Semiannual
Yearly = Yearly

For any of the plan types above, you don’t need to send interval and installments, because the system will automatically set the interval and the number of installments according to the selected plan type.

A Custom planType must have interval of at least 20 and installments greater than zero.

Retry policy ("Teimosinha")

The attempts field indicates the number of retry attempts. Retries happen when the payment attempt fails due to insufficient funds. If the card is canceled, retries won’t happen and the system will block the subscription account.

Retry rules:

  • If attempts is 1 and the first payment attempt fails, the system retries 2 days after the last failure.
  • If attempts is 4 and 3 attempts have already failed, the system retries 4 days after the last failure.
  • If attempts is 4 and 4 attempts have already failed, the system retries 8 days after the last failure and won’t try again.
  • If a payment due date is 01/01, retries will happen on 03/01, 05/01, 09/01, and the 4th and last retry on 17/01.
Plan created successfully
"59ff5efc-33e0-4c5c-b45f-e342057c4775"

Data dictionary - Response

PROPERTYDESCRIPTIONTYPE
PlanIdIdentifier of the created plan.string

Search plans

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

GET /v1/recurrences/plans?name={name}&status={status}&orderBy={orderBy}&page={page}&limit={limit}

Data dictionary - Query parameters

PROPERTYDESCRIPTIONTYPELOCATIONREQUIRED
NamePlan name.stringquery paramsno
StatusPlan status filter.stringquery paramsno
OrderByResult ordering.stringquery paramsno
PagePage number.integerquery paramsno
LimitItems per page.integerquery paramsno
Plans found
{
"items": [
{
"merchantId": "017005555500000",
"name": "plano - Mensal 1 9999",
"description": "plano - Mensal 1 9999",
"amount": 29.990000,
"planType": "Monthly",
"trialDays": 0,
"paymentMethod": "CreditCard",
"interval": 30,
"installments": 1,
"status": "Active",
"attempts": 0,
"id": "07d3e68a-1e61-4010-9dee-3f6db3c52dec",
"createdDate": "2020-04-14T12:21:23.337"
},
{
"merchantId": "017005555500000",
"name": "PLANO CUSTOM 3",
"description": "PLANO DE RECORRÊNCIA EM 5X",
"amount": 27.000000,
"planType": "Custom",
"trialDays": 0,
"paymentMethod": "CreditCard",
"interval": 30,
"installments": 5,
"status": "Active",
"attempts": 4,
"id": "0dd23cbd-de75-45a5-b2d1-972191140593",
"createdDate": "2020-04-14T12:21:23.337"
}
],
"page": 1,
"limit": 2,
"total": 47
}

Data dictionary - Response

PROPERTYDESCRIPTIONTYPE
MerchantIdMerchant identifier.string
NamePlan name.string
DescriptionPlan description.string
AmountPlan installment amount.decimal
PlanTypePlan type.string
TrialDaysTrial days.integer
PaymentMethodPayment method.string
IntervalBilling interval in days.integer
InstallmentsNumber of installments.integer
StatusPlan status.string
AttemptsRetry attempts count.integer
IdPlan identifier.string
CreatedDatePlan creation date/time.datetime
PageCurrent page number.integer
LimitItems per page.integer
TotalTotal items found.integer

Get plan by ID

To retrieve a specific plan by ID:

GET /v1/recurrences/plans/{planId}

Data dictionary - Parameters

PROPERTYDESCRIPTIONTYPELOCATIONREQUIREDMAX SIZE
PlanIdPlan identifier.stringpathyes36
Plan found
{
"merchantId": "017005555500000",
"name": "PLANO CUSTOM 3",
"description": "PLANO DE RECORRÊNCIA EM 5X",
"amount": 27.000000,
"planType": "Custom",
"trialDays": 0,
"paymentMethod": "CreditCard",
"interval": 30,
"installments": 5,
"status": "Active",
"attempts": 4,
"id": "0dd23cbd-de75-45a5-b2d1-972191140593",
"createdDate": "2020-04-14T12:21:23.337"
}

Data dictionary - Response

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

Update plan

To update a plan, send a request as shown below:

POST /v1/recurrences/plans/{planId}
Notes
  • You cannot change plan amounts if the plan is active.
  • Other plan fields can only be changed if the plan is not in use; otherwise only name and description can be changed.

Via REST request with the following body:

Request
{
"merchantId": "017005555500000",
"name": "plano - Mensal 1 9999",
"description": "plano - Mensal 1 9999",
"amount": 29.990000,
"planType": "Monthly",
"trialDays": 0,
"paymentMethod": "CreditCard",
"interval": 30,
"installments": 1,
"attempts": 0
}

Data dictionary - Parameters

PROPERTYDESCRIPTIONTYPELOCATIONREQUIREDMAX SIZE
PlanIdIdentifier of the plan to update.stringpathyes36
MerchantIdMerchant identifier.stringbodyyes20
NamePlan name.stringbodyyes255
DescriptionPlan description.stringbodyyes255
AmountAmount.decimalbodyyes12
PlanTypePlan type.stringbodyyesfixed
TrialDaysTrial days.integerbodynoN/A
PaymentMethodPayment method.stringbodyyesfixed
IntervalBilling interval in days.integerbodyconditionalGreater than 20
InstallmentsNumber of installments.integerbodyconditionalN/A
AttemptsRetry attempts count (up to 4).integerbodyconditional4
Plan updated successfully
"0dd23cbd-de75-45a5-b2d1-972191140593"

Data dictionary - Response

PROPERTYDESCRIPTIONTYPE
PlanIdIdentifier of the updated plan.string

Update plan status

To update a plan status:

POST /v1/recurrences/plans/{planId}/status

Via REST request with the following body:

Request
{
"status": "Active"
}

Data dictionary - Parameters

PROPERTYDESCRIPTIONTYPELOCATIONREQUIREDMAX SIZE
PlanIdIdentifier of the plan to update.stringpathyes36
StatusStatus (Active, Inactive, Canceled).stringbodyyesfixed
Status updated successfully
"0dd23cbd-de75-45a5-b2d1-972191140593"

Data dictionary - Response

PROPERTYDESCRIPTIONTYPE
PlanIdIdentifier of the updated plan.string

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