PDA

View Full Version : Does Webshop PayPal work?



David Martinko
23-Apr-2009, 11:01 PM
After completing a sale, I only get

We were unable to determine the status of your payment. Please contact us to verify your order.
I read up on the paypal site, but I don't know how to see the return values to know why it can't be verified.
Is this fixed in 3.2? Does anyone have it working?

Edwin van der Velden
24-Apr-2009, 07:10 AM
David,

As far as I know it should work, last time I tried I don't recall having any issues activating a paypal integration. Of course there are several things to keep in mind:

account type, make sure you select to correct one, sandbox if using a sandbox account and live when using a live account. Most likely you are working with a sandbox account for test purposes.

Account name, make sure to have the correct account name filled out.

Normally CancelOrder.asp or CompleteOrder.asp should be called, however when it's stating that the status can't be determined it's possible neither of these have been called for some reason. Another area you can check is the input values sent to the paypal site which you can find in webshopCheckout.inc following the line:

<!-- paypal -->
<% If (sPSPMethod = "1" and sPaymentMethod = sPaypalName) Then %>

If you still can't find the issue let me know.

David Martinko
24-Apr-2009, 07:28 AM
I am using a sandbox account. I have test accounts setup for buying and selling. I can complete the payment process. I believe the problem to be happening in the verify portion of the routine.

After the payment happens, the user has to click a button on the paypal site to return them to the merchant website. WebshopCheckout.inc tells PayPal to use the WebshopComplete.asp to verify the sale. WebshopComplete.asp is then looking for "VERIFIED" in the return line and then posts the info back to PayPal for verification.

I do know that everything works because when people buy on my website, I do get the money. It's just that the users get the error that it can't be verified.

Edwin van der Velden
24-Apr-2009, 07:45 AM
What I believe happens when the Paypal payment is done:

- Paypal sends a call to the complete page (our default CompleteOrder.asp)
- Paypal directs the user back to the webshop (our default WebshopCheckout.inc)

Could it be that the call to CompleteOrder which is done in the background hasn't completed in time to update to the correct status yet?

Please let me know of which Electos version the templates you based on are and I'll have a look at it.

David Martinko
24-Apr-2009, 07:59 AM
My website version is 3.1.15.121.

I don't see any markings of what version the template is. One website uses: Osicia. The other uses the default design that comes in MyWebsite.

I don't think CompleteOrder.asp is being called because the order status is always "unfinished". If it ever made it to this asp, then it should be changed. If I were to Cancel, it does properly cancel the order.

I just think that something is not the way it was expected, so I want to debug it... but how can I debug the VBScript? Maybe I can have the VBScript write data out to a file on the server? I'll look into that. I'm sure if I can figure how to debug it, I can make it work.

David Martinko
24-Apr-2009, 08:17 AM
Ok, that works... The CompleteOrder.asp is being called and here are the values.



sPSPMethod :1
sPaypalName :Paypal
sProtXName :
iOrderID :33
iErr :
"----------" :----------
sUrl :https://www.sandbox.paypal.com/cgi-bin/webscr
sDecoded :
sPSPStatus :
sPSPStatusText :
sPSPTransactionID:
"----------" :----------
iPageId :
Item_name :Your Order Id : 33
Item_number :
Payment_status :Pending
Payment_amount :949.00
"----------" :----------
Payment_currency :USD
Txn_id :61B2XXXXXXXXX733U
Receiver_email :XXXXXX@XXXXXX.com
Payer_email :XXXXXXX@XXXXXXXX.com
"/----------\" :/----------\
str :mc_gross=949.00&invoice=33&protection_eligibility=Ineligible&address_status=confirmed&payer_id=XXXXXXXX&tax=0.00&address_street=4403+Pine+Court&payment_date=06%3A11%3A36+Apr+24%2C+2009+PDT&payment_status=Pending&charset=windows-1252&address_zip=48316&first_name=Test&mc_fee=27.82&address_country_code=US&address_name=dave+Martinko&notify_version=2.8&custom=&payer_status=verified&business=XXXXXXXXX%40XXXXX.com&address_country=United+States&address_city=Shelby+Township&quantity=1&verify_sign=An5ns1Kso7MWUdW4ErQKJJJ4qi4-AJschpOSRF-eqzy18xD4HTF1FZTz&payer_email=XXXXX%40XXXXX.com&txn_id=XXXXXXX&payment_type=instant&last_name=User&address_state=MI&receiver_email=XXXXXXXXXXXX%40XXXXXX.com&payment_fee=27.82&receiver_id=XXXXXXXXXXXXXX&pending_reason=paymentreview&txn_type=web_accept&item_name=Your+Order+Id+%3A+33&mc_currency=USD&item_number=&residence_country=US&test_ipn=1&handling_amount=0.00&transaction_subject=Your+Order+Id+%3A+33&payment_gross=949.00&shipping=50.00&cmd=_notify-validate
"\----------/" :\----------/
iPrice :
iTotalPrice :
sCurrency :
sBusinessEmail :
sPaypalType :0
"----------" :----------

David Martinko
24-Apr-2009, 08:45 AM
Ok, so the problem appears to be that the payment status is "Pending". The call back to paypal is "VERIFIED", so everything is correct. I just need to see why it is "Pending".

David Martinko
24-Apr-2009, 09:00 AM
I found the solution on the PayPal website....


In your developer.paypal.com account select "Test Accounts" from the login page. in her you will see a list of the sandbox accounts you have created and a section enabled "Payment Review" with a link in it labeled "enabled". Click this link to disable the Payment review functionality of the associated sandbox account.I had to do this for BOTH the merchant I was using AND the payee. Now to figure out what to do for the NON-Sandbox accounts.

Edwin van der Velden
24-Apr-2009, 09:01 AM
So it would seem: &pending_reason=paymentreview

Which means paypal needs to review the payment for any risks.

Hopefully below instructions are still up-to-date:

You will need to do the following...

1. Login to Developer Central.
2. Click on "Test Accounts".
3. Locate the column 'Payment Review'.
4. Find the sandbox account you are using and click on "Enabled" in the 'Payment Review' column.
5. This should change to "Disabled" and now payments funded from your balance and credit card will complete instantly.

David Martinko
24-Apr-2009, 02:20 PM
UPDATE!

There is an error when in Electos, I am not collecting sales tax, but in PayPal it is. PayPal collects the tax for me.

So there is an error because the totals do not match.
(CDbl(iTotalPrice) = CDbl(Payment_amount) and sCurrency = Payment_currency)


I removed the salestax option from my paypal account, so this won't happen again. So PayPal won't collect sales tax unless I add an item for it... Or unless a future rev adds this ability.

David Martinko
24-Apr-2009, 04:16 PM
Here is a replacement for the "CompleteOrder.asp" which has debugging code added. To use it, you will need to set PPDebugOn to True, and set the output path to a valid directory on the server. I suggest using the APPHTML path so that you can view the log file in the Electos Studio.



<!-- #Include file='Base64.inc' -->

<%
'######### DEBUG ################################################## ######
'Open up the path to save the information into a text file for debugging
Dim Stuff, myFSO, PPDebugOn

PPDebugOn = False ' True or False
If (PPDebugOn) Then
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set WriteStuff = myFSO.OpenTextFile("C:\Program Files\Electos\Websites\{WEBSITE_NAME_HERE}\apphtml \paypal.txt", 8, True)
End If

'######### DEBUG ################################################## ######
%>

<%

' General
Dim sPSPMethod, sPaypalName, sProtXName

' Common
Dim iOrderID, iErr, sUrl, sDecoded, sPSPStatus, sPSPStatusText, sPSPTransactionID, iPageId

' Paypal
Dim Item_name, Item_number, Payment_status, Payment_amount, Payment_currency
Dim Txn_id, Receiver_email, Payer_email
Dim objHttp, str, iTotalPrice, sCurrency, sBusinessEmail, sPaypalType

sPSPMethod = oWebshopPublisher.Call("Get_GetWebshopSetting", "PSPMethodName", "PSPInformation")
sPaypalName = oWebshopPublisher.Call("Get_GetWebshopSetting", "PaypalName", "PSPInformation")
sProtXName = oWebshopPublisher.Call("Get_GetWebshopSetting", "ProtXName", "PSPInformation")

'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("sPaypalName= " & sPaypalName)
End If

%>
<html>
<title>Completing order...</title>
<head>
<%
If (sPSPMethod = "1") Then

sPaypalType = oWebshopPublisher.Call("Get_GetWebshopSetting", "PaypalType", "PSPInformation")
'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("sPaypalType= " & sPaypalType)
End If

If (sPaypalType = "1") Then
sUrl = "https://www.paypal.com/cgi-bin/webscr" 'paypal live
Else
sUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr" 'paypal sandbox
End If

'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("sUrl= " & sUrl)
End If

' read post from PayPal system and add 'cmd'
str = Request.Form & "&cmd=_notify-validate"
'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("str= " & str)
End If

' post back to PayPal system to validate
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")

objHttp.open "POST", sUrl, false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send str

' assign posted variables to local variables
Item_name = Request.Form("item_name")
Item_number = Request.Form("item_number")
Payment_status = Request.Form("payment_status")
Payment_amount = Request.Form("mc_gross")
Payment_currency = Request.Form("mc_currency")
Txn_id = Request.Form("txn_id")
Receiver_email = Request.Form("receiver_email")
Payer_email = Request.Form("payer_email")
iOrderId = Request.Form("invoice")
'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("Item_name= " & Item_name)
WriteStuff.WriteLine("Item_number= " & Item_number)
WriteStuff.WriteLine("Payment_status= " & Payment_status)
WriteStuff.WriteLine("Payment_amount= " & Payment_amount)
WriteStuff.WriteLine("Payment_currency= " & Payment_currency)
WriteStuff.WriteLine("Txn_id= " & Txn_id)
WriteStuff.WriteLine("Receiver_email= " & Receiver_email)
WriteStuff.WriteLine("Payer_email= " & Payer_email)
WriteStuff.WriteLine("iOrderID= " & iOrderID)
End If

'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("HTTP Status= " & objHttp.status)
WriteStuff.WriteLine("HTTP Response= " & objHttp.responseText)
End If
' Check notification validation
if (objHttp.status <> 200 ) then
' HTTP error handling
elseif (objHttp.responseText = "VERIFIED") then

' check that Payment_status=Completed
if (Payment_status="Completed") then
' check that Txn_id has not been previously processed
if (oWebshopPublisher.Call ("Get_CheckTransactionID",Txn_id) = "0") then
' check that Receiver_email is your Primary PayPal email
sBusinessEmail = oWebshopPublisher.Call("Get_GetWebshopSetting", "BusinessEmailAddress", "PSPInformation")
if (UCase(Receiver_email) = UCase(sBusinessEmail)) then
iTotalPrice = Replace(oWebshopPublisher.Call ("Get_GetOrderTotal",iOrderId),",",".")
sCurrency = oWebshopPublisher.Call("Get_GetWebshopSetting", "Currency", "General")
' check that Payment_amount/Payment_currency are correct
if (CDbl(iTotalPrice) = CDbl(Payment_amount) and sCurrency = Payment_currency) then
' process payment
iErr = oWebshopPublisher.Call ("Get_ProcessOrder", iOrderId, Txn_id, "", "")
else
'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("ERROR: (CDbl(iTotalPrice) = CDbl(Payment_amount) and sCurrency = Payment_currency)")
End If
end if
else
'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("ERROR: (UCase(Receiver_email) = UCase(sBusinessEmail))")
End If
end if
else
'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("ERROR: (oWebshopPublisher.Call (""Get_CheckTransactionID"",Txn_id) = ""0"")")
End If
end if
else
'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("ERROR: (Payment_status=""Completed"")")
End If
end if


elseif (objHttp.responseText = "INVALID") then
' log for manual investigation
else
' error
end if

set objHttp = nothing

'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.Close
SET WriteStuff = NOTHING
SET myFSO = NOTHING
End If
'######### DEBUG ################################################## ######
ElseIf (sPSPMethod = "2") Then

If (Request.QueryString("Crypt") <> "") Then

sDecoded=SimpleXor(Base64Decode(Request.QueryStrin g("Crypt")),oWebshopPublisher.Call("Get_GetWebshopSetting", "ProtXEncryptionPassword", "PSPInformation"))

sPSPStatus=getToken(sDecoded,"Status")
sPSPStatusText=getToken(sDecoded,"StatusDetail")
sPSPTransactionID=getToken(Decoded,"VPSTxId")

End If

'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("iOrderId = " & iOrderId)
WriteStuff.WriteLine("sPSPTransactionID = " & sPSPTransactionID)
WriteStuff.WriteLine("sPSPStatus = " & sPSPStatus)
WriteStuff.WriteLine("sPSPStatusText = " & sPSPStatusText)
End If
iOrderID = Request.QueryString("Order_Id")
iErr = oWebshopPublisher.Call ("Get_ProcessOrder", iOrderId, sPSPTransactionID, sPSPStatus, sPSPStatusText)
sUrl = oPublisher.call("Get_WebsiteUrl")
iPageId = Request.QueryString("pageid")
'######### DEBUG ################################################## ######
If (PPDebugOn) Then
WriteStuff.WriteLine("iErr= " & iErr)
WriteStuff.WriteLine("sUrl= " & sUrl)
WriteStuff.WriteLine("iPageId= " & iPageId)
WriteStuff.Close
SET WriteStuff = NOTHING
SET myFSO = NOTHING
End If
Response.redirect (sUrl + "webshopCheckout.asp?currentStep=4&invoice=" + iOrderID + "&payment_status=Completed&pageid=" + iPageId)

End If
%>

</head>
<body>
</body>
</html>