Forum

Thread tagged as: Shop

Shop App order_successful

Hi,

I have a payment result page using the perch_shop_order_successful function, so if the payment is successful it presents the message and also adds a tag.

Problem is it will present the message and add the tag regardless if a payment was successful. I can hit this URL without the token back from paypal and still get the message and the tag set.

I only want this to be true if a payment is made.

<?php 
    include('../perch/runtime.php');
    if (!perch_member_logged_in()) {
        PerchUtil::redirect('/login');
    }
    perch_layout('global.header');
?>

<div class="container">
    <hr class="hr-spacer-inv space50">
    <div class="well billing">

        <?php
          perch_shop_complete_payment('paypal-express');

          if (perch_shop_order_successful()) {
              echo '<h1>Thank you for your order!</h1>';

              perch_member_add_tag('payment-made');

            }else{
              echo '<h1>Sorry!</h1>';
            }
        ?>

    </div>
    <hr class="hr-spacer-inv space50"> 
</div>

<?php perch_layout('global.footer'); ?>

Shawn North

Shawn North 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_shop_order_successful() is session-based, so it will be true once you've placed an order in that session, unless a subsequent order then fails or the session times out.

It seems that perch_shop_order_successful() is true regardless of the session.

If the function is set at this URL for example http"//domain.com/members/payment-result.php, That URL with be passed the token from paypal and picked up by perch_shop_complete_payment()

If payment is successful... do this

But I can go to the URL http"//domain.com/members/payment-result.php with out the token and perch_shop_order_successful() is still true. How can it be true if no token is passed?

Is it not ideal to set a tag this way, is there a better way to set a tag if the payment was successful?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you tested with a new private browsing window?

My bad... just tested in another browser. It works as expected. Thank you!