1. 1 :
  2. 2 : (function(root, factory) {
  3. 3 :
  4. 4 : if (typeof module === 'object' && module.exports) {
  5. 5 : // CommonJS-like environments that support module.exports, like Node.
  6. 6 : module.exports = factory(require('logtown').getLogger('/src/handlers/RetrievePaymentSetupsHandler'), require('../ApiClient'), require('../api/PaymentSetupApi'), require('../OrbipayApiError'), require('../CommonUtil'));
  7. 7 : }
  8. 8 : }(this, function(logger, ApiClient, PaymentSetupApi, OrbipayApiError, CommonUtil) {
  9. 9 : 'use strict';
  10. 10 :
  11. 11 : /**
  12. 12 : * @module ApiClient
  13. 13 : */
  14. 14 :
  15. 15 : /**
  16. 16 : * <h3 style="color:red"> This class subject to change without prior notice, Please dont use this class directly. </h3>
  17. 17 :
  18. 18 : * @module handlers/RetrievePaymentSetupsHandler
  19. 19 : * @class
  20. 20 : */
  21. 21 :
  22. 22 : var exports = function() {
  23. 23 : };
  24. 24 :
  25. 25 : exports.prototype.process = function (paymentSetups, callback) {
  26. 26 :
  27. 27 : var secret = paymentSetups.invocation_context.secret;
  28. 28 : var host = paymentSetups.api_end_point;
  29. 29 : var api_key = paymentSetups.invocation_context.api_key;
  30. 30 : var auth_scheme = paymentSetups.invocation_context.auth_scheme;
  31. 31 : var _this=this;
  32. 32 : var response = {};
  33. 33 : var exception;
  34. 34 : try {
  35. 35 : var api_client = new ApiClient(secret, host,api_key,auth_scheme);
  36. 36 : var api_instance = new PaymentSetupApi(api_client);
  37. 37 : var channel = paymentSetups.invocation_context['channel'];
  38. 38 : var client_key = paymentSetups.invocation_context['client_key'];
  39. 39 : var product = paymentSetups.invocation_context['product'];
  40. 40 : var timestamp;
  41. 41 : if (paymentSetups.invocation_context['timestamp'])
  42. 42 : {
  43. 43 : timestamp = paymentSetups.invocation_context['timestamp'];
  44. 44 : }
  45. 45 : else
  46. 46 : {
  47. 47 : timestamp = CommonUtil.getTimeStamp();
  48. 48 : }
  49. 49 : var idempotent_request_key = paymentSetups.invocation_context['idempotent_request_key'];
  50. 50 : var requestor_type = paymentSetups.invocation_context['requestor_type'];
  51. 51 : var opts = _this.getOptions(paymentSetups);
  52. 52 : var result = api_instance.retrievePaymentSetups(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, opts, callback);
  53. 53 : response['request'] = result;
  54. 54 : return response;
  55. 55 : } catch (e) {
  56. 56 : exception = OrbipayApiError.getDefaultException(e);
  57. 57 : if (callback) {
  58. 58 : callback(null, null, null, exception);
  59. 59 : }
  60. 60 : response['exception'] = exception;
  61. 61 : return response;
  62. 62 : }
  63. 63 : };
  64. 64 :
  65. 65 : exports.prototype.getOptions = function (paymentSetups) {
  66. 66 : return {
  67. 67 : 'requestor': paymentSetups['invocation_context']['requestor'],
  68. 68 : 'x_opay_headers': paymentSetups['invocation_context']['X-OPAY-Headers'],
  69. 69 : 'trace_id': paymentSetups['invocation_context']['trace_id'],
  70. 70 : 'id_customer': paymentSetups['id_customer'],
  71. 71 : 'id_funding_account': paymentSetups['id_funding_account'],
  72. 72 : 'id_customer_account': paymentSetups['id_customer_account'],
  73. 73 : 'confirmation_number': paymentSetups['confirmation_number'],
  74. 74 : 'status': paymentSetups['status'],
  75. 75 : 'payment_setup_schedule_type': paymentSetups['payment_setup_schedule_type'],
  76. 76 : 'from_date': paymentSetups['from_date'],
  77. 77 : 'to_date': paymentSetups['to_date'],
  78. 78 : 'page_size': paymentSetups['page_size'],
  79. 79 : 'query_id': paymentSetups['query_id'],
  80. 80 : 'from_index': paymentSetups['from_index'],
  81. 81 : 'to_index': paymentSetups['to_index']
  82. 82 : };
  83. 83 : };
  84. 84 :
  85. 85 :
  86. 86 : return exports;
  87. 87 : }));