Guest User

Untitled

a guest
Feb 21st, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. function Payment(callback){
  2. request({
  3. method: 'POST',
  4. url: 'https://secure.snd.payu.com/pl/standard/user/oauth/authorize', //server B
  5. headers: {
  6. 'Content-Type': 'application/x-www-form-urlencoded',
  7. },
  8. body: "credentials_id"
  9. }, function (error, response, body) {
  10. callback(null, JSON.parse(body).access_token);
  11. }
  12. )
  13. }
  14.  
  15. router.post('/sendOrders', function(req, res){
  16. Payment(function(err, body){
  17. request({
  18. method: 'POST',
  19. url: 'https://secure.snd.payu.com/api/v2_1/orders/',
  20. headers: {
  21. 'Content-Type': 'application/json',
  22. 'Authorization': 'Bearer ' + body
  23. },
  24. body: JSON.stringify({
  25. "notifyUrl": "http://test:8080/notify", //server A
  26. "continueUrl": "http://test:8080/continue", //server A
  27. "customerIp": "xxxxx",
  28. "settings":{
  29. "invoiceDisabled":"true"
  30. },
  31. "products": product
  32. })
  33. }, function(error, response, body){
  34. res.send({ success: true, body: JSON.parse(body)})
  35. }) ;
  36. })
  37.  
  38. router.get('/notify', function(req, res){
  39. request({
  40. method: 'GET',
  41. url: 'http://test/notify', //server A
  42. headers: {
  43. 'Content-Type': 'application/json',
  44. },
  45. }, function(error, response, body){
  46. console.log(body)
  47. })
  48. })
Add Comment
Please, Sign In to add comment