I have an asp.net MVC4 action that has a subscribe paypal button:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="payPalForm">
<input type="hidden" name="item_number" value="@item.Id">
<input type="hidden" name="item_name" value="@item.Name">
<input type="hidden" name="src" value="1">@*Recurring until user cancels*@
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="p3" value="1"> @*Billing cycle amount*@
<input type="hidden" name="t3" value="M"> @*billing cycle period - Month*@
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="business" value="dude@dude.com">@*Hiva's paypal account*@
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="@returnUrl">
<input type="hidden" name="amount" id="amount" value="@item.Price">
<input type="submit" name="Submit" value="Subscribe">
</form>
In the return URL it hits an action where I want to be able to see the form details and whether the payment went through, and all that good stuff. This is what I have:
public ActionResult PaymentConfirm(FormCollection form)
{
//if successful, blah blah
var user = User.Identity.Name;
//Merchant merch = ctx.Merchants.Single(x => x.User.UserName == user);
//merch.Plan = plan;
return RedirectToAction("Index", "Merchant");
}
How can I get this data!
As the comment mentioned, the solution is the IPN. Basically, IPN is an url you setup on your merchant account, under selling tools.
you would want to create the url that points to your actions. (To do it locally, you would need to do port forwarding to made you site public available)
The IPN contains all the information you need. It gets call whenever a payment is been made and it also comes with payment status whether is successful or failed.
Here is a link to there code samples that you can reference to.
https://www.x.com/developers/PayPal/documentation-tools/code-sample/216623
Update: for details how IPN works behind the scene, reference to the following link
https://www.paypal.com/cgi-bin/webscr?cmd=p/acc/ipn-info-outside