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_network_response')) {
  113. 113 : var PaymentNetworkResponse = require('./PaymentNetworkResponse');
  114. 114 : obj['payment_network_response'] = PaymentNetworkResponse.constructFromObject(data['payment_network_response']);
  115. 115 : }
  116. 116 : if (data.hasOwnProperty('audit_info')) {
  117. 117 : var AuditInfo = require('./AuditInfo');
  118. 118 : obj['audit_info'] = AuditInfo.constructFromObject(data['audit_info']);
  119. 119 : }
  120. 120 : if (data.hasOwnProperty('ID_FEE')) {
  121. 121 : obj['ID_FEE'] = data['ID_FEE'];
  122. 122 : }
  123. 123 : if (data.hasOwnProperty('ID_CUSTOMER')) {
  124. 124 : obj['ID_CUSTOMER'] = data['ID_CUSTOMER'];
  125. 125 : }
  126. 126 : }
  127. 127 : return obj;
  128. 128 : };
  129. 129 :
  130. 130 :
  131. 131 : exports.prototype = Object.create(Base.prototype);
  132. 132 : exports.prototype.constructor = exports;
  133. 133 :
  134. 134 : /**
  135. 135 : * The unique identifier assigned by Orbipay to the payment.
  136. 136 : * @member {String} id
  137. 137 : */
  138. 138 : exports.prototype['id'] = undefined;
  139. 139 : /**
  140. 140 : * This URL fetches the details of payment.
  141. 141 : * @member {String} url
  142. 142 : */
  143. 143 : exports.prototype['url'] = undefined;
  144. 144 : /**
  145. 145 : * @member {Fee} fee
  146. 146 : */
  147. 147 : exports.prototype['fee'] = undefined;
  148. 148 : /**
  149. 149 : * The status of the payment.
  150. 150 : * @member {String} status
  151. 151 : */
  152. 152 : exports.prototype['status'] = undefined;
  153. 153 : /**
  154. 154 : * The fulfillment method for the payment.
  155. 155 : * @member {String} payment_method
  156. 156 : */
  157. 157 : exports.prototype['payment_method'] = undefined;
  158. 158 : /**
  159. 159 : * The confirmation number or reference provided to the customer for the payment.
  160. 160 : * @member {String} confirmation_number
  161. 161 : */
  162. 162 : exports.prototype['confirmation_number'] = undefined;
  163. 163 : /**
  164. 164 : * 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.
  165. 165 : * @member {{String: String}} custom_fields
  166. 166 : */
  167. 167 : exports.prototype['custom_fields'] = undefined;
  168. 168 : /**
  169. 169 : * 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.
  170. 170 : * @member {String} currency_code3d
  171. 171 : */
  172. 172 : exports.prototype['currency_code3d'] = undefined;
  173. 173 : /**
  174. 174 : * 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.
  175. 175 : * @member {String} amount
  176. 176 : */
  177. 177 : exports.prototype['amount'] = undefined;
  178. 178 : /**
  179. 179 : * This is never returned by Orbipay. This needs to be passed to Orbipay when making or editing a payment with a card funding account.
  180. 180 : * @member {String} card_cvv_number
  181. 181 : */
  182. 182 : exports.prototype['card_cvv_number'] = undefined;
  183. 183 : /**
  184. 184 : * The date on which the payment is scheduled to be made. It must be in ISO8601 full-date format, namely, YYYY-MM-DD.
  185. 185 : * @member {String} payment_date
  186. 186 : */
  187. 187 : exports.prototype['payment_date'] = undefined;
  188. 188 : /**
  189. 189 : * The schedule type for the payment. This defaults to one_time_payment.
  190. 190 : * @member {String} payment_schedule_type
  191. 191 : */
  192. 192 : exports.prototype['payment_schedule_type'] = undefined;
  193. 193 : /**
  194. 194 : * 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.
  195. 195 : * @member {String} payment_request_date
  196. 196 : */
  197. 197 : exports.prototype['payment_request_date'] = undefined;
  198. 198 : /**
  199. 199 : * 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.
  200. 200 : * @member {String} payment_amount_type
  201. 201 : */
  202. 202 : exports.prototype['payment_amount_type'] = undefined;
  203. 203 : /**
  204. 204 : * The unique identifier in the client system for the payment.
  205. 205 : * @member {String} payment_reference
  206. 206 : */
  207. 207 : exports.prototype['payment_reference'] = undefined;
  208. 208 : /**
  209. 209 : * 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.
  210. 210 : * @member {String} expected_payment_settlement_date
  211. 211 : */
  212. 212 : exports.prototype['expected_payment_settlement_date'] = undefined;
  213. 213 : /**
  214. 214 : * The date on which the payment is captured in Orbipay. It must be in ISO8601 full-date format, namely, YYYY-MM-DD.
  215. 215 : * @member {String} payment_entry_date
  216. 216 : */
  217. 217 : exports.prototype['payment_entry_date'] = undefined;
  218. 218 : /**
  219. 219 : * The date on which the ACH returns is received by Orbipay.
  220. 220 : * @member {String} payment_return_date
  221. 221 : */
  222. 222 : exports.prototype['payment_return_date'] = undefined;
  223. 223 : /**
  224. 224 : * The ACH return code or the chargeback code received from Visa/Mastercard, in the event of returned payments.
  225. 225 : * @member {String} return_code
  226. 226 : */
  227. 227 : exports.prototype['return_code'] = undefined;
  228. 228 : /**
  229. 229 : * 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.
  230. 230 : * @member {String} payment_notification_email
  231. 231 : */
  232. 232 : exports.prototype['payment_notification_email'] = undefined;
  233. 233 : /**
  234. 234 : * 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.
  235. 235 : * @member {String} comments
  236. 236 : */
  237. 237 : exports.prototype['comments'] = undefined;
  238. 238 : /**
  239. 239 : * The status of payment which says whether the payment is deleted or not
  240. 240 : * @member {String} deleted
  241. 241 : */
  242. 242 : exports.prototype['deleted'] = undefined;
  243. 243 : /**
  244. 244 : * @member {Customer} customer
  245. 245 : */
  246. 246 : exports.prototype['customer'] = undefined;
  247. 247 : /**
  248. 248 : * @member {FundingAccount} funding_account
  249. 249 : */
  250. 250 : exports.prototype['funding_account'] = undefined;
  251. 251 : /**
  252. 252 : * @member {CustomerAccount} customer_account
  253. 253 : */
  254. 254 : exports.prototype['customer_account'] = undefined;
  255. 255 : /**
  256. 256 : * @member {PaymentNetworkResponse} payment_network_response
  257. 257 : */
  258. 258 : exports.prototype['payment_network_response'] = undefined;
  259. 259 : /**
  260. 260 : * @member {AuditInfo} audit_info
  261. 261 : */
  262. 262 : exports.prototype['audit_info'] = undefined;
  263. 263 : /**
  264. 264 : * The unique identifier assigned by OrbiPay to the FeePayment.
  265. 265 : * @member {String} ID_FEE
  266. 266 : */
  267. 267 : exports.prototype['ID_FEE'] = undefined;
  268. 268 : /**
  269. 269 : * The unique identifier assigned by OrbiPay to the customer.
  270. 270 : * @member {String} ID_CUSTOMER
  271. 271 : */
  272. 272 : exports.prototype['ID_CUSTOMER'] = undefined;
  273. 273 :
  274. 274 : /**
  275. 275 : * @param {String} client_key - The client_key of FeePayment.
  276. 276 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  277. 277 : */
  278. 278 : exports.prototype.forClient = function (client_key) {
  279. 279 : var _this = this;
  280. 280 : Base.prototype.forClient.call(_this,client_key);
  281. 281 : return _this;
  282. 282 : };
  283. 283 : /**
  284. 284 : * @param {String} channel - The channel of FeePayment.
  285. 285 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  286. 286 : */
  287. 287 : exports.prototype.videChannel = function (channel) {
  288. 288 : var _this = this;
  289. 289 : Base.prototype.videChannel.call(_this,channel);
  290. 290 : return _this;
  291. 291 : };
  292. 292 : /**
  293. 293 : * @param {String} payment_amount_type - The payment_amount_type of FeePayment.
  294. 294 : * @param {String} amount - The amount of FeePayment.
  295. 295 : * @param {String} payment_date - The payment_date of FeePayment.
  296. 296 : * @param {String} payment_request_date - The payment_request_date of FeePayment.
  297. 297 : * @param {String} card_cvv_number - The card_cvv_number of FeePayment.
  298. 298 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  299. 299 : */
  300. 300 : exports.prototype.withDetails = function (payment_amount_type, amount, payment_date, payment_request_date, card_cvv_number) {
  301. 301 : var _this = this;
  302. 302 :
  303. 303 : _this['payment_amount_type'] = payment_amount_type;
  304. 304 :
  305. 305 : _this['amount'] = amount;
  306. 306 :
  307. 307 : _this['payment_date'] = payment_date;
  308. 308 :
  309. 309 : _this['payment_request_date'] = payment_request_date;
  310. 310 :
  311. 311 : _this['card_cvv_number'] = card_cvv_number;
  312. 312 :
  313. 313 :
  314. 314 : return _this;
  315. 315 : };
  316. 316 : /**
  317. 317 : * @param {FundingAccount} funding_account - The funding_account of FeePayment.
  318. 318 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  319. 319 : */
  320. 320 : exports.prototype.fromAccount = function (funding_account) {
  321. 321 : var _this = this;
  322. 322 :
  323. 323 : _this['funding_account'] = funding_account;
  324. 324 :
  325. 325 :
  326. 326 : return _this;
  327. 327 : };
  328. 328 : /**
  329. 329 : * @param {CustomerAccount} customer_account - The customer_account of FeePayment.
  330. 330 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  331. 331 : */
  332. 332 : exports.prototype.toAccount = function (customer_account) {
  333. 333 : var _this = this;
  334. 334 :
  335. 335 : _this['customer_account'] = customer_account;
  336. 336 :
  337. 337 :
  338. 338 : return _this;
  339. 339 : };
  340. 340 : /**
  341. 341 : * @param {String} payment_reference - The payment_reference of FeePayment.
  342. 342 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  343. 343 : */
  344. 344 : exports.prototype.withReference = function (payment_reference) {
  345. 345 : var _this = this;
  346. 346 :
  347. 347 : _this['payment_reference'] = payment_reference;
  348. 348 :
  349. 349 :
  350. 350 : return _this;
  351. 351 : };
  352. 352 : /**
  353. 353 : * @param {String} status - The status of FeePayment.
  354. 354 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  355. 355 : */
  356. 356 : exports.prototype.withStatus = function (status) {
  357. 357 : var _this = this;
  358. 358 :
  359. 359 : _this['status'] = status;
  360. 360 :
  361. 361 :
  362. 362 : return _this;
  363. 363 : };
  364. 364 : /**
  365. 365 : * @param {{String: String}} custom_fields - The custom_fields of FeePayment.
  366. 366 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  367. 367 : */
  368. 368 : exports.prototype.withCustomFields = function (custom_fields) {
  369. 369 : var _this = this;
  370. 370 :
  371. 371 : _this['custom_fields'] = custom_fields;
  372. 372 :
  373. 373 :
  374. 374 : return _this;
  375. 375 : };
  376. 376 : /**
  377. 377 : * @param {String} comments - The comments of FeePayment.
  378. 378 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  379. 379 : */
  380. 380 : exports.prototype.withMemo = function (comments) {
  381. 381 : var _this = this;
  382. 382 :
  383. 383 : _this['comments'] = comments;
  384. 384 :
  385. 385 :
  386. 386 : return _this;
  387. 387 : };
  388. 388 : /**
  389. 389 : * @param {Fee} fee - The fee of FeePayment.
  390. 390 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  391. 391 : */
  392. 392 : exports.prototype.withFee = function (fee) {
  393. 393 : var _this = this;
  394. 394 :
  395. 395 : _this['fee'] = fee;
  396. 396 :
  397. 397 :
  398. 398 : return _this;
  399. 399 : };
  400. 400 : /**
  401. 401 : * @param {String} ID_CUSTOMER - The ID_CUSTOMER of FeePayment.
  402. 402 : * @return {module:wrappers/FeePayment} The instance of <code>FeePayment</code>.
  403. 403 : */
  404. 404 : exports.prototype.forCustomer = function (id_customer) {
  405. 405 : var _this = this;
  406. 406 :
  407. 407 : _this['ID_CUSTOMER'] = id_customer;
  408. 408 :
  409. 409 :
  410. 410 : return _this;
  411. 411 : };
  412. 412 :
  413. 413 : exports.prototype.retrievedBy = function (requestor, requestor_type) {
  414. 414 : var _this = this;
  415. 415 : _this.requestedBy(requestor, requestor_type);
  416. 416 : return _this;
  417. 417 : };
  418. 418 :
  419. 419 : exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
  420. 420 : var _this = this;
  421. 421 : var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
  422. 422 : try {
  423. 423 : var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
  424. 424 : if (callback) {
  425. 425 : callback(response['exception'], response['data'])
  426. 426 : }
  427. 427 : } catch (e) {
  428. 428 : exception = OrbipayApiError.getDefaultException(e);
  429. 429 : if (callback) {
  430. 430 : callback(exception)
  431. 431 : }
  432. 432 : }
  433. 433 : };
  434. 434 : try {
  435. 435 : _this.withContext(invocation_context, live_mode, api_end_point);
  436. 436 : var handler = new RetrieveFeePaymentHandler();
  437. 437 : if (callback && CommonUtil.isFunction(callback)) {
  438. 438 : return handler.process(_this, internalCallback);
  439. 439 : } else {
  440. 440 : return handler.process(_this);
  441. 441 : }
  442. 442 : }
  443. 443 : catch (e){
  444. 444 : var error = OrbipayApiError.getDefaultException(e);
  445. 445 : if (callback) {
  446. 446 : callback(error)
  447. 447 : }
  448. 448 : }
  449. 449 : };
  450. 450 :
  451. 451 : return exports;
  452. 452 :
  453. 453 : }));