Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Payment(callback){
- request({
- method: 'POST',
- url: 'https://secure.snd.payu.com/pl/standard/user/oauth/authorize', //server B
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- },
- body: "credentials_id"
- }, function (error, response, body) {
- callback(null, JSON.parse(body).access_token);
- }
- )
- }
- router.post('/sendOrders', function(req, res){
- Payment(function(err, body){
- request({
- method: 'POST',
- url: 'https://secure.snd.payu.com/api/v2_1/orders/',
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer ' + body
- },
- body: JSON.stringify({
- "notifyUrl": "http://test:8080/notify", //server A
- "continueUrl": "http://test:8080/continue", //server A
- "customerIp": "xxxxx",
- "settings":{
- "invoiceDisabled":"true"
- },
- "products": product
- })
- }, function(error, response, body){
- res.send({ success: true, body: JSON.parse(body)})
- }) ;
- })
- router.get('/notify', function(req, res){
- request({
- method: 'GET',
- url: 'http://test/notify', //server A
- headers: {
- 'Content-Type': 'application/json',
- },
- }, function(error, response, body){
- console.log(body)
- })
- })
Add Comment
Please, Sign In to add comment