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.
|