Skip to content

Commit

Permalink
Revert "[EP-2486] Prevent invalid payment methods from being chosen" (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bizz authored Mar 13, 2024
1 parent f5b2c65 commit 7341b36
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,13 @@ class ExistingPaymentMethodsController {
}

selectDefaultPaymentMethod () {
const paymentMethods = this.paymentMethods.filter(paymentMethod => this.validPaymentMethod(paymentMethod))
const chosenPaymentMethod = find(paymentMethods, { chosen: true })
const chosenPaymentMethod = find(this.paymentMethods, { chosen: true })
if (chosenPaymentMethod) {
// Select the payment method previously chosen for the order
this.selectedPaymentMethod = chosenPaymentMethod
} else {
// Select the first payment method
this.selectedPaymentMethod = paymentMethods[0]
this.selectedPaymentMethod = this.paymentMethods[0]
}
this.switchPayment()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ describe('checkout', () => {
})

describe('selectDefaultPaymentMethod', () => {
beforeEach(() => {
jest.spyOn(self.controller, 'validPaymentMethod').mockReturnValue(true)
})

it('should choose the payment method that is marked chosen in cortex', () => {
self.controller.paymentMethods = [
{
Expand Down Expand Up @@ -189,38 +185,6 @@ describe('checkout', () => {
expect(self.controller.selectedPaymentMethod).toEqual({ selectAction: 'first uri' })
})

it('should choose the first payment method if the one marked chosen in cortex is invalid', () => {
jest.spyOn(self.controller, 'validPaymentMethod').mockImplementation(paymentMethod => paymentMethod.selectAction === 'first uri')
self.controller.paymentMethods = [
{
selectAction: 'first uri'
},
{
selectAction: 'second uri',
chosen: true
}
]
self.controller.selectDefaultPaymentMethod()

expect(self.controller.selectedPaymentMethod).toEqual({ selectAction: 'first uri' })
})

it('should set selectedPaymentMethod to undefined if none are valid', () => {
jest.spyOn(self.controller, 'validPaymentMethod').mockReturnValue(undefined)
self.controller.paymentMethods = [
{
selectAction: 'first uri'
},
{
selectAction: 'second uri',
chosen: true
}
]
self.controller.selectDefaultPaymentMethod()

expect(self.controller.selectedPaymentMethod).toBeUndefined()
})

it('should check whether or not the fee coverage should be altered based on selected payment type', () => {
jest.spyOn(self.controller, 'switchPayment').mockImplementation(() => {})
self.controller.paymentMethods = [
Expand Down
2 changes: 1 addition & 1 deletion src/app/checkout/step-2/step-2.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<button id="previousStepButton1" class="btn btn-default" ng-click="$ctrl.changeStep({newStep: 'contact'})">Previous Step</button>
</div>
<div class="col-sm-5 col-sm-offset-2">
<button id="continueCheckoutButton" class="btn btn-primary pull-right btn-block-mobile" ng-click="$ctrl.submit()" ng-disabled="!$ctrl.selectedPaymentMethod || $ctrl.loadingPaymentMethods || $ctrl.paymentFormState === 'loading' || $ctrl.paymentFormState === 'encrypting'">
<button id="continueCheckoutButton" class="btn btn-primary pull-right btn-block-mobile" ng-click="$ctrl.submit()" ng-disabled="$ctrl.loadingPaymentMethods || $ctrl.paymentFormState === 'loading' || $ctrl.paymentFormState === 'encrypting'">
Continue
</button>
<button id="previousStepButton2" class="btn btn-link btn-block visible-xs" ng-click="$ctrl.changeStep({newStep: 'contact'})"><i class="fa fa-angle-left"></i> Previous Step</button>
Expand Down

0 comments on commit 7341b36

Please sign in to comment.