close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

sending to success if no need for payment on paypal express

Thread began 5/25/2012 9:37 am by Christopher West | Last modified 5/30/2012 11:40 am by Christopher West | 845 views | 7 replies |

Christopher WestCommunity Expert

sending to success if no need for payment on paypal express

Jason remember that line of code I had on my "paypal standards" confirm page that checked for a customer using a gift voucher and if the order was zero or less then it would go directly to the success page. well im trying to think of the logic in putting it on the new pages i have created using paypal express.

the problem is that its the confirm page that has all the order summary displayed. but that confirm page is only reached after the user goes to paypal express. but on the paypal page i added something so that no order informaiton is displayed on the paypal page (a message on paypal states that the order info will be on the website page - i think this shows like this either because i put in a invoice reference or a description in one of the paypal server behaviours) - but I beleive to understand that no payment will go through on paypal express until a customer clicks on the submit order button back on the confirm page (so the paypal page is just acting more of a logging in page if im correct). anyway back to my point. so with this information said im attaching the confirm and checkout pages - just wanted the best course of action to place code so that if detects if an order is either zero or less then (due to a order costing £35 and a customer uses a gift voucher code for £45). once that has been detected then it would go to the relevant page to create the order (ie send email, add to orders summary - this code is on the success page)

Chris

Attached Files
NEW.ZIP
Sign in to reply to this post

Christopher WestCommunity Expert

Jason, I was thinking of using this code in the checkout.php file but when i test this...the sessions arnt being setup so errors occur on the success page due to no sessions. but the sessions are created if the page goes to paypal. just wondered why they dont get set any other way as i assumed they were set on any post.

ive attached the original files to show code structure (with the below code to check for orders that are zero. (also how can i code it so that if the voucher code is £45 and the order is £35 that the order invoices wont display £-10 (would prefer it just to say £0 but that would mean i woul need to hand code every single reference of the total cost on any page that displays them. is there another easier way to just display £0 rather then any negative value?

the code i was thinking of using for the checking of orders are that <= 0 is:

<?php if(isset($_SESSION['FormVoucherAmount']) && $_SESSION['FormVoucherAmount'] != "" && $DinkyCart->GrandTotal() < 0.01) { ?>

<form name="PayPal_ExpressCheckout_form" action="confirm.php" method="post">

<?php } else { ?>

<form name="PayPal_ExpressCheckout_form" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">

<?php } ?>

Attached Files
free payments.zip
Sign in to reply to this post

Jason ByrnesWebAssist

On the checkout page at lines line 103 - 214 is the code for the authentication for paypal express checkout behavior.

it begins the first few lines and last few lines look like this:

php:
<?php

$WA_PP_ECO_SetResult 
WA_PP_ECO_SOAPObject();
if (isset(
$_POST["PayPal_ExpressCheckout_button_x"]))  {
.....
.....
.....
  
$WA_PP_ECO_SetResult WA_PP_ECO_Set_Post($WA_PP_ECO_Set_params,$WA_PP_ECO_Do_itemized);
  if (
$WA_PP_ECO_SetResult->isError) {
    if (
"http://www.dinkyfingerprint.co.uk/failure.php" != "") {
      
header("Location: ""http://www.dinkyfingerprint.co.uk/failure.php"); exit;
    }
  }
  else {
    
$DinkyCart->redirStr $WA_PP_ECO_SetResult->ECOServer;
  }
}
?>




add an if statement around that code so it only executes if the cart total is greater than 0:

php:
<?php if($DinkyCart->GrandTotal() > 0) { ?>

<?php
$WA_PP_ECO_SetResult 
WA_PP_ECO_SOAPObject();
if (isset(
$_POST["PayPal_ExpressCheckout_button_x"]))  {
.....
.....
.....
  
$WA_PP_ECO_SetResult WA_PP_ECO_Set_Post($WA_PP_ECO_Set_params,$WA_PP_ECO_Do_itemized);
  if (
$WA_PP_ECO_SetResult->isError) {
    if (
"http://www.dinkyfingerprint.co.uk/failure.php" != "") {
      
header("Location: ""http://www.dinkyfingerprint.co.uk/failure.php"); exit;
    }
  }
  else {
    
$DinkyCart->redirStr $WA_PP_ECO_SetResult->ECOServer;
  }
}
?>
<?php 
} else { $DinkyCart->redirStr "http://www.dinkyfingerprint.co.uk/confirm.php" ?>







on the confirm page, at lines 19 - 134, there is also express checkout code, for the Get Payer Profile and Process transaction with express checkout behaviors, you need to add a similar statements to prevent that code from processing if the total is not greater than 0 and set the redirect to the success page if it is.

Sign in to reply to this post

Christopher WestCommunity Expert

Hi Jason I implimented the code you stated (had to change the else statement a little as it came up with a syntax error.

Its not working though, as when i click the button to go to checkout page it automatically sends me to the success.php page and comes up with this error:

"Duplicate entry '' for key 3"

Im attaching the 2 files, checkout.php and confirm.php pages.

I did 2 types of tests:

In my Admin I created 2 voucher codes one being £80 and the second being £79

I then created an order consisting off:
Product £68
Product Option £5

On the checkout page I was going to select the delivery cost of £7

This would then = £80 for the total order...

(so then I was going to test how the website tackles the grandtotal of £0 AND second test of grandtotal being £1 (If I had selected the voucher for £79).

However the logical error for all this is that the code you supplied is checking the grandtotal BEFORE i select my delivery option of £7 because it automatically bypasses the checkout and confirm pages and goes straight to success (then gives me that error "Duplicate entry '' for key 3")

I can see that if in the cart the grandtotal would be "currently" £73 (since i havent selected the delivery option on the checkout page) so the code assumes that the grandtotal is <=0.

help :)

Attached Files
redirection.zip
Sign in to reply to this post

Jason ByrnesWebAssist

On the checkout page, change the code for the else statement to:

php:
<?php 
} else { 
    if (isset(
$_POST["PayPal_ExpressCheckout_button_x"]))  {
        
$DinkyCart->redirStr "http://www.dinkyfingerprint.co.uk/confirm.php" 
    
}
 } 
?>




on the confirm page, use this code for the else statement:

php:
<?php 
} else { 
    if (isset(
$_POST["Submit_order_x"]))  {
        
$DinkyCart->redirStr "http://www.dinkyfingerprint.co.uk/success.php" 
    
}
 } 
?>
Sign in to reply to this post

Christopher WestCommunity Expert

Thanks Jason I will try this late tonight when most of the population are asleep in case the page goes wrong..as uploading it on the live server.

once this is sorted, I wanted to make sure that if a customer had used a voucher code that made the transaction go into a negative value, I would then use a IF statement around the total price, grand total price etc to check if <0 then display 0 so that the customer will never see a £-5, £-10, £-15 etc etc. however this would mean I would need to make sure i do that for every instance in my website...if there some kind of "global" IF statement I could do as a function so that any values in my website with a negative value are displayed as £0

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

no, there is not a global if statement you could use, you need to add the if statement to each place the total price is shown.

Sign in to reply to this post

Christopher WestCommunity Expert

ok thats all good :) thanks for the help will test it all out later tonight :)

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...