Forum

Thread tagged as: Question, Addons, Shop

Payment Gateways based on delivery

Hi, I would like to have two payment gateways. Manual & PayPal on a one checkout page. Manual for order with "Payment on Delivery", and PayPal for the rest.

I do not know how to get button for Manual, and button for PayPal on the same page. I will be thankfull for some help on this.

my checkout flow

<?php

        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 {

                // T&Cs are agreed, so on to the payment step!
                  // your 'success' return URL
                  $return_url = 'https://../';
                  $cancel_url = 'https://../';
                  perch_shop_checkout('paypal-express', [
                    'return_url' => $return_url,
                    'cancel_url' => $cancel_url,
                  ]);
            }
        }

    ?>
Maciej Pieńczewski

Maciej Pieńczewski 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The only way I can think to do this through Shop itself (rather than using your own code to track the selection) would be to inspect the value of shippingID in the output from perch_shop_cart().

Can You help me more Drew? How I can find in a payment condition specific shippingID?

if (perch_shop_cart( ?? )) {

      // your 'success' return URL
      $return_url = 'https://../';
      $cancel_url = 'https://../';

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



}else{

    // T&Cs are agreed, so on to the payment step!
      // your 'success' return URL
      $return_url = 'https://../';
      $cancel_url = 'https:/../';

      perch_shop_checkout('paypal-express', [
        'return_url' => $return_url,
        'cancel_url' => $cancel_url,
      ]);
}

Can You suggest any documentation on this topic?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You'll need to look at the cart with perch_shop_cart() - it should contain the shippingID so you can tell one method from another. There's no automatic functionality for this.

I will be honest, I have no idea how to find shippingID in perch_shop_cart() function.

Drew McLellan

Drew McLellan 2638 points
Perch Support

$cart = perch_shop_cart(['skip-template'=>true]);
$shippingID = $cart['shipping_id'];

Thanks Drew! That 's why I love Perch - AMAZING support!