1. 1 :
  2. 2 :
  3. 3 : (function(root, factory) {
  4. 4 :
  5. 5 : if (typeof module === 'object' && module.exports) {
  6. 6 : // CommonJS-like environments that support module.exports, like Node.
  7. 7 : module.exports = factory(require('../ApiClient'), require('./InvocationContext'), require('../CommonUtil'), require('../ResponseWrapper'), require('./Base')
  8. 8 : , require('../handlers/RetrieveFeePaymentHandler'), require('../OrbipayApiError'));
  9. 9 : }
  10. 10 : }(this, function(ApiClient, InvocationContext, CommonUtil, ResponseWrapper, Base, RetrieveFeePaymentHandler, OrbipayApiError) {
  11. 11 : 'use strict';
  12. 12 :
  13. 13 : /**
  14. 14 : * The FeePayment wrapper module.
  15. 15 : * @module wrappers/FeePayment
  16. 16 : */
  17. 17 : var exports = function(id_fee) {
  18. 18 : var _this = this;
  19. 19 : Base.call(_this);
  20. 20 : _this['ID_FEE'] = id_fee;
  21. 21 : };
  22. 22 :
  23. 23 : /**
  24. 24 : * Constructs a <code>FeePayment</code> from a plain JavaScript object, optionally creating a new instance.
  25. 25 : * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
  26. 26 : * @param {Object} data The plain JavaScript object bearing properties of interest.
  27. 27 : * @param {module:wrappers/FeePayment} obj Optional instance to populate.
  28. 28 : * @return {module:wrappers/FeePayment} The populated <code>FeePayment</code> instance.
  29. 29 : */
  30. 30 : exports.constructFromObject = function (data, obj) {
  31. 31 : if (data) {
  32. 32 : obj = obj || new exports();
  33. 33 : if (data.hasOwnProperty('id')) {
  34. 34 : obj['id'] = data['id'];
  35. 35 : }
  36. 36 : if (data.hasOwnProperty('url')) {
  37. 37 : obj['url'] = data['url'];
  38. 38 : }
  39. 39 : if (data.hasOwnProperty('fee')) {
  40. 40 : var Fee = require('./Fee');
  41. 41 : obj['fee'] = Fee.constructFromObject(data['fee']);
  42. 42 : }
  43. 43 : if (data.hasOwnProperty('status')) {
  44. 44 : obj['status'] = data['status'];
  45. 45 : }
  46. 46 : if (data.hasOwnProperty('payment_method')) {
  47. 47 : obj['payment_method'] = data['payment_method'];
  48. 48 : }
  49. 49 : if (data.hasOwnProperty('confirmation_number')) {
  50. 50 : obj['confirmation_number'] = data['confirmation_number'];
  51. 51 : }
  52. 52 : if (data.hasOwnProperty('custom_fields')) {
  53. 53 : obj['custom_fields'] = data['custom_fields'];
  54. 54 : }
  55. 55 : if (data.hasOwnProperty('currency_code3d')) {
  56. 56 : obj['currency_code3d'] = data['currency_code3d'];
  57. 57 : }
  58. 58 : if (data.hasOwnProperty('amount')) {
  59. 59 : obj['amount'] = data['amount'];
  60. 60 : }
  61. 61 : if (data.hasOwnProperty('card_cvv_number')) {
  62. 62 : obj['card_cvv_number'] = data['card_cvv_number'];
  63. 63 : }
  64. 64 : if (data.hasOwnProperty('payment_date')) {
  65. 65 : obj['payment_date'] = data['payment_date'];
  66. 66 : }
  67. 67 : if (data.hasOwnProperty('payment_schedule_type')) {
  68. 68 : obj['payment_schedule_type'] = data['payment_schedule_type'];
  69. 69 : }
  70. 70 : if (data.hasOwnProperty('payment_request_date')) {
  71. 71 : obj['payment_request_date'] = data['payment_request_date'];
  72. 72 : }
  73. 73 : if (data.hasOwnProperty('payment_amount_type')) {
  74. 74 : obj['payment_amount_type'] = data['payment_amount_type'];
  75. 75 : }
  76. 76 : if (data.hasOwnProperty('payment_reference')) {
  77. 77 : obj['payment_reference'] = data['payment_reference'];
  78. 78 : }
  79. 79 : if (data.hasOwnProperty('expected_payment_settlement_date')) {
  80. 80 : obj['expected_payment_settlement_date'] = data['expected_payment_settlement_date'];
  81. 81 : }
  82. 82 : if (data.hasOwnProperty('payment_entry_date')) {
  83. 83 : obj['payment_entry_date'] = data['payment_entry_date'];
  84. 84 : }
  85. 85 : if (data.hasOwnProperty('payment_return_date')) {
  86. 86 : obj['payment_return_date'] = data['payment_return_date'];
  87. 87 : }
  88. 88 : if (data.hasOwnProperty('return_code')) {
  89. 89 : obj['return_code'] = data['return_code'];
  90. 90 : }
  91. 91 : if (data.hasOwnProperty('payment_notification_email')) {
  92. 92 : obj['payment_notification_email'] = data['payment_notification_email'];
  93. 93 : }
  94. 94 : if (data.hasOwnProperty('comments')) {
  95. 95 : obj['comments'] = data['comments'];
  96. 96 : }
  97. 97 : if (data.hasOwnProperty('deleted')) {
  98. 98 : obj['deleted'] = data['deleted'];
  99. 99 : }
  100. 100 : if (data.hasOwnProperty('customer')) {
  101. 101 : var Customer = require('./Customer');
  102. 102 : obj['customer'] = Customer.constructFromObject(data['customer']);
  103. 103 : }
  104. 104 : if (data.hasOwnProperty('funding_account')) {
  105. 105 : var FundingAccount = require('./FundingAccount');
  106. 106 : obj['funding_account'] = FundingAccount.constructFromObject(data['funding_account']);
  107. 107 : }
  108. 108 : if (data.hasOwnProperty('customer_account')) {
  109. 109 : var CustomerAccount = require('./CustomerAccount');
  110. 110 : obj['customer_account'] = CustomerAccount.constructFromObject(data['customer_account']);
  111. 111 : }
  112. 112 : if (data.hasOwnProperty('payment_authorization')) {
  113. 113 : var PaymentAuthorization = require('./PaymentAuthorization');
  114. 114 : obj['payment_authorization'] = PaymentAuthorization.constructFromObject(data['payment_authorization']);
  115. 115 : }
  116. 116 : if (data.hasOwnProperty('payment_network_response')) {
  117. 117 : var PaymentNetworkResponse = require('./PaymentNetworkResponse');
  118. 118 : obj['payment_network_response'] = PaymentNetworkResponse.constructFromObject(data['payment_network_response']);
  119. 119 : }
  120. 120 : if (data.hasOwnProperty('audit_info')) {
  121. 121 : var AuditInfo = require('./AuditInfo');
  122. 122 : obj['audit_info'] = AuditInfo.constructFromObject(data['audit_info']);
  123. 123 : }
  124. 124 : if (data.hasOwnProperty('ID_FEE')) {
  125. 125 : obj['ID_FEE'] = data['ID_FEE'];
  126. 126 : }
  127. 127 : if (data.hasOwnProperty('ID_CUSTOMER')) {
  128. 128 : obj['ID_CUSTOMER'] = data['ID_CUSTOMER'];
  129. 129 : }
  130. 130 : }
  131. 131 : return obj;
  132. 132 : };
  133. 133 :
  134. 134 :
  135. 135 : exports.prototype = Object.create(Base.prototype);
  136. 136 : exports.prototype.constructor = exports;
  137. 137 :
  138. 138 : /**
  139. 139 : * The unique identifier assigned by Orbipay to the payment.
  140. 140 : * @member {String} id
  141. 141 : */
  142. 142 : exports.prototype['id'] = undefined;
  143. 143 : /**
  144. 144 : * This URL fetches the details of payment.
  145. 145 : * @member {String} url
  146. 146 : */
  147. 147 : exports.prototype['url'] = undefined;
  148. 148 : /**
  149. 149 : * @member {Fee} fee
  150. 150 : */
  151. 151 : exports.prototype['fee'] = undefined;
  152. 152 : /**
  153. 153 : * The status of the payment.
  154. 154 : * @member {String} status
  155. 155 : */
  156. 156 : exports.prototype['status'] = undefined;
  157. 157 : /**
  158. 158 : * The fulfillment method for the payment.
  159. 159 : * @member {String} payment_method
  160. 160 : */
  161. 161 : exports.prototype['payment_method'] = undefined;
  162. 162 : /**
  163. 163 : * The confirmation number or reference provided to the customer for the payment.
  164. 164 : * @member {String} confirmation_number
  165. 165 : */
  166. 166 : exports.prototype['confirmation_number'] = undefined;
  167. 167 : /**
  168. 168 : * The additional information or meta-information that Orbipay can accept, maintain and transmit back to the client. The custom fields need to be configured with Orbipay before they can be accepted. Orbipay 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. Only the custom fields enabled for the client, in Orbipay, would be accepted in the requests.
  169. 169 : * @member {{String: String}} custom_fields
  170. 170 : */
  171. 171 : exports.prototype['custom_fields'] = undefined;
  172. 172 : /**
  173. 173 : * The three-letter currency code in the ISO4217 format, in uppercase, for the card account. It must be a currency supported by Orbipay. This defaults to USD.
  174. 174 : * @member {String} currency_code3d
  175. 175 : */
  176. 176 : exports.prototype['currency_code3d'] = undefined;
  177. 177 : /**
  178. 178 : * The amount being paid. In case the payment_amount_type is 'discounted_amount', 'penalty_amount' or 'other', the amount needs to be specified. In other cases, this is derived from the payment_amount_type.
  179. 179 : * @member {String} amount
  180. 180 : */
  181. 181 : exports.prototype['amount'] = undefined;
  182. 182 : /**
  183. 183 : * This is never returned by Orbipay. This needs to be passed to Orbipay when making or editing a payment with a card funding account.
  184. 184 : * @member {String} card_cvv_number
  185. 185 : */
  186. 186 : exports.prototype['card_cvv_number'] = undefined;
  187. 187 : /**
  188. 188 : * The date on which the payment is scheduled to be made. It must be in ISO8601 full-date format, namely, YYYY-MM-DD.
  189. 189 : * @member {String} payment_date
  190. 190 : */
  191. 191 : exports.prototype['payment_date'] = undefined;
  192. 192 : /**
  193. 193 : * The schedule type for the payment. This defaults to one_time_payment.
  194. 194 : * @member {String} payment_schedule_type
  195. 195 : */
  196. 196 : exports.prototype['payment_schedule_type'] = undefined;
  197. 197 : /**
  198. 198 : * The date on which the biller wants the payment to be settled. It must be in ISO8601 full-date format, namely, YYYY-MM-DD. This is applicable only if the client has opted for it.
  199. 199 : * @member {String} payment_request_date
  200. 200 : */
  201. 201 : exports.prototype['payment_request_date'] = undefined;
  202. 202 : /**
  203. 203 : * 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.
  204. 204 : * @member {String} payment_amount_type
  205. 205 : */
  206. 206 : exports.prototype['payment_amount_type'] = undefined;
  207. 207 : /**
  208. 208 : * The unique identifier in the client system for the payment.
  209. 209 : * @member {String} payment_reference
  210. 210 : */
  211. 211 : exports.prototype['payment_reference'] = undefined;
  212. 212 : /**
  213. 213 : * The date on which the payment is expected to be settled with the biller. It must be in ISO8601 full-date format, namely, YYYY-MM-DD.
  214. 214 : * @member {String} expected_payment_settlement_date
  215. 215 : */
  216. 216 : exports.prototype['expected_payment_settlement_date'] = undefined;
  217. 217 : /**
  218. 218 : * The date on which the payment is captured in Orbipay. It must be in ISO8601 full-date format, namely, YYYY-MM-DD.
  219. 219 : * @member {String} payment_entry_date
  220. 220 : */
  221. 221 : exports.prototype['payment_entry_date'] = undefined;
  222. 222 : /**
  223. 223 : * The date on which the ACH returns is received by Orbipay.
  224. 224 : * @member {String} payment_return_date
  225. 225 : */
  226. 226 : exports.prototype['payment_return_date'] = undefined;
  227. 227 : /**
  228. 228 : * The ACH return code or the chargeback code received from Visa/Mastercard, in the event of returned payments.
  229. 229 : * @member {String} return_code
  230. 230 : */
  231. 231 : exports.prototype['return_code'] = undefined;
  232. 232 : /**
  233. 233 : * The email address to which notifications for the payment will be sent. The notifications will be sent to the customer's email in case this is not provided.
  234. 234 : * @member {String} payment_notification_email
  235. 235 : */
  236. 236 : exports.prototype['payment_notification_email'] = undefined;
  237. 237 : /**
  238. 238 : * 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 (Orbipay) is not responsible for the security of any sensitive information that may be passed as part of the memo.
  239. 239 : * @member {String} comments
  240. 240 : */
  241. 241 : exports.prototype['comments'] = undefined;
  242. 242 : /**
  243. 243 : * The status of payment which says whether the payment is deleted or not
  244. 244 : * @member {String} deleted
  245. 245 : */
  246. 246 : exports.prototype['deleted'] = undefined;
  247. 247 : /**
  248. 248 : * @member {Customer} customer
  249. 249 : */
  250. 250 : exports.prototype['customer'] = undefined;
  251. 251 : /**
  252. 252 : * @member {FundingAccount} funding_account
  253. 253 : */
  254. 254 : exports.prototype['funding_account'] = undefined;
  255. 255 : /**
  256. 256 : * @member {CustomerAccount} customer_account
  257. 257 : */
  258. 258 : exports.prototype['customer_account'] = undefined;
  259. 259 : /**
  260. 260 : * @member {PaymentAuthorization} payment_authorization
  261. 261 : */
  262. 262 : exports.prototype['payment_authorization'] = undefined;
  263. 263 : /**
  264. 264 : * @member {PaymentNetworkResponse} payment_network_response
  265. 265 : */
  266. 266 : exports.prototype['payment_network_response'] = undefined;
  267. 267 : /**
  268. 268 : * @member {AuditInfo} audit_info
  269. 269 : */
  270. 270 : exports.prototype['audit_info'] = undefined;
  271. 271 : /**
  272. 272 : * The unique identifier assigned by OrbiPay to the FeePayment.
  273. 273 : * @member {String} ID_FEE
  274. 274 : */
  275. 275 : exports.prototype['ID_FEE'] = undefined;
  276. 276 : /**
  277. 277 : * The unique identifier assigned by OrbiPay to the customer.
  278. 278 : * @member {String} ID_CUSTOMER
  279. 279 : */
  280. 280 : exports.prototype['ID_CUSTOMER'] = undefined;
  281. 281 :
  282. 282 : /**
  283. 283 : * @param {String} client_key - The client_key of FeePayment.
  284. 284 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  285. 285 : */
  286. 286 : exports.prototype.forClient = function (client_key) {
  287. 287 : var _this = this;
  288. 288 : Base.prototype.forClient.call(_this,client_key);
  289. 289 : return _this;
  290. 290 : };
  291. 291 : /**
  292. 292 : * @param {String} channel - The channel of FeePayment.
  293. 293 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  294. 294 : */
  295. 295 : exports.prototype.videChannel = function (channel) {
  296. 296 : var _this = this;
  297. 297 : Base.prototype.videChannel.call(_this,channel);
  298. 298 : return _this;
  299. 299 : };
  300. 300 : /**
  301. 301 : * @param {String} payment_amount_type - The payment_amount_type of FeePayment.
  302. 302 : * @param {String} amount - The amount of FeePayment.
  303. 303 : * @param {String} payment_date - The payment_date of FeePayment.
  304. 304 : * @param {String} payment_request_date - The payment_request_date of FeePayment.
  305. 305 : * @param {String} card_cvv_number - The card_cvv_number of FeePayment.
  306. 306 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  307. 307 : */
  308. 308 : exports.prototype.withDetails = function (payment_amount_type, amount, payment_date, payment_request_date, card_cvv_number) {
  309. 309 : var _this = this;
  310. 310 :
  311. 311 : _this['payment_amount_type'] = payment_amount_type;
  312. 312 :
  313. 313 : _this['amount'] = amount;
  314. 314 :
  315. 315 : _this['payment_date'] = payment_date;
  316. 316 :
  317. 317 : _this['payment_request_date'] = payment_request_date;
  318. 318 :
  319. 319 : _this['card_cvv_number'] = card_cvv_number;
  320. 320 :
  321. 321 :
  322. 322 : return _this;
  323. 323 : };
  324. 324 : /**
  325. 325 : * @param {FundingAccount} funding_account - The funding_account of FeePayment.
  326. 326 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  327. 327 : */
  328. 328 : exports.prototype.fromAccount = function (funding_account) {
  329. 329 : var _this = this;
  330. 330 :
  331. 331 : _this['funding_account'] = funding_account;
  332. 332 :
  333. 333 :
  334. 334 : return _this;
  335. 335 : };
  336. 336 : /**
  337. 337 : * @param {CustomerAccount} customer_account - The customer_account of FeePayment.
  338. 338 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  339. 339 : */
  340. 340 : exports.prototype.toAccount = function (customer_account) {
  341. 341 : var _this = this;
  342. 342 :
  343. 343 : _this['customer_account'] = customer_account;
  344. 344 :
  345. 345 :
  346. 346 : return _this;
  347. 347 : };
  348. 348 : /**
  349. 349 : * @param {String} payment_reference - The payment_reference of FeePayment.
  350. 350 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  351. 351 : */
  352. 352 : exports.prototype.withReference = function (payment_reference) {
  353. 353 : var _this = this;
  354. 354 :
  355. 355 : _this['payment_reference'] = payment_reference;
  356. 356 :
  357. 357 :
  358. 358 : return _this;
  359. 359 : };
  360. 360 : /**
  361. 361 : * @param {String} status - The status of FeePayment.
  362. 362 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  363. 363 : */
  364. 364 : exports.prototype.withStatus = function (status) {
  365. 365 : var _this = this;
  366. 366 :
  367. 367 : _this['status'] = status;
  368. 368 :
  369. 369 :
  370. 370 : return _this;
  371. 371 : };
  372. 372 : /**
  373. 373 : * @param {{String: String}} custom_fields - The custom_fields of FeePayment.
  374. 374 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  375. 375 : */
  376. 376 : exports.prototype.withCustomFields = function (custom_fields) {
  377. 377 : var _this = this;
  378. 378 :
  379. 379 : _this['custom_fields'] = custom_fields;
  380. 380 :
  381. 381 :
  382. 382 : return _this;
  383. 383 : };
  384. 384 : /**
  385. 385 : * @param {String} comments - The comments of FeePayment.
  386. 386 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  387. 387 : */
  388. 388 : exports.prototype.withMemo = function (comments) {
  389. 389 : var _this = this;
  390. 390 :
  391. 391 : _this['comments'] = comments;
  392. 392 :
  393. 393 :
  394. 394 : return _this;
  395. 395 : };
  396. 396 : /**
  397. 397 : * @param {Fee} fee - The fee of FeePayment.
  398. 398 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  399. 399 : */
  400. 400 : exports.prototype.withFee = function (fee) {
  401. 401 : var _this = this;
  402. 402 :
  403. 403 : _this['fee'] = fee;
  404. 404 :
  405. 405 :
  406. 406 : return _this;
  407. 407 : };
  408. 408 : /**
  409. 409 : * @param {String} ID_CUSTOMER - The ID_CUSTOMER of FeePayment.
  410. 410 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  411. 411 : */
  412. 412 : exports.prototype.forCustomer = function (id_customer) {
  413. 413 : var _this = this;
  414. 414 :
  415. 415 : _this['ID_CUSTOMER'] = id_customer;
  416. 416 :
  417. 417 :
  418. 418 : return _this;
  419. 419 : };
  420. 420 :
  421. 421 : exports.prototype.retrievedBy = function (requestor, requestor_type) {
  422. 422 : var _this = this;
  423. 423 : _this.requestedBy(requestor, requestor_type);
  424. 424 : return _this;
  425. 425 : };
  426. 426 :
  427. 427 : exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
  428. 428 : var _this = this;
  429. 429 : var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
  430. 430 : try {
  431. 431 : var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
  432. 432 : if (callback) {
  433. 433 : callback(response['exception'], response['data'])
  434. 434 : }
  435. 435 : } catch (e) {
  436. 436 : exception = OrbipayApiError.getDefaultException(e);
  437. 437 : if (callback) {
  438. 438 : callback(exception)
  439. 439 : }
  440. 440 : }
  441. 441 : };
  442. 442 : try {
  443. 443 : _this.withContext(invocation_context, live_mode, api_end_point);
  444. 444 : var handler = new RetrieveFeePaymentHandler();
  445. 445 : if (callback && CommonUtil.isFunction(callback)) {
  446. 446 : return handler.process(_this, internalCallback);
  447. 447 : } else {
  448. 448 : return handler.process(_this);
  449. 449 : }
  450. 450 : }
  451. 451 : catch (e){
  452. 452 : var error = OrbipayApiError.getDefaultException(e);
  453. 453 : if (callback) {
  454. 454 : callback(error)
  455. 455 : }
  456. 456 : }
  457. 457 : };
  458. 458 :
  459. 459 : return exports;
  460. 460 :
  461. 461 : }));