armlocker Posted June 6, 2013 Share Posted June 6, 2013 Hi All. I can't get a redirect back to the "checkout.php" in chapter 19. I am using a personalised paypal button. Firstly; are these lines correct in checkout.php? // customer is logged in and this page has access to the customer's ID: session_id)£id); // this page receives the order total: $subtotal = $_SESSION['cart'][$row['print_id']]['quantity'] * $_SESSION['cart'][$row['print_id']]['price']; Secondly; heres the code from view_cart.php with my paypal button, but the problem is that it's not directing it back to checkout.php (above code may be incorrect?) <!--- this is where the user comes back to after they finished making the payment ---> <input type="hidden" name="notify_url" Value="http://wolfcut.co.uk/checkout.php" /> <!-- Specify details about the item that buyers will purchase. --> '.$string_of_item_names.' '.$string_of_item_amounts.' <input type="hidden" name="currency_code" value="GBP"> <!-- Display the payment button. --> <div align="center"> <input type="image" name="submit" border="0" align="center" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online"> <img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > </div> Any advice is appreciated. Thanking you! Link to comment Share on other sites More sharing options...
HartleySan Posted June 7, 2013 Share Posted June 7, 2013 "session_id)£id);" seems like a syntax error. So does the following (unless you're starting your echo statement somewhere not in your code): '.$string_of_item_names.' '.$string_of_item_amounts.' Link to comment Share on other sites More sharing options...
armlocker Posted June 7, 2013 Author Share Posted June 7, 2013 Hi HartleySan Yep, I've just spotted that typo too, should be: session_id($cid); the view_cart.php with the added paypal button looks like this - which is not linking to the checkout.php after the customer presses the buy button: echo "\t<tr> <td align=\"left\">{$row['artist']}</td> <td align=\"left\">{$row['print_name']}</td> <td align=\"right\">£{$_SESSION['cart'][$row['print_id']]['price']}</td> <td align=\"center\"><input type=\"text\" size=\"3\" name=\"qty[{$row['print_id']}]\" value=\"{$_SESSION['cart'][$row['print_id']]['quantity']}\" /></td> <td align=\"right\">£" . number_format ($subtotal, 2) . "</td> </tr>\n"; $string_of_item_names = $string_of_item_names.' <input type="hidden" name="item_name_'.$count.'" Value="'.$row['print_name'].'" >'; # build item name string of all items in the basket $string_of_item_amounts = $string_of_item_amounts.' <input type="hidden" name="amount_'.$count.'" Value="'. number_format ($subtotal, 2).'" >'; # build string of prices for items in basket # use count as a reference to match names with prices in paypal $count++; } // End of the WHILE loop. mysqli_close($con); // Close the database connection. if ($_SESSION['userid']>0) $checkout_button = ('<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- Identify your business so that you can collect the payments. HELP: https://www.paypal.com/us/cgi-bin/webscr?cmd=_pdn_xclick_techview_outside https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HF00TZS We use cart becuase we have our own (third party which is us) --> <input type="hidden" name="business" value="hello@richmond"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <!--- this is where the user comes back to after they finished making the payment ---> <input type="hidden" name="notify_url" Value="http://www.wolfcut.co.uk/checkout.php" /> <!-- Specify details about the item that buyers will purchase. --> '.$string_of_item_names.' '.$string_of_item_amounts.' <input type="hidden" name="currency_code" value="GBP"> <!-- Display the payment button. --> <div align="center"> <input type="image" name="submit" border="0" align="center" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online"> <img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > </div> </form>'); else $checkout_button = '<a href="login.php">You must be logged in to purchase or please sign up.</a>'; // Print the total, close the table, and the form: echo '<tr> <td colspan="4" align="right"><b>Total: </b></td> <td align="right">£' . number_format ($total, 2) . '</td> </tr> </table> <div align="center"><input type="submit" name="submit" value="Update My Cart" /></div> </form><p align="center">Enter a quantity of 0 to remove an item. <br /><br />'.$checkout_button.'</p>'; Link to comment Share on other sites More sharing options...
HartleySan Posted June 7, 2013 Share Posted June 7, 2013 which is not linking to the checkout.php after the customer presses the buy button: Could you please elaborate on this? Link to comment Share on other sites More sharing options...
armlocker Posted June 7, 2013 Author Share Posted June 7, 2013 .... you see these parts in the script; they are meant to bring the user back to checkout.php after they press the pay button. <br /><br />'.$checkout_button.'</p>'; and this part: <input type="hidden" name="notify_url" Value="http://www.wolfcut.co.uk/checkout.php" /> I was trying this; to link the checkout button; which didn't work either: <br /><br /><a href="checkout.php"'.$checkout_button.'</a></p>'; Link to comment Share on other sites More sharing options...
HartleySan Posted June 7, 2013 Share Posted June 7, 2013 Looking at the PayPal API documentation for the SetExpressCheckout method, you need to specify the return URL in the RETURNURL parameter. Please see the following for details: https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout Is that what you're asking? Link to comment Share on other sites More sharing options...
Recommended Posts