Skip to content

Commit

Permalink
Merge pull request #166 from solidusio/elia+kennyadsl/ssf-support
Browse files Browse the repository at this point in the history
Setup compatibility with the starter frontend
  • Loading branch information
elia authored Dec 5, 2022
2 parents 067e58d + 002dfe8 commit b2558c1
Show file tree
Hide file tree
Showing 53 changed files with 512 additions and 422 deletions.
30 changes: 21 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,45 @@ 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 install -y libvips
- solidusio_extensions/test-branch:
branch: master
command: |
export FRONTEND=starter
sudo gem update --system
gem install bundler
bin/dummy-app
bin/rspec
- solidusio_extensions/store-test-results

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

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

run-specs-with-sqlite:
executor:
name: solidusio_extensions/sqlite
ruby_version: '2.7'
steps:
- checkout
- browser-tools/install-chrome
- solidusio_extensions/run-tests
- test-with-starter-frontend

lint-code:
executor: solidusio_extensions/sqlite-memory
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pkg
spec/dummy
spec/examples.txt
/sandbox
/dummy-app
.rvmrc
.ruby-version
.ruby-gemset
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
--color
--require spec_helper
5 changes: 3 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ AllCops:
TargetRubyVersion: '2.7'
Exclude:
- sandbox/**/*
- dummy-app/**/*
- spec/dummy/**/*
- vendor/bundle/**/*

Expand All @@ -23,10 +24,10 @@ Naming/VariableNumber:
RSpec/AnyInstance:
Enabled: false

# Feature specs are not describing any class or module.
# System specs are not describing any class or module.
RSpec/DescribeClass:
Exclude:
- spec/features/**/*
- spec/system/**/*

# No need to make the code more complex for no real gain.
RSpec/MessageSpies:
Expand Down
41 changes: 0 additions & 41 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
%w[solidusio/solidus solidusio/solidus_frontend]
else
%w[solidusio/solidus] * 2
end
gem 'solidus', github: solidus_git, branch: branch
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch

# Needed to help Bundler figure out how to resolve dependencies,
# otherwise it takes forever to resolve them.
# See https://github.com/bundler/bundler/issues/6677
gem 'rails', ENV.fetch('RAILS_VERSION', '>0.a')

# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'

case ENV.fetch('DB', nil)
when 'mysql'
gem 'mysql2'
when 'postgresql'
gem 'pg'
else
gem 'sqlite3'
end

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3')
# 'net/smtp' is required by 'mail', see:
# - https://github.com/ruby/net-protocol/issues/10
# - https://stackoverflow.com/a/72474475
gem 'net-smtp', require: false
end

gemspec

# Use a local Gemfile to include development dependencies that might not be
# relevant for the project or for other contributors, e.g. pry-byebug.
#
# We use `send` instead of calling `eval_gemfile` to work around an issue with
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Since PayPal is being used as the checkout if the user checks out on the product

A) Turn off cart and product page checkout - configurable on the admin payment method page for PayPal Commerce Platform.
-OR-
B) Collect the users phone number seperately
B) Collect the users phone number separately

and then override the `Spree::Address` method `require_phone?` to return `true`.

Expand Down Expand Up @@ -93,6 +93,7 @@ end
The instances of your wizard class should respond to `#name` and `#partial_name`, where `partial_name` will return the path to the partial you'd like to display on the wizard setup section. In our case, we just display a button to direct the user to PayPal.

## State Guesser

PayPal users can change their shipping address directly on PayPal, which will
update their address on Solidus as well. However, in some instances, Solidus
uses the incorrect subregion level for states, which causes validation problems
Expand All @@ -101,7 +102,7 @@ with the addresses that PayPal sends to us.
For instance, if your user lives in Pescara, Italy, then PayPal will return
"Pescara" as the state. However on older version of Solidus, the region
"Abruzzo" is used, so the address will not be able to validate. To solve this
issue, we've implented a class that attempts to guess the state of the user
issue, we've implemented a class that attempts to guess the state of the user
using Carmen subregions if the state cannot be initially found. You can, of
course, implement your own state guesser and set it like this:

Expand All @@ -121,6 +122,7 @@ With product and cart page checkout, the user is directed to the checkout confir
PayPals API does not allow for admin-side payments. Instead, backend users taking payments for customers will need to use the PayPal Virtual Terminal to take payments. [More info is available on the PayPal website.](https://www.paypal.com/merchantapps/appcenter/acceptpayments/virtualterminal?locale.x=en_US)

## Venmo

Venmo is currently available to US merchants and buyers. There are also other [prequisites](https://developer.paypal.com/docs/business/checkout/pay-with-venmo/#eligibility).

If the transaction supports Venmo and it is enabled by the following, then a button should appear for it on checkout payment page. Note, Venmo cannot currently be rendered on the product or cart pages.
Expand All @@ -135,6 +137,7 @@ See more about preferences([Configuration](#configuration)) below.
[_As Venmo is only available in the US, you may want to mock your location for testing_](#mocking-your-buyer-country)

## Configuration

The easiest way to change the `Payment Method`'s preferences is through admin: `Settings > Payments > "PayPal Commerce Platform" > Edit`.

See more about preferences [here](https://guides.solidus.io/developers/preferences/add-model-preferences.html#access-your-preferences)/
Expand All @@ -145,10 +148,10 @@ See more about preferences [here](https://guides.solidus.io/developers/preferenc

First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
`bin/rake extension:test_app`.
`bin/dummy-app`.

```shell
bundle
bin/setup
bin/rake
```

Expand All @@ -158,13 +161,6 @@ To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
bundle exec rubocop
```

When testing your application's integration with this extension you may use its factories.
Simply add this require statement to your spec_helper:

```ruby
require 'solidus_paypal_commerce_platform/factories'
```

### Running the sandbox

To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
Expand All @@ -182,6 +178,7 @@ Use Ctrl-C to stop
```

### Mocking your buyer country

PayPal normally looks at your IP geolocation to see where you are located to determine what funding sources are available to you. For example, Venmo is currently only available to US buyers.
Because of this, you may want to pretend you are from US check that that Venmo is correctly integrated for these customers. To do this, set the payment method's preference of `force_buyer_country` to "US". See more information about preferences above.

Expand Down Expand Up @@ -216,4 +213,4 @@ By using this extension, you are giving back to Solidus. PayPal will pay a fee t

## License

Copyright (c) 2020 Nebulab srls, released under the New BSD License
Copyright (c) 2022 Nebulab srls, released under the New BSD License
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
Loading

0 comments on commit b2558c1

Please sign in to comment.