solidus_paypal_braintree 0.4.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +44 -0
- data/.gem_release.yml +5 -0
- data/.github/stale.yml +17 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.rubocop.yml +76 -0
- data/CHANGELOG.md +327 -0
- data/Gemfile +38 -0
- data/LICENSE +2 -2
- data/README.md +170 -25
- data/Rakefile +4 -25
- data/app/assets/config/solidus_paypal_braintree_manifest.js +1 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_blue_button_280x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_blue_button_320x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_blue_button_375x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_white_button_280x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_white_button_320x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_white_button_375x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_acceptance_mark.svg +15 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_button_280x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_button_320x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_button_375x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_logo.svg +18 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_acceptance_mark.svg +20 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_button_280x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_button_320x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_button_375x48.svg +19 -0
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_logo.svg +18 -0
- data/app/assets/javascripts/solidus_paypal_braintree/checkout.js +32 -3
- data/app/assets/javascripts/solidus_paypal_braintree/client.js +57 -4
- data/app/assets/javascripts/solidus_paypal_braintree/constants.js +27 -0
- data/app/assets/javascripts/solidus_paypal_braintree/frontend.js +2 -0
- data/app/assets/javascripts/solidus_paypal_braintree/hosted_form.js +15 -5
- data/app/assets/javascripts/solidus_paypal_braintree/paypal_button.js +71 -21
- data/app/assets/javascripts/solidus_paypal_braintree/paypal_messaging.js +22 -0
- data/app/assets/javascripts/solidus_paypal_braintree/venmo_button.js +86 -0
- data/app/assets/javascripts/spree/backend/solidus_paypal_braintree.js +2 -2
- data/app/assets/javascripts/spree/frontend/paypal_button.js +3 -3
- data/app/assets/stylesheets/spree/frontend/solidus_paypal_braintree.css +12 -0
- data/app/decorators/controllers/solidus_paypal_braintree/admin_payments_controller_decorator.rb +11 -0
- data/app/decorators/controllers/solidus_paypal_braintree/checkout_controller_decorator.rb +11 -0
- data/app/decorators/controllers/solidus_paypal_braintree/client_tokens_controller.rb +41 -0
- data/app/decorators/controllers/solidus_paypal_braintree/orders_controller_decorator.rb +11 -0
- data/app/decorators/models/solidus_paypal_braintree/spree/store_decorator.rb +20 -0
- data/app/decorators/models/solidus_paypal_braintree/spree/user_decorator.rb +13 -0
- data/app/helpers/solidus_paypal_braintree/braintree_admin_helper.rb +23 -0
- data/app/helpers/solidus_paypal_braintree/braintree_checkout_helper.rb +60 -0
- data/app/models/application_record.rb +2 -0
- data/app/models/solidus_paypal_braintree/address.rb +64 -0
- data/app/models/solidus_paypal_braintree/avs_result.rb +3 -0
- data/app/models/solidus_paypal_braintree/configuration.rb +39 -3
- data/app/models/solidus_paypal_braintree/customer.rb +7 -3
- data/app/models/solidus_paypal_braintree/gateway.rb +80 -21
- data/app/models/solidus_paypal_braintree/response.rb +3 -2
- data/app/models/solidus_paypal_braintree/source.rb +51 -8
- data/app/models/solidus_paypal_braintree/transaction.rb +5 -3
- data/app/models/solidus_paypal_braintree/transaction_address.rb +34 -12
- data/app/models/solidus_paypal_braintree/transaction_import.rb +17 -12
- data/app/overrides/spree/payments/payment/add_paypal_funding_source_to_payment.rb +9 -0
- data/app/views/spree/api/payments/source_views/_paypal_braintree.json.jbuilder +3 -0
- data/app/views/spree/checkout/existing_payment/_paypal_braintree.html.erb +10 -0
- data/app/views/spree/shared/_apple_pay_button.html.erb +2 -2
- data/app/views/spree/shared/_braintree_errors.html.erb +14 -17
- data/app/views/spree/shared/_braintree_hosted_fields.html.erb +24 -9
- data/app/views/spree/shared/_paypal_braintree_head_scripts.html.erb +13 -6
- data/app/views/spree/shared/_paypal_cart_button.html.erb +18 -2
- data/app/views/spree/shared/_paypal_messaging.html.erb +13 -0
- data/app/views/spree/shared/_venmo_button.html.erb +33 -0
- data/bin/console +17 -0
- data/bin/rails +15 -0
- data/bin/setup +8 -0
- data/config/locales/en.yml +44 -0
- data/config/locales/it.yml +53 -8
- data/config/routes.rb +2 -0
- data/db/migrate/20160906201711_create_solidus_paypal_braintree_customers.rb +3 -1
- data/db/migrate/20161125172005_add_braintree_configuration_to_stores.rb +5 -7
- data/db/migrate/20170505193712_add_null_constraint_to_sources.rb +3 -1
- data/db/migrate/20190705115327_add_paypal_button_preferences_to_braintree_configurations.rb +5 -0
- data/db/migrate/20190911141712_add_3d_secure_to_braintree_configuration.rb +5 -0
- data/db/migrate/20211222170950_add_paypal_funding_source_to_solidus_paypal_braintree_sources.rb +5 -0
- data/db/migrate/20220104150301_add_venmo_to_braintree_configuration.rb +5 -0
- data/lib/controllers/backend/solidus_paypal_braintree/configurations_controller.rb +23 -5
- data/lib/controllers/frontend/solidus_paypal_braintree/checkouts_controller.rb +25 -21
- data/lib/controllers/frontend/solidus_paypal_braintree/transactions_controller.rb +56 -51
- data/lib/generators/solidus_paypal_braintree/install/install_generator.rb +7 -5
- data/lib/solidus_paypal_braintree/country_mapper.rb +4 -2
- data/lib/solidus_paypal_braintree/engine.rb +17 -13
- data/lib/solidus_paypal_braintree/factories.rb +39 -4
- data/lib/solidus_paypal_braintree/request_protection.rb +3 -0
- data/lib/solidus_paypal_braintree/version.rb +3 -1
- data/lib/solidus_paypal_braintree.rb +4 -0
- data/lib/views/backend/solidus_paypal_braintree/configurations/list.html.erb +38 -5
- data/lib/views/backend/spree/admin/payments/source_forms/_paypal_braintree.html.erb +2 -2
- data/lib/views/backend/spree/admin/payments/source_views/_paypal_braintree.html.erb +7 -2
- data/lib/views/backend/spree/admin/shared/preference_fields/_preference_select.html.erb +13 -0
- data/lib/views/backend_v1.2/spree/admin/payments/source_forms/_paypal_braintree.html.erb +2 -2
- data/lib/views/frontend/solidus_paypal_braintree/payments/_payment.html.erb +12 -0
- data/lib/views/frontend/spree/checkout/payment/_paypal_braintree.html.erb +8 -2
- data/lib/views/frontend/spree/shared/_paypal_checkout_button.html.erb +32 -0
- data/solidus_paypal_braintree.gemspec +42 -0
- metadata +95 -188
- data/app/controllers/solidus_paypal_braintree/client_tokens_controller.rb +0 -22
- data/app/helpers/braintree_admin_helper.rb +0 -18
- data/app/models/spree/store_decorator.rb +0 -11
- data/app/views/spree/shared/_paypal_checkout_button.html.erb +0 -27
- data/config/initializers/braintree.rb +0 -1
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SolidusPaypalBraintree
|
2
4
|
module CountryMapper
|
3
5
|
extend ActiveSupport::Concern
|
@@ -12,12 +14,12 @@ module SolidusPaypalBraintree
|
|
12
14
|
"usa",
|
13
15
|
"u.s.",
|
14
16
|
"us"
|
15
|
-
]
|
17
|
+
].freeze
|
16
18
|
|
17
19
|
CANADA_VARIANTS = [
|
18
20
|
"canada",
|
19
21
|
"ca"
|
20
|
-
]
|
22
|
+
].freeze
|
21
23
|
|
22
24
|
# Generates a hash mapping each variant of the country name to the same ISO
|
23
25
|
# ie: { "usa" => "US", "united states" => "US", "canada" => "CA", ... }
|
@@ -1,33 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'solidus_support'
|
2
4
|
|
3
5
|
module SolidusPaypalBraintree
|
4
6
|
class Engine < Rails::Engine
|
7
|
+
include SolidusSupport::EngineExtensions
|
8
|
+
|
5
9
|
isolate_namespace SolidusPaypalBraintree
|
6
10
|
engine_name 'solidus_paypal_braintree'
|
7
11
|
|
12
|
+
ActiveSupport::Inflector.inflections do |inflect|
|
13
|
+
inflect.acronym 'AVS'
|
14
|
+
end
|
15
|
+
|
8
16
|
# use rspec for tests
|
9
17
|
config.generators do |g|
|
10
18
|
g.test_framework :rspec
|
11
19
|
end
|
12
20
|
|
13
21
|
initializer "register_solidus_paypal_braintree_gateway", after: "spree.register.payment_methods" do |app|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def self.activate
|
19
|
-
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
20
|
-
Rails.configuration.cache_classes ? require(c) : load(c)
|
22
|
+
config.to_prepare do
|
23
|
+
app.config.spree.payment_methods << SolidusPaypalBraintree::Gateway
|
24
|
+
SolidusPaypalBraintree::Gateway.allowed_admin_form_preference_types.push(:preference_select).uniq!
|
25
|
+
::Spree::PermittedAttributes.source_attributes.concat([:nonce, :payment_type, :paypal_funding_source]).uniq!
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
24
|
-
config.to_prepare(&method(:activate).to_proc)
|
25
|
-
|
26
29
|
if SolidusSupport.frontend_available?
|
27
30
|
config.assets.precompile += [
|
28
31
|
'solidus_paypal_braintree/checkout.js',
|
29
32
|
'solidus_paypal_braintree/frontend.js',
|
30
|
-
'spree/frontend/apple_pay_button.js'
|
33
|
+
'spree/frontend/apple_pay_button.js',
|
34
|
+
'solidus_paypal_braintree_manifest.js'
|
31
35
|
]
|
32
36
|
paths["app/controllers"] << "lib/controllers/frontend"
|
33
37
|
paths["app/views"] << "lib/views/frontend"
|
@@ -39,17 +43,17 @@ module SolidusPaypalBraintree
|
|
39
43
|
|
40
44
|
# We support Solidus v1.2, which requires some different markup in the
|
41
45
|
# source form partial. This will take precedence over lib/views/backend.
|
42
|
-
paths["app/views"] << "lib/views/backend_v1.2" if
|
46
|
+
paths["app/views"] << "lib/views/backend_v1.2" if Spree.solidus_gem_version < Gem::Version.new('1.3')
|
43
47
|
|
44
48
|
# Solidus v2.4 introduced preference field partials but does not ship a hash field type.
|
45
49
|
# This is solved in Solidus v2.5.
|
46
|
-
if
|
50
|
+
if Spree.solidus_gem_version <= Gem::Version.new('2.5.0')
|
47
51
|
paths["app/views"] << "lib/views/backend_v2.4"
|
48
52
|
end
|
49
53
|
|
50
54
|
paths["app/views"] << "lib/views/backend"
|
51
55
|
|
52
|
-
initializer "solidus_paypal_braintree_admin_menu_item", after: "register_solidus_paypal_braintree_gateway" do
|
56
|
+
initializer "solidus_paypal_braintree_admin_menu_item", after: "register_solidus_paypal_braintree_gateway" do
|
53
57
|
Spree::Backend::Config.configure do |config|
|
54
58
|
config.menu_items << config.class::MenuItem.new(
|
55
59
|
[:braintree],
|
@@ -1,18 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
FactoryBot.define do
|
2
|
-
# Define your Spree extensions Factories within this file to enable applications,
|
4
|
+
# Define your Spree extensions Factories within this file to enable applications,
|
5
|
+
# and other extensions to use and override them.
|
3
6
|
#
|
4
7
|
# Example adding this to your spec_helper will load these Factories for use:
|
5
8
|
# require 'solidus_paypal_braintree/factories'
|
9
|
+
|
10
|
+
factory :solidus_paypal_braintree_payment_method, class: SolidusPaypalBraintree::Gateway do
|
11
|
+
name 'Solidus PayPal Braintree Gateway'
|
12
|
+
active true
|
13
|
+
end
|
14
|
+
|
15
|
+
factory :solidus_paypal_braintree_source, class: SolidusPaypalBraintree::Source do
|
16
|
+
association(:payment_method, factory: :solidus_paypal_braintree_payment_method)
|
17
|
+
user
|
18
|
+
|
19
|
+
trait :credit_card do
|
20
|
+
payment_type SolidusPaypalBraintree::Source::CREDIT_CARD
|
21
|
+
end
|
22
|
+
|
23
|
+
trait :paypal do
|
24
|
+
payment_type SolidusPaypalBraintree::Source::PAYPAL
|
25
|
+
end
|
26
|
+
|
27
|
+
trait :apple_pay do
|
28
|
+
payment_type SolidusPaypalBraintree::Source::APPLE_PAY
|
29
|
+
end
|
30
|
+
end
|
6
31
|
end
|
7
32
|
|
8
33
|
FactoryBot.modify do
|
9
34
|
# The Solidus address factory randomizes the zipcode.
|
10
35
|
# The OrderWalkThrough we use in the credit card checkout spec uses this factory for the user addresses.
|
11
36
|
# For credit card payments we transmit the billing address to braintree, for paypal payments the shipping address.
|
12
|
-
# As we match the body in our VCR settings VCR can not match the request anymore and therefore cannot replay existing
|
37
|
+
# As we match the body in our VCR settings VCR can not match the request anymore and therefore cannot replay existing
|
38
|
+
# cassettes.
|
13
39
|
#
|
40
|
+
|
14
41
|
factory :address do
|
15
|
-
zipcode '21088-0255'
|
16
|
-
|
42
|
+
zipcode { '21088-0255' }
|
43
|
+
|
44
|
+
if SolidusSupport.combined_first_and_last_name_in_address?
|
45
|
+
transient do
|
46
|
+
firstname { "John" }
|
47
|
+
lastname { "Doe" }
|
48
|
+
end
|
49
|
+
|
50
|
+
name { "#{firstname} #{lastname}" }
|
51
|
+
end
|
17
52
|
end
|
18
53
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_merchant/network_connection_retries'
|
2
4
|
|
3
5
|
module SolidusPaypalBraintree
|
@@ -6,6 +8,7 @@ module SolidusPaypalBraintree
|
|
6
8
|
|
7
9
|
def protected_request
|
8
10
|
raise ArgumentError unless block_given?
|
11
|
+
|
9
12
|
options = {
|
10
13
|
connection_exceptions: {
|
11
14
|
Braintree::BraintreeError => 'Error while connecting to Braintree gateway'
|
@@ -1,7 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'solidus_core'
|
4
|
+
require 'solidus_paypal_braintree/version'
|
2
5
|
require 'solidus_paypal_braintree/engine'
|
3
6
|
require 'solidus_paypal_braintree/country_mapper'
|
4
7
|
require 'solidus_paypal_braintree/request_protection'
|
8
|
+
require 'solidus_support'
|
5
9
|
|
6
10
|
module SolidusPaypalBraintree
|
7
11
|
def self.table_name_prefix
|
@@ -6,25 +6,58 @@
|
|
6
6
|
<% @configurations.each do |config| %>
|
7
7
|
<div class="row">
|
8
8
|
<fieldset>
|
9
|
-
<
|
9
|
+
<legend><%= config.store.name %></legend>
|
10
10
|
|
11
11
|
<%= f.fields_for 'configuration_fields[]', config do |c| %>
|
12
12
|
<div class="field">
|
13
|
-
<%= c.label :paypal %>
|
14
13
|
<%= c.check_box :paypal %>
|
14
|
+
<%= c.label :paypal do %>
|
15
|
+
<%= tag.i class: 'fa fa-paypal' %>
|
16
|
+
<%= c.object.class.human_attribute_name(:paypal) %>
|
17
|
+
<% end %>
|
15
18
|
</div>
|
19
|
+
|
16
20
|
<div class="field">
|
17
|
-
<%= c.label :apple_pay %>
|
18
21
|
<%= c.check_box :apple_pay %>
|
22
|
+
<%= c.label :apple_pay do %>
|
23
|
+
<%= tag.i class: 'fa fa-apple' %>
|
24
|
+
<%= c.object.class.human_attribute_name(:apple_pay) %>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="field">
|
29
|
+
<%= c.check_box :venmo %>
|
30
|
+
<%= c.label :venmo do %>
|
31
|
+
<%= tag.i class: 'fa fa-mobile' %>
|
32
|
+
<%= c.object.class.human_attribute_name(:venmo) %>
|
33
|
+
<% end %>
|
19
34
|
</div>
|
35
|
+
|
20
36
|
<div class="field">
|
21
|
-
<%= c.label :credit_card %>
|
22
37
|
<%= c.check_box :credit_card %>
|
38
|
+
<%= c.label :credit_card do %>
|
39
|
+
<%= tag.i class: 'fa fa-credit-card' %>
|
40
|
+
<%= c.object.class.human_attribute_name(:credit_card) %>
|
41
|
+
<% end %>
|
42
|
+
+
|
43
|
+
<%= c.check_box :three_d_secure %>
|
44
|
+
<%= c.label :three_d_secure do %>
|
45
|
+
<%= tag.i class: 'fa fa-shield' %>
|
46
|
+
<%= c.object.class.human_attribute_name(:three_d_secure) %>
|
47
|
+
<% end %>
|
23
48
|
</div>
|
49
|
+
|
50
|
+
<% config.admin_form_preference_names.each do |name| %>
|
51
|
+
<%= render "spree/admin/shared/preference_fields/#{config.preference_type(name)}",
|
52
|
+
form: c, attribute: "preferred_#{name}",
|
53
|
+
label: t(name, scope: 'spree', default: name.to_s.humanize) %>
|
54
|
+
<% end %>
|
24
55
|
<% end %>
|
25
56
|
</fieldset>
|
26
57
|
</div>
|
27
58
|
<% end %>
|
28
59
|
|
29
|
-
|
60
|
+
<div class="form-buttons filter-actions actions">
|
61
|
+
<%= submit_tag "Update", class: 'btn btn-primary' %>
|
62
|
+
</div>
|
30
63
|
<% end %>
|
@@ -6,11 +6,11 @@
|
|
6
6
|
<% previous_cards.each do |card| %>
|
7
7
|
<label><%= radio_button_tag :card, card.id, card == previous_cards.first %> <%= card.display_number %><br /></label>
|
8
8
|
<% end %>
|
9
|
-
<label><%= radio_button_tag :card, "new", false, { id: "card_new#{id}" } %> <%=
|
9
|
+
<label><%= radio_button_tag :card, "new", false, { id: "card_new#{id}" } %> <%= I18n.t("spree.use_new_cc") %></label>
|
10
10
|
<% end %>
|
11
11
|
</div>
|
12
12
|
|
13
13
|
<div id="card_form<%= id %>" data-hook style="display: none;">
|
14
|
-
<%= render partial: "spree/shared/braintree_hosted_fields", locals: {
|
14
|
+
<%= render partial: "spree/shared/braintree_hosted_fields", locals: { payment_method: payment_method } %>
|
15
15
|
</div>
|
16
16
|
</fieldset>
|
@@ -4,10 +4,10 @@
|
|
4
4
|
<div class="row">
|
5
5
|
<div class="alpha six columns">
|
6
6
|
<dl>
|
7
|
-
<dt><%=
|
7
|
+
<dt><%= I18n.t("spree.identifier") %>:</dt>
|
8
8
|
<dd><%= payment.number %></dd>
|
9
9
|
|
10
|
-
<dt><%=
|
10
|
+
<dt><%= I18n.t("spree.response_code") %>:</dt>
|
11
11
|
<dd><%= braintree_transaction_link(payment) %></dd>
|
12
12
|
|
13
13
|
<% if payment.source.token.present? %>
|
@@ -28,6 +28,11 @@
|
|
28
28
|
<dt><%= Spree::CreditCard.human_attribute_name(:last_digits) %>:</dt>
|
29
29
|
<dd><%= payment.source.last_digits %></dd>
|
30
30
|
<% end %>
|
31
|
+
|
32
|
+
<% if payment.source.paypal? %>
|
33
|
+
<dt><%= I18n.t('spree.paypal_funding_source') %>:</dt>
|
34
|
+
<dd><%= payment.source.display_paypal_funding_source %></dd>
|
35
|
+
<% end %>
|
31
36
|
</dl>
|
32
37
|
</div>
|
33
38
|
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% label = local_assigns[:label].presence %>
|
2
|
+
<% html_options = {class: 'custom-select fullwidth'}.update(local_assigns[:html_options] || {}) %>
|
3
|
+
<% options = form.object.send("#{attribute}_options") %>
|
4
|
+
|
5
|
+
<div class="field">
|
6
|
+
<% if local_assigns[:form] %>
|
7
|
+
<%= form.label attribute, label %>
|
8
|
+
<%= form.select attribute, options, {}, html_options %>
|
9
|
+
<% else %>
|
10
|
+
<%= label_tag name, label %>
|
11
|
+
<%= select_tag name, value, html_options %>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
@@ -6,11 +6,11 @@
|
|
6
6
|
<% previous_cards.each do |card| %>
|
7
7
|
<label><%= radio_button_tag :card, card.id, card == previous_cards.first %> <%= card.display_number %><br /></label>
|
8
8
|
<% end %>
|
9
|
-
<label><%= radio_button_tag :card, "new", false, { id: "card_new#{id}" } %> <%=
|
9
|
+
<label><%= radio_button_tag :card, "new", false, { id: "card_new#{id}" } %> <%= I18n.t("spree.use_new_cc") %></label>
|
10
10
|
<% end %>
|
11
11
|
</div>
|
12
12
|
|
13
13
|
<div id="card_form<%= id %>" data-hook style="display: none;">
|
14
|
-
<%= render partial: "spree/shared/braintree_hosted_fields", locals: {
|
14
|
+
<%= render partial: "spree/shared/braintree_hosted_fields", locals: { payment_method: payment_method } %>
|
15
15
|
</div>
|
16
16
|
</fieldset>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<br />
|
2
|
+
<%= payment.source.display_payment_type %>
|
3
|
+
|
4
|
+
<% if payment.source.paypal? %>
|
5
|
+
<% if payment.source.respond_to?(:paypal_funding_source) && payment.source.paypal_funding_source.present? %>
|
6
|
+
<br />
|
7
|
+
<%= t('spree.paypal_funding', funding: payment.source.display_paypal_funding_source) %>
|
8
|
+
<% end %>
|
9
|
+
<% elsif payment.source.venmo? %>
|
10
|
+
<br />
|
11
|
+
<%= payment.source.source_description %>
|
12
|
+
<% end %>
|
@@ -8,10 +8,16 @@
|
|
8
8
|
|
9
9
|
<% if current_store.braintree_configuration.credit_card? %>
|
10
10
|
<fieldset class="braintree-hosted-fields" data-braintree-hosted-fields data-id="<%= id %>">
|
11
|
-
<%= render "spree/shared/braintree_hosted_fields",
|
11
|
+
<%= render "spree/shared/braintree_hosted_fields", payment_method: payment_method %>
|
12
12
|
</fieldset>
|
13
13
|
<% end %>
|
14
14
|
|
15
15
|
<% if current_store.braintree_configuration.apple_pay? %>
|
16
|
-
<%= render "spree/shared/apple_pay_button" %>
|
16
|
+
<%= render "spree/shared/apple_pay_button", id: id %>
|
17
17
|
<% end %>
|
18
|
+
|
19
|
+
<% if current_store.braintree_configuration.venmo? %>
|
20
|
+
<%= render "spree/shared/venmo_button", payment_method: payment_method %>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<%= render "spree/shared/braintree_errors" %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<div id="paypal-button"></div>
|
2
|
+
<div data-pp-message data-pp-placement="payment" data-pp-amount="<%= @order.total %>"></div>
|
3
|
+
|
4
|
+
<script>
|
5
|
+
var address = <%= sanitize SolidusPaypalBraintree::Address.new(current_order.ship_address).to_json %>
|
6
|
+
|
7
|
+
var paypalOptions = {
|
8
|
+
flow: '<%= SolidusPaypalBraintree::Gateway.first.preferred_paypal_flow %>',
|
9
|
+
amount: '<%= current_order.total %>',
|
10
|
+
currency: '<%= current_order.currency %>',
|
11
|
+
enableShippingAddress: true,
|
12
|
+
venmoFunding: <%= SolidusPaypalBraintree::Gateway.first.preferred_enable_venmo_funding %>,
|
13
|
+
buyerCountry: '<%= SolidusPaypalBraintree::Gateway.first.preferred_force_buyer_country %>',
|
14
|
+
shippingAddressOverride: address,
|
15
|
+
shippingAddressEditable: false,
|
16
|
+
environment: '<%= Rails.env.production? ? "production" : "sandbox" %>',
|
17
|
+
locale: '<%= paypal_button_preference(:paypal_button_locale, store: current_store) %>',
|
18
|
+
style: {
|
19
|
+
color: '<%= paypal_button_preference(:paypal_button_color, store: current_store) %>',
|
20
|
+
shape: '<%= paypal_button_preference(:paypal_button_shape, store: current_store) %>',
|
21
|
+
label: '<%= paypal_button_preference(:paypal_button_label, store: current_store) %>',
|
22
|
+
layout: '<%= paypal_button_preference(:paypal_button_layout, store: current_store) %>',
|
23
|
+
<% if paypal_button_preference(:paypal_button_layout, store: current_store) == "horizontal" %>
|
24
|
+
tagline: '<%= paypal_button_preference(:paypal_button_tagline, store: current_store) %>',
|
25
|
+
<% end %>
|
26
|
+
messaging: '<%= paypal_button_preference(:paypal_button_messaging, store: current_store) %>'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
var button = new SolidusPaypalBraintree.createPaypalButton(document.querySelector("#paypal-button"), paypalOptions);
|
31
|
+
button.initialize();
|
32
|
+
</script>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$:.push File.expand_path('lib', __dir__)
|
4
|
+
require 'solidus_paypal_braintree/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'solidus_paypal_braintree'
|
8
|
+
s.version = SolidusPaypalBraintree::VERSION
|
9
|
+
s.summary = 'Officially supported Paypal/Braintree extension'
|
10
|
+
s.description = 'Uses the javascript API for seamless braintree payments'
|
11
|
+
s.license = 'BSD-3-Clause'
|
12
|
+
|
13
|
+
s.author = 'Stembolt'
|
14
|
+
s.email = 'braintree+gemfile@stembolt.com'
|
15
|
+
s.homepage = 'https://github.com/solidusio/solidus_paypal_braintree'
|
16
|
+
|
17
|
+
s.required_ruby_version = '>= 2.5'
|
18
|
+
|
19
|
+
s.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
s.bindir = "exe"
|
23
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
|
26
|
+
if s.respond_to?(:metadata)
|
27
|
+
s.metadata["homepage_uri"] = s.homepage if s.homepage
|
28
|
+
s.metadata["source_code_uri"] = s.homepage if s.homepage
|
29
|
+
s.metadata["rubygems_mfa_required"] = 'true'
|
30
|
+
end
|
31
|
+
|
32
|
+
s.add_dependency 'activemerchant', '~> 1.48'
|
33
|
+
s.add_dependency 'braintree', '~> 3.4'
|
34
|
+
s.add_dependency 'solidus_api', ['>= 2.0.0', '< 4']
|
35
|
+
s.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
|
36
|
+
s.add_dependency 'solidus_support', ['>= 0.8.1', '< 1']
|
37
|
+
|
38
|
+
s.add_development_dependency 'selenium-webdriver'
|
39
|
+
s.add_development_dependency 'solidus_dev_support'
|
40
|
+
s.add_development_dependency 'vcr'
|
41
|
+
s.add_development_dependency 'webmock'
|
42
|
+
end
|