asp.net mvc 4 - Reditect url from the method of notify_url of paypal in mvc -
i using paypal payment. in paypal found 2 type url -
- return_url
 - notify_url
 
i wan check validity after transaction, save data , redirect buyer receipt page unique value saved in db. why m not using redirect_url
here code
[httppost]         public actionresult testpaypalipn()         {             var response = new streamreader(request.inputstream, system.text.encoding.utf8).readtoend();              var webclient = new webclient();             string address = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate&" + response;             system.io.file.writealltext(@"d:\streamstech\content\requestaddress.txt", address);              try             {                 string result = webclient.downloadstring(address);                 system.io.file.writealltext(@"d:\streamstech\content\response.txt", result);                 if (result == "verified")                 {                     if (request.params["payment_status"] == "completed" && request.params["business"] == request.params["receiver_email"])                     {                         var lisencekey = request.params["transaction_subject"];                          var userproductlisence = userproductlisencerepository.getconditional(                         l => l.lisencekey == lisencekey).firstordefault();                          if (userproductlisence != null)                         {                             if (userproductlisence.paypaltransactionid == null)                             {                                 userproductlisence.paypaltransactionid = request.params["txn_id"];                                 userproductlisence.payeremailforpaypaltransaction = uri.escapeuristring(request.params["payer_email"]);                                 userproductlisencerepository.edit(userproductlisence);                                 return redirecttoaction("receipt", "transaction", new { requestid = userproductlisence.lisencekey });                             }                         }                     }                     return redirecttoaction("showerror", "transaction", new { errorname = "", errormessage = "something went wrong, try again later" });                 }                 return redirecttoaction("showerror", "transaction", new { errorname = "verification problem", errormessage = "transaction not verified" });             }             catch (exception e)             {                 system.io.file.writealltext(@"d:\streamstech\content\error.txt", e.message);                 return redirecttoaction("showerror", "transaction", new { errorname = "error..!!!", errormessage = "something went wrong, try again later" });                 throw;             }              return null;         }   here can compare, save data database.. not redirecting receipt page.. problem here in code...??
or suggestion how can it.. ? thank you..
based on requirement, need use return_url instead of notify_url. notify_url, it's used receiving message in system end , maybe can't receive after payment done. refer https://developer.paypal.com/docs/classic/ipn/integration-guide/ipnpdtanalternativetoipn/
Comments
Post a Comment