Node.js

Author: Semaka 67 views
				
					var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://gateway.switch.tj/api/v1/payment-key',
  'headers': {
    'Authorization': 'Basic V2hvb3NoRGVtb0FQSTpmZGZsa2RmZXVlbzM4Mzk4',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Cookie': 'PHPSESSID=abk57kqs42fjpdfvv8a78ckfd7'
  },
  form: {
    'merchant_reference': '12312312312',
    'amount': '5.00',
    'error_url': 'https://url-to-your-success-page.co.za',
    'success_url': 'https://url-to-your-success-page.co.za',
    'cancel_url': 'https://url-to-your-success-page.co.za',
    'notify_url': 'https://url-to-your-success-page.co.za',
    'payment_type': 'credit_card'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});