I am trying to integrate paypal sandbox
with my asp.net application ! I have integrated module and i have redirected to paypal sandbox
site ! You can login to sandbox and make payment ! Paypal focus redirects to my return URL ! Now the problem is I don't know what paypal sandbox
returns with 'return URL' and even I am new with sandbox so I don't know how to manage the redirected data ! Kindly Inform me ! Thank you !
I have tried to download demos ! But in demos most of uses their own dll ! They are not providing class definition so I am little bit confused !
At first, check the paypal docs which fields are returned. As Mr. Disappointment guessed, the data will probably be returned as form data in a HTTP POST request.
You can check the request and the data with fiddler.
To access form data within an ASP.NET app, you simply use the Request object:
var field = Request["fieldName"];
Log into your sandbox account, then click on Documentation --> Sample Code then click the Integration Wizard link to generate all the sample code that you need.
The return URL will have two URL Params:
token, payerId
I am using MVC so my Controller Method signature looks like this:
public ActionResult PaypalOrderConfirmation(string token, string payerId)
but you could just use eg Request.QueryString("token"); //Is that right it's been a while...
Then you need to "Commit the payment"
NVPCodec nvpCodec = new NVPCodec();
string returnMessage;
bool success = PayPal.CommitPayment(someTotal, token, payerId, out nvpCodec, out returnMessage);
//----------------------------------------------------------------------------//
public static bool CommitPayment(decimal finalPaymentAmount, string token, string payerId, out NVPCodec nvpCodec, out string returnMessage)
{
nvpCodec = new NVPCodec();
returnMessage = "";
bool success = new NVPAPICaller().ConfirmPayment(finalPaymentAmount.ToString(), token, payerId, ref nvpCodec, ref returnMessage);
return success;
}
I will go have another look on paypal for the download code and add it to this post if I find it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.