views:

120

answers:

2

So on my website I have paypal enabled but when the user clicks the "buy now" button I want to shoot an email to the store owner with some information before it redirects to paypal.com. I can't think of how to do this for the life of me because (I don't think) it's ever postedback to my page before it's redirected. Any ideas? It's absolute critical that this email is sent. The page is in asp.net with C#.

The paypal code is:

form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="form1" runat="server">

input type="hidden" name="cmd" value="_xclick" />

input type="hidden" name="lc" value="US" />

input type="hidden" name="item_name" value="Lollipops Gift Baskets Order" />

input type="hidden" id="paypal_amount" runat="server" name="amount" value="56.00" />

input type="hidden" name="currency_code" value="USD" />

input type="hidden" name="button_subtype" value="products" />

input type="hidden" name="tax_rate" value="0.000" />

input type="hidden" id="paypal_shipping" runat="server" name="shipping" value="0.00" />

input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" id="submit1" runat="server" />

img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />

/form>
A: 

Assuming that form ultimately generates HTML with an action on paypal.com, you won't get a request to your server when they click it. You'd need to do something like:

  • Send the request to your server, have it send the email and submit the post, or
  • Use AJAX or similar to make to requests from the browser (which is inherently insecure, so don't even think about doing this with, for instance, an email which says "go ship the lollypops").
  • If there's a paypal API that allows you to specify a "where to redirect when transaction is complete" address or similar, perhaps you can direct it back to you and send the email then?
James
how do you do the first bullet point?
Danni
A: 

I removed the action from my form tag and did all the behind the scenes work I needed to before doing a response.redirect to "https://www.paypal.com/cgi-bin/webscr". It seems to work.

Danni