i using adaptivepayments api.the code paypal key is,
payrequest payrequest = new payrequest(requestenvelope, "pay_primary", getproperties().getproperty("paypal_failed_url").trim() + bookingid, "sgd", receiverlist, getproperties().getproperty("paypal_success_url").trim() + bookingid); payrequest.setfeespayer("primaryreceiver"); payrequest.settrackingid(transactionkey); payrequest.setreceiverlist(receiverlist); adaptivepaymentsservice service = null; map<string, string> sdkconfig = new hashmap<string, string>(); sdkconfig.put("mode", "sandbox"); sdkconfig.put("acct1.username", "sg_owner_api1.owner.com"); sdkconfig.put("acct1.password", "wy8haw6wgunm3r72"); sdkconfig.put("acct1.signature", "afcwxv21c7fd0v3byyyrcpssrl31atxmpr-efttpngimumxw80wnhgsq"); sdkconfig.put("acct1.appid", "app-80w284485p519543t"); service = new adaptivepaymentsservice(sdkconfig); payresponse payresponse = null; // ## making api call // invoke appropriate method corresponding api in service // wrapper object payresponse = service.pay(payrequest); logger.debug("-->" + payresponse.getpaykey()); logger.debug("-->" + payresponse.getresponseenvelope().getack());
the paykey returned successfully, after payment paypal page should shown user's authorization , sandbox link , (https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=paykey)
foe doing ,
httpresponse.addheader("access-control-allow-origin", "*"); httpresponse.addheader("access-control-allow-methods", "get, post, delete, put"); httpresponse.addheader("access-control-allow-headers", "access-control-allow-origin,content-type, accept"); httpresponse.sendredirect(url + paykey); return response.status(successresponse.getcode()).entity(successresponse).build();
the paypal palpage not shown , can see error in browser console,"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=paykey"
geeting error, no 'access-control-allow-origin' header present on requested resource. origin 'localhost:8080' therefore not allowed access.
please let me know needs done redirected paypal page.
thanks, gayithri
afaik might chrome not support localhost go through access-control-allow-origin
to send access-control-allow-origin in header, try localhost in hostfile (c:\windows\system32\drivers\etc\hosts
on windows, /etc/hosts
on unixes) other domain, like:
127.0.0.1 localhost mydomain.com
then if you'd access script using mydomain.com instead of localhost, call should succeed.
Comments
Post a Comment