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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ff966bb
Replace OrderWalkthrough with local version
gsmendoza Feb 14, 2023
cdb7cc5
Avoid modifying the address factory
gsmendoza Feb 15, 2023
f8e81f3
Rename auto_run_migrations option to migrate
gsmendoza Feb 6, 2023
1281da6
[BREAKS BUILD] Run specs on solidus_starter_frontend
gsmendoza Feb 6, 2023
e9e24d5
Indent commands in setup_javascripts
gsmendoza Feb 6, 2023
990a39c
Move SolidusBraintree requirement calls to StarterFrontend assets
gsmendoza Feb 6, 2023
6f144fe
Separate frontend and backend JavaScript assets
gsmendoza Feb 6, 2023
998f4a8
Update Spree.pathFor references
gsmendoza Feb 6, 2023
6c64a50
Move checkout view directories out of spree
gsmendoza Feb 6, 2023
1aa4e33
Update path to checkout.js
gsmendoza Feb 8, 2023
22de4ec
Add jQuery to solidus_braintree
gsmendoza Feb 8, 2023
5350374
Add SolidusBraintree.ajax
gsmendoza Feb 8, 2023
6c751fc
[SSF specs passing] Loosen selector for checkout submit element
gsmendoza Feb 8, 2023
50e5912
Move feature specs to system
gsmendoza Feb 8, 2023
81f71a9
Install SolidusBraintree specs when generating extension
gsmendoza Feb 8, 2023
7138b2b
Namespace RSpec describe and shared_context blocks
gsmendoza Feb 8, 2023
1768556
Replace spec helper with solidus braintree helper
gsmendoza Feb 8, 2023
7772052
Install vcr and webmock as test gems
gsmendoza Feb 8, 2023
9a39498
Fix path to order_ready_for_payment
gsmendoza Feb 8, 2023
70fd14b
Update superclasses of SolidusBraintree controllers
gsmendoza Feb 8, 2023
c3ddaa6
Move factories to spec/support
gsmendoza Feb 8, 2023
bfcc149
Remove spree namespace from frontend paths
gsmendoza Feb 8, 2023
1a1e6f9
Change Spree::CheckoutController to CheckoutsController
gsmendoza Feb 9, 2023
d071a81
Remove Solidus.frontend_available? checks
gsmendoza Feb 9, 2023
d2c7fd5
Change Spree::OrdersController to OrdersController
gsmendoza Feb 9, 2023
2a6227d
Update "Place Order" calls in spec
gsmendoza Feb 9, 2023
c488c75
Loosen selectors for Checkout submit element
gsmendoza Feb 9, 2023
e131a47
Show Braintree errors before main container
gsmendoza Feb 9, 2023
256a468
Fix transactions controller spec
gsmendoza Feb 13, 2023
5ae7ffa
[SPECS FIXED] Fix: display PayPal button in cart page
gsmendoza Feb 9, 2023
e2eecb9
Copy CircleCI config from SolidusPaypalCommercePlatform
gsmendoza Feb 13, 2023
097ef64
Update required Ruby version to 2.7
gsmendoza Feb 15, 2023
c58a1c9
Wrap zipcode documentation
gsmendoza Feb 15, 2023
cfd5c67
Update specs excluded from MultipleMemoizedHelpers
gsmendoza Feb 15, 2023
b9937b2
Declare excluded directories from RuboCop
gsmendoza Feb 15, 2023
675c273
[Passes RuboCop] Specify backend spec as feature spec
gsmendoza Feb 15, 2023
e5b8cd7
Copy sandbox script from SolidusPaypalCommercePlatform
gsmendoza Feb 15, 2023
827ace2
Remove CVV link
gsmendoza Feb 21, 2023
1c4ccb7
Remove unnecessary paths from engine's precompile list
gsmendoza Feb 15, 2023
1746d41
Update README that extension is to be used with StarterFrontend
gsmendoza Feb 15, 2023
48429a3
Inject SolidusBraintree dependencies into controllers
gsmendoza Feb 17, 2023
08d2a32
Wrap address in SolidusBraintree::Address
gsmendoza Feb 20, 2023
cb628af
Remove radio button from existing Braintree payment partial
gsmendoza Feb 22, 2023
ac0e6d4
Tokenize hosted fieldset Braintree form only if fieldset is enabled
gsmendoza Feb 22, 2023
b8f5bf1
Fix payment method container selector in spec
gsmendoza Feb 22, 2023
96a259c
Do not allow buttons in disabled payment-step to be clickable
gsmendoza Feb 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: 2.1

orbs:
# Required for feature specs.
browser-tools: circleci/[email protected]

# Always take the latest version of the orb, this allows us to
Expand All @@ -10,28 +9,59 @@ orbs:
# or goes EOL.
solidusio_extensions: solidusio/extensions@volatile

commands:
test-with-starter-frontend:
steps:
- checkout
- browser-tools/install-chrome
- run:
name: Install libvips
command: |
sudo apt-get update
sudo apt-get install -yq libvips-dev
- solidusio_extensions/test-branch:
branch: master
command: |
export FRONTEND=starter
sudo gem update --system
gem install bundler rails
bin/dummy-app
bin/rspec
- solidusio_extensions/store-test-results

jobs:
run-specs-with-postgres:
executor: solidusio_extensions/postgres
executor:
name: solidusio_extensions/postgres
ruby_version: '3.1'
steps:
- browser-tools/install-browser-tools
- solidusio_extensions/run-tests
- test-with-starter-frontend

run-specs-with-mysql:
executor: solidusio_extensions/mysql
executor:
name: solidusio_extensions/mysql
ruby_version: '3.0'
steps:
- browser-tools/install-browser-tools
- solidusio_extensions/run-tests
- test-with-starter-frontend

run-specs-with-sqlite:
executor:
name: solidusio_extensions/sqlite
ruby_version: '2.7'
steps:
- test-with-starter-frontend

lint-code:
executor: solidusio_extensions/sqlite-memory
steps:
- browser-tools/install-browser-tools
- solidusio_extensions/lint-code

workflows:
"Run specs on supported Solidus versions":
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
- run-specs-with-sqlite
- lint-code

"Weekly run specs against master":
Expand All @@ -45,3 +75,4 @@ workflows:
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
- run-specs-with-sqlite
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.project
.sass-cache
coverage
dummy-app
Gemfile.lock
tmp
nbproject
Expand Down
9 changes: 8 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ require:

AllCops:
NewCops: disable
TargetRubyVersion: '2.7'
Exclude:
- sandbox/**/*
- dummy-app/**/*
- spec/dummy/**/*
- vendor/bundle/**/*

Layout/FirstArgumentIndentation:
EnforcedStyle: consistent
Expand Down Expand Up @@ -72,7 +78,8 @@ RSpec/MultipleMemoizedHelpers:
- spec/models/solidus_braintree/response_spec.rb
- spec/models/solidus_braintree/gateway_spec.rb
- spec/controllers/solidus_braintree/client_tokens_controller_spec.rb
- spec/features/frontend/braintree_credit_card_checkout_spec.rb
- spec/system/frontend/braintree_credit_card_checkout_spec.rb
- spec/system/frontend/paypal_checkout_spec.rb

Rails/ApplicationRecord:
Exclude:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

`solidus_braintree` is an extension that adds support for using [Braintree](https://www.braintreepayments.com) as a payment source in your [Solidus](https://solidus.io/) store. It supports Apple Pay, PayPal, and credit card transactions.

🚧 This extension is currently only compatible with the legacy `solidus_frontend` 🚧
🚧 This extension is currently only compatible with the `solidus_starter_frontend` 🚧

## Installation

Expand Down Expand Up @@ -119,7 +119,7 @@ Your payment method can accept payments in three ways: through Paypal, through A
end
```

4. If your site uses an unmodified `solidus_frontend`, it should now be ready to take payments. See below for more information on configuring Paypal and ApplePay.
4. If your site uses an unmodified Solidus Starter Frontend, it should now be ready to take payments. See below for more information on configuring Paypal and ApplePay.

5. Typical Solidus sites will have customized frontend code, and may require some additional work. Use `lib/views/frontend/spree/checkout/payment/_braintree.html.erb` and `app/assets/javascripts/solidus_braintree/checkout.js` as models.

Expand Down
7 changes: 6 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
require 'solidus_dev_support/rake_tasks'
SolidusDevSupport::RakeTasks.install

task default: 'extension:specs'
task :default do
require 'bundler'
Bundler.with_unbundled_env do
sh 'bin/rspec'
end
end
14 changes: 0 additions & 14 deletions app/assets/javascripts/solidus_braintree/frontend.js

This file was deleted.

8 changes: 4 additions & 4 deletions app/assets/javascripts/spree/backend/solidus_braintree.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//= require solidus_braintree/constants
//= require solidus_braintree/client
//= require solidus_braintree/promise
//= require solidus_braintree/hosted_form
//= require spree/backend/solidus_braintree/constants
//= require spree/backend/solidus_braintree/client
//= require spree/backend/solidus_braintree/promise
//= require spree/backend/solidus_braintree/hosted_form

$(function() {
var $paymentForm = $("#new_payment"),
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/spree/frontend/paypal_button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//= require solidus_braintree/paypal_button
//= require spree/frontend/solidus_braintree/paypal_button

// This is the PayPal button on the cart page
$(document).ready(function() {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/spree/frontend/solidus_braintree.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//= require solidus_braintree/frontend
//= require spree/frontend/solidus_braintree/frontend
13 changes: 13 additions & 0 deletions app/assets/javascripts/spree/frontend/solidus_braintree/ajax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SolidusBraintree.ajax = function(url, options) {
if (typeof url === "object") {
options = url;
url = undefined;
}
options = options || {};
options = $.extend(options, {
headers: {
'Authorization': 'Bearer '
}
});
return $.ajax(url, options);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//= require solidus_braintree/constants
//= require spree/frontend/solidus_braintree/constants
/**
* Constructor for Apple Pay button object
* @constructor
Expand Down Expand Up @@ -94,7 +94,7 @@ SolidusBraintree.ApplepayButton.prototype.tokenize = function (session, payment)
};

SolidusBraintree.ApplepayButton.prototype._createTransaction = function (session, payment, payload) {
Spree.ajax({
SolidusBraintree.ajax({
data: this._transactionParams(payload, payment.shippingContact),
dataType: 'json',
type: 'POST',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//= require solidus_braintree/frontend
//= require spree/frontend/solidus_braintree/frontend

$(function() {
/* This provides a default error handler for Braintree. Since we prevent
Expand Down Expand Up @@ -40,7 +40,7 @@ $(function() {
$paymentForm.on("submit",function(event) {
var $field = $(hostedField);

if ($field.is(":visible") && !$field.data("submitting")) {
if ($field.is(":visible") && $field.is(":enabled") && !$field.data("submitting")) {
var $nonce = $("#payment_method_nonce", $field);

if ($nonce.length > 0 && $nonce.val() === "") {
Expand Down Expand Up @@ -84,7 +84,7 @@ $(function() {

var $paymentForm = $("#checkout_form_payment");
var $hostedFields = $("[data-braintree-hosted-fields]");
var $submitButton = $("input[type='submit']", $paymentForm);
var $submitButton = $("[type='submit']", $paymentForm);

// If we're not using hosted fields, the form doesn't need to wait.
if ($hostedFields.length > 0) {
Expand Down
Loading