Advertisement
Guest User

Untitled

a guest
Apr 8th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. var username = '123',
  2. password = '123',
  3. url = 'https://' + username + ':' + password + '@api.sofort.com/api/xml';
  4.  
  5. request({url: url}, function (error, respa, body) { // Im endeffekt muss ich im selben Schritt auch noch den XML string
  6. // der drunter zu finden ist da iwie mit rein bekommen
  7. // Do more stuff with 'body' here
  8. if (error) throw error;
  9. console.log(respa);
  10. console.log(body);
  11. });
  12.  
  13. var success_url = "url";
  14. var abort_url = "url";
  15. var notification_url = "url";
  16. var amount = 0;
  17. if(product === "wochenplan"){
  18. amount = "9.90";
  19. }else if(product === "basic"){
  20. amount = "14.90";
  21. }else{
  22. amount = "19.90";
  23. }
  24. var XML = '<?xml version="1.0" encoding="UTF-8" ?>'+
  25. '<multipay>'+
  26. '<project_id>1</project_id>'+
  27. '<interface_version>pn_test_1</interface_version>'+
  28. '<amount>'+amount+'</amount>'+
  29. '<currency_code>EUR</currency_code>'+
  30. '<reasons>'+
  31. '<reason>Testueberweisung</reason>'+
  32. '<reason>-TRANSACTION-</reason>'+
  33. '</reasons>'+
  34. '<user_variables>'+
  35. '<user_variable>test</user_variable>'+
  36. '</user_variables>'+
  37. '<success_url>'+success_url+'</success_url>'+
  38. '<success_link_redirect>1</success_link_redirect>'+
  39. '<abort_url>'+abort_url+'</abort_url>'+
  40. '<notification_emails>'+
  41. '<notification_email>office@snoutnet.com</notification_email>'+
  42. '</notification_emails>'+
  43. '<su />'+
  44. '</multipay>';
  45. request({
  46. url: "https://api.sofort.com/api/xml",
  47. method: "POST",
  48. headers: {
  49. "content-type": "application/xml",
  50. },
  51. body: XML
  52. }, function (error, resp, body){
  53. console.log(body);
  54. // response.send(resp);
  55. });
  56. }else{
  57. console.log("Exiting with due to wrong product.");
  58. response.send("error");
  59. return;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement