Forum

Thread tagged as: Question, Error, Shop

Missing Arguement on Checkout

Hi,

I am using the shop app and have built the checkout system with Stripe integration. The operation of the checkout and payment works with notifications coming into Perch and Stripe when I test payments.

I am, however getting this error coming up below the checkout form and Stripe payment button.

Warning: Missing argument 1 for perch_shop_checkout(), called in /home/airpiie/public_html/checkout.php on line 94 and defined in /home/airpiie/public_html/perch/addons/apps/perch_shop/runtime/cart.php on line 172

On my checkout.php page the code on line 94 is: <?php perch_shop_checkout(); ?>

On my ../runtime/cart.php the code on line 172 is: function perch_shop_checkout($gateway, $opts=[], $address='stripe')

I changed the $address= from 'default' to 'stripe' but there is no difference.

Thanks, Orla

Orla Kirwan

Orla Kirwan 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to pass the name of the gateway and the success and failure URLs (as an options array) to perch_shop_checkout().

If you look at the Stripe gateway page in the documentation, it gives an example of how to do this.

Hi Drew,

Thanks.

I should have put more info in original question. I have the following code at top of my checkout.php page;

<?php
if (perch_member_logged_in() && perch_post('stripeToken')) {
      perch_shop_checkout('stripe', [
        'return_url' => 'success.php',
        'cancel_url' => 'failure.php',
        'token'      => perch_post('stripeToken')
      ]);
    }
?>

and this in body:

 <?php perch_shop_payment_form('stripe');?>  
<?php perch_shop_checkout(); ?>

Am I confined to using the success/failure URls as in docs (as below) or can I use my own (as above)?

$return_url = '/payment/stripe';
$cancel_url = '/payment/went/wrong';
Drew McLellan

Drew McLellan 2638 points
Perch Support

That's fine, but in the body where you have this:

 <?php perch_shop_payment_form('stripe');?>  
<?php perch_shop_checkout(); ?>

It should just be:

 <?php perch_shop_payment_form('stripe');?>  

Ah, so simple! That's worked perfectly.

Thanks! Orla