- Copy this files below, to your project desired folder:
-
lib/mercadopago.asp
-
lib/JSON_2.0.4.asp
-
lib/json2.asp
-
Get your CLIENT_ID and CLIENT_SECRET in the following address:
- Argentina: https://www.mercadopago.com/mla/herramientas/aplicaciones
- Brazil: https://www.mercadopago.com/mlb/ferramentas/aplicacoes
- Mexico: https://www.mercadopago.com/mlm/herramientas/aplicaciones
- Venezuela: https://www.mercadopago.com/mlv/herramientas/aplicaciones
- Colombia: https://www.mercadopago.com/mco/herramientas/aplicaciones
- Chile: https://www.mercadopago.com/mlc/herramientas/aplicaciones
<!--#include file="lib\mercadopago.asp"-->
<!--#include file="lib\JSON_2.0.4.asp"-->
<!--#include file="lib\json2.asp"-->
<%
Dim mp
Set mp = new Mercadopago
mp.construct "CLIENT_ID", "CLIENT_SECRET"
%>
<%
Dim accessToken
accessToken = mp.get_access_token()
Response.write (accessToken)
%>
<%
Dim preferenceResult
preferenceResult = mp.get_preference(PREFERENCE_ID)
Response.write (preferenceResult)
%>
<%
Dim o
Dim var_json
Set o = jsObject()
Set o("items") = jsArray()
Set o("items")(Null) = jsObject()
o("items")(Null)("id") = "Product ID"
o("items")(Null)("title") = "Product Name"
o("items")(Null)("description") = "Description"
o("items")(Null)("quantity") = 1
o("items")(Null)("unit_price") = 50.5
o("items")(Null)("currency_id") = "BRL"
o("items")(Null)("picture_url") = ""
o("external_reference")="Your_control_id"
Set o("payer") = jsObject()
o("payer")("name") = "payer-name"
o("payer")("surname") = "payer-surname"
o("payer")("email") = "payer@email.com"
Set o("back_urls") = jsObject()
o("back_urls")("success") = ""
o("back_urls")("failure") = ""
o("back_urls")("pending") = ""
Set o("payment_methods") = jsObject()
Set o("payment_methods")("excluded_payment_methods") = jsArray()
Set o("payment_methods")("excluded_payment_methods")(Null) = jsObject()
o("payment_methods")("excluded_payment_methods")(Null)("id")="amex"
Set o("payment_methods")("excluded_payment_types") = jsArray()
Set o("payment_methods")("excluded_payment_types")(Null) = jsObject()
o("payment_methods")("excluded_payment_types")(Null)("id")="ticket"
o("payment_methods")("installments") = 12
var_json = o.jsString
Dim mp
Dim response
Set mp = new Mercadopago
mp.construct "CLIENT_ID", "CLIENT_SECRET"
response=mp.create_preference(var_json)
'Decode JSON - Create Preference
Dim objJSON,preferenceResult
Set objJSON = JSON
Set preferenceResult = objJSON.parse(join(array(response)))
' Preference with SANDBOX - > preferenceResult.sandbox_init_point
' Preference -> preferenceResult.init_point
%>
<%
Dim o
Dim var_json
Set o = jsObject()
Set o("items") = jsArray()
Set o("items")(Null) = jsObject()
o("items")(Null)("title") = "Test Modified"
o("items")(Null)("quantity") = 1
o("items")(Null)("unit_price") = 80.5
o("items")(Null)("currency_id") = "BRL"
var_json = o.jsString
Dim preferenceResult
preferenceResult=mp.update_preference(PREFERENCE_ID,var_json)
Response.write (preferenceResult)
%>
###Searching:
<%
Dim payment_info
Dim strSearch,site_id,external_reference
id = "00000"
external_reference = "Reference_1234"
strSearch = "id="& site_id & "&external_reference=" & external_reference
payment_info = mp.search_payment(strSearch,null,null)
Response.write( "<br>" & payment_info & "<br><br>")
%>
- Go to Mercadopago IPN configuration:
- Argentina: https://www.mercadopago.com/mla/herramientas/notificaciones
- Brasil: https://www.mercadopago.com/mlb/ferramentas/notificacoes
- Mexico: https://www.mercadopago.com/mlm/herramientas/notificaciones
- Venezuela: https://www.mercadopago.com/mlv/herramientas/notificaciones
- Colombia: https://www.mercadopago.com/mco/herramientas/notificaciones
- Chile: https://www.mercadopago.com/mlc/herramientas/notificaciones
<!--#include file="lib\mercadopago.asp"-->
<!--#include file="lib\json2.asp"-->
<%
Dim payment_info
Dim id
Dim mp
Set mp = new Mercadopago
mp.construct "CLIENT_ID", "CLIENT_SECRET"
id = Request.Querystring("id")
' Get the payment reported by the IPN. Glossary of attributes response in https://developers.mercadopago.com
if id <> "" then
payment_info = mp.get_payment_info(id)
Response.write( "<br>" & payment_info & "<br><br>")
Dim objJSON,retJSON
Set objJSON = JSON
Set retJSON = objJSON.parse(join(array(payment_info)))
Response.write( " **** DECODE JSON **** <BR><BR> ")
Response.write( " - id :" & retJSON.id & "<br>" )
Response.write( " - external_reference :" & retJSON.external_reference & "<br>" )
Response.write( " - status : " & retJSON.status & "<br>" )
Response.write( " - payment_type : " & retJSON.payment_type_id & "<br>" )
else
Response.write( " **** ID = " & id & " Null **** <BR><BR> ")
end if
%>
<%
Dim result
result = mp.cancel_payment(Request.Querystring("id"))
Response.write (result)
%>
<%
Dim result
result = mp.refund_payment(Request.Querystring("id"))
Response.write (result)
%>
- Get your ACCESS_TOKEN in the following address:
- Argentina: https://www.mercadopago.com/mla/account/credentials
- Brazil: https://www.mercadopago.com/mlb/account/credentials
- Mexico: https://www.mercadopago.com/mlm/account/credentials
- Venezuela: https://www.mercadopago.com/mlv/account/credentials
- Colombia: https://www.mercadopago.com/mco/account/credentials
<!--#include file="lib\mercadopago.asp"-->
<!--#include file="lib\json2.asp"-->
<%
Dim mp
Set mp = new Mercadopago
mp.acctoken_LL "Access_token_Longlive"
%>
<%
mp.doPost("/v1/payments", payment_data)
%>
<%
mp.doPost("/v1/customers", '{"email" => "email@test.com"}')
%>
<%
mp.doGet("/v1/customers/CUSTOMER_ID")
%>
- View more Custom checkout related APIs in Developers Site
- Argentina: https://www.mercadopago.com.ar/developers
- Brazil: https://www.mercadopago.com.br/developers
- Mexico: https://www.mercadopago.com.mx/developers
- Venezuela: https://www.mercadopago.com.ve/developers
- Colombia: https://www.mercadopago.com.co/developers
You can access any resource from the MercadoPago API (https://api.mercadopago.com) using the generic methods:
<%
' Get a resource, with optional URL params. Also you can disable authentication for public APIs
mp.doGet("/resource/uri?params=123")
' Create a resource with "data" and optional URL params.
mp.doPost("/resource/uri", data)
' Update a resource with "data" and optional URL params.
mp.doPut("/resource/uri?params=123", data)
' Delete a resource with optional URL params.
mp.doDelete("/resource/uri?params=123")
%>