Getting Error On PayPal

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MehtabKhan
    New Member
    • Feb 2008
    • 1

    Getting Error On PayPal

    Any one who tell me what’s wrong with this code. When I pass values to pay pal by using www.sandbox.paypal.com/cgi-bin/webscr all the code are working well.
    The orders are generating accurately. The code after returning from paypal is as follows.
    [code=asp]
    <!--#include file="../includes/connection1.asp "-->
    <!--#include file="Cart_Incl ude.asp"-->
    <%
    ' read post from PayPal system and add 'cmd'
    str ="cmd=_notif y-validate&"& Request.QuerySt ring
    ' post back to PayPal system to validate
    set objHttp = Server.CreateOb ject("Msxml2.Se rverXMLHTTP")
    'objHttp.open "POST", "https://www.sandbox.pay pal.com/cgi-bin/webscr", false
    objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false
    objHttp.setRequ estHeader "Content-type", "applicatio n/x-www-form-urlencoded"
    objHTTP.setRequ estHeader "Content-Length", Len(str)
    objHttp.Send str
    if (objHttp.status <> 200 ) then
    ' HTTP error handling
    Response.write "An Error Occured"
    elseif (objHttp.respon seText = "VERIFIED") then
    if request("Paymen t_Status") ="Completed" then
    orderstatus=2
    msg="error=Cong ratuation, Your Credits has been upgrated
    successfully"
    else
    orderstatus=1
    msg="error=Your Payment status is Pending, As Soon as it is verified we will send you a confirmation Email."
    end if
    set rs=server.creat eobject("adodb. recordset")
    sql="select * from orders"
    rs.open sql,conn,3,3
    rs.addnew
    rs("order_price ")=request("mc_ gross")
    rs("contactname ")=request("fir st_name") & " "& request
    ("last_name" )
    rs("address")=r equest("address _street")
    rs("city")=requ est("address_ci ty")
    rs("country")=r equest("address _country")
    rs("zip")=reque st("address_zip ")
    rs("order_quant ity")=request(" custom")
    rs("order_statu s")=ordersta tus
    rs("email")=req uest("payer_ema il")
    rs("order_date" )=paymentdate
    rs.update
    set rs=nothing
    Call InsetOrderDetai ls()
    response.Redire ct("mesg.asp?" & msg)
    else
    response.Redire ct("mesg.asp?er ror=Error on receiving information, please contact to Admin")
    end if
    [/code]
    But the problem become when i send data by using
    www.paypal.com/cgi-bin/webscr. after receiveing data from paypal the else statement are execute such as

    response.Redire ct("mesg.asp?er ror=Error on receiving information, please contact to Admin").

    The orders are not generating by using www.paypal.com/cgi-bin/webscr.

    Please Help Me.
    Thank You
    Mehtab Khan.
    Last edited by jhardman; Apr 7 '08, 07:56 PM. Reason: put code in code tags. Please note button marked - #
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    I usually check for error using the method [code=asp]on error resume next
    ...
    if err.number <> 0 then %>
    An error occurred. <br> Please notify <a
    href="mailto:me @address.com">w ebmaster</a> if error continues.
    error# <%=err.number%> : <%=err.descript ion%>
    <% err.clear
    else
    'do your magic here
    end if %>[/code]Try this method, let me know if it gives you a different output.

    Jared

    Comment

    Working...