solidus_paypal_braintree 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -1
  3. data/Gemfile +1 -3
  4. data/README.md +96 -5
  5. data/app/assets/config/solidus_paypal_braintree_manifest.js +1 -0
  6. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_blue_button_280x48.svg +19 -0
  7. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_blue_button_320x48.svg +19 -0
  8. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_blue_button_375x48.svg +19 -0
  9. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_white_button_280x48.svg +19 -0
  10. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_white_button_320x48.svg +19 -0
  11. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_white_button_375x48.svg +19 -0
  12. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_acceptance_mark.svg +15 -0
  13. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_button_280x48.svg +19 -0
  14. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_button_320x48.svg +19 -0
  15. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_button_375x48.svg +19 -0
  16. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_logo.svg +18 -0
  17. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_acceptance_mark.svg +20 -0
  18. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_button_280x48.svg +19 -0
  19. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_button_320x48.svg +19 -0
  20. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_button_375x48.svg +19 -0
  21. data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_logo.svg +18 -0
  22. data/app/assets/javascripts/solidus_paypal_braintree/client.js +34 -0
  23. data/app/assets/javascripts/solidus_paypal_braintree/constants.js +8 -0
  24. data/app/assets/javascripts/solidus_paypal_braintree/frontend.js +1 -0
  25. data/app/assets/javascripts/solidus_paypal_braintree/paypal_button.js +26 -3
  26. data/app/assets/javascripts/solidus_paypal_braintree/venmo_button.js +86 -0
  27. data/app/assets/javascripts/spree/backend/solidus_paypal_braintree.js +2 -2
  28. data/app/assets/javascripts/spree/frontend/paypal_button.js +3 -3
  29. data/app/assets/stylesheets/spree/frontend/solidus_paypal_braintree.css +12 -0
  30. data/app/decorators/controllers/solidus_paypal_braintree/checkout_controller_decorator.rb +1 -1
  31. data/app/decorators/controllers/solidus_paypal_braintree/orders_controller_decorator.rb +1 -1
  32. data/app/helpers/solidus_paypal_braintree/braintree_checkout_helper.rb +19 -5
  33. data/app/models/solidus_paypal_braintree/address.rb +43 -9
  34. data/app/models/solidus_paypal_braintree/avs_result.rb +3 -0
  35. data/app/models/solidus_paypal_braintree/configuration.rb +15 -2
  36. data/app/models/solidus_paypal_braintree/gateway.rb +27 -2
  37. data/app/models/solidus_paypal_braintree/source.rb +31 -2
  38. data/app/models/solidus_paypal_braintree/transaction.rb +1 -1
  39. data/app/models/solidus_paypal_braintree/transaction_address.rb +17 -13
  40. data/app/models/solidus_paypal_braintree/transaction_import.rb +2 -1
  41. data/app/overrides/spree/payments/payment/add_paypal_funding_source_to_payment.rb +9 -0
  42. data/app/views/spree/shared/_braintree_errors.html.erb +3 -0
  43. data/app/views/spree/shared/_paypal_braintree_head_scripts.html.erb +10 -6
  44. data/app/views/spree/shared/_paypal_cart_button.html.erb +2 -0
  45. data/app/views/spree/shared/_venmo_button.html.erb +33 -0
  46. data/config/locales/en.yml +34 -0
  47. data/config/locales/it.yml +2 -0
  48. data/db/migrate/20211222170950_add_paypal_funding_source_to_solidus_paypal_braintree_sources.rb +5 -0
  49. data/db/migrate/20220104150301_add_venmo_to_braintree_configuration.rb +5 -0
  50. data/lib/controllers/backend/solidus_paypal_braintree/configurations_controller.rb +4 -1
  51. data/lib/controllers/frontend/solidus_paypal_braintree/transactions_controller.rb +1 -0
  52. data/lib/solidus_paypal_braintree/engine.rb +4 -2
  53. data/lib/solidus_paypal_braintree/factories.rb +32 -1
  54. data/lib/solidus_paypal_braintree/version.rb +1 -1
  55. data/lib/views/backend/solidus_paypal_braintree/configurations/list.html.erb +8 -0
  56. data/lib/views/backend/spree/admin/payments/source_views/_paypal_braintree.html.erb +5 -0
  57. data/lib/views/backend/spree/admin/shared/preference_fields/_preference_select.html.erb +13 -0
  58. data/lib/views/frontend/solidus_paypal_braintree/payments/_payment.html.erb +12 -0
  59. data/lib/views/frontend/spree/checkout/payment/_paypal_braintree.html.erb +4 -0
  60. data/lib/views/frontend/spree/shared/_paypal_checkout_button.html.erb +2 -0
  61. data/solidus_paypal_braintree.gemspec +6 -5
  62. data/spec/controllers/solidus_paypal_braintree/transactions_controller_spec.rb +1 -1
  63. data/spec/features/frontend/braintree_credit_card_checkout_spec.rb +5 -1
  64. data/spec/features/frontend/venmo_checkout_spec.rb +189 -0
  65. data/spec/fixtures/cassettes/checkout/valid_venmo_transaction.yml +599 -0
  66. data/spec/helpers/solidus_paypal_braintree/braintree_checkout_helper_spec.rb +70 -0
  67. data/spec/models/solidus_paypal_braintree/address_spec.rb +20 -0
  68. data/spec/models/solidus_paypal_braintree/gateway_spec.rb +1 -1
  69. data/spec/models/solidus_paypal_braintree/source_spec.rb +139 -0
  70. data/spec/models/solidus_paypal_braintree/transaction_address_spec.rb +8 -26
  71. data/spec/models/solidus_paypal_braintree/transaction_import_spec.rb +17 -0
  72. data/spec/spec_helper.rb +3 -0
  73. metadata +52 -15
@@ -51,16 +51,24 @@ module SolidusPaypalBraintree
51
51
  zipcode: zip
52
52
  )
53
53
 
54
- if !first_name.nil?
55
- ::Spree::Deprecation.warn("first_name and last_name are deprecated. Use name instead.", caller)
56
- address.first_name = first_name
57
- address.last_name = last_name || "(left blank)"
58
- elsif address.respond_to? :name
59
- address.name = name
54
+ if SolidusSupport.combined_first_and_last_name_in_address?
55
+ address.name = begin
56
+ if first_name.nil?
57
+ name
58
+ else
59
+ [first_name, last_name].join(" ")
60
+ end
61
+ end
60
62
  else
61
- first_name, last_name = split_name(name)
62
- address.first_name = first_name
63
- address.last_name = last_name || "(left blank)"
63
+ ::Spree::Deprecation.warn("first_name and last_name are deprecated. Use name instead.", caller)
64
+ if first_name.nil?
65
+ first, last = SolidusPaypalBraintree::Address.split_name(name)
66
+ address.firstname = first
67
+ address.lastname = last || "(left blank)"
68
+ else
69
+ address.firstname = first_name
70
+ address.lastname = last_name || "(left blank)"
71
+ end
64
72
  end
65
73
 
66
74
  if spree_state
@@ -71,10 +79,6 @@ module SolidusPaypalBraintree
71
79
  address
72
80
  end
73
81
 
74
- def split_name(name)
75
- name.strip.split(' ', 2)
76
- end
77
-
78
82
  # Check to see if this address should match to a state model in the database
79
83
  def should_match_state_model?
80
84
  spree_country&.states_required?
@@ -31,6 +31,7 @@ module SolidusPaypalBraintree
31
31
  nonce: transaction.nonce,
32
32
  payment_type: transaction.payment_type,
33
33
  payment_method: transaction.payment_method,
34
+ paypal_funding_source: transaction.paypal_funding_source,
34
35
  user: user
35
36
  )
36
37
  end
@@ -45,7 +46,7 @@ module SolidusPaypalBraintree
45
46
  order.shipping_address = order.billing_address = address
46
47
  # work around a bug in most solidus versions
47
48
  # about tax zone cachine between address changes
48
- order.instance_variable_set("@tax_zone", nil)
49
+ order.instance_variable_set(:@tax_zone, nil)
49
50
  end
50
51
 
51
52
  payment = order.payments.new(
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ Deface::Override.new(
4
+ name: "payments/payment/add_paypal_funding_source_to_payment",
5
+ virtual_path: "spree/payments/_payment",
6
+ original: "0b5b5ae53626059cb3a202ef95d10827dd399925",
7
+ insert_after: "erb[loud]:contains('content_tag(:span, payment.payment_method.name)')",
8
+ partial: "solidus_paypal_braintree/payments/payment"
9
+ )
@@ -10,4 +10,7 @@
10
10
  BraintreeError.HOSTED_FIELDS_TOKENIZATION_CVV_VERIFICATION_FAILED = "<%= I18n.t('solidus_paypal_braintree.errors.cvv_verification_failed')%>"
11
11
  BraintreeError.THREEDS_AUTHENTICATION_FAILED = "<%= t('solidus_paypal_braintree.errors.threeds.authentication_failed') %>";
12
12
  BraintreeError.THREEDS_CARDINAL_SDK_ERROR = "<%= t('solidus_paypal_braintree.errors.threeds.authentication_failed') %>";
13
+ BraintreeError.VENMO_CANCELED = "<%= t('solidus_paypal_braintree.errors.venmo.canceled') %>";
14
+ BraintreeError.VENMO_DESKTOP_CANCELED = "<%= t('solidus_paypal_braintree.errors.venmo.desktop_canceled') %>";
15
+ BraintreeError.VENMO_APP_CANCELED = "<%= t('solidus_paypal_braintree.errors.venmo.app_canceled') %>";
13
16
  </script>
@@ -1,21 +1,25 @@
1
1
  <% content_for :head do %>
2
- <script src="https://js.braintreegateway.com/web/3.67.0/js/client.min.js"></script>
3
- <script src="https://js.braintreegateway.com/web/3.67.0/js/data-collector.min.js"></script>
2
+ <script src="https://js.braintreegateway.com/web/3.84.0/js/client.min.js"></script>
3
+ <script src="https://js.braintreegateway.com/web/3.84.0/js/data-collector.min.js"></script>
4
4
 
5
5
  <% if current_store.braintree_configuration.paypal? %>
6
- <script src="https://js.braintreegateway.com/web/3.67.0/js/paypal-checkout.min.js"></script>
6
+ <script src="https://js.braintreegateway.com/web/3.84.0/js/paypal-checkout.min.js"></script>
7
7
  <% end %>
8
8
 
9
9
  <% if current_store.braintree_configuration.credit_card? %>
10
- <script src="https://js.braintreegateway.com/web/3.67.0/js/hosted-fields.min.js"></script>
10
+ <script src="https://js.braintreegateway.com/web/3.84.0/js/hosted-fields.min.js"></script>
11
11
 
12
12
  <% if current_store.braintree_configuration.three_d_secure? %>
13
- <script src="https://js.braintreegateway.com/web/3.67.0/js/three-d-secure.min.js"></script>
13
+ <script src="https://js.braintreegateway.com/web/3.84.0/js/three-d-secure.min.js"></script>
14
14
  <% end %>
15
15
  <% end %>
16
16
 
17
17
  <% if current_store.braintree_configuration.apple_pay? %>
18
- <script src="https://js.braintreegateway.com/web/3.67.0/js/apple-pay.min.js"></script>
18
+ <script src="https://js.braintreegateway.com/web/3.84.0/js/apple-pay.min.js"></script>
19
+ <% end %>
20
+
21
+ <% if current_store.braintree_configuration.venmo? %>
22
+ <script src="https://js.braintreegateway.com/web/3.84.0/js/venmo.min.js"></script>
19
23
  <% end %>
20
24
 
21
25
  <%= javascript_include_tag "solidus_paypal_braintree/checkout" %>
@@ -9,8 +9,10 @@
9
9
  amount: '<%= current_order.total %>',
10
10
  currency: '<%= current_order.currency %>',
11
11
  enableShippingAddress: true,
12
+ buyerCountry: '<%= SolidusPaypalBraintree::Gateway.first.preferred_force_buyer_country %>',
12
13
  environment: '<%= Rails.env.production? ? "production" : "sandbox" %>',
13
14
  locale: '<%= paypal_button_preference(:paypal_button_locale, store: current_store) %>',
15
+ useDataCollector: <%= SolidusPaypalBraintree::Gateway.first.preferred_use_data_collector %>,
14
16
  style: {
15
17
  color: '<%= paypal_button_preference(:paypal_button_color, store: current_store) %>',
16
18
  shape: '<%= paypal_button_preference(:paypal_button_shape, store: current_store) %>',
@@ -0,0 +1,33 @@
1
+ <%= button_tag '', id: 'venmo-button', class: 'venmo-button', type: 'button' %>
2
+
3
+ <% store = Spree::Store.default %>
4
+ <% style = venmo_button_style(store) %>
5
+
6
+ <style>
7
+ .venmo-button {
8
+ width: <%= style[:width] %>px;
9
+ background-image: url('<%= venmo_button_asset_url(style)%>');
10
+ }
11
+ .venmo-button:active, .venmo-button:hover {
12
+ background-color: transparent !important;
13
+ background-image: url('<%= venmo_button_asset_url(style, active: true)%>') !important;
14
+ }
15
+ </style>
16
+
17
+ <% prefix = "payment_source[#{payment_method.id}]" %>
18
+
19
+ <div class="venmo-fields">
20
+ <div class="clear"></div>
21
+ <input disabled type="hidden" name="<%= prefix %>[payment_type]" value="<%= SolidusPaypalBraintree::Source::VENMO %>">
22
+ <input disabled type="hidden" id="venmo_payment_method_nonce" name="<%= prefix %>[nonce]">
23
+ </div>
24
+
25
+ <script>
26
+ var venmoButtonElement = document.getElementById('venmo-button');
27
+ var venmoOptions = {
28
+ newBrowserTabSupported: <%= SolidusPaypalBraintree::Gateway.first.preferred_venmo_new_tab_support %>,
29
+ flow: '<%= SolidusPaypalBraintree::Gateway.first.preferred_paypal_flow %>'
30
+ };
31
+ var button = new SolidusPaypalBraintree.createVenmoButton(venmoButtonElement, venmoOptions);
32
+ button.initialize();
33
+ </script>
@@ -8,6 +8,7 @@ en:
8
8
  apple_pay: Apple Pay
9
9
  credit_card: Credit Card
10
10
  three_d_secure: 3D Secure
11
+ venmo: Venmo
11
12
  spree:
12
13
  admin:
13
14
  tab:
@@ -21,6 +22,8 @@ en:
21
22
  public_key: Public key
22
23
  token_generation_enabled: Token generation enabled?
23
24
  paypal_flow: PayPal flow
25
+ paypal_funding: 'PayPal Funding: %{funding}'
26
+ paypal_funding_source: 'PayPal Funding Source'
24
27
  solidus_paypal_braintree:
25
28
  braintree: Braintree
26
29
  nonce: Nonce
@@ -37,11 +40,16 @@ en:
37
40
  cvv_verification_failed: "CVV did not pass verification."
38
41
  threeds:
39
42
  authentication_failed: "3D Secure authentication failed. Please try again using a different payment method."
43
+ venmo:
44
+ canceled: "App is not available or you aborted the payment flow."
45
+ desktop_canceled: "Venmo authorization was canceled by closing the Venmo Desktop modal."
46
+ app_canceled: "Payment flow was canceled."
40
47
  payment_type:
41
48
  label: Payment Type
42
49
  apple_pay_card: Apple Pay
43
50
  credit_card: Credit Card
44
51
  pay_pal_account: PayPal
52
+ venmo_account: Venmo
45
53
  configurations:
46
54
  title: Braintree Configurations
47
55
  tab: Braintree
@@ -60,3 +68,29 @@ en:
60
68
  gateway_rejected: Gateway rejected this transaction.
61
69
  processor_declined: Processor declined this transaction.
62
70
  settlement_declined: Settlement was declined by processor.
71
+ paypal_funding_sources:
72
+ applepay: 'Apple Pay'
73
+ bancontact: 'Bancontact'
74
+ blik: 'BLIK'
75
+ boleto: 'Boleto'
76
+ card: 'Credit or debit card'
77
+ credit: 'PayPal Credit'
78
+ eps: 'eps'
79
+ giropay: 'giropay'
80
+ ideal: 'iDEAL'
81
+ itau: 'Itau'
82
+ maxima: 'Maxima'
83
+ mercadopago: 'Mercado Pago'
84
+ mybank: 'MyBank'
85
+ oxxo: 'Oxxo'
86
+ p24: 'Przelewy24'
87
+ paylater: 'Pay Later'
88
+ paypal: 'PayPal'
89
+ payu: 'PayU'
90
+ sepa: 'SEPA-Lastschrift'
91
+ sofort: 'Sofort'
92
+ trustly: 'Trustly'
93
+ venmo: 'Venmo'
94
+ verkkopankki: 'Verkkopankki'
95
+ wechatpay: 'WeChat Pay'
96
+ zimpler: 'Zimpler'
@@ -29,6 +29,8 @@ it:
29
29
  duplicate_iframe: Ci sono due iframe di Braintree.
30
30
  fail_on_duplicate: Questo metodo di pagamento esiste già.
31
31
  cvv_verification_failed: Il codice CVV non è corretto.
32
+ threeds:
33
+ authentication_failed: "Autenticazione 3D Secure fallita. Riprova usando un altro metodo di pagamento."
32
34
  payment_type:
33
35
  label: Metodo di Pagamento
34
36
  apple_pay_card: Apple Pay
@@ -0,0 +1,5 @@
1
+ class AddPaypalFundingSourceToSolidusPaypalBraintreeSources < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :solidus_paypal_braintree_sources, :paypal_funding_source, :integer
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddVenmoToBraintreeConfiguration < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :solidus_paypal_braintree_configurations, :venmo, :boolean, null: false, default: false
4
+ end
5
+ end
@@ -30,6 +30,7 @@ module SolidusPaypalBraintree
30
30
  permit(configuration_fields: [
31
31
  :paypal,
32
32
  :apple_pay,
33
+ :venmo,
33
34
  :credit_card,
34
35
  :three_d_secure,
35
36
  :preferred_paypal_button_locale,
@@ -38,7 +39,9 @@ module SolidusPaypalBraintree
38
39
  :preferred_paypal_button_label,
39
40
  :preferred_paypal_button_tagline,
40
41
  :preferred_paypal_button_layout,
41
- :preferred_paypal_button_messaging
42
+ :preferred_paypal_button_messaging,
43
+ :preferred_venmo_button_color,
44
+ :preferred_venmo_button_width
42
45
  ])
43
46
  end
44
47
  end
@@ -7,6 +7,7 @@ module SolidusPaypalBraintree
7
7
  PERMITTED_BRAINTREE_TRANSACTION_PARAMS = [
8
8
  :nonce,
9
9
  :payment_type,
10
+ :paypal_funding_source,
10
11
  :phone,
11
12
  :email,
12
13
  { address_attributes: [
@@ -20,14 +20,16 @@ module SolidusPaypalBraintree
20
20
 
21
21
  initializer "register_solidus_paypal_braintree_gateway", after: "spree.register.payment_methods" do |app|
22
22
  app.config.spree.payment_methods << SolidusPaypalBraintree::Gateway
23
- Spree::PermittedAttributes.source_attributes.concat [:nonce, :payment_type]
23
+ SolidusPaypalBraintree::Gateway.allowed_admin_form_preference_types << :preference_select
24
+ Spree::PermittedAttributes.source_attributes.concat [:nonce, :payment_type, :paypal_funding_source]
24
25
  end
25
26
 
26
27
  if SolidusSupport.frontend_available?
27
28
  config.assets.precompile += [
28
29
  'solidus_paypal_braintree/checkout.js',
29
30
  'solidus_paypal_braintree/frontend.js',
30
- 'spree/frontend/apple_pay_button.js'
31
+ 'spree/frontend/apple_pay_button.js',
32
+ 'solidus_paypal_braintree_manifest.js'
31
33
  ]
32
34
  paths["app/controllers"] << "lib/controllers/frontend"
33
35
  paths["app/views"] << "lib/views/frontend"
@@ -6,6 +6,28 @@ FactoryBot.define do
6
6
  #
7
7
  # Example adding this to your spec_helper will load these Factories for use:
8
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
9
31
  end
10
32
 
11
33
  FactoryBot.modify do
@@ -15,8 +37,17 @@ FactoryBot.modify do
15
37
  # As we match the body in our VCR settings VCR can not match the request anymore and therefore cannot replay existing
16
38
  # cassettes.
17
39
  #
40
+
18
41
  factory :address do
19
42
  zipcode { '21088-0255' }
20
- lastname { 'Doe' }
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
21
52
  end
22
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusPaypalBraintree
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -25,6 +25,14 @@
25
25
  <% end %>
26
26
  </div>
27
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 %>
34
+ </div>
35
+
28
36
  <div class="field">
29
37
  <%= c.check_box :credit_card %>
30
38
  <%= c.label :credit_card do %>
@@ -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>
@@ -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 %>
@@ -16,4 +16,8 @@
16
16
  <%= render "spree/shared/apple_pay_button", id: id %>
17
17
  <% end %>
18
18
 
19
+ <% if current_store.braintree_configuration.venmo? %>
20
+ <%= render "spree/shared/venmo_button", payment_method: payment_method %>
21
+ <% end %>
22
+
19
23
  <%= render "spree/shared/braintree_errors" %>
@@ -9,6 +9,8 @@
9
9
  amount: '<%= current_order.total %>',
10
10
  currency: '<%= current_order.currency %>',
11
11
  enableShippingAddress: true,
12
+ venmoFunding: <%= SolidusPaypalBraintree::Gateway.first.preferred_enable_venmo_funding %>,
13
+ buyerCountry: '<%= SolidusPaypalBraintree::Gateway.first.preferred_force_buyer_country %>',
12
14
  shippingAddressOverride: address,
13
15
  shippingAddressEditable: false,
14
16
  environment: '<%= Rails.env.production? ? "production" : "sandbox" %>',
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.email = 'braintree+gemfile@stembolt.com'
15
15
  s.homepage = 'https://github.com/solidusio/solidus_paypal_braintree'
16
16
 
17
- s.required_ruby_version = '~> 2.4'
17
+ s.required_ruby_version = '>= 2.5'
18
18
 
19
19
  s.files = Dir.chdir(File.expand_path(__dir__)) do
20
20
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -27,13 +27,14 @@ Gem::Specification.new do |s|
27
27
  if s.respond_to?(:metadata)
28
28
  s.metadata["homepage_uri"] = s.homepage if s.homepage
29
29
  s.metadata["source_code_uri"] = s.homepage if s.homepage
30
+ s.metadata["rubygems_mfa_required"] = 'true'
30
31
  end
31
32
 
32
33
  s.add_dependency 'activemerchant', '~> 1.48'
33
- s.add_dependency 'braintree', '~> 2.65'
34
- s.add_dependency 'solidus_api', ['>= 2.0.0', '< 3']
35
- s.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
36
- s.add_dependency 'solidus_support', '~> 0.5.0'
34
+ s.add_dependency 'braintree', '~> 3.4'
35
+ s.add_dependency 'solidus_api', ['>= 2.0.0', '< 4']
36
+ s.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
37
+ s.add_dependency 'solidus_support', ['>= 0.8.1', '< 1']
37
38
 
38
39
  s.add_development_dependency 'selenium-webdriver'
39
40
  s.add_development_dependency 'solidus_dev_support'
@@ -101,7 +101,7 @@ RSpec.describe SolidusPaypalBraintree::TransactionsController, type: :controller
101
101
  # the transaction import only creates 1 new one
102
102
  order
103
103
  expect { post_create }.to change { Spree::Address.count }.by(1)
104
- expect(Spree::Address.last.full_name).to eq "Wade Wilson"
104
+ expect(Spree::Address.last.address1).to eq "123 Fake Street"
105
105
  end
106
106
  end
107
107
 
@@ -5,6 +5,7 @@ shared_context "with frontend checkout setup" do
5
5
  let(:braintree) { new_gateway(active: true) }
6
6
  let!(:gateway) { create :payment_method }
7
7
  let(:three_d_secure_enabled) { false }
8
+ let(:venmo_enabled) { false }
8
9
  let(:card_number) { "4111111111111111" }
9
10
  let(:card_expiration) { "01/#{Time.now.utc.year + 2}" }
10
11
 
@@ -14,7 +15,8 @@ shared_context "with frontend checkout setup" do
14
15
  create(:store, payment_methods: [gateway, braintree]).tap do |store|
15
16
  store.braintree_configuration.update!(
16
17
  credit_card: true,
17
- three_d_secure: three_d_secure_enabled
18
+ three_d_secure: three_d_secure_enabled,
19
+ venmo: venmo_enabled
18
20
  )
19
21
 
20
22
  braintree.update(
@@ -77,6 +79,8 @@ describe 'entering credit card details', type: :feature, js: true do
77
79
  match_requests_on: [:braintree_uri]
78
80
  } do
79
81
  include_context "with frontend checkout setup"
82
+ # To ensure Venmo inputs do not conflict with checkout
83
+ let(:venmo_enabled) { true }
80
84
 
81
85
  before do
82
86
  within_frame("braintree-hosted-field-number") do