-
Notifications
You must be signed in to change notification settings - Fork 0
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
[INTER-3851] Braintree Paypal buttons #35
Conversation
BoldCole
commented
Jun 18, 2024
- Implement paypal buttons for braintree paypal
src/braintree/getBraintreeJsUrls.ts
Outdated
} = braintreeConstants; | ||
version ??= jsVersion; | ||
const clientJsURL = `${base}/${version}/${clientJs}`; | ||
const appleJsURL = `${base}/${version}/${appleJs}`; | ||
const braintreeGoogleJsURL = `${base}/${version}/${googleJs}`; | ||
const dataCollectorJsURL = `${base}/${version}/${dataCollectorJs}`; | ||
const fastlaneJsURL = `${base}/${version}/${fastlaneJs}`; | ||
const paypalCheckoutURL = `${base}/${version}/${paypalCheckoutUrl}`; |
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.
Having two variable names that only differ in their case, seems like asking for trouble. My two bits.
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.
Fixed
|
||
interface IEstimateShippingLinesResponse { | ||
// Yes this is the correct key | ||
'shipping options': IShippingLine[]; |
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 this formatted key coming from checkout or the platform connector?
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.
Checkout
return paypalCheckout.createPayment({ | ||
currency: getCurrency().iso_code, | ||
flow: 'checkout', | ||
amount: totals.totalAmountDue / 100, |
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.
Should we have a currency helper here? Is this going to cause off by one cent issues?
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.
Fixed
const shippingAddress = result.details.shippingAddress; | ||
const billingAddress = result.details.billingAddress; | ||
const shippingCountry = shippingAddress ? countries.find(c => c.iso_code === shippingAddress.countryCode) : null; | ||
const billingCountry = countries.find(c => c.iso_code === billingAddress.countryCode); |
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.
Are we guarenteed to have a billing address here? Or should you add a null check for billing address like you did for shipping address?
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.
Yes, there MUST be a billing address
const shippingOption = order.purchase_units[0].shipping?.options?.find(o => o.selected); | ||
|
||
/* istanbul ignore next */ | ||
if (!billingProvince || !billingCountry) { |
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.
what if shippingProvince
or shippingCountry
are undefined? Do we need to throw an error, or is it okay to continue with empty values?
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.
It's okay for those values to be empty in the case where shipping is not required for the cart.
const paypalButtonDiv = document.createElement('div'); | ||
const paypalButtonDivId = 'ppcp-paypal-express-payment-button'; | ||
paypalButtonDiv.id = paypalButtonDivId; | ||
paypalButtonDiv.dataset.testid = paypalButtonDivId; |
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.
Can you add the class name express-payment
to both the paypal and paylater buttons so they match the existing express pay buttons. This was recently an issue with the ppcp buttons: #34
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.
Fixed