(function(root, factory) {
if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('./InvocationContext'), require('../CommonUtil'), require('../ResponseWrapper'), require('./Base')
, require('../handlers/DeleteRecordPaymentHandler')
, require('../handlers/GetRecordPaymentHandler')
, require('../handlers/RecordPaymentHandler'), require('../OrbipayApiError'));
}
}(this, function(ApiClient, InvocationContext, CommonUtil, ResponseWrapper, Base, DeleteRecordPaymentHandler, GetRecordPaymentHandler, RecordPaymentHandler, OrbipayApiError) {
'use strict';
/**
* The RecordedPayment wrapper module.
* @module wrappers/RecordedPayment
*/
var exports = function(id_payment) {
var _this = this;
Base.call(_this);
_this['ID_PAYMENT'] = id_payment;
_this.id = id_payment;
};
/**
* Constructs a <code>RecordedPayment</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:wrappers/RecordedPayment} obj Optional instance to populate.
* @return {module:wrappers/RecordedPayment} The populated <code>RecordedPayment</code> instance.
*/
exports.constructFromObject = function (data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id')) {
obj['id'] = data['id'];
}
if (data.hasOwnProperty('url')) {
obj['url'] = data['url'];
}
if (data.hasOwnProperty('fee')) {
var Fee = require('./Fee');
obj['fee'] = Fee.constructFromObject(data['fee']);
}
if (data.hasOwnProperty('status')) {
obj['status'] = data['status'];
}
if (data.hasOwnProperty('payment_method')) {
obj['payment_method'] = data['payment_method'];
}
if (data.hasOwnProperty('token')) {
obj['token'] = data['token'];
}
if (data.hasOwnProperty('confirmation_number')) {
obj['confirmation_number'] = data['confirmation_number'];
}
if (data.hasOwnProperty('custom_fields')) {
obj['custom_fields'] = data['custom_fields'];
}
if (data.hasOwnProperty('currency_code3d')) {
obj['currency_code3d'] = data['currency_code3d'];
}
if (data.hasOwnProperty('amount')) {
obj['amount'] = data['amount'];
}
if (data.hasOwnProperty('payment_date')) {
obj['payment_date'] = data['payment_date'];
}
if (data.hasOwnProperty('payment_schedule_type')) {
obj['payment_schedule_type'] = data['payment_schedule_type'];
}
if (data.hasOwnProperty('payment_amount_type')) {
obj['payment_amount_type'] = data['payment_amount_type'];
}
if (data.hasOwnProperty('payment_reference')) {
obj['payment_reference'] = data['payment_reference'];
}
if (data.hasOwnProperty('payment_entry_date')) {
obj['payment_entry_date'] = data['payment_entry_date'];
}
if (data.hasOwnProperty('payment_return_date')) {
obj['payment_return_date'] = data['payment_return_date'];
}
if (data.hasOwnProperty('comments')) {
obj['comments'] = data['comments'];
}
if (data.hasOwnProperty('return_code')) {
obj['return_code'] = data['return_code'];
}
if (data.hasOwnProperty('customer')) {
var Customer = require('./Customer');
obj['customer'] = Customer.constructFromObject(data['customer']);
}
if (data.hasOwnProperty('funding_account')) {
var FundingAccount = require('./FundingAccount');
obj['funding_account'] = FundingAccount.constructFromObject(data['funding_account']);
}
if (data.hasOwnProperty('customer_account')) {
var CustomerAccount = require('./CustomerAccount');
obj['customer_account'] = CustomerAccount.constructFromObject(data['customer_account']);
}
if (data.hasOwnProperty('audit_info')) {
var AuditInfo = require('./AuditInfo');
obj['audit_info'] = AuditInfo.constructFromObject(data['audit_info']);
}
if (data.hasOwnProperty('ID_PAYMENT')) {
obj['ID_PAYMENT'] = data['ID_PAYMENT'];
}
}
return obj;
};
exports.prototype = Object.create(Base.prototype);
exports.prototype.constructor = exports;
/**
* The unique identifier assigned by EBPP to the payment.
* @member {String} id
*/
exports.prototype['id'] = undefined;
/**
* This URL fetches the details of payment.
* @member {String} url
*/
exports.prototype['url'] = undefined;
/**
* @member {Fee} fee
*/
exports.prototype['fee'] = undefined;
/**
* The status of the payment.
* @member {String} status
*/
exports.prototype['status'] = undefined;
/**
* The non fulfillment method for the payment.
* @member {String} payment_method
*/
exports.prototype['payment_method'] = undefined;
/**
* The token is used to uniquely identify the payment, such as the POS token.
* @member {String} token
*/
exports.prototype['token'] = undefined;
/**
* The confirmation number or reference provided to the customer for the payment.
* @member {String} confirmation_number
*/
exports.prototype['confirmation_number'] = undefined;
/**
* The additional information or meta-information that EBPP can accept, maintain and transmit back to the client. The custom fields need to be configured with EBPP before they can be accepted. EBPP would reject custom fields that are not pre-configured. Please contact <a href = \"mailto: support@billerpayments.com\">support@billerpayments.com</a> for more information on configuring and using custom fields.
* @member {{String: String}} custom_fields
*/
exports.prototype['custom_fields'] = undefined;
/**
* The three-letter currency code in the ISO4217 format, in uppercase, for the card account. It must be a currency supported by EBPP. This defaults to USD.
* @member {String} currency_code3d
*/
exports.prototype['currency_code3d'] = undefined;
/**
* The amount being paid. In case the payment_amount_type is 'other', the amount needs to be specified. In other cases, this is derived from the payment_amount_type.
* @member {String} amount
*/
exports.prototype['amount'] = undefined;
/**
* The date on which the payment is scheduled to be made. It must be in ISO8601 full-date format, namely, YYYY-MM-DD.
* @member {String} payment_date
*/
exports.prototype['payment_date'] = undefined;
/**
* The schedule type for the payment. This defaults to one_time_payment.
* @member {String} payment_schedule_type
*/
exports.prototype['payment_schedule_type'] = undefined;
/**
* The type of amount, as per the bill/statement, that is being paid. The payment amount is derived from the amount type selected for the payment. This defaults to other.
* @member {String} payment_amount_type
*/
exports.prototype['payment_amount_type'] = undefined;
/**
* The unique identifier in the client system for the payment.
* @member {String} payment_reference
*/
exports.prototype['payment_reference'] = undefined;
/**
* The date on which the payment is captured in EBPP. It must be in ISO8601 full-date format, namely, YYYY-MM-DD.
* @member {String} payment_entry_date
*/
exports.prototype['payment_entry_date'] = undefined;
/**
* The date on which the ACH returns is received by EBPP.
* @member {String} payment_return_date
*/
exports.prototype['payment_return_date'] = undefined;
/**
* Comments that can be used to recollect the operation performed on the resource object. API clients need to ensure that no sensitive information is passed in the memo. Alacriti (EBPP) is not responsible for the security of any sensitive information that may be passed as part of the memo.
* @member {String} comments
*/
exports.prototype['comments'] = undefined;
/**
* The ACH return code or the chargeback code received from Visa/Mastercard, in the event of returned payments.
* @member {String} return_code
*/
exports.prototype['return_code'] = undefined;
/**
* @member {Customer} customer
*/
exports.prototype['customer'] = undefined;
/**
* @member {FundingAccount} funding_account
*/
exports.prototype['funding_account'] = undefined;
/**
* @member {CustomerAccount} customer_account
*/
exports.prototype['customer_account'] = undefined;
/**
* @member {AuditInfo} audit_info
*/
exports.prototype['audit_info'] = undefined;
/**
* The unique identifier assigned by EBPP to the payment.
* @member {String} ID_PAYMENT
*/
exports.prototype['ID_PAYMENT'] = undefined;
/**
* @param {String} client_key - The client_key of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.forClient = function (client_key) {
var _this = this;
Base.prototype.forClient.call(_this,client_key);
return _this;
};
/**
* @param {String} channel - The channel of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.videChannel = function (channel) {
var _this = this;
Base.prototype.videChannel.call(_this,channel);
return _this;
};
/**
* @param {String} payment_amount_type - The payment_amount_type of RecordedPayment.
* @param {String} amount - The amount of RecordedPayment.
* @param {String} payment_date - The payment_date of RecordedPayment.
* @param {String} payment_method - The payment_method of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.withDetails = function (payment_amount_type, amount, payment_date, payment_method) {
var _this = this;
_this['payment_amount_type'] = payment_amount_type;
_this['amount'] = amount;
_this['payment_date'] = payment_date;
_this['payment_method'] = payment_method;
return _this;
};
/**
* @param {FundingAccount} funding_account - The funding_account of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.fromAccount = function (funding_account) {
var _this = this;
_this['funding_account'] = funding_account;
return _this;
};
/**
* @param {String} token - The token of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.withToken = function (token) {
var _this = this;
_this['token'] = token;
return _this;
};
/**
* @param {CustomerAccount} customer_account - The customer_account of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.toAccount = function (customer_account) {
var _this = this;
_this['customer_account'] = customer_account;
return _this;
};
/**
* @param {String} payment_reference - The payment_reference of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.withReference = function (payment_reference) {
var _this = this;
_this['payment_reference'] = payment_reference;
return _this;
};
/**
* @param {{String: String}} custom_fields - The custom_fields of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.withCustomFields = function (custom_fields) {
var _this = this;
_this['custom_fields'] = custom_fields;
return _this;
};
/**
* @param {String} comments - The comments of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.withMemo = function (comments) {
var _this = this;
_this['comments'] = comments;
return _this;
};
/**
* @param {Fee} fee - The fee of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.withFee = function (fee) {
var _this = this;
_this['fee'] = fee;
return _this;
};
/**
* @param {Customer} customer - The customer of RecordedPayment.
* @return {module:wrappers/RecordedPayment} The instance of <code>RecordedPayment</code>.
*/
exports.prototype.withCustomer = function (customer) {
var _this = this;
_this['customer'] = customer;
return _this;
};
exports.prototype.deletedBy = function (requestor, requestor_type) {
var _this = this;
_this.requestedBy(requestor, requestor_type);
return _this;
};
exports.prototype.retrievedBy = function (requestor, requestor_type) {
var _this = this;
_this.requestedBy(requestor, requestor_type);
return _this;
};
exports.prototype.createdBy = function (requestor, requestor_type) {
var _this = this;
_this.requestedBy(requestor, requestor_type);
return _this;
};
exports.prototype.delete = function (invocation_context, callback, live_mode, api_end_point) {
var _this = this;
var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
try {
var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
if (callback) {
callback(response['exception'], response['data'])
}
} catch (e) {
exception = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(exception)
}
}
};
try {
_this.withContext(invocation_context, live_mode, api_end_point);
var handler = new DeleteRecordPaymentHandler();
if (callback && CommonUtil.isFunction(callback)) {
return handler.process(_this, internalCallback);
} else {
return handler.process(_this);
}
}
catch (e){
var error = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(error)
}
}
};
exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
var _this = this;
var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
try {
var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
if (callback) {
callback(response['exception'], response['data'])
}
} catch (e) {
exception = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(exception)
}
}
};
try {
_this.withContext(invocation_context, live_mode, api_end_point);
var handler = new GetRecordPaymentHandler();
if (callback && CommonUtil.isFunction(callback)) {
return handler.process(_this, internalCallback);
} else {
return handler.process(_this);
}
}
catch (e){
var error = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(error)
}
}
};
exports.prototype.create = function (invocation_context, callback, live_mode, api_end_point) {
var _this = this;
var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
try {
var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
if (callback) {
callback(response['exception'], response['data'])
}
} catch (e) {
exception = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(exception)
}
}
};
try {
_this.withContext(invocation_context, live_mode, api_end_point);
var handler = new RecordPaymentHandler();
if (callback && CommonUtil.isFunction(callback)) {
return handler.process(_this, internalCallback);
} else {
return handler.process(_this);
}
}
catch (e){
var error = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(error)
}
}
};
return exports;
}));