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

Make Solidus Braintree compatible with Starter Frontend #102

Merged
merged 46 commits into from
Feb 22, 2023

Conversation

gsmendoza
Copy link
Contributor

@gsmendoza gsmendoza commented Feb 10, 2023

Summary

Closes #91.

Scope

This doesn't include updating the InstallGenerator to copy the frontend code to the user's app. That will be handled in #104 .

Likewise, updating InstallerGenerator to match the one from SolidusPaypalCommercePlatform will be done in #104.

Demo

screencast-bpconcjcammlapcogcnnelfmaeghhagj-2023.02.16-08_54_40.webm

Postponed tasks

TODOs

PR updates - first round

  • @elia - Document purpose for local OrderWalkthrough in commit message.
  • @elia - Install VCR and Webmock as development dependencies in client app.
  • @waiting-for-dev - Convert decorators to modules and include them to SSF controllers.
  • @waiting-for-dev - Test if the payment method is working without problems in the backend.
  • @kennyadsl - Remove CVV link.
  • Update existing payment partial based on recent updates to SSF.
    • Fix: selecting an existing payment method returns an "All fields are empty" error
    • Fix: Given I have chosen an existing payment method, I can still click on the Paypal button in the new payment method option.
    • Fix spec.

Fix CI

  • Fix transactions controller spec.
  • Update dummy app generation to fix system specs
  • Fix lint issues

Production environment

  • Ensure that assets are precompiled

Development environment

  • Fix sandbox

Documentation

  • Update README: no longer compatible with solidus_frontend.

Testing

  • Test Credit card checkout with 3D secure.
  • Test PayPal checkout.
  • Test PayPal checkout with cart button.

PR documentation

  • Demonstrate checkout.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@gsmendoza gsmendoza self-assigned this Feb 10, 2023
@gsmendoza gsmendoza force-pushed the gsmendoza/91-ssf-dummy-app branch 8 times, most recently from cdc518e to 2e76450 Compare February 15, 2023 05:04
@gsmendoza gsmendoza marked this pull request as ready for review February 15, 2023 05:11
Copy link
Member

@elia elia left a comment

Choose a reason for hiding this comment

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

LGTM overall, just left a couple of nits

spec/features/backend/new_payment_spec.rb Show resolved Hide resolved
solidus_braintree.gemspec Outdated Show resolved Hide resolved
The extension currently modifies the address factory so that it can
set a fixed zipcode for the addresses created by OrderWalkthrough.
However, once we change the frontend of this gem to
SolidusStarterFrontend and run this extension's specs together with the
frontend specs, the address modification would cause the frontend's
coupon code spec to fail. See
https://app.circleci.com/pipelines/github/solidusio/solidus_braintree/239/workflows/06370bde-ef25-49cf-8fc2-1aefd5a2f86e/jobs/623/parallel-runs/0/steps/0-108.

To prevent that, we're going to avoid modifying the address by having a
local version of the OrderWalkthrough class.
We'll be changing the frontend of the extension to
SolidusStarterFrontend in the following commits. In the resulting
update, specs for this extension and specs for the frontend will
be run together in a single dummy app. Based on my tests, it seems
the factory modifications are causing the coupon code spec from the
starter frontend spec suite to break.

Instead of modifying the address factory, we're taking the route of
creating a subclass of the factory that is namespaced to
solidus_braintree. This makes it safer to merge the extension's specs
with the starter frontend specs.

Done:

* Created solidus_braintree_address factory.
* Created with_first_and_last_name trait.
* Created with_fixed_zipcode trait.
* Used with_fixed_zipcode trait in OrderWalkthrough class.
* Copy Rakefile and dependencies from SolidusPaypalCommercePlatform
* Rename references to solidus_paypal_commerce_platform to solidus_braintree.
* Ignore dummy-app directory.
Allows extension assets to be required after StarterFrontend assets.
Consolidate `checkouts` directories to app directory.
@gsmendoza gsmendoza force-pushed the gsmendoza/91-ssf-dummy-app branch 4 times, most recently from a4c62e5 to a3ee7ed Compare February 16, 2023 04:50
Copy link
Contributor

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

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

Thanks, @gsmendoza. I left two comments about the need to monkey patch what the user owns. Also, did you try if the payment method is working without problems in the backend? See solidusio/solidus_stripe#165 for more context.

@gsmendoza gsmendoza force-pushed the gsmendoza/91-ssf-dummy-app branch from a3ee7ed to 803c246 Compare February 16, 2023 05:30
gsmendoza added a commit that referenced this pull request Feb 17, 2023
Instead of monkeypatching the controllers, which the user already owns.

#102 (comment)
@gsmendoza
Copy link
Contributor Author

@waiting-for-dev I am able to configure the SolidusBraintree payment method in the backend:

image

* Change OrdersControllerDecorator to CartsControllerDecorator.
* Introduce "with prepended view fixtures" shared context.
* Change PayPal checkout spec fixture to cart footer.
Postponing since we want to minimize the changes in this branch.
* apple_pay_button.js is already required by frontend.js
* frontend.js is already required by solidus_braintree.js
Instead of monkeypatching the controllers, which the user already owns.

#102 (comment)
@gsmendoza gsmendoza force-pushed the gsmendoza/91-ssf-dummy-app branch from 7ea093b to 08d2a32 Compare February 21, 2023 08:31
@gsmendoza
Copy link
Contributor Author

Regarding #102 (comment), I also tried changing my location to a US server via a VPN, but I'm still getting the "Merchant account does not support payment instrument." error.

Also simplify markup of partial.

Payment step UI was reorganized upstream at
solidusio/solidus_starter_frontend#321.
@gsmendoza gsmendoza force-pushed the gsmendoza/91-ssf-dummy-app branch from c9983bf to 492d47c Compare February 22, 2023 04:08
The fieldset is now always visible due to the payment step UI
reorganization in solidusio/solidus_starter_frontend#321.
This is a workaround. Note that it's still possible to trigger the
PayPal button iframe by tabbing to it and hitting enter.

The hack works for the Venmo and PayPal buttons. The Apple Pay Button is
also not yet tested as of this commit. It will be tested in
#105.
@gsmendoza gsmendoza force-pushed the gsmendoza/91-ssf-dummy-app branch from 492d47c to 96a259c Compare February 22, 2023 06:23
@gsmendoza
Copy link
Contributor Author

I've updated the PR based on your feedback and recent changes. Please see the following commits for the changes:

  • @elia - Replace OrderWalkthrough with local version - Updated commit message
  • @elia - Install vcr and webmock as test gems
  • @waiting-for-dev - Inject SolidusBraintree dependencies into controllers
  • @kennyadsl - Remove CVV link
  • @elia - I added the following commits in response to Payment step cleanup solidus_starter_frontend#321:
    • Remove radio button from existing Braintree payment partial
    • Tokenize hosted fieldset Braintree form only if fieldset is enabled
    • Fix payment method container selector in spec
    • Do not allow buttons in disabled payment-step to be clickable

@elia, regarding "Do not allow buttons in disabled payment-step to be clickable", it might be possible to disable the PayPal, Venmo, and Apple Pay buttons via JS. However, we'll still need to discuss whether to implement that in StarterFrontend or within each payment extension. For the meantime, the CSS workaround prevents the buttons from being clicked.

Here's a quick demo of the payment page:

2023-02-22-payment.webm

@gsmendoza
Copy link
Contributor Author

@elia @waiting-for-dev Merging this now so that we can move forward with the #105 and #106 tickets. If you have additional feedback, I can work on them while working on #104.

@gsmendoza gsmendoza merged commit 26dd805 into master Feb 22, 2023
@elia elia deleted the gsmendoza/91-ssf-dummy-app branch February 22, 2023 10:37
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.

Make Solidus Braintree compatible with Starter Frontend
4 participants