c# - How to use the paypal IPN -
i'm trying create page :
1.the user clicks button called buy 2.the user redirected paypal page needs log in , pay.after paid , redirected page where:
1.in page load , check if payment made.i've done seems not working. have done?
1.enabled ipn paypal business relationship , url set asp page.
2.hosted 2 files ( php/asp.net ) on website
3.tested label text not changing "done,payment made" means couldn't process payment.
the php page buying product:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="business" value="seller@domain.com" /> <input type="hidden" name="item_name" value="happiness" /> <input type="hidden" name="amount" value="6.52" /> <input type="submit" value="buy!" /> </form>
the asp.net page:
protected void page_load(object sender, eventargs e) { string strsandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr"; httpwebrequest req = (httpwebrequest)webrequest.create(strsandbox); //set values request req.method = "post"; req.contenttype = "application/x-www-form-urlencoded"; byte[] param = request.binaryread(httpcontext.current.request.contentlength); string strrequest = encoding.ascii.getstring(param); strrequest += "&cmd=_notify-validate"; req.contentlength = strrequest.length; streamwriter streamout = new streamwriter(req.getrequeststream(), system.text.encoding.ascii); streamout.write(strrequest); streamout.close(); streamreader streamin = new streamreader(req.getresponse().getresponsestream()); string strresponse = streamin.readtoend(); streamin.close(); if (strresponse == "verified") { label1.text = "done,payment made."; } else if (strresponse == "invalid") { //whatever } else { //whatever } }
what can do?
ipn transactions sent in batches, , many minutes later. shouldn't designing page user sees reflect status of ipn messages. in scheme tell users purchase finish , fulfilled when paypal advises clearance of funds, , advise them of email.
c# asp.net paypal paypal-ipn paypal-sandbox
No comments:
Post a Comment