Forum

Thread tagged as: Question, Shop

Multiple payment options

Hi there,

Our client is using the shop app to book swimming holidays, they have asked the question whether its possible to have multiple payment options i.e.

  • Stripe
  • PayPal
  • Pay by Cheque

Is this possible? Currently I have my checkout page set up using the stripe payment gateway

<?php

    if (!perch_member_logged_in()) {
        PerchSystem::redirect('/shop/register');
    }

    if (perch_member_logged_in() && perch_post('stripeToken')) {

        // your 'success' and 'failure' URLs
        $return_url = '/shop/result';
        $cancel_url = '/shop';

        perch_shop_checkout('stripe', [
            'return_url' => $return_url,
            'cancel_url' => $cancel_url,
            'token'      => perch_post('stripeToken')
        ]);
    }

    // Include the header. You can find this in tempates/layouts/global
    perch_layout('global/header');
?>

    <div class="canvas">

        <?php
            // Show the cart with a non-interactive template
            perch_shop_cart([
                'template'=>'cart/cart_static.html'
            ]);

            perch_shop_order_address_form();
        ?>

            <div class="content  clear  row">
                <?php
                    // Display the form with the T&Cs checkbox
                    // perch_shop_form('checkout/confirm.html');
                    perch_shop_payment_form('stripe');
                ?>
            </div>

        <?php
            // Include the footer. You can find this in tempates/layouts/global
            perch_layout('global/footer');
        ?>

    </div> <!-- Closes Canvas Div -->

    <script src="/assets/build/js/main.min.js"></script>

</body>
</html>

If its possible how would I go about integrating it into my template.

Thanks

Fishtank Creative

Fishtank Creative 2 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you can do that. How you implement it depends on how you want the process to work in your user interface.

Basically the process would be, once the customer arrives at checkout. They would see

  • Pay with Card (Stripe Button)
  • Pay with PayPal
  • Pay via Cheque (Manual Payment)

Then its up to the customer the best one that suits them.

Thanks

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Yes, I've done that. It's a case of working out the flow and writing a bit of code to let people pick then sending them through the right process.

It mostly is a job of deciding what you want the experience of the customer to be. I'd start with that :)

Hi Damien,

Like you I currently have Stripe set up, and want to add a Paypal button next to the Stripe one at the last stage of checkout. I will be working on it this week, I will let you know if I work it out!

Hi,

I have this, which works, though I am not sure if it is the best approach. Have this at the top of the page:


if (perch_member_logged_in() && perch_post('stripeToken')) { $return_url = '/shop/successful-payment'; $cancel_url = '/shop/unsuccessful-payment'; perch_shop_checkout('stripe', [ 'return_url' => $return_url, 'cancel_url' => $cancel_url, 'token' => perch_post('stripeToken') ]); } if (perch_member_logged_in() && isset($_POST["paypal"])) { $return_url = 'https://website.com/shop/successful-payment'; $cancel_url = 'https://website.com/shop/unsuccessful-payment'; perch_shop_checkout('paypal-express', [ 'return_url' => $return_url, 'cancel_url' => $cancel_url, ]); }

And then this to set the POST:

<form action="" method="post">

<button name="paypal" value="true">Pay with Paypal</button>

</form>

Got that next to the perch_shop_payment_form('stripe'); so the two buttons are next to each other.

Seems ok?