From 9f39f87a2665d314b9285127b12162ee7c57fa15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Guti=C3=A9rrez?= Date: Fri, 6 Dec 2024 10:43:23 -0600 Subject: [PATCH] [5.4] MSTR-327: Fix Payment Method Pop-up After Successful ACH Setup (#1252) --- .../myaccount/submodules/billing/billing.js | 6 ++--- .../submodules/creditCard/creditCard.js | 24 +++++-------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/apps/myaccount/submodules/billing/billing.js b/src/apps/myaccount/submodules/billing/billing.js index 04b83d306..4e3dac2d1 100644 --- a/src/apps/myaccount/submodules/billing/billing.js +++ b/src/apps/myaccount/submodules/billing/billing.js @@ -481,7 +481,7 @@ define(function(require) { return next(null, mainData); } - self.getPaymentMethods({ + self.billingGetPaymentMethods({ success: function(payments) { next(null, _.assign({}, mainData, { payments: payments })); }, @@ -644,7 +644,7 @@ define(function(require) { monster.waterfall([ function reloadPaymentMethods(next) { - self.getPaymentMethods({ + self.billingGetPaymentMethods({ success: function(payments) { next(null, payments); }, @@ -1144,7 +1144,7 @@ define(function(require) { }); }, - getPaymentMethods: function(args) { + billingGetPaymentMethods: function(args) { var self = this; monster.request({ diff --git a/src/apps/myaccount/submodules/creditCard/creditCard.js b/src/apps/myaccount/submodules/creditCard/creditCard.js index e06027362..43f8c6c32 100644 --- a/src/apps/myaccount/submodules/creditCard/creditCard.js +++ b/src/apps/myaccount/submodules/creditCard/creditCard.js @@ -576,21 +576,7 @@ define(function(require) { } }); }, - billing: function(next) { - self.callApi({ - resource: 'billing.get', - data: { - accountId: self.accountId, - generateError: false - }, - success: function(data) { - next(null, data.data); - }, - error: function() { - next(true); - } - }); - } + billing: _.bind(self.billingGetBillingData, self) }, function(err, results) { if (err) { return; @@ -599,13 +585,15 @@ define(function(require) { var account = results.account, billing = results.billing, isSurchargeAccepted = self.billingIsSurchargeAccepted(account), - hasCreditCards = !_.chain(billing).get('credit_cards', []).isEmpty().value(), + hasCreditCards = !_.chain(billing).get('customer.credit_cards', []).isEmpty().value(), country = _.get(account, ['contact', 'billing', 'country']), region = _.get(account, ['contact', 'billing', 'region']), surcharge = self.billingGetCreditCardSurcharge(country, region), - isCardAccepted = !!surcharge; + isCardAccepted = !!surcharge, + hasVerifiedACH = _.chain(billing).get('payments', []).some({ type: 'ach', verified: true, 'default': true }).value(); - if (!hasCreditCards || country !== 'US' || (isCardAccepted && isSurchargeAccepted)) { + if ( + !hasCreditCards || country !== 'US' || (isCardAccepted && isSurchargeAccepted) || hasVerifiedACH) { return; }