SmartButtons Return URL's not working

johmarjac
Contributor
Contributor

Hi,

 

I am currently trying to get Smart Payment Buttons working.

I was following the documentations integration guide. This is my code so far:

 

<!DOCTYPE html>
<html>
	
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	</head>

	<body>
		<h1>PayPal Smart Button Test</h1>
	
		<div id="paypal-button-container"></div>
	
		<script src="https://www.paypal.com/sdk/js?client-id=myclientid&currency=USD&disable-funding=credit,card,sepa"></script>
		
		<script>
			  paypal.Buttons({
				createOrder: function(data, actions) {
				  return actions.order.create({
					purchase_units: [{
					  amount: {
						value: '0.01'
					  }
					}],
					return_urls: {
						return_url: 'https://www.google.de/',
						cancel_url: 'https://www.youtube.de/'
					}
				  });
				},
				onApprove: function(data, actions) {
				  // Capture the funds from the transaction
				  return actions.order.capture().then(function(details) {
					// Show a success message to your buyer
					alert('Transaction completed by ' + details.payer.name.given_name);
				  });
				}
			  }).render('#paypal-button-container');
		</script>
	</body>
</html>

This renders the button, and I can do the sandbox payment. But neither of the both return url's provided work. It doesnt return to the cancel url when canceling the order, nor does it return to the success url when the payment is completed. I also cannot find any documentation to this.

Why isnt that working properly? Do I have to setup more settings? What am I doing wrong?

 

Thanks

Login to Me Too
3 REPLIES 3

southcoastkenny
Contributor
Contributor

Hi.

Hope this helps but return and cancel urls are no longer being used.

https://developer.paypal.com/docs/checkout/reference/upgrade-integration/

 

About half way down the page:

Note: return_url and cancel_url in the /v1/billing-agreements/agreement-tokens API are not used by the PayPal JavaScript SDK integration.

Pass https://www.paypal.com/checkoutnow/error as a placeholder value for these keys, and use on onApprove, onCancel and onError to handle transaction success or failure.

Many Thanks

Kenny

Login to Me Too

demsley
Contributor
Contributor

Thanks @southcoastkenny - be nice if they took down code that doesn't work anymore.

Two hours wasted!!

 

 

Login to Me Too

juanhdv
New Community Member

2 days wasted for me!!! :(((((

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.