You need to sign in to do that
Don't have an account?
Aakanksha Singh 11
PayU payment Gatway Poland
Hello Everyone,
I'm currently working on PayU payment gateway. I implemented it through rest api in apex, it is thorwing syntax error, as we have to send JSON body.
So, I tried to send request through jquery, bt I'm facing issue while redirecting. Please refer to the code below.
Code for generating access token is working fine.
Please respond.
Thanx in advance
Regards
Aakanksha Singh
I'm currently working on PayU payment gateway. I implemented it through rest api in apex, it is thorwing syntax error, as we have to send JSON body.
So, I tried to send request through jquery, bt I'm facing issue while redirecting. Please refer to the code below.
<script> function placeOrderPayU(){ $.ajax('https://secure.snd.payu.com/api/v2_1/orders',{ type: 'POST', data: $.parseJSON('{"notifyUrl":"/apex/orderconfirm","customerIp":"203.122.41.218","extOrderId":'+'"'+Math.floor((Math.random()*1000)+1)+'"'+',"merchantposId":"300746","description":"des","currencyCode":"PLN","totalAmount":"4793.34","buyer":{"email":"test@wk.com","phone":"34454545","firstName":"test","lastName":"test","language":"en"},"settings":{"invoiceDisabled":"true"},"products":[{"name":"Camera","unitPrice":"1368.3400","quantity":"1"},{"name":"Jeans","unitPrice":"3425.0000","quantity":"1"}]}'), crossdomain:'true', dataType: 'jsonp', success: function(response){ var res = response["redirectUri"]; alert(res); }, beforeSend: function (xhr,settings) { xhr.setRequestHeader('Content-Type','application/json'); xhr.setRequestHeader('Accept','*/*'); xhr.setRequestHeader('Authorization','Bearer <your token>'); xhr.setRequestHeader('Accept-Encoding','gzip'); xhr.setRequestHeader('Access-Control-Allow-Headers','*'); xhr.setRequestHeader('Access-Control-Allow-Origin','*'); xhr.setRequestHeader("Access-Control-Allow-Methods", "POST"); xhr.setRequestHeader('Access-Control-Request-Headers','origin,Authorization,Content-Type,Accept'); }, }) } </script>
Code for generating access token is working fine.
<!--Controller--> public with sharing class payuconfig { public string str{get;set;} public void click(){ try{ HttpRequest req = new HttpRequest(); req.setEndpoint('https://secure.snd.payu.com/pl/standard/user/oauth/authorize'); req.setMethod('POST'); req.setHeader('Content-Type','application/x-www-form-urlencoded'); req.setBody('grant_type=client_credentials&client_id=300746&client_secret=2ee86a66e5d97e3fadc400c9f19b065d'); Http http = new Http(); HTTPresponse res= http.send(req); str = res.getBody(); system.debug(str); }catch(exception e){ system.debug(e); } } } <!-- Visualforce Page --> <apex:page controller="payuconfig" standardstylesheets="false" applyHtmlTag="false" applybodytag="false" cache="false" showheader="false" doctype="html-5.0" title="Payu"> <apex:form > <apex:outputPanel id="main"> {!str} </apex:outputPanel> <apex:commandButton value="Click" action="{!click}" rerender="main"/> </apex:form> </apex:page>
Please respond.
Thanx in advance
Regards
Aakanksha Singh
I also have a requirement to integrate PayU money with Salesforce. Where you able to do it sucessfully? Any help around this will be much appreaciated.
Regards,
Disha Bhagchandani
The only differnce/change I made in Postman is
Kept this Flag off. If I turn it on, will get response as HTML.
So, the only question for now is, do need to keep this flag off from code too? If yes, the how we can do that?