Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 27th, 2007, 12:54 AM
Registered User
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Paypal Pro Integration in Classic ASP

Hi,
 I have to integrate Paypal Pro with a website developed in classic ASP. And in that I have to use API certificate and not the API signature.
  My query is how to use API certificate with NVP method. I encrypted the API certificate and installed in my PC. and the i made following changes in hash_call function in the ASP NVP samples that paypal provided.

Function hash_call ( methodName,nvpStr )
On Error Resume Next
    Set objHttp = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1")
 nvpStr = Server.URLEncode("METHOD")&"=" &Server.URLEncode(methodName) &nvpStr &"&" &Server.URLEncode("VERSION")&"=" &Server.URLEncode(gv_Version) &"&" &Server.URLEncode("USER") &"=" &Server.URLEncode(gv_APIUserName)&"&PWD=" &Server.URLEncode(gv_APIPassword)

    Set SESSION("nvpReqArray")= deformatNVP(nvpStr)
    objHttp.open "POST", gv_APIEndpoint, False
    objHttp.SetClientCertificate "LOCAL_MACHINE\my\" & gv_APIUserName
gv_APIUserName
    WinHttpRequestOption_SslErrorIgnoreFlags=4
    objHttp.Option(WinHttpRequestOption_SslErrorIgnore Flags) = &H3300


    If gv_UseProxy Then
    'Proxy Call
    objHttp.SetProxy gv_Proxy, gv_ProxyServer& ":" &gv_ProxyServerPort
    End If

    objHttp.Send nvpStr

    Set SESSION("nvpReqArray")= deformatNVP(nvpStr)
    Set nvpResponseCollection = deformatNVP(objHttp.responseText)
    Set hash_call = nvpResponseCollection
    Set objHttp = Nothing
    If Err.Number <> 0 Then
    SESSION("ErrorMessage") = ErrorFormatter(Err.Description,Err.Number,Err.Sour ce,"hash_call")
    SESSION("nvpReqArray") = Null
    Response.Redirect "APIError.asp"
    Else
    SESSION("ErrorMessage") = Null
    End If
End Function

Function deformatNVP ( nvpstr )
On Error Resume Next
    Dim AndSplitedArray,EqualtoSplitedArray,Index1,Index2, NextIndex
    Set NvpCollection = Server.CreateObject("Scripting.Dictionary")
    AndSplitedArray = Split(nvpstr, "&", -1, 1)

    NextIndex=0
    For Index1 = 0 To UBound(AndSplitedArray)
        EqualtoSplitedArray=Split(AndSplitedArray(Index1), "=", -1, 1)
        For Index2 = 0 To UBound(EqualtoSplitedArray)
            NextIndex=Index2+1
            NvpCollection.Add URLDecode(EqualtoSplitedArray(Index2)),URLDecode(E qualtoSplitedArray(NextIndex))
            Index2=Index2+1
        Next
    Next



    Set deformatNVP = NvpCollection
    response.write("tt=" & err.number)
    If Err.Number <> 0 Then
    SESSION("ErrorMessage") = ErrorFormatter(Err.Description,Err.Number,Err.Sour ce,"deformatNVP")
' response.Write("hi" & err.number & "ss=" & err.source)
' response.End()
    Response.Redirect "APIError.asp"
    else
    SESSION("ErrorMessage") = Null
    End If
End Function

But this is not executing. Either it gives "Security Error in hash function " or "Subscript out of range " deformatNVP function.


If any one have any sample code regarding NVP method using API certificate in classic ASP, then let me know. As I got stuck here and i m getting no way to proceed.
It's urgent to complete it.

Any help will be greatly appreciated. Thanks in advance.








Similar Threads
Thread Thread Starter Forum Replies Last Post
paypal and asp ocabrera70 Classic ASP Professional 3 September 25th, 2014 06:30 AM
PayPal Integration takwirira ASP.NET 2.0 Basics 0 May 12th, 2008 05:44 AM
PHP and PayPal Pro harpua Pro PHP 1 September 19th, 2005 05:35 AM
Paypal and IPN Using ASP.NET stu9820 ASP.NET 1.0 and 1.1 Basics 1 May 21st, 2005 12:52 AM
Beginning E-Commerce ASP.NET PayPal problems mluirette All Other Wrox Books 0 December 18th, 2003 03:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.