MercadoPago Custom Subscription Checkout

Official Content

Checkout Steps

  • Create Local Subscription
  • Search for Customer
    • Create Customer if Customer not Found
  • Create New Plan (MercadoPago)
  • Save Plan to Local DataBase
  • Create Subscription in MercadoPago


When using the custom subscription method, the user will not leave the seller’s website.
You need a standard token, seller id and a transaction to store information about the subscriptions and one to store information about plans.
First, you need to save a subscription (same as Basic Checkout), which will be edited later, after the user makes the payment.

Create Local Subscription

&Suscription.SusName = 'GX Suscription Custom'
&Suscription.SusCurrency_id = currency_id.Mexico
&Suscription.SusStartDate = now()    
&Suscription.SusDate = now()
&Suscription.SusEndDate = &Suscription.SusStartDate.AddDays(10)
&Suscription.SusAmount = 10
&Suscription.SusFrequency = 1
&Suscription.SusFrequencyType = frequency_type.days
&Suscription.SusPayer_email = !''
&Suscription.SusMPCollector = &Collector_Id

Search For Customer

You must search for the user (in MercadoPago) using the SearchUser procedure where &Email is the user’s you want to search for e-mail.:


//If &ErrorCode = 0 you load the user
if & 
    for &s in &SearchUserSDT.results                                                          
        &user.UserId = &
        &user.UserMPId = &                                                              
        &user.UserEmail = &
        &user.UserForTest = false
        &user.UserType = UserType.Buyer

&SearchUserSDT is a SearchUserSDT variable.

Note: &user is a User type variable (transaction in which users are stored in your DataBase).
Note: User is an example transaction, each developer may create the user with the attributes it prefers.

Create Customer

//If &ErrorCode is not 0 (this means the user was not found), then you have to create a user (in MercadoPago):
MercadoPago.Users.CreateCustomer(&Email, &ClientSDT,&Message,&ErrorCode)
if &ErrorCode = 0
    &user = new()
    &user.UserId = &
    &user.UserMPId = &
    &user.UserNickName = &ClientSDT.nickname.Trim()
    &user.UserPassword = &ClientSDT.password.Trim()              
    &user.UserEmail = &
    &user.UserForTest = false
    &user.UserType = UserType.Buyer

Create New Plan

A subscription plan indicates how payments are going to be made (ex: monthly, once every month, xxx price, etc.)

&CreatePlanSDT = new()
&CreatePlanSDT.external_reference = 'GX Plan'             
&CreatePlanSDT.status = 'active'
&CreatePlanSDT.description = &Suscription.SusName.Trim()
&CreatePlanSDT.auto_recurring.currency_id = &Suscription.SusCurrency_id  
&CreatePlanSDT.auto_recurring.frequency = &Suscription.SusFrequency
&CreatePlanSDT.auto_recurring.frequency_type = &Suscription.SusFrequencyType
&CreatePlanSDT.auto_recurring.transaction_amount = &Suscription.SusAmount
&CreatePlanSDT.auto_recurring.repetitions = 5
&CreatePlanSDT.auto_recurring.debit_date = &Today.Day()

Information is returned in &planSDT

Save Plan to Local DataBase

Now a new plan must be created in the local DataBase using the returned information

&plan = new()
&plan.Plan_debit_date = &planSdt.auto_recurring.debit_date
&plan.PlanCurrency = &planSdt.auto_recurring.currency_id
&plan.PlanDsc = &planSdt.description
&plan.PlanFrec_type = &planSdt.auto_recurring.frequency_type
&plan.PlanFrecuency = &planSdt.auto_recurring.frequency
&plan.PlanMPId = &
&plan.PlanRepetitions = &planSdt.auto_recurring.repetitions
&plan.PlanStatus = &planSdt.status
&plan.PlanTrn_amount = &planSdt.auto_recurring.transaction_amount

Create Subscription in MercadoPago

Finally, create the subscription in MercadoPago

&CreateSubscriptionSDT = new()
&CreateSubscriptionSDT.description = &Suscription.SusName
&CreateSubscriptionSDT.plan_id = &plan.PlanMPId                      
&CreateSubscriptionSDT.external_reference = &Suscription.SuscId.ToString().Trim()
& = &user.UserMPId

If success (ErrorCode = 0), update your subscription status, date, planId, etc.