- 1 :
- 2 :
- 3 :
(function(root, factory) {
- 4 :
- 5 :
if (typeof module === 'object' && module.exports) {
- 6 :
// CommonJS-like environments that support module.exports, like Node.
- 7 :
module.exports = factory(require('../ApiClient'), require('./InvocationContext'), require('../CommonUtil'), require('../ResponseWrapper'), require('./Base')
- 8 :
, require('../handlers/RetrievePaymentsHandler'), require('../OrbipayApiError'));
- 9 :
}
- 10 :
}(this, function(ApiClient, InvocationContext, CommonUtil, ResponseWrapper, Base, RetrievePaymentsHandler, OrbipayApiError) {
- 11 :
'use strict';
- 12 :
- 13 :
/**
- 14 :
* The Payments wrapper module.
- 15 :
* @module wrappers/Payments
- 16 :
*/
- 17 :
var exports = function() {
- 18 :
- 19 :
};
- 20 :
exports.constructFromObject = function (data, obj) {
- 21 :
if (data) {
- 22 :
obj = obj || new exports();
- 23 :
if (data.hasOwnProperty('list')) {
- 24 :
var Payment = require('./Payment');
- 25 :
obj['list'] = ApiClient.convertToType(data['list'], [Payment]);
- 26 :
}
- 27 :
if (data.hasOwnProperty('total_results_count')) {
- 28 :
obj['total_results_count'] = data['total_results_count'];
- 29 :
}
- 30 :
if (data.hasOwnProperty('has_more_results')) {
- 31 :
obj['has_more_results'] = data['has_more_results'];
- 32 :
}
- 33 :
if (data.hasOwnProperty('url')) {
- 34 :
obj['url'] = data['url'];
- 35 :
}
- 36 :
if (data.hasOwnProperty('from_index')) {
- 37 :
obj['from_index'] = data['from_index'];
- 38 :
}
- 39 :
if (data.hasOwnProperty('to_index')) {
- 40 :
obj['to_index'] = data['to_index'];
- 41 :
}
- 42 :
if (data.hasOwnProperty('query_id')) {
- 43 :
obj['query_id'] = data['query_id'];
- 44 :
}
- 45 :
if (data.hasOwnProperty('id_customer')) {
- 46 :
obj['id_customer'] = data['id_customer'];
- 47 :
}
- 48 :
if (data.hasOwnProperty('id_funding_account')) {
- 49 :
obj['id_funding_account'] = data['id_funding_account'];
- 50 :
}
- 51 :
if (data.hasOwnProperty('id_customer_account')) {
- 52 :
obj['id_customer_account'] = data['id_customer_account'];
- 53 :
}
- 54 :
if (data.hasOwnProperty('confirmation_number')) {
- 55 :
obj['confirmation_number'] = data['confirmation_number'];
- 56 :
}
- 57 :
if (data.hasOwnProperty('status')) {
- 58 :
obj['status'] = data['status'];
- 59 :
}
- 60 :
if (data.hasOwnProperty('payment_schedule_type')) {
- 61 :
obj['payment_schedule_type'] = data['payment_schedule_type'];
- 62 :
}
- 63 :
if (data.hasOwnProperty('payment_method')) {
- 64 :
obj['payment_method'] = data['payment_method'];
- 65 :
}
- 66 :
if (data.hasOwnProperty('from_date')) {
- 67 :
obj['from_date'] = data['from_date'];
- 68 :
}
- 69 :
if (data.hasOwnProperty('to_date')) {
- 70 :
obj['to_date'] = data['to_date'];
- 71 :
}
- 72 :
if (data.hasOwnProperty('page_size')) {
- 73 :
obj['page_size'] = data['page_size'];
- 74 :
}
- 75 :
}
- 76 :
return obj;
- 77 :
};
- 78 :
- 79 :
- 80 :
exports.prototype = Object.create(Base.prototype);
- 81 :
exports.prototype.constructor = exports;
- 82 :
- 83 :
/**
- 84 :
* @member [Payment] list
- 85 :
*/
- 86 :
exports.prototype['list'] = undefined;
- 87 :
/**
- 88 :
* total number of payments available with matching criteria
- 89 :
* @member {String} total_results_count
- 90 :
*/
- 91 :
exports.prototype['total_results_count'] = undefined;
- 92 :
/**
- 93 :
* true if there are more results or pages
- 94 :
* @member {String} has_more_results
- 95 :
*/
- 96 :
exports.prototype['has_more_results'] = undefined;
- 97 :
/**
- 98 :
* This URL fetches the next or previous set of payments, based on the presence of after_object or before_object parameter.
- 99 :
* @member {String} url
- 100 :
*/
- 101 :
exports.prototype['url'] = undefined;
- 102 :
/**
- 103 :
* The id of the object before which the previous set of objects are to be retrieved.
- 104 :
* @member {String} from_index
- 105 :
*/
- 106 :
exports.prototype['from_index'] = undefined;
- 107 :
/**
- 108 :
* The id of the object after which the next set of objects are to be retrieved.
- 109 :
* @member {String} to_index
- 110 :
*/
- 111 :
exports.prototype['to_index'] = undefined;
- 112 :
/**
- 113 :
* The query id of the object.
- 114 :
* @member {String} query_id
- 115 :
*/
- 116 :
exports.prototype['query_id'] = undefined;
- 117 :
/**
- 118 :
* The unique identifier assigned by EBPP to the customer.
- 119 :
* @member {String} id_customer
- 120 :
*/
- 121 :
exports.prototype['id_customer'] = undefined;
- 122 :
/**
- 123 :
* The unique identifier assigned by EBPP to the funding account
- 124 :
* @member {String} id_funding_account
- 125 :
*/
- 126 :
exports.prototype['id_funding_account'] = undefined;
- 127 :
/**
- 128 :
* The unique identifier assigned by EBPP to the customer account
- 129 :
* @member {String} id_customer_account
- 130 :
*/
- 131 :
exports.prototype['id_customer_account'] = undefined;
- 132 :
/**
- 133 :
* The confirmation number or reference provided to the customer for the successful payment.
- 134 :
* @member {String} confirmation_number
- 135 :
*/
- 136 :
exports.prototype['confirmation_number'] = undefined;
- 137 :
/**
- 138 :
* The status of the payment. This can take multiple values in the format key=value1&key=value2....
- 139 :
* @member [String] status
- 140 :
*/
- 141 :
exports.prototype['status'] = undefined;
- 142 :
/**
- 143 :
* The schedule type for the payment setup. This can take multiple values in the format key=value1&key=value2....
- 144 :
* @member [String] payment_schedule_type
- 145 :
*/
- 146 :
exports.prototype['payment_schedule_type'] = undefined;
- 147 :
/**
- 148 :
* The fulfillment method for the payment.
- 149 :
* @member [String] payment_method
- 150 :
*/
- 151 :
exports.prototype['payment_method'] = undefined;
- 152 :
/**
- 153 :
* The date from which payments, matching the criteria specified, need to be retrieved.
- 154 :
* @member {String} from_date
- 155 :
*/
- 156 :
exports.prototype['from_date'] = undefined;
- 157 :
/**
- 158 :
* The date upto which payments, matching the criteria specified, need to be retrieved.
- 159 :
* @member {String} to_date
- 160 :
*/
- 161 :
exports.prototype['to_date'] = undefined;
- 162 :
/**
- 163 :
* The maximum number of objects returned in the query.
- 164 :
* @member {String} page_size
- 165 :
*/
- 166 :
exports.prototype['page_size'] = undefined;
- 167 :
- 168 :
/**
- 169 :
* @param {String} client_key - The client_key of Payments.
- 170 :
* @return {module:wrappers/Payments} The instance of <code>Payments</code>.
- 171 :
*/
- 172 :
exports.prototype.forClient = function (client_key) {
- 173 :
var _this = this;
- 174 :
Base.prototype.forClient.call(_this,client_key);
- 175 :
return _this;
- 176 :
};
- 177 :
/**
- 178 :
* @param {String} channel - The channel of Payments.
- 179 :
* @return {module:wrappers/Payments} The instance of <code>Payments</code>.
- 180 :
*/
- 181 :
exports.prototype.videChannel = function (channel) {
- 182 :
var _this = this;
- 183 :
Base.prototype.videChannel.call(_this,channel);
- 184 :
return _this;
- 185 :
};
- 186 :
/**
- 187 :
* @param {String} id_funding_account - The id_funding_account of Payments.
- 188 :
* @param {String} id_customer_account - The id_customer_account of Payments.
- 189 :
* @param {String} confirmation_number - The confirmation_number of Payments.
- 190 :
* @param [String] payment_schedule_type - The payment_schedule_type of Payments.
- 191 :
* @param {String} from_date - The from_date of Payments.
- 192 :
* @param {String} to_date - The to_date of Payments.
- 193 :
* @param [String] status - The status of Payments.
- 194 :
* @param {String} page_size - The page_size of Payments.
- 195 :
* @param {String} query_id - The query_id of Payments.
- 196 :
* @param {String} from_index - The from_index of Payments.
- 197 :
* @param {String} to_index - The to_index of Payments.
- 198 :
* @return {module:wrappers/Payments} The instance of <code>Payments</code>.
- 199 :
*/
- 200 :
exports.prototype.findBy = function (filterParameters) {
- 201 :
var _this = this;
- 202 :
if(filterParameters){
- 203 :
- 204 :
_this['id_funding_account'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'id_funding_account', false);
- 205 :
- 206 :
_this['id_customer_account'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'id_customer_account', false);
- 207 :
- 208 :
_this['confirmation_number'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'confirmation_number', false);
- 209 :
_this['payment_schedule_type'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'payment_schedule_type', true);
- 210 :
- 211 :
- 212 :
_this['from_date'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'from_date', false);
- 213 :
- 214 :
_this['to_date'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'to_date', false);
- 215 :
_this['status'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'status', true);
- 216 :
- 217 :
- 218 :
_this['page_size'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'page_size', false);
- 219 :
- 220 :
_this['query_id'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'query_id', false);
- 221 :
- 222 :
_this['from_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'from_index', false);
- 223 :
- 224 :
_this['to_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'to_index', false);
- 225 :
}
- 226 :
return _this;
- 227 :
};
- 228 :
/**
- 229 :
* @param {String} id_customer - The id_customer of Payments.
- 230 :
* @return {module:wrappers/Payments} The instance of <code>Payments</code>.
- 231 :
*/
- 232 :
exports.prototype.forCustomer = function (id_customer) {
- 233 :
var _this = this;
- 234 :
- 235 :
_this['id_customer'] = id_customer;
- 236 :
- 237 :
- 238 :
return _this;
- 239 :
};
- 240 :
- 241 :
exports.prototype.retrievedBy = function (requestor, requestor_type) {
- 242 :
var _this = this;
- 243 :
_this.requestedBy(requestor, requestor_type);
- 244 :
return _this;
- 245 :
};
- 246 :
- 247 :
exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
- 248 :
var _this = this;
- 249 :
var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
- 250 :
try {
- 251 :
var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
- 252 :
if (callback) {
- 253 :
callback(response['exception'], response['data'])
- 254 :
}
- 255 :
} catch (e) {
- 256 :
exception = OrbipayApiError.getDefaultException(e);
- 257 :
if (callback) {
- 258 :
callback(exception)
- 259 :
}
- 260 :
}
- 261 :
};
- 262 :
try {
- 263 :
_this.withContext(invocation_context, live_mode, api_end_point);
- 264 :
var handler = new RetrievePaymentsHandler();
- 265 :
if (callback && CommonUtil.isFunction(callback)) {
- 266 :
return handler.process(_this, internalCallback);
- 267 :
} else {
- 268 :
return handler.process(_this);
- 269 :
}
- 270 :
}
- 271 :
catch (e){
- 272 :
var error = OrbipayApiError.getDefaultException(e);
- 273 :
if (callback) {
- 274 :
callback(error)
- 275 :
}
- 276 :
}
- 277 :
};
- 278 :
- 279 :
return exports;
- 280 :
- 281 :
}));