Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place order button is disabled after re-render of payment component #2506

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,16 @@ define(

renderCheckoutComponent: function() {
this.isPlaceOrderAllowed(false);
let configuration = this.buildComponentConfiguration(this.paymentMethod(), this.paymentMethodsExtraInfo());

this.mountPaymentMethodComponent(this.paymentMethod(), configuration);
const configuration = this.buildComponentConfiguration(
this.paymentMethod(),
this.paymentMethodsExtraInfo()
);
this.mountPaymentMethodComponent(this.paymentMethod(), configuration).then(
function() {
const hasBillingAddress = quote.billingAddress() !== null
this.isPlaceOrderAllowed(hasBillingAddress);
}
Comment on lines +190 to +193

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran across this issue while debugging why isPlaceOrderActionAllowed was false for a non-Adyen payment method and I tried your solution.

I'm getting Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'isPlaceOrderAllowed').

Switching the callback to an arrow function retained the proper this context and resolved the TypeError.

Suggested change
function() {
const hasBillingAddress = quote.billingAddress() !== null
this.isPlaceOrderAllowed(hasBillingAddress);
}
() => {
const hasBillingAddress = quote.billingAddress() !== null
this.isPlaceOrderAllowed(hasBillingAddress);
}

);
},

buildComponentConfiguration: function (paymentMethod, paymentMethodsExtraInfo) {
Expand Down Expand Up @@ -222,14 +229,14 @@ define(
return this.item.method;
},

mountPaymentMethodComponent(paymentMethod, configuration)
mountPaymentMethodComponent: async function(paymentMethod, configuration)
{
let self = this;

try {
const containerId = '#' + paymentMethod.type + 'Container';

this.paymentComponent = adyenCheckout.mountPaymentMethodComponent(
this.paymentComponent = await adyenCheckout.mountPaymentMethodComponent(
self.checkoutComponent,
self.getTxVariant(),
configuration,
Expand Down
Loading