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

[INTER-3851] Braintree Paypal buttons #35

Closed
wants to merge 1 commit into from
Closed

[INTER-3851] Braintree Paypal buttons #35

wants to merge 1 commit into from

Conversation

BoldCole
Copy link
Contributor

  • Implement paypal buttons for braintree paypal

} = 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}`;

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.

Copy link
Contributor Author

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[];
Copy link
Contributor

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?

Copy link
Contributor Author

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,
Copy link
Contributor

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?

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants