(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/DeleteRecordPaymentHandler'), require('../ApiClient'), require('../api/RecordedPaymentApi'), require('../OrbipayApiError'), require('../CommonUtil'));
}
}(this, function(logger, ApiClient, RecordedPaymentApi, 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/DeleteRecordPaymentHandler
* @class
*/
var exports = function() {
};
exports.prototype.process = function (recordedPayment, callback) {
var secret = recordedPayment.invocation_context.secret;
var host = recordedPayment.api_end_point;
var api_key = recordedPayment.invocation_context.api_key;
var auth_scheme = recordedPayment.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 RecordedPaymentApi(api_client);
var channel = recordedPayment.invocation_context['channel'];
var client_key = recordedPayment.invocation_context['client_key'];
var product = recordedPayment.invocation_context['product'];
var timestamp;
if (recordedPayment.invocation_context['timestamp'])
{
timestamp = recordedPayment.invocation_context['timestamp'];
}
else
{
timestamp = CommonUtil.getTimeStamp();
}
var idempotent_request_key = recordedPayment.invocation_context['idempotent_request_key'];
var requestor_type = recordedPayment.invocation_context['requestor_type'];
var id_payment = recordedPayment['ID_PAYMENT'];
var delete_recorded_payment_request = _this.populate_body(recordedPayment);
var opts = _this.getOptions(recordedPayment);
var result = api_instance.deleteRecordPayment(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_payment, delete_recorded_payment_request, 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 (recordedPayment) {
return {
'requestor': recordedPayment['invocation_context']['requestor'],
'x_opay_headers': recordedPayment['invocation_context']['X-OPAY-Headers']
};
};
exports.prototype.populate_body = function(recordedPayment){
var DeleteRecordedPaymentRequest = require('../models/DeleteRecordedPaymentRequest');
return DeleteRecordedPaymentRequest.constructFromObject(recordedPayment);
};
return exports;
}));