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