Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1114
  • Last Modified:

Paypal Express -

Hi Experts,

I'm trying to implement Paypal express my website.

I have successfully integrated it and test it with the Paypal sandbox, no problems.

So I am now trying to put it liven real, not in the sandbox.
But I've got the following error message:
HTTP Status 405 - Request method 'POST' not supported

I have read on the web it may be caused by the cookies, I deleted them but the bug persists.

Any idea what it wrong ?

Thanks

Here are the code I use:
<cfif Session.ccard NEQ "Paypal">
	<form action="order_confirmed.cfm" method="post">
		<td><input type="submit" name="confirm" value="Confirm my order" onClick="processing();" /></td>
	</form>
<cfelse>
	<cfform name="ppExpForm" method="post" action="#CGI.SCRIPT_NAME#?ppExp=true">
		<td> <input type="image" name="submit" src="https://www.paypalobjects.com/en_GB/GB/i/btn/btn_xpressCheckout.gif" id="submit" runat="server" onclick="processing();"></td>
	</cfform>
</cfif>

Open in new window


<!--- SetExpressCheckout --->
<cfif CGI.request_method eq "POST" AND isdefined("URL.ppExp") AND URL.ppExp eq "true">
	<!--- set our values to send to paypal into a struct --->
	<cfset VARIABLES.ppVals = structnew()>
	
	<cfset VARIABLES.ppVals.method = "SetExpressCheckout">
	<cfset VARIABLES.ppVals.paymentAction = "Sale">
	<cfset VARIABLES.ppVals.user = "x">
	<cfset VARIABLES.ppVals.pwd = "x">
	<cfset VARIABLES.ppVals.signature = "x">
	<cfset VARIABLES.ppVals.version = "52">
	<cfset VARIABLES.ppVals.amt = NumberFormat(session.totalBasketPrice + session.shipping, '___.__')>
	<cfset VARIABLES.ppVals.returnurl = "https://www.joe-cool.co.uk/EN/basket2/checkout.cfm">
	<cfset VARIABLES.ppVals.cancelurl = "https://www.joe-cool.co.uk/EN/basket/shopping_basket.cfm">
	
	<!--- call the method to initiate the pp request ---> <!--- test url = https://api-3t.sandbox.paypal.com/nvp --->
	<cfinvoke component="CallerService" method="doHttppost" requestdata="#VARIABLES.ppVals#" serverurl="https://www.paypal.com/uk/cgi-bin/webscr" returnvariable="VARIABLES.response">
	
	<!--- send data to method to return it as a struct --->
	<cfinvoke component="CallerService" method="getNVPResponse" nvpString="#URLDecode(VARIABLES.response)#" returnvariable="VARIABLES.responseStruct">
	
	<!--- check if the connection with paypal was a success --->
	<cfif isdefined("VARIABLES.responseStruct.ack") AND VARIABLES.responseStruct.ack eq "success">
		<!--- send the user to paypal login --->
		<cflocation url="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#VARIABLES.responseStruct.token#"  addtoken="false">
	<cfelse>
		<!--- output an error message --->
		<p style="text-align:center;color:red;font-size:x-large;">Sorry. There was a problem connecting with the PayPal server.</p>
		<p style="text-align:center;"><cfdump var="#VARIABLES.responseStruct#"></p>
	</cfif>
</cfif>

<!--- GetExpressCheckoutDetails --->
<cfif isdefined("URL.token") AND isdefined("URL.payerid")>
	<!--- set our values to send to paypal into a struct --->
	<cfset VARIABLES.ppVals = structnew()>
	
	<cfset VARIABLES.ppVals.method = "GetExpressCheckoutDetails">
	<cfset VARIABLES.ppVals.user = "x">
	<cfset VARIABLES.ppVals.pwd = "x">
	<cfset VARIABLES.ppVals.signature = "x">
	<cfset VARIABLES.ppVals.version = "52">
	<cfset VARIABLES.ppVals.token = URL.token>
	
	<!--- call the method to initiate the pp request --->
	<cfinvoke component="CallerService" method="doHttppost" requestdata="#VARIABLES.ppVals#" serverurl="https://www.paypal.com/uk/cgi-bin/webscr" returnvariable="VARIABLES.response">
	
	<!--- send data to method to return it as a struct --->
	<cfinvoke component="CallerService" method="getNVPResponse" nvpString="#URLDecode(VARIABLES.response)#" returnvariable="VARIABLES.responseStruct">
	
	<!--- if we get back the details set them into the user session --->
	<cfif isdefined("VARIABLES.responseStruct.ack") AND VARIABLES.responseStruct.ack eq "success">
		<cfset SESSION.user.countryCode = VARIABLES.responseStruct.countrycode>
		<cfset SESSION.user.email = VARIABLES.responseStruct.email>
		<cfset SESSION.user.firstName = VARIABLES.responseStruct.firstname>
		<cfset SESSION.user.lastName = VARIABLES.responseStruct.lastname>
		<cfset SESSION.user.payerid = VARIABLES.responseStruct.payerid>
		<cfset SESSION.user.payerstatus = VARIABLES.responseStruct.payerstatus>
		<cfset SESSION.user.shippingCountryCode = VARIABLES.responseStruct.shiptocountrycode>
		<cfset SESSION.user.shippingCountryName = VARIABLES.responseStruct.shiptocountryname>
		<cfset SESSION.user.shippingName = VARIABLES.responseStruct.shiptoname>
		<cfset SESSION.user.shippingCity = VARIABLES.responseStruct.shiptocity>
		<cfset SESSION.user.shippingState = VARIABLES.responseStruct.shiptostate>
		<cfset SESSION.user.shippingAddress = VARIABLES.responseStruct.shiptostreet>
		<cfset SESSION.user.shippingZipCode = VARIABLES.responseStruct.shiptozip>
		<cfset SESSION.user.token = VARIABLES.responseStruct.token>
		
		<!--- move the user to the billing and shipping page --->
		<cflocation url="https://www.joe-cool.co.uk/EN/basket2/checkout.cfm?ppDo=true" addtoken="false">
	<cfelse>
		<!--- output an error message --->
		<p style="text-align:center;color:red;font-size:x-large;">Sorry. There was a problem connecting with the PayPal server.</p>
		<p style="text-align:center;"><!---<cfdump var="#VARIABLES.responseStruct#">---></p>
	</cfif>
</cfif>

<!--- DoExpressCheckoutPayment --->
<cfif isdefined("URL.ppDo") AND URL.ppDo eq "true">
	<!--- set our values to send to paypal into a struct --->
	<cfset VARIABLES.ppVals = structnew()>
	
	<cfset VARIABLES.ppVals.method = "DoExpressCheckoutPayment">
	<cfset VARIABLES.ppVals.user = "x">
	<cfset VARIABLES.ppVals.pwd = "x">
	<cfset VARIABLES.ppVals.signature = "x">
	<cfset VARIABLES.ppVals.version = "52">
	<cfset VARIABLES.ppVals.token = SESSION.user.token>
	<cfset VARIABLES.ppVals.payerid = SESSION.user.payerid>
	<cfset VARIABLES.ppVals.paymentaction = "Sale">
	<cfset VARIABLES.ppVals.amt = NumberFormat(session.totalBasketPrice + session.shipping, '___.__')>
	
	<!--- call the method to initiate the pp request --->
	<cfinvoke component="CallerService" method="doHttppost" requestdata="#VARIABLES.ppVals#" serverurl="https://www.paypal.com/uk/cgi-bin/webscr" returnvariable="VARIABLES.response">
	
	<!--- send data to method to return it as a struct --->
	<cfinvoke component="CallerService" method="getNVPResponse" nvpString="#URLDecode(VARIABLES.response)#" returnvariable="VARIABLES.responseStruct">
	
	<!--- make sure the transaction was finalized --->
	<cfif VARIABLES.responseStruct.ack eq "success">
		<!--- redirect the user to the order confirm page --->
		<cflocation url="https://www.joe-cool.co.uk/EN/basket2/order_confirmed.cfm?ppExp=true" addtoken="false">
	<cfelse>
		<!--- output an error message --->
		<p style="text-align:center;color:red;font-size:x-large;">Sorry. There was a problem connecting with the PayPal server.</p>
		<p style="text-align:center;"><!---<cfdump var="#VARIABLES.responseStruct#">---></p>
	</cfif>
</cfif>

Open in new window

0
adam1h
Asked:
adam1h
  • 8
  • 4
  • 2
  • +1
1 Solution
 
SidFishesCommented:
Wild guess...have you tried using GET? That will submit all form variables as url values. Might be worth a try...
0
 
Dave BaldwinFixer of ProblemsCommented:
No, POST is required with Paypal.  You are still sending to the 'sandbox' in https://www.sandbox.paypal.com/ .  That is not the correct URL for a live site which is https://www.paypal.com/ .
0
 
adam1hAuthor Commented:
Hi SidFishes and DaveBaldwin,

@DaveBaldwin:
Thanks to point this to me.
I have corrected the url, but I still have the same issue :-(
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Dave BaldwinFixer of ProblemsCommented:
I tried calling Paypal but I got no answer from any of the developer numbers.  For some reason, I keep thinking that the API credentials for the sandbox are not the ones you use for the live site.

However your error message comes from the web server before you even get to that part.  Have you gone back to the sandbox and made sure your code is still working there?
0
 
adam1hAuthor Commented:
Yes, it works fine in the sandbox
0
 
adam1hAuthor Commented:
Hi,

Well after many searches, I resolve this issue by adding a variable in the setExpressCheckout call :
<cfset VARIABLES.ppVals.SolutionType = "Mark">

Open in new window


But now I have another issue :
Error 11601 :  Request for billing address failed
Billing address request is not enabled for merchant

But it happens in the setExpressMethod call, so I don't understand, I don't ask for billing address !

Do you have an idea why it happens ?
0
 
Dave BaldwinFixer of ProblemsCommented:
No idea.  But I did get a response from Paypal saying that Sandbox credentials are not valid on the live site.  They didn't answer about where I needed to get the 'live' credentials.
0
 
adam1hAuthor Commented:
Yes indeed, but I have changed credentials (user/password/signature). With the live ones.

Maybe the URL I use to connect to API and redirect user is wrong. But it's difficult to find a clear answer on the web.
0
 
Dave BaldwinFixer of ProblemsCommented:
It's difficult getting a clear answer from Paypal!!
0
 
adam1hAuthor Commented:
I have finally resolved this issue :

Some of the parameters were deprecated :
paymentAction is now PAYMENTREQUEST_0_PAYMENTACTION
amt is now PAYMENTREQUEST_0_AMT

And the url to redirect the customer to paypal is :
https://www.paypal.com/webscr?cmd=_express-checkout&token=#VARIABLES.responseStruct.token#
and not what I had
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#VARIABLES.responseStruct.token#

Now it rocks
0
 
adam1hAuthor Commented:
As described in my last comment, I have found and resolved the errors on my code.
0
 
CFDevvCommented:
Could you share your full working example as I'm trying to add Paypal Express Checkout to my shopping cart also.
0
 
adam1hAuthor Commented:
Hi,

This workflow is proper to our site and can be modified.

1st the user go to his details page where he select paypal.
2nd he go on a checkout page where the paypal transaction is initiate on the 1st run, ans on the 2nd one I retrieve his data from paypal.
3nd he go to an order_confirmed page where the transaction is performed.

Here is the code:
on checkout's head:
<!--- SetExpressCheckout --->
<cfif CGI.request_method eq "POST" AND isdefined("URL.ppExp") AND URL.ppExp eq "true">
	<!--- set our values to send to paypal into a struct --->
	<cfset VARIABLES.ppVals = structnew()>
	
	<cfset VARIABLES.ppVals.method = "SetExpressCheckout">
	<cfset VARIABLES.ppVals.PAYMENTREQUEST_0_PAYMENTACTION = "Sale">
	<cfset VARIABLES.ppVals.user = "blahblah">
	<cfset VARIABLES.ppVals.pwd = "blahblah">
	<cfset VARIABLES.ppVals.signature = "blahblah">
	<cfset VARIABLES.ppVals.version = "76.0">
	<cfset VARIABLES.ppVals.PAYMENTREQUEST_0_AMT = NumberFormat(session.totalBasketPrice + session.shipping, '___.__')>
	<cfset VARIABLES.ppVals.PAYMENTREQUEST_0_CURRENCYCODE = uCase(session.currency)>
	<cfset VARIABLES.ppVals.returnurl = "https://www.joe-cool.co.uk/EN/basket/checkout.cfm">
	<cfset VARIABLES.ppVals.cancelurl = "https://www.joe-cool.co.uk/EN/basket/shopping_basket.cfm">
	<cfset VARIABLES.ppVals.SolutionType = "Mark">
	
	<!--- call the method to initiate the pp request ---> <!--- test url = https://api-3t.sandbox.paypal.com/nvp --->
	<cfinvoke component="CallerService" method="doHttppost" requestdata="#VARIABLES.ppVals#" serverurl="https://api-3t.paypal.com/nvp" returnvariable="VARIABLES.response">
	
	<!--- send data to method to return it as a struct --->
	<cfinvoke component="CallerService" method="getNVPResponse" nvpString="#URLDecode(VARIABLES.response)#" returnvariable="VARIABLES.responseStruct">
	
	<!--- check if the connection with paypal was a success --->
	<cfif isdefined("VARIABLES.responseStruct.ack") AND VARIABLES.responseStruct.ack eq "success">
		<!--- send the user to paypal login --->
		<!---<cflocation url="https://api-3t.paypal.com/nvp/cgi-bin/webscr?cmd=_express-checkout&token=#VARIABLES.responseStruct.token#"  addtoken="false">--->
		<cflocation url="https://www.paypal.com/webscr?cmd=_express-checkout&token=#VARIABLES.responseStruct.token#"  addtoken="false">
	<cfelse>
		<!--- output an error message --->
		<p style="text-align:center;color:red;font-size:x-large;">Sorry. There was a problem connecting with the PayPal server.</p>
		<p style="text-align:center;"><cfdump var="#VARIABLES.responseStruct#"></p>
	</cfif>
</cfif>

<!--- GetExpressCheckoutDetails --->
<cfif isdefined("URL.token") AND isdefined("URL.PayerId")>
	<!--- set our values to send to paypal into a struct --->
	<cfset VARIABLES.ppVals = structnew()>
	
	<cfset VARIABLES.ppVals.method = "GetExpressCheckoutDetails">
	<cfset VARIABLES.ppVals.user = "blahblah">
	<cfset VARIABLES.ppVals.pwd = "blahblah">
	<cfset VARIABLES.ppVals.signature = "blahblah">
	<cfset VARIABLES.ppVals.version = "76.0">
	<cfset VARIABLES.ppVals.token = URL.token>
	
	<!--- call the method to initiate the pp request --->
	<cfinvoke component="CallerService" method="doHttppost" requestdata="#VARIABLES.ppVals#" serverurl="https://api-3t.paypal.com/nvp" returnvariable="VARIABLES.response">
	
	<!--- send data to method to return it as a struct --->
	<cfinvoke component="CallerService" method="getNVPResponse" nvpString="#URLDecode(VARIABLES.response)#" returnvariable="VARIABLES.responseStruct">
	
	<!--- if we get back the details set them into the user session --->
	<cfif isdefined("VARIABLES.responseStruct.ack") AND VARIABLES.responseStruct.ack eq "success">
		<cfset SESSION.user.countryCode = VARIABLES.responseStruct.countrycode>
		<cfset SESSION.user.email = VARIABLES.responseStruct.email>
		<cfset SESSION.user.firstName = VARIABLES.responseStruct.firstname>
		<cfset SESSION.user.lastName = VARIABLES.responseStruct.lastname>
		<cfset SESSION.user.payerid = VARIABLES.responseStruct.payerid>
		<cfset SESSION.user.payerstatus = VARIABLES.responseStruct.payerstatus>
		<cfset SESSION.user.shippingCountryCode = VARIABLES.responseStruct.shiptocountrycode>
		<cfset SESSION.user.shippingCountryName = VARIABLES.responseStruct.shiptocountryname>
		<cfset SESSION.user.shippingName = VARIABLES.responseStruct.shiptoname>
		<cfset SESSION.user.shippingCity = VARIABLES.responseStruct.shiptocity>
		<cfif isDefined("VARIABLES.responseStruct.shiptostate")> <cfset SESSION.user.shippingState = VARIABLES.responseStruct.shiptostate>
		<cfelse> <cfset SESSION.user.shippingState = "n/a"> </cfif>
		<cfset SESSION.user.shippingAddress = VARIABLES.responseStruct.shiptostreet>
		<cfset SESSION.user.shippingZipCode = VARIABLES.responseStruct.shiptozip>
		<cfset SESSION.user.token = VARIABLES.responseStruct.token>
		
		<!--- move the user to the billing and shipping page --->
		<!---<cflocation url="https://www.joe-cool.co.uk/EN/basket/checkout.cfm?ppDo=true" addtoken="false">--->
	<cfelse>
		<!--- output an error message --->
		<p style="text-align:center;color:red;font-size:x-large;">Sorry. There was a problem connecting with the PayPal server.</p>
		<p style="text-align:center;"><!---<cfdump var="#VARIABLES.responseStruct#">---></p>
	</cfif>
</cfif>

Open in new window


on checkout's body:
<cfif Session.ccard EQ "Paypal" AND NOT isdefined("URL.token") AND NOT isdefined("URL.PayerId")>
						<cfform name="ppExpForm" method="post" action="#CGI.SCRIPT_NAME#?ppExp=true">
							<!---<td> <input type="image" name="paypalSubmit" src="https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamic-image" alt="Paypal" border="0"> </td>---> 
							<td> <input type="image" name="submit" src="https://www.paypalobjects.com/en_GB/GB/i/btn/btn_xpressCheckout.gif" id="submit" runat="server" onclick="processing();"></td>
						</cfform>
					</cfif>

Open in new window


on orderconfirmed's head:
<!--- DoExpressCheckoutPayment --->
		<cfif isdefined("URL.ppDo") AND URL.ppDo eq "true">
			<!--- set our values to send to paypal into a struct --->
			<cfset VARIABLES.ppVals = structnew()>
			
			<cfset VARIABLES.ppVals.method = "DoExpressCheckoutPayment">
			<cfset VARIABLES.ppVals.user = "blahblah">
			<cfset VARIABLES.ppVals.pwd = "blahblah">
			<cfset VARIABLES.ppVals.signature = "blahblah">
			<cfset VARIABLES.ppVals.version = "76.0">
			<cfset VARIABLES.ppVals.token = SESSION.user.token>
			<cfset VARIABLES.ppVals.payerid = SESSION.user.payerid>
			<cfset VARIABLES.ppVals.PAYMENTREQUEST_0_PAYMENTACTION = "Sale">
			<cfset VARIABLES.ppVals.PAYMENTREQUEST_0_AMT = NumberFormat(session.totalBasketPrice + session.shipping, '___.__')>
			<cfset VARIABLES.ppVals.PAYMENTREQUEST_0_CURRENCYCODE = uCase(session.currency)>
			
			<!--- call the method to initiate the pp request --->
			<cfinvoke component="CallerService" method="doHttppost" requestdata="#VARIABLES.ppVals#" serverurl="https://api-3t.paypal.com/nvp" returnvariable="VARIABLES.response">
			
			<!--- send data to method to return it as a struct --->
			<cfinvoke component="CallerService" method="getNVPResponse" nvpString="#URLDecode(VARIABLES.response)#" returnvariable="VARIABLES.responseStruct">
			
			<!--- make sure the transaction was finalized --->
			<cfif VARIABLES.responseStruct.ack eq "success">
				<!--- redirect the user to the order confirm page --->
				<!---<cflocation url="https://www.joe-cool.co.uk/EN/basket/order_confirmed.cfm?ppExp=true" addtoken="false">--->
			<cfelse>
				<!--- output an error message --->
				<p style="text-align:center;color:red;font-size:x-large;">Sorry. There was a problem connecting with the PayPal server.</p>
				<p style="text-align:center;"><!---<cfdump var="#VARIABLES.responseStruct#">---></p>
			</cfif>
		</cfif>

Open in new window

0
 
adam1hAuthor Commented:
Hope it helps :-)
0
 
CFDevvCommented:
So the first page is the one that makes the call to Paypal once they have selected paypal and click next on the cart.

The third one is the return url confirming the payment.

Just to confirm, what is the second page doing?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now