c# - Paypal IPN sample code has no ActionResult. How am i meant to give a url if there is no view? -
this paypals sample code ipn. have been on few days , getting no where. not sure meant call. in previous question asked said dont call receive method. lead me on think how paypal know go. (i.e method use.)
public class ipncontroller : controller { [httppost] public httpstatuscoderesult receive() { //store ipn received paypal logrequest(request); //fire , forget verification task task.run(() => verifytask(request)); //reply 200 code return new httpstatuscoderesult(httpstatuscode.ok); } private void verifytask(httprequestbase ipnrequest) { var verificationresponse = string.empty; try { var verificationrequest = (httpwebrequest)webrequest.create("https://www.sandbox.paypal.com/cgi-bin/webscr"); //set values verification request verificationrequest.method = "post"; verificationrequest.contenttype = "application/x-www-form-urlencoded"; var param = request.binaryread(ipnrequest.contentlength); var strrequest = encoding.ascii.getstring(param); //add cmd=_notify-validate payload strrequest = "cmd=_notify-validate&" + strrequest; verificationrequest.contentlength = strrequest.length; //attach payload verification request var streamout = new streamwriter(verificationrequest.getrequeststream(), encoding.ascii); streamout.write(strrequest); streamout.close(); //send request paypal , response var streamin = new streamreader(verificationrequest.getresponse().getresponsestream()); verificationresponse = streamin.readtoend(); streamin.close(); } catch ( exception exception) { //capture exception manual investigation } processverificationresponse(verificationresponse); } private void logrequest(httprequestbase request) { // persist request values database or temporary data store } private void processverificationresponse(string verificationresponse) { if (verificationresponse.equals("verified")) { // check payment_status=completed // check txn_id has not been processed // check receiver_email primary paypal email // check payment_amount/payment_currency correct // process payment } else if (verificationresponse.equals("invalid")) { //log manual investigation } else { //log error } } }
there no actionresult how meant give url. thought of seems return invalid
public actionresult ipn() { receive() }
i have asked previous questions still cant seem head around ipn.
Comments
Post a Comment