(function(root, factory) {
if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('logtown').getLogger('/src/handlers/RetrieveFeePaymentHandler'), require('../ApiClient'), require('../api/PaymentApi'), require('../OrbipayApiError'), require('../CommonUtil'));
}
}(this, function(logger, ApiClient, PaymentApi, OrbipayApiError, CommonUtil) {
'use strict';
/**
* @module ApiClient
*/
/**
* <h3 style="color:red"> This class subject to change without prior notice, Please dont use this class directly. </h3>
* @module handlers/RetrieveFeePaymentHandler
* @class
*/
var exports = function() {
};
exports.prototype.process = function (feePayment, callback) {
var secret = feePayment.invocation_context.secret;
var host = feePayment.api_end_point;
var api_key = feePayment.invocation_context.api_key;
var auth_scheme = feePayment.invocation_context.auth_scheme;
var _this=this;
var response = {};
var exception;
try {
var api_client = new ApiClient(secret, host,api_key,auth_scheme);
var api_instance = new PaymentApi(api_client);
var channel = feePayment.invocation_context['channel'];
var client_key = feePayment.invocation_context['client_key'];
var product = feePayment.invocation_context['product'];
var timestamp;
if (feePayment.invocation_context['timestamp'])
{
timestamp = feePayment.invocation_context['timestamp'];
}
else
{
timestamp = CommonUtil.getTimeStamp();
}
var idempotent_request_key = feePayment.invocation_context['idempotent_request_key'];
var requestor_type = feePayment.invocation_context['requestor_type'];
var id_fee = feePayment['ID_FEE'];
var id_customer = feePayment['ID_CUSTOMER'];
var opts = _this.getOptions(feePayment);
var result = api_instance.retrieveFeePayment(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_fee, id_customer, opts, callback);
response['request'] = result;
return response;
} catch (e) {
exception = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(null, null, null, exception);
}
response['exception'] = exception;
return response;
}
};
exports.prototype.getOptions = function (feePayment) {
return {
'requestor': feePayment['invocation_context']['requestor'],
'x_opay_headers': feePayment['invocation_context']['X-OPAY-Headers'],
'trace_id': feePayment['invocation_context']['trace_id']
};
};
return exports;
}));