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