Forum
PayPal Express always cancels
Every time I click my PayPal express button and I go to the page calling perch_shop_checkout()
for PayPal express, it never sends me to the PayPal site, but instead straight to my cancel page.
I have my shop.php file with all the appropriate keys (replaced here with x's). I pulled them straight form PayPal developer site.
<?php
return [
'gateways' => [
'paypal-express' => [
'enabled' => true,
'test_mode' => true,
'live' => [
'username' => 'xxx',
'password' => 'xxxxxx',
'signature' => 'xxxxxx',
],
'test' => [
'username' => 'xxx',
'password' => 'xxxxxx',
'signature' => 'xxxxxx',
],
],
'braintree' => [
'enabled' => true,
'test_mode' => true,
'live' => [
'merchantId' => 'xxx',
'publicKey' => 'xxxxxx',
'privateKey' => 'xxxxxx',
],
'test' => [
'merchantId' => 'xxx',
'publicKey' => 'xxxxxx',
'privateKey' => 'xxxxxx',
],
],
]
];
here's the basic code for the page ... all that I have before it are a few snippets of code defining DOMAIN as well as the runtime.php file.
<?php
if (perch_member_logged_in()) {
// your 'success' return URL
$return_url = 'https://'.DOMAIN.'/checkout/success-paypal.php';
$cancel_url = 'https://'.DOMAIN.'/checkout/cancel.php';
perch_shop_checkout('paypal-express', [
'return_url' => $return_url,
'cancel_url' => $cancel_url,
]);
} else {
PerchUtil::redirect('https://'.DOMAIN.'/checkout/checkout.php');
}
?>
I guess I can't say it ALWAYS cancels, since TWICE it has properly redirected me to PayPal express checkout form.
So why did it send me twice to the PayPal express checkout form and the rest of the time to the cancel page?
I've got no idea. What more can you tell me?
I'm not sure what else there is to say ... I've tried it on the live server and my development server ... I've tried different browsers too.
I tried calling the debugger, but that just stops everything from happening.
Have you turned on debug? Is there anything in your server error log? Are your SSL certs up to date?
Yes, I have debug on, but nothing pops up.
SSL certs are good as well. Although ... I'm using Let's Encrypt ... do you think that has anything to do with it?
No, I mean the outbound SSL configuration for contacting PayPal, not your site's HTTPS connection.
I was finally able to catch a debug on the issue ... here's the part I think you need ...
That does seem to confirm what I'm saying, yes.
its just so strange ... if I manually add PayPal Express Checkout (not using Perch's setup), I can get it to work just fine ... it doesn't return a token that validates, but I can at least see the checkout pop up, log into PayPal, etc ... so I'm not sure how to incorporate manually adding PayPal Checkout and have it complete the order.
Do you have any advice?
Is the same occurring on your server?
Yes, both my testing server (my Mac at home) and the live/testing server on Dreamhost.