subscriptions.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup Payment Payment
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. function BxPaymentSubscriptions(oOptions) {
  11. this.init(oOptions);
  12. }
  13. BxPaymentSubscriptions.prototype = new BxPaymentMain();
  14. BxPaymentSubscriptions.prototype.init = function(oOptions) {
  15. if($.isEmptyObject(oOptions))
  16. return;
  17. this._sActionsUrl = oOptions.sActionUrl;
  18. this._sObjName = oOptions.sObjName == undefined ? 'oPmtSubscriptions' : oOptions.sObjName;
  19. this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
  20. this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
  21. };
  22. BxPaymentSubscriptions.prototype.getDetails = function(oLink, iId) {
  23. var $this = this;
  24. var oDate = new Date();
  25. this.loadingInButton(oLink, true);
  26. $.post(
  27. this._sActionsUrl + 'subscription_get_details/' + iId + '/',
  28. {
  29. _t:oDate.getTime()
  30. },
  31. function(oData){
  32. $this.loadingInButton(oLink, false);
  33. $(".bx-popup-applied:visible").dolPopupHide();
  34. $this.processResult(oData);
  35. },
  36. 'json'
  37. );
  38. };
  39. BxPaymentSubscriptions.prototype.getBilling = function(oLink, iId) {
  40. var $this = this;
  41. var oDate = new Date();
  42. this.loadingInButton(oLink, true);
  43. $.post(
  44. this._sActionsUrl + 'subscription_get_billing/' + iId + '/',
  45. {
  46. _t:oDate.getTime()
  47. },
  48. function(oData){
  49. $this.loadingInButton(oLink, false);
  50. $(".bx-popup-applied:visible").dolPopupHide();
  51. $this.processResult(oData);
  52. },
  53. 'json'
  54. );
  55. };
  56. BxPaymentSubscriptions.prototype.changeBilling = function(oLink, iId) {
  57. var $this = this;
  58. var oDate = new Date();
  59. this.loadingInButton(oLink, true);
  60. $.post(
  61. this._sActionsUrl + 'subscription_change_billing/' + iId + '/',
  62. {
  63. _t:oDate.getTime()
  64. },
  65. function(oData){
  66. $this.loadingInButton(oLink, false);
  67. $(".bx-popup-applied:visible").dolPopupHide();
  68. $this.processResult(oData);
  69. },
  70. 'json'
  71. );
  72. };
  73. BxPaymentSubscriptions.prototype.requestCancelation = function(oLink, iId) {
  74. var $this = this;
  75. var oDate = new Date();
  76. this.loadingInButton(oLink, true);
  77. $.post(
  78. this._sActionsUrl + 'subscription_cancelation/' + iId + '/',
  79. {
  80. _t:oDate.getTime()
  81. },
  82. function(oData){
  83. $this.loadingInButton(oLink, false);
  84. $(".bx-popup-applied:visible").dolPopupHide();
  85. $this.processResult(oData);
  86. },
  87. 'json'
  88. );
  89. };
  90. /** @} */