Forum
How to route the checkout page for PayPal Express in Runway?
When the Checkout Now
link on my cart page is clicked, it goes to an empty/blank page. I have debug on but I'm not sure how to get the correct route from it. Please help me route this correctly.
My current template setup and debug info (admin = the perch folder) is below, it's more or less copied direct from the documentation so I can make sure everything works at its most basic...
Master page: cart.php located in admin/pages/
<?php perch_shop_cart();
?>
Master page: checkout.php located in admin/pages/
<?php
if (perch_member_logged_in()) {
// your 'success' return URL
$return_url = '/shop/payment';
$cancel_url = '/';
perch_shop_checkout('paypal-express', [
'return_url' => $return_url,
'cancel_url' => $cancel_url,
]);
}
?>
Master page: payment.php located in admin/pages/
<?php
perch_shop_complete_payment('paypal-express');
if (perch_shop_order_successful()) {
echo '<h1>Thank you for your order!</h1>';
}else{
echo '<h1>Sorry!</h1>';
}
?>
The location path for my Payment page is /shop/payment
My config for PayPal Express is set up in admin/config/shop.php
like this:
<?php
return [
/*
|--------------------------------------------------------------------------
| Gateway settings
|--------------------------------------------------------------------------
*/
'gateways' => [
'default' => [
'enabled' => false,
'test_mode' => false,
'live' => [
'api_key' => 'abc123',
],
'test' => [
'api_key' => 'abc123',
],
],
'paypal-express' => [
'enabled' => true,
'test_mode' => true,
'live' => [
'username' => 'paypal_api_username',
'password' => 'paypal_api_password',
'signature' => 'paypal_api_signature',
],
'test' => [
'username' => '43ranch_api1.lmlgraphics.com',
'password' => '5JFMNSXS6773DHN7',
'signature' => 'AFcWxV21C7fd0v3bYYYRCpSSRl31Az9U8FhOSoCZdIHQiXqolF1CweiO',
],
],
],
],
];
My understanding from this docs page is that the Checkout page should link directly to PayPal if the config file is set up, but I must be missing something.
You can add products to the cart on the development server / see the issue live here: https://138.197.208.91/shop
Here is the debug from the blank checkout page:
Debug Message - Perch Runway 3.0.10
[11] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch3_pages p LEFT JOIN perch3_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch3_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch3_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
Matched page: /shop/checkout, so not using routes.
Using master page: /templates/pages/checkout.php
[41] SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
[1] SELECT * FROM perch3_pages WHERE pagePath='/shop/checkout' LIMIT 1
[1] SELECT * FROM perch3_shop_cart WHERE cartID=7493
[1] SELECT * FROM perch3_shop_cart WHERE cartID=7493
[nil] SELECT * FROM perch3_shop_sales WHERE saleFrom<='2017-10-17 04:54:00' AND saleTo>'2017-10-17 04:54:00' AND saleActive=1 AND saleDeleted IS NULL ORDER BY saleOrder ASC
Request time: 0.0098
Process time: 0.0092
Memory: 0.9013
Have you checked your error log?
Hi Drew, thanks for helping. I'm so stumped!
My error log—you mean in browser developer tools?—isn't showing anything, just a little message saying
Navigated to https://138.197.208.91/shop/checkout
which is unfortunately a blank page.Is there a debug I should look at besides the one I'm seeing on at
shop/checkout
included above? Everything up to that point seems to be working and I didn't notice any red error messages.If I type the payment page URL into the browser, I see it's sort of working (I get the "Sorry!" message): https://138.197.208.91/shop/payment
My site diagnostics show I'm healthy, here's the summary readout:
I mean your PHP error log on the web server. If you're getting a blank page it sounds like the process is exiting with an error.
Sorry, of course, so many places to look for errors.
Here's the most recent php error log, the only one from today.
Hi, sorry to pester the forum, but my PHP is not strong enough to know what issue the above error log is pointing me toward. Does anyone have any insight?
ETA: To my eyes it looks like an unrelated error involving my homepage. But it's the only error from today, so if it doesn't help I'm back to square one with the checkout problem. :(
There is an error in your php on your home.php or the layout code.
I am on my phone so I can’t really read the error easily. But it is a php error, not likely a perch one.
Hi Robert, thanks for taking a look. There was an error on my home.php layout code, but I think now that it's probably a red herring unrelated to my main problem. I only shared that error text because Drew asked if there were any errors logged and it was the only error logged today/yesterday.
My main issue with having my checkout page show up blank during PayPal Express checkout doesn't seem to be logging any errors. :-/ It's probably difficult to see on a phone, but I have my template code and debug info loaded into my initial post above. I'd really appreciate if you took a look, if you have time. Thanks so much.
Hi Lindsay,
when you get to the checkout page, are you logged in as a member?
Hi Duncan, I'm not, I haven't set any of the member stuff up yet at all. I'm guessing by your question that maybe I should? Ideally, I would like people to be able to check out without signing in.
Your checkout page has code that is wrapped in code that checks if the member is logged in:
That code currently won't run.
Thank you, Duncan, that's a great catch. I modified the code to get rid of the if/logged in check:
<?php perch_shop_checkout('paypal-express', [ 'return_url' => '/shop/payment', 'cancel_url' => '/', ]); ?>
Now I am getting this error, which seems to imply that I do need the membership features turned on:
I don't think you can go that far without a member - you still need a name, email and postal address in order to be able to process a payment.
Look through this link to see how to create a password-less member:
https://docs.grabaperch.com/addons/shop/examples/no-account/