Forum

Thread tagged as: Question, Problem, Shop

Does not redirect after successful order

I use manual payment gateway

$return_url = 'https://.../payment/manual.php';
$cancel_url = 'https://.../payment/manual.php';

perch_shop_checkout('manual', [
'return_url' => $return_url,
'cancel_url' => $cancel_url,
]);

order is prosseced successfully but, after that it does not redirect me to $return_url, Debug does not show any errors if it is placed above checkout flow, when placed below it does not appear.

What can cause this kind of problem?

Checkout flow works fine when I use PayPal.

Maciej Pieńczewski

Maciej Pieńczewski 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Those aren't valid URLs, so it's likely they're just not responding. If you want to redirect just within your own site, the format to use would be:

$return_url = '/payment/manual.php';
$cancel_url = '/payment/manual.php';

Same URL works for PayPal, but doesn't work for Manual payment, so this is not about valid URL's. I have checked your suggestion, but still the same problem.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Where does it appear in the page?

On a checkout page. After succesfull checkout (I see order in admin panel, and receive confirmation emails).

My checkout page

<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php');?>   
<?php include($_SERVER['DOCUMENT_ROOT'].'/header.php'); ?>
<main>
    <section class="rewiev">

<?php
        $cart = perch_shop_cart(['skip-template'=>true]);
        $shippingID = $cart['shipping_id'];    
        $shippingZaPobraniem = 4;

        if (!perch_member_logged_in()) {
            echo '<div class="left-col-checkout">';
            // New customer sign up form
            perch_shop_registration_form([
                'template' => 'checkout/customer_create_passwordless.html'
            ]);
            echo '</div>';
            perch_shop_cart([
                'template'=>'cart/cart_static.html'
            ]);
        }

        else  {

             if (!perch_shop_cart_has_property('terms_agreed')) {

                echo '<div class="left-col-checkout">';
                perch_shop_order_addresses();
                perch_shop_shipping_options();
                perch_shop_shipping_method_form();
                perch_shop_form('checkout/confirm.html');
                echo '</div>';
                perch_shop_cart([
                    'template'=>'cart/cart_static.html'
                ]);

             } else {

                    if ($shippingID == $shippingZaPobraniem) {
                          $return_url = '/shop/payment/manual.php';
                          $cancel_url = '/shop/payment/manual.php';
                          perch_shop_checkout('manual', [
                            'return_url' => $return_url,
                            'cancel_url' => $cancel_url,
                          ]);


                    }

                    else {

                          $return_url = 'https://../shop/payment';
                          $cancel_url = 'https://../shop/payment';
                          perch_shop_checkout('paypal-express', [
                            'return_url' => $return_url,
                            'cancel_url' => $cancel_url,
                          ]);
                    }
            }
        }

    ?>
    </section>

</main>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Anything that causes a redirect needs to appear before the body of the response is sent. So that needs to be right up above your header include.

Ok. So why this works for PayPal, and does not work for manual? Neither one nor the other are above header include. But redicrect works for paypal, but does not work for manual.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I believe PayPal uses JavaScript, so that's completely different.

You've come asking for help, yet each time I make a suggestion you argue with it rather than try it out. Perhaps someone else can help you better. Good luck with your project.