Jump to content

Recommended Posts

OK here is the method which I am using...

 

Buyer clicks product catagories or searches for products, once product found they clickdrop down select (1-20) and select qty, then click 'update' form button which refreshes the page and adds the product/s to they cart in a $_SESSION variable.

 

Once shopping finished they click 'view cart' link to be take to another page that adds they shoppping list to the paypal payment button.

 

Once they click the paypal pay button they are taken to paypal to pay and this is where i get stuck..

 

in the paypal button i have the variables set up like so....  (i have added a tab after the first character as it was placing the code as a button!)

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input name="cmd" value="_cart" type="hidden">

<input name="upload" value="1" type="hidden">
<input name="item_name" value="Shopping Cart" type="hidden">
<input name="item_name_1" value="No More Nails Interior - KIWI Dispenser" type="hidden">
<input name="quantity_1" value="1" type="hidden">
<input name="amount_1" value="7.99" type="hidden">
<input name="item_number_1" value="3552" type="hidden">

<input name="item_name_2" value="Loctite Power Flex Gel 3g" type="hidden">
<input name="quantity_2" value="3" type="hidden">
<input name="amount_2" value="3.99" type="hidden">
<input name="item_number_2" value="3554" type="hidden">
<input name="amount" value="19.96" type="hidden">

<input name="business" value="email@email.co.uk" type="hidden">
<input name="currency_code" value="GBP" type="hidden">

<input name="custom" value="variable" type="hidden">
<input name="image_url" value="https://www.paypal.com/en_US/i/btn/btn_paynow_LG.gif" type="hidden">
<input name="no_shipping" value="0" type="hidden">
<input name="no_note" value="0" type="hidden">
<input name="return" value="http://www.site.com/paypal_paid.php" type="hidden">
<input name="notify_url" value="http://www.site.com/sample-ipn2.php" type="hidden">
<input name="cancel_return" value="http://www.site.com/paypal_cancel.php" type="hidden">
<input value="I Agree, proceed to Payment" name="submit" class="paypalbutton" type="submit">
</form>

 

I have added the line

 

unset($_SESSION['cart']);

 

to the paypal_paid.php

 

But paypal does not always redirect them back to the site so the cart will look like it has not been paid for !

 

Can anyone suggest what I might be doing wrong that is causing paypal not to redirect them back to my site after payment so that they cart can be cleared ?

As a paypal user I know that once you pay for stuff you do not need to go back to the site that sold you the items. Just close the browser tag. Same goes for paying, Once on paypal all that is needed is to close the tag and not pay. I don't know if you get info about this.

 

But here are my thoughts.

Do not use form action="https://www.paypal.com/cgi-bin/webscr" method="post". Write a new php file. Have your cart form send you there and create a paypal-account-receivable file from the cart and then delete the cart and forward info to paypal. This gives you a record to keep until you receive payment. Which maybe instantaneous or never.

 

You will also need to write a file to process the paypal payment and start your shipping section.

I have been wondering how to get round this problem.

 

My method...

 

Create a table in MySQL called 'cartTemp', once the customer visit the cart.php file it checks if the $_SESSION['purchaseID'] isset, if not then create a unique HASH string and place this in the session.  If the session isset then do nothing as the cart is still being added or viewed by the customer.

 

In the paypal form code add the $_SESSION['purchaseID'] to one of the fields say 'custom'  or something else that i can add it to.

 

Then once payment is made paypal will send the order details to the 'notify_url' stored in the form code and this file will check the 'purchaseID' with those stored in MySQL and update the other field called 'paid' with the string 'paid'  !

 

Should the customer not go back to the shopping cart for any reason this is fine as the server will know that the payment was sent (completed/pending) or otherwise.

 

So if they are not redirected back to the stores site but instead went to another new page for example (far fetched i know, but i have to make sure i have covered everything!)  and then visited the store site they would have seen the cart order still as though it was not paid, but this time i check the MySQL for the session previously stored and check if paypal has sent anything to the notify_url about payment. if paypal did then i just clear the cart session data ready for a new order to be made.

 

But my problem is know ing what variable to use that will get sent to the notify_url and to my 'return' url for this method to work correctly.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.