(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/RetrieveRecordPaymentsHandler'), 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/RetrieveRecordPaymentsHandler
* @class
*/
var exports = function() {
};
exports.prototype.process = function (recordedPayments, callback) {
var secret = recordedPayments.invocation_context.secret;
var host = recordedPayments.api_end_point;
var api_key = recordedPayments.invocation_context.api_key;
var auth_scheme = recordedPayments.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 = recordedPayments.invocation_context['channel'];
var client_key = recordedPayments.invocation_context['client_key'];
var product = recordedPayments.invocation_context['product'];
var timestamp;
if (recordedPayments.invocation_context['timestamp'])
{
timestamp = recordedPayments.invocation_context['timestamp'];
}
else
{
timestamp = CommonUtil.getTimeStamp();
}
var idempotent_request_key = recordedPayments.invocation_context['idempotent_request_key'];
var requestor_type = recordedPayments.invocation_context['requestor_type'];
var id_customer = recordedPayments['id_customer'];
var opts = _this.getOptions(recordedPayments);
var result = api_instance.retrieveRecordPayments(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, 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 (recordedPayments) {
return {
'id_customer': recordedPayments['id_customer'],
'requestor': recordedPayments['invocation_context']['requestor'],
'x_opay_headers': recordedPayments['invocation_context']['X-OPAY-Headers'],
'trace_id': recordedPayments['invocation_context']['trace_id'],
'id_customer_account': recordedPayments['id_customer_account'],
'confirmation_number': recordedPayments['confirmation_number'],
'payment_method': recordedPayments['payment_method'],
'status': recordedPayments['status'],
'from_date': recordedPayments['from_date'],
'to_date': recordedPayments['to_date'],
'page_size': recordedPayments['page_size'],
'query_id': recordedPayments['query_id'],
'from_index': recordedPayments['from_index'],
'to_index': recordedPayments['to_index']
};
};
return exports;
}));