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

feat(payment): PAYPAL-4051 Apple Pay throws an error in checkout due to attempting to load Braintree information #2469

Merged
merged 5 commits into from May 15, 2024

Conversation

bc-nick
Copy link
Contributor

@bc-nick bc-nick commented Apr 18, 2024

What?

Added try {} catch {} to solve the applepay issue with braintree initialization process when credit card feature is disabled

Why?

To get the collect data the credit card feature must to be enabled otherwise the request for getting braintree data will be failed. In this case we can not be able to use braintree integration for collecting data because we do not have clientToken for correct initialization

This is a temporary solution for a quick fix

Testing / Proof

Manual testing

@bigcommerce/team-checkout @bigcommerce/team-payments

Copy link
Contributor

@serhii-tkachenko serhii-tkachenko left a comment

Choose a reason for hiding this comment

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

Please add a video proof and unit tests

storeConfig,
);
} catch (_) {
return noop();
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not necessary to add noop here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment to prevent lint error for empty block

storeConfig,
);
} catch (_) {
return noop();
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not necessary to add noop here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same

Copy link
Contributor

@serhii-tkachenko serhii-tkachenko left a comment

Choose a reason for hiding this comment

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

Thanks for a fix. LGTM! 👍


return data.deviceData;
if (braintreePaymentMethod?.clientToken) {
const data = await this._braintreeIntegrationService.getDataCollector();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way we can avoid BT calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can not avid it because we need to initialize BT to collect device data based on merchant configuration

ApplePayGatewayType.BRAINTREE,
);
try {
await this._paymentIntegrationService.loadPaymentMethod(ApplePayGatewayType.BRAINTREE);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seemed to be called in initialize path, is there a reason why we need to load braintree payment method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we need to get a BT client instance to get collect device data

Copy link
Contributor

Choose a reason for hiding this comment

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

#2469 (comment)

Is this the same as here? Since we might be doing the same thing twice? Also maybe add a TODO with a JIRA for plans to fix this i.e. avoid making this call and maybe pass the data as part of apple pay config load.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@animesh1987 it's not the same. This is the best way to fix the issue at this point. It's a quick fix. I've already talked to our team about it, and it's going to take some time to fix it on the backend side. When another way will be found, the Braintree initialization process will be removed. At the moment we have some issue with generating clientToken on the backend side to pass it to the applepay configuration.

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems ok, can we please add a TODO with JIRA to address the issue above so we have a plan.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@animesh1987 added TODO without JIRA. We need to create a ticket for backend developers with description. But they are aware of this problem

Copy link
Contributor

Choose a reason for hiding this comment

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

Please create a Jira ticket for tracking purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@animesh1987 @bc-peng i have updated PR with adding JIRA ticket

storeConfig,
);
} catch (_) {
// we don't need to do anything in this block
Copy link
Contributor

Choose a reason for hiding this comment

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

I see // we don't need to do anything in this block appears twice in the PR.
Could you please explain what would happen if an error occurs in the middle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bc-peng This will mean that the braintree payment method cannot be initialized because we have enabled the appropriate feature in the CP

@bc-nick bc-nick merged commit 7599f66 into bigcommerce:master May 15, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants