-
Notifications
You must be signed in to change notification settings - Fork 212
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
Changes from all commits
fc4026f
7956856
fd7ed91
028bebe
7a2ae82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -543,29 +543,42 @@ export default class ApplePayCustomerStrategy implements CustomerStrategy { | |
} | ||
|
||
private async _getBraintreeDeviceData() { | ||
const data = await this._braintreeIntegrationService.getDataCollector(); | ||
const braintreePaymentMethod = this._paymentIntegrationService | ||
.getState() | ||
.getPaymentMethod(ApplePayGatewayType.BRAINTREE); | ||
|
||
return data.deviceData; | ||
if (braintreePaymentMethod?.clientToken) { | ||
const data = await this._braintreeIntegrationService.getDataCollector(); | ||
|
||
return data.deviceData; | ||
} | ||
} | ||
|
||
private async _initializeBraintreeIntegrationService() { | ||
const state = await this._paymentIntegrationService.loadPaymentMethod( | ||
ApplePayGatewayType.BRAINTREE, | ||
); | ||
try { | ||
// TODO: temporary solution to initialize the braintree payment method to get a clientToken to create a braintree client instance | ||
// TODO: this approach should be removed in the future | ||
// TODO: Jira ticket for tracking purpose: https://bigcommercecloud.atlassian.net/browse/PAYPAL-4122 | ||
await this._paymentIntegrationService.loadPaymentMethod(ApplePayGatewayType.BRAINTREE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please create a Jira ticket for tracking purpose. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @animesh1987 @bc-peng i have updated PR with adding JIRA ticket |
||
|
||
const storeConfig = state.getStoreConfigOrThrow(); | ||
const state = this._paymentIntegrationService.getState(); | ||
|
||
const braintreePaymentMethod: PaymentMethod = state.getPaymentMethodOrThrow( | ||
ApplePayGatewayType.BRAINTREE, | ||
); | ||
const storeConfig = state.getStoreConfigOrThrow(); | ||
|
||
if (!braintreePaymentMethod.clientToken || !braintreePaymentMethod.initializationData) { | ||
throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod); | ||
} | ||
const braintreePaymentMethod: PaymentMethod = state.getPaymentMethodOrThrow( | ||
ApplePayGatewayType.BRAINTREE, | ||
); | ||
|
||
this._braintreeIntegrationService.initialize( | ||
braintreePaymentMethod.clientToken, | ||
storeConfig, | ||
); | ||
if (!braintreePaymentMethod.clientToken || !braintreePaymentMethod.initializationData) { | ||
throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod); | ||
} | ||
|
||
this._braintreeIntegrationService.initialize( | ||
braintreePaymentMethod.clientToken, | ||
storeConfig, | ||
); | ||
} catch (_) { | ||
// we don't need to do anything in this block | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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