PK

ADDRLIN : /HMFS2/WEB/DTC038/v0071350.ferozo.com/public_html/
FLL :
Current File : //HMFS2/WEB/DTC038/v0071350.ferozo.com/public_html/mercadopago_IPN.asp

<!--#include file="administrador/includes/openconn.asp" -->

<!--#include file="lib\mercadopago.asp"-->
<!--#include file="lib\json2.asp"-->
<%

    Dim payment_info
    Dim id

    Dim mp
    Set mp = new Mercadopago

    mp.construct "2517981530800963", "4K3ZtGT7laPWecggpp5hGvSCZsvmANuE"

    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.collection.id  & "<br>"  )
        Response.write( " - external_reference :" & retJSON.collection.external_reference  & "<br>" )
        Response.write( " - status : " & retJSON.collection.status  & "<br>"  )
        Response.write( " - payment_type : " & retJSON.collection.payment_type  & "<br>"  )
		
		rs.open "SELECT * FROM Mercadopago_ipn WHERE idipn = 0",conn,2,2
		rs.addnew
	
		rs("ipn_now") = now()
		rs("ipn_IP") = request.ServerVariables("REMOTE_ADDR")
		rs("ipn_info") = payment_info
		if retJSON.collection.external_reference <> "" then
			rs("xidpedido") = retJSON.collection.external_reference
		end if	
		
		rs.update
		rs.close

		if retJSON.collection.status = "approved" then
			rs.open "SELECT * FROM Pedidos WHERE idpedido = " & retJSON.collection.external_reference,conn,2,2
			rs.movefirst
		
			'rs("xidpe") = 2
			'rs("ped_fechapago")=now()
			rs("ped_pagado") = now()
			
			rs.update
			rs.close
		end if

    else

		Response.Status = "200 OK"
		Response.Flush()
        Response.write( " **** ID = " & id & " Null **** <BR><BR> ")
		Response.end

    end if
%>

<!--#include file="administrador/includes/closeconn.asp" -->


PK 99