Unofficial Content

This option requires a redirect to the MercadoPago Checkout form to complete the subscription process. If you prefer to avoid this redirect, see MercadoPago Custom Subscription Integration.

There are two ways to create subscriptions, from a Plan or from a Subscription preference.

From a Plan:

  • Setting Credentials
  • Create a Plan
  • Get the init_point from the results and redirect the buyer to that link in order to complete the process in the Mercado Pago checkout form.

From a Subscription Preference

  • Setting Credentials
  • Create a Subscription preference (status pending)
  • Get the init_point from the results and redirect the buyer to that link in order to complete the process in the Mercado Pago checkout form.

Example

This example shows how to integrate to subscriptions creating a Subscription Preference.

&SubscriptionInputSDT = new()
&SubscriptionInputSDT.back_url = <mysite url>
&SubscriptionInputSDT.collector_id = &CollectorID
&SubscriptionInputSDT.reason = "Anual Subscription - Premium"
&SubscriptionInputSDT.status = subscription_status.Pending
&SubscriptionInputSDT.payer_email = &UserEmail

&SubscriptionInputSDT.auto_recurring.currency_id = "MXN"
&SubscriptionInputSDT.auto_recurring.transaction_amount = 120
&SubscriptionInputSDT.auto_recurring.frequency_type = frequency_type.months
&SubscriptionInputSDT.auto_recurring.frequency = 1  //once per months
&SubscriptionInputSDT.auto_recurring.start_date = now()
&SubscriptionInputSDT.auto_recurring.end_date = &SubscriptionInputSDT.auto_recurring.start_date.AddYears(1)

MercadoPago.Subscriptions.CreateSubscription(&AccessToken, &SubscriptionInputSDT, &SubscriptionInfoSDT, &Message, &ErrorCode)
If &ErrorCode = 0
   msg(format('Subscription %1 successfully created', &SubscriptionInfoSDT.id), status)
   link(SubscriptionInfoSDT.init_point)
else
   msg(&Message.Description, status)
endif

To create the subscription, you need to fulfill the SubscriptionInputSDT with the required information. 

back_url refers to the URL in your application to which the user will be redirected after the transaction is completed in MercadoPago's website.

Once created, redirect the user to the init_point url, where the subscription can be completed (from MercadoPago’s site) following these steps:


 

Step 1   
image_2021330194728_1_png  
Step 2  
image_2021330194826_1_png  
Step 3  
image_202133019494_1_png  
Step 4  
image_2021330194937_1_png  
Step 5  
image_2021330194957_1_png  

 

 

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant