spree_braintree_vzero 3.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +15 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/.travis.yml +63 -0
- data/Appraisals +45 -0
- data/CONTRIBUTING.md +28 -0
- data/Gemfile +14 -0
- data/LICENSE +26 -0
- data/README.md +83 -0
- data/Rakefile +21 -0
- data/app/assets/images/credit_cards/icons/jcb.png +0 -0
- data/app/assets/javascripts/spree/backend/payments.js +19 -0
- data/app/assets/javascripts/spree/backend/spree_braintree_vzero.js +81 -0
- data/app/assets/javascripts/spree/frontend/spree_braintree_vzero.js +68 -0
- data/app/assets/stylesheets/spree/backend/spree_braintree_vzero.css +5 -0
- data/app/controllers/spree/admin/payments_controller_decorator.rb +43 -0
- data/app/controllers/spree/api/v1/braintree_client_token_controller.rb +31 -0
- data/app/controllers/spree/checkout_controller_decorator.rb +38 -0
- data/app/controllers/spree/orders_controller_decorator.rb +62 -0
- data/app/controllers/spree/user_sessions_controller_decorator.rb +15 -0
- data/app/helpers/spree/admin/decorated_navigation_helper.rb +10 -0
- data/app/helpers/spree/admin/payment_methods_helper.rb +101 -0
- data/app/helpers/spree/braintree_helper.rb +27 -0
- data/app/models/braintree/successful_result_decorator.rb +21 -0
- data/app/models/spree/address_decorator.rb +18 -0
- data/app/models/spree/braintree_checkout.rb +105 -0
- data/app/models/spree/gateway/braintree_vzero_base.rb +168 -0
- data/app/models/spree/gateway/braintree_vzero_base/address.rb +33 -0
- data/app/models/spree/gateway/braintree_vzero_base/braintree_user.rb +25 -0
- data/app/models/spree/gateway/braintree_vzero_base/purchase_data.rb +48 -0
- data/app/models/spree/gateway/braintree_vzero_base/transaction.rb +39 -0
- data/app/models/spree/gateway/braintree_vzero_base/utils.rb +108 -0
- data/app/models/spree/gateway/braintree_vzero_drop_in_ui.rb +24 -0
- data/app/models/spree/gateway/braintree_vzero_hosted_fields.rb +28 -0
- data/app/models/spree/gateway/braintree_vzero_paypal_express.rb +36 -0
- data/app/models/spree/order_decorator.rb +153 -0
- data/app/models/spree/payment_decorator.rb +10 -0
- data/app/models/spree/payment_processing_decorator.rb +61 -0
- data/app/models/spree/preferences/preferable_decorator.rb +54 -0
- data/app/overrides/spree/admin/orders/customer_details/_form.rb +8 -0
- data/app/overrides/spree/admin/payment_methods/_form.rb +10 -0
- data/app/overrides/spree/admin/shared/_order_summary.rb +23 -0
- data/app/overrides/spree/admin/shared/_refunds.rb +13 -0
- data/app/overrides/spree/checkout/_new_user.rb +6 -0
- data/app/overrides/spree/checkout/_payment.rb +20 -0
- data/app/overrides/spree/checkout/registration.rb +6 -0
- data/app/overrides/spree/orders/edit.rb +6 -0
- data/app/overrides/spree/shared/_order_details.rb +13 -0
- data/app/overrides/spree/shared/_payment.rb +28 -0
- data/app/views/spree/admin/payment_methods/_braintree_vzero_form.html.erb +83 -0
- data/app/views/spree/admin/payments/source_forms/_braintree_vzero_dropin_ui.html.erb +1 -0
- data/app/views/spree/admin/payments/source_forms/_braintree_vzero_hosted_fields.html.erb +1 -0
- data/app/views/spree/admin/payments/source_forms/_braintree_vzero_paypal_express.html.erb +1 -0
- data/app/views/spree/admin/payments/source_forms/braintree_vzero/_payments.html.erb +87 -0
- data/app/views/spree/admin/payments/source_views/_braintree_vzero_dropin_ui.html.erb +1 -0
- data/app/views/spree/admin/payments/source_views/_braintree_vzero_hosted_fields.html.erb +1 -0
- data/app/views/spree/admin/payments/source_views/_braintree_vzero_paypal_express.html.erb +1 -0
- data/app/views/spree/admin/payments/source_views/braintree_vzero/_payment.html.erb +17 -0
- data/app/views/spree/braintree_vzero/_paypal_checkout.html.erb +87 -0
- data/app/views/spree/checkout/payment/_braintree_vzero_dropin_ui.html.erb +4 -0
- data/app/views/spree/checkout/payment/_braintree_vzero_hosted_fields.html.erb +4 -0
- data/app/views/spree/checkout/payment/_braintree_vzero_paypal_express.html.erb +4 -0
- data/app/views/spree/checkout/payment/braintree_vzero/_buttons.html.erb +11 -0
- data/app/views/spree/checkout/payment/braintree_vzero/_dropin_on_error_callback.js.erb +3 -0
- data/app/views/spree/checkout/payment/braintree_vzero/_dropin_on_ready_callback.js.erb +1 -0
- data/app/views/spree/checkout/payment/braintree_vzero/_hosted_fields_on_field_event_callback.js.erb +12 -0
- data/app/views/spree/checkout/payment/braintree_vzero/_hosted_fields_styles.js.erb +29 -0
- data/app/views/spree/checkout/payment/braintree_vzero/_payment.html.erb +84 -0
- data/app/views/spree/checkout/payment/braintree_vzero/_three_d_secure.html.erb +218 -0
- data/app/views/spree/shared/braintree_vzero/_dropin.js.erb +70 -0
- data/app/views/spree/shared/braintree_vzero/_hosted.js.erb +66 -0
- data/app/views/spree/shared/braintree_vzero/_paypal.js.erb +39 -0
- data/bin/rails +7 -0
- data/config/initializers/extend_spree_permitted_checkout_attributes.rb +5 -0
- data/config/initializers/prepend_helpers.rb +1 -0
- data/config/locales/en.yml +79 -0
- data/config/routes.rb +7 -0
- data/db/migrate/20150904143013_create_spree_braintree_checkouts.rb +9 -0
- data/db/migrate/20151002094655_add_braintree_id_to_spree_addresses.rb +5 -0
- data/db/migrate/20151018123907_add_braintree_token_and_nonce_to_spree_payments.rb +6 -0
- data/db/migrate/20151027135109_add_paypal_email_to_spree_braintree_checkout.rb +5 -0
- data/db/migrate/20151028095515_add_advanced_fraud_data_to_spree_braintree_checkout.rb +5 -0
- data/db/migrate/20151202095956_add_risk_id_and_risk_decision_to_spree_braintree_checkouts.rb +6 -0
- data/db/migrate/20151211100203_add_braintree_last_digits_and_braintree_card_type_to_spree_braintree_checkouts.rb +6 -0
- data/db/migrate/20160112153422_add_admin_payment_to_spree_braintree_checkout.rb +5 -0
- data/gemfiles/spree_3_5.gemfile +12 -0
- data/gemfiles/spree_3_5_spree_auth_devise.gemfile +13 -0
- data/gemfiles/spree_3_7.gemfile +12 -0
- data/gemfiles/spree_3_7_spree_auth_devise.gemfile +13 -0
- data/gemfiles/spree_4_0.gemfile +11 -0
- data/gemfiles/spree_4_0_spree_auth_devise.gemfile +12 -0
- data/gemfiles/spree_master.gemfile +11 -0
- data/gemfiles/spree_master_spree_auth_devise.gemfile +12 -0
- data/lib/generators/spree_braintree_vzero/install/install_generator.rb +34 -0
- data/lib/spree_braintree_vzero.rb +6 -0
- data/lib/spree_braintree_vzero/engine.rb +28 -0
- data/lib/spree_braintree_vzero/factories.rb +10 -0
- data/lib/spree_braintree_vzero/railtie.rb +8 -0
- data/lib/spree_braintree_vzero/version.rb +17 -0
- data/lib/tasks/spree_braintree_vzero.rake +6 -0
- data/spec/controllers/spree/api/v1/braintree_client_token_controller_spec.rb +49 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +85 -0
- data/spec/controllers/spree/orders_controller_spec.rb +97 -0
- data/spec/factories/braintree_checkout_factory.rb +7 -0
- data/spec/factories/braintree_gateway_factory.rb +35 -0
- data/spec/factories/payment_factory_decorator.rb +28 -0
- data/spec/features/spree/admin/log_entries_spec.rb +63 -0
- data/spec/models/gateway/braintree_vzero_base/address_spec.rb +28 -0
- data/spec/models/gateway/braintree_vzero_base/purchase_data_spec.rb +57 -0
- data/spec/models/gateway/braintree_vzero_base_spec.rb +346 -0
- data/spec/models/gateway/braintree_vzero_dropin_ui_spec.rb +35 -0
- data/spec/models/gateway/braintree_vzero_hosted_fields_spec.rb +35 -0
- data/spec/models/spree/order_spec.rb +186 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/support/vcr.rb +10 -0
- data/spec/vcr/Log_entries/with_a_failed_log_entry/shows_a_failed_attempt.yml +91 -0
- data/spec/vcr/Log_entries/with_a_successful_log_entry/shows_a_successful_attempt.yml +113 -0
- data/spec/vcr/Spree_Api_V1_BraintreeClientTokenController/POST_create/guest_checkout/returns_proper_json_data_when_gateway_not_specified.yml +90 -0
- data/spec/vcr/Spree_Api_V1_BraintreeClientTokenController/POST_create/guest_checkout/returns_proper_json_data_when_gateway_specified.yml +90 -0
- data/spec/vcr/Spree_Api_V1_BraintreeClientTokenController/POST_create/user_checkout/returns_proper_json_data_when_gateway_not_specified.yml +191 -0
- data/spec/vcr/Spree_Api_V1_BraintreeClientTokenController/POST_create/user_checkout/returns_proper_json_data_when_gateway_specified.yml +191 -0
- data/spec/vcr/Spree_CheckoutController/_update/braintree_payment/advanced_fraud_data_in_source_should_be_updated.yml +71 -0
- data/spec/vcr/Spree_CheckoutController/_update/braintree_payment/when_token_credit_card_data_in_source_should_be_updated_from_Braintree_Vault.yml +139 -0
- data/spec/vcr/Spree_CheckoutController/_update/braintree_paypal_express_payment/amount_in_payment_should_be_updated.yml +280 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_capture/captures_authorized_amount/updates_Payment_state.yml +206 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_credit/with_refundable_state/should_be_a_success.yml +211 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_credit/with_unrefundable_state/should_not_be_a_success.yml +177 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/data_from_admin_panel/should_include_only_essential_data.yml +78 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/does_not_store_Transaction_in_Vault_by_default.yml +111 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/returns_false_with_invalid_nonce.yml +88 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/returns_false_with_invalid_token.yml +88 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/returns_success_with_valid_token.yml +113 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/returns_suceess_with_valid_nonce.yml +111 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/using_Vault/saves_Braintree_Address_id_to_Spree_Address_when_address_is_being_saved.yml +130 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/using_Vault/saves_unique_Braintree_Addresses_ids.yml +143 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/using_Vault/sends_empty_address_id_when_address_is_already_in_vault.yml +553 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/using_Vault/stores_Transaction.yml +181 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/with_3DSecure_option_turned_on/performs_3DSecure_check.yml +112 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/with_3DSecure_option_turned_on/returns_error.yml +112 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/with_advanced_fraud_tool_enabled/returns_fraud_data.yml +111 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_purchase/with_advanced_fraud_tool_enabled/returns_success.yml +111 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_settle/settles_authorized_amount/does_not_update_Order_payment_state.yml +204 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_settle/settles_authorized_amount/prepares_Checkout_for_status_updating.yml +204 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_settle/settles_authorized_amount/submits_Transaction_for_settlement.yml +377 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_settle/settles_authorized_amount/updates_Payment_state.yml +203 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_update_states/does_not_update_completed_Checkout_on_subsequent_runs.yml +202 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_update_states/updates_Order_payment_state_when_Checkout_is_updated.yml +202 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_update_states/updates_Payment_state_when_Checkout_is_updated.yml +202 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_update_states/updates_payment_State.yml +202 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_void/with_unvoidable_state/should_not_change_payment_source_state.yml +178 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/_void/with_voidable_state/should_change_payment_source_state_to_voided.yml +199 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/generates_token_for_User_registered_in_Braintree.yml +356 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/generates_token_for_new_User.yml +189 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/valid_credentials/generates_token_without_User.yml +89 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase/with_invalid_credentials/raises_Braintree_error.yml +62 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase_Address/_create/creates_Braintree_Address.yml +84 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase_Address/_create/deletes_Braintree_Address.yml +141 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase_Address/_create/finds_Braintree_Address.yml +148 -0
- data/spec/vcr/Spree_Gateway_BraintreeVzeroBase_Address/_create/updates_Braintree_Address.yml +154 -0
- data/spec/vcr/Spree_Order/complete_with_braintree_vzero_standard_payment/with_auto_capture/should_complete_payment.yml +116 -0
- data/spec/vcr/Spree_Order/complete_with_braintree_vzero_standard_payment/with_auto_capture/should_update_payment_s_response_code.yml +111 -0
- data/spec/vcr/Spree_Order/complete_with_braintree_vzero_standard_payment/with_auto_capture/should_update_payment_s_source_state_and_transaction_id.yml +111 -0
- data/spec/vcr/Spree_Order/complete_with_braintree_vzero_standard_payment/without_auto_capture/should_pend_payment.yml +111 -0
- data/spec/vcr/Spree_Order/complete_with_braintree_vzero_standard_payment/without_auto_capture/should_update_payment_s_response_code.yml +111 -0
- data/spec/vcr/Spree_Order/complete_with_braintree_vzero_standard_payment/without_auto_capture/should_update_payment_s_source_state_and_transaction_id.yml +110 -0
- data/spree_braintree_vzero.gemspec +52 -0
- data/vendor/assets/javascripts/maskedinput/jquery.maskedinput.min.js +7 -0
- metadata +643 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
Deface::Override.new(
|
2
|
+
virtual_path: 'spree/shared/_order_details',
|
3
|
+
name: 'Displays payment data for PayPal Express payment methods',
|
4
|
+
replace: %{erb[silent]:contains('order.has_step?("payment")')},
|
5
|
+
text: '<% if @order.has_step?("payment") || @order.paid_with_paypal_express? %>'
|
6
|
+
)
|
7
|
+
|
8
|
+
Deface::Override.new(
|
9
|
+
virtual_path: 'spree/shared/_order_details',
|
10
|
+
name: 'Removes redirect to payment step when there is no payment',
|
11
|
+
replace: 'erb[loud]:contains("checkout_state_path(:payment) unless order.completed?")',
|
12
|
+
text: '<%= link_to "(#{Spree.t(:edit)})", checkout_state_path(:payment) unless order.completed? || order.paid_with_paypal_express? %>'
|
13
|
+
)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Deface::Override.new(
|
2
|
+
virtual_path: 'spree/shared/_payment',
|
3
|
+
name: 'Displays payment data for PayPal Express payment methods',
|
4
|
+
replace: 'erb[silent]:contains("else")',
|
5
|
+
text: %{
|
6
|
+
<% elsif payment.payment_method.kind_of?(Spree::Gateway::BraintreeVzeroBase) %>
|
7
|
+
<% if (last_digits = payment.source.braintree_last_digits) %>
|
8
|
+
<%
|
9
|
+
cc_type = payment.source.braintree_card_type
|
10
|
+
img = "credit_cards/icons/" + cc_type.downcase + ".png"
|
11
|
+
%>
|
12
|
+
<% if asset_available?(img) %>
|
13
|
+
<%= image_tag img %>
|
14
|
+
<% else %>
|
15
|
+
<p><%= Spree.t(:cc_type) + ": " + cc_type %></p>
|
16
|
+
</br>
|
17
|
+
<% end %>
|
18
|
+
<p><%= Spree.t(:ending_in) + " " + last_digits %></p>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% if (paypal_email = payment.source.paypal_email) %>
|
22
|
+
<!-- PayPal Logo --><img src="https://www.paypalobjects.com/webstatic/mktg/logo/pp_cc_mark_37x23.jpg" border="0" alt="PayPal Logo"><!-- PayPal Logo -->
|
23
|
+
<%= paypal_email %>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<% else %>
|
27
|
+
}
|
28
|
+
)
|
@@ -0,0 +1,83 @@
|
|
1
|
+
<div data-hook="admin_payment_method_form_fields">
|
2
|
+
|
3
|
+
<div class="card mb-3">
|
4
|
+
<div class="card-header">
|
5
|
+
<h1 class="card-title h5 mb-0">
|
6
|
+
<%= Spree.t(:general_settings)%>
|
7
|
+
</h1>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="card-body">
|
11
|
+
<div class="row">
|
12
|
+
<div class="col-lg-4">
|
13
|
+
<%= f.field_container :provider, class: ['form-group'] do %>
|
14
|
+
<%= f.label :type, Spree.t(:provider) %>
|
15
|
+
<%= collection_select(:payment_method, :type, @providers, :to_s, :name, {}, {id: 'gtwy-type', class: 'select2'}) %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<% unless @object.new_record? %>
|
19
|
+
<%= braintree_basic_preference_fields(@object, f) %>
|
20
|
+
|
21
|
+
<% if @object.respond_to?(:preferences) %>
|
22
|
+
<div id="gateway-settings-warning" class="info warning">
|
23
|
+
<%= Spree.t(:provider_settings_warning) %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
<%= f.field_container :payment_method_display_on, class: ['form-group'] do %>
|
29
|
+
<%= label_tag :payment_method_display_on, Spree.t(:display) %>
|
30
|
+
<%= select(:payment_method, :display_on, Spree::PaymentMethod::DISPLAY.collect { |display| [Spree.t(display), display.to_s] }, {}, {:class => 'select2'}) %>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
<%= f.field_container :payment_method_auto_capture, class: ['form-group'] do %>
|
34
|
+
<%= label_tag :payment_method_auto_capture, Spree.t(:auto_capture) %>
|
35
|
+
<%= select(:payment_method, :auto_capture, [["#{Spree.t(:use_app_default)} (#{Spree::Config[:auto_capture]})", ''], [Spree.t(:say_yes), true], [Spree.t(:say_no), false]], {}, {:class => 'select2'}) %>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<%= f.field_container :payment_method_active, class: ['form-group'] do %>
|
39
|
+
<strong><%= Spree.t(:active) %></strong>
|
40
|
+
<div class="radio">
|
41
|
+
<%= label_tag :payment_method_active_true do %>
|
42
|
+
<%= radio_button :payment_method, :active, true %>
|
43
|
+
<%= Spree.t(:say_yes) %>
|
44
|
+
<% end %>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div class="radio">
|
48
|
+
<%= label_tag :payment_method_active_false do %>
|
49
|
+
<%= radio_button :payment_method, :active, false %>
|
50
|
+
<%= Spree.t(:say_no) %>
|
51
|
+
<% end %>
|
52
|
+
</div>
|
53
|
+
<% end %>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
<div class="col-lg-8">
|
57
|
+
<%= f.field_container :payment_method_name, class: ['form-group'] do %>
|
58
|
+
<%= label_tag :payment_method_name, Spree.t(:name) %>
|
59
|
+
<%= text_field :payment_method, :name, :class => 'form-control' %>
|
60
|
+
<% end %>
|
61
|
+
<%= f.field_container :payment_method_description, class: ['form-group'] do %>
|
62
|
+
<%= label_tag :payment_method_description, Spree.t(:description) %>
|
63
|
+
<%= text_area :payment_method, :description, { :cols => 60, :rows => 6, :class => 'form-control' } %>
|
64
|
+
<% end %>
|
65
|
+
</div>
|
66
|
+
</div>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
|
70
|
+
<div class="card mb-3">
|
71
|
+
<div class="card-header" id="advanced-preferences-heading" style="cursor: pointer;">
|
72
|
+
<h1 class="card-title h5 mb-0">
|
73
|
+
<span class="icon icon-chevron-right"></span>
|
74
|
+
<%= Spree.t(:advanced_settings)%></h1>
|
75
|
+
</div>
|
76
|
+
|
77
|
+
<div class="card-body collapsed" id="advanced-preferences" style="display: none;">
|
78
|
+
<% unless @object.new_record? %>
|
79
|
+
<%= braintree_advanced_preference_fields(@object, f) %>
|
80
|
+
<% end %>
|
81
|
+
</div>
|
82
|
+
</div>
|
83
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: 'spree/admin/payments/source_forms/braintree_vzero/payments', locals: { payment_method: payment_method, payment_method_type: 'dropin' } %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: 'spree/admin/payments/source_forms/braintree_vzero/payments', locals: { payment_method: payment_method, payment_method_type: 'custom' } %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: 'spree/admin/payments/source_forms/braintree_vzero/payments', locals: { payment_method: payment_method, payment_method_type: 'paypal' } %>
|
@@ -0,0 +1,87 @@
|
|
1
|
+
<% display_payment_methods_list = (@methods = payment_method.customer_payment_methods(@order, payment_method_type)).any? %>
|
2
|
+
<% shipping_address = @order.shipping_address %>
|
3
|
+
<% paypal = payment_method_type.eql?('paypal') %>
|
4
|
+
<% dropin = payment_method_type.eql?('dropin') %>
|
5
|
+
<% hosted = payment_method_type.eql?('custom') %>
|
6
|
+
|
7
|
+
<div class="clearfix">
|
8
|
+
<% if display_payment_methods_list %>
|
9
|
+
<%= label_tag 'saved_payment_methods', I18n.t("braintree.checkout.saved_payment_method.#{payment_method_type}") %>
|
10
|
+
<%= select_tag "saved_payment_methods_for_#{payment_method.id}", options_from_braintree_payments(@methods, true), class: 'form-control saved-payment-methods' %>
|
11
|
+
|
12
|
+
<% unless paypal %>
|
13
|
+
<div class="radio show-new-payment">
|
14
|
+
<label data-hook="braintree_payment_method_field">
|
15
|
+
<%= link_to Spree.t(dropin ? :add_new_payment_method : :add_new_credit_card), '', id: 'show-new-payment' %>
|
16
|
+
</label>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% if paypal %>
|
22
|
+
<div>
|
23
|
+
<% unless display_payment_methods_list %>
|
24
|
+
<div class="alert alert-warning">
|
25
|
+
<%= I18n.t('braintree.admin.no_paypal_payments') %>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
<% else %>
|
29
|
+
<div class="<%= display_payment_methods_list ? 'new-braintree-payment-method' : '' %>" style="<%= display_payment_methods_list ? 'display: none;' : '' %>">
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
<% if hosted %>
|
33
|
+
<br/>
|
34
|
+
<%= label_tag 'card_number_label', payment_method.preferred_number_placeholder %>
|
35
|
+
<span class="required">*</span><br />
|
36
|
+
<p id="hosted-fields-number" class="form-control"></p>
|
37
|
+
|
38
|
+
<%= label_tag 'cvv_label', payment_method.preferred_cvv_placeholder %>
|
39
|
+
<span class="required">*</span><br />
|
40
|
+
<p id="hosted-fields-cvv" class="form-control"></p>
|
41
|
+
|
42
|
+
<%= label_tag 'expiration_date_label', payment_method.preferred_expiration_date_placeholder %>
|
43
|
+
<span class="required">*</span><br />
|
44
|
+
<p id="hosted-fields-expiration-date" class="form-control"></p>
|
45
|
+
<br/>
|
46
|
+
<% elsif dropin %>
|
47
|
+
<br/>
|
48
|
+
<div id="payment-form"/>
|
49
|
+
<br/>
|
50
|
+
<% end %>
|
51
|
+
</div>
|
52
|
+
|
53
|
+
<% unless paypal %>
|
54
|
+
<%= button Spree.t('actions.update'), 'save', 'submit', class: 'new-braintree-payment-method braintree-submit' %>
|
55
|
+
<% end %>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
|
59
|
+
<script src="https://js.braintreegateway.com/v1/braintree-data.js" async=true></script>
|
60
|
+
|
61
|
+
<script type="text/javascript">
|
62
|
+
$('#payment_payment_method_id_<%= payment_method.id %>').click(function (e) {
|
63
|
+
var checkoutFormId = "new_payment";
|
64
|
+
|
65
|
+
SpreeBraintreeVzero.advancedFraudTools = false;
|
66
|
+
SpreeBraintreeVzero.paymentMethodID = "<%= payment_method.id %>";
|
67
|
+
SpreeBraintreeVzero.checkoutFormId = "#" + checkoutFormId;
|
68
|
+
SpreeBraintreeVzero.threeDSecure = false;
|
69
|
+
SpreeBraintreeVzero.paypal = <%= paypal %>;
|
70
|
+
SpreeBraintreeVzero.admin = true;
|
71
|
+
SpreeBraintreeVzero.paypal_empty = <%= !display_payment_methods_list %>
|
72
|
+
|
73
|
+
var clientToken = "<%= payment_method.client_token(@order) %>";
|
74
|
+
var errorMessagesContainer = "col-md-12";
|
75
|
+
|
76
|
+
<% if dropin %>
|
77
|
+
var container = "payment-form";
|
78
|
+
$('#' + container).empty();
|
79
|
+
<% end %>
|
80
|
+
var checkout;
|
81
|
+
|
82
|
+
braintree.setup(clientToken, '<%= payment_method_type %>', {
|
83
|
+
<%= render(partial: 'spree/shared/braintree_vzero/dropin', locals: { shipping_address: shipping_address, payment_method: payment_method }, formats: [:js]) if dropin %>
|
84
|
+
<%= render(partial: 'spree/shared/braintree_vzero/hosted', locals: { payment_method: payment_method }, formats: [:js]) if hosted %>
|
85
|
+
});
|
86
|
+
});
|
87
|
+
</script>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: 'spree/admin/payments/source_views/braintree_vzero/payment', locals: { payment: payment, payment_type: 'dropin' } %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: 'spree/admin/payments/source_views/braintree_vzero/payment', locals: { payment: payment, payment_type: 'custom' } %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: 'spree/admin/payments/source_views/braintree_vzero/payment', locals: { payment: payment, payment_type: 'paypal' } %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<fieldset data-hook="braintree_vzero">
|
2
|
+
<legend><%= I18n.t("braintree.title.#{payment_type}") %></legend>
|
3
|
+
<table class="table table-condensed table-bordered">
|
4
|
+
<tr>
|
5
|
+
<th width="20%"><%= Spree.t(:transaction_id) %>:</th>
|
6
|
+
<td><%= payment.source.transaction_id %></td>
|
7
|
+
</tr>
|
8
|
+
<tr>
|
9
|
+
<th><%= I18n.t('braintree.state') %>:</th>
|
10
|
+
<td><%= payment.source.state %></td>
|
11
|
+
</tr>
|
12
|
+
<tr>
|
13
|
+
<th><%= Spree.t(:state) %>:</th>
|
14
|
+
<td><%= payment.state %></td>
|
15
|
+
</tr>
|
16
|
+
</table>
|
17
|
+
</fieldset>
|
@@ -0,0 +1,87 @@
|
|
1
|
+
<% if (payment_method = Spree::PaymentMethod.where(type: 'Spree::Gateway::BraintreeVzeroPaypalExpress', active: true).last).try(:preferred_paypal_display_on_cart) %>
|
2
|
+
<div id="paypal-container" class="btn">
|
3
|
+
<input type='hidden' name='paypal[payment_method_id]' value='<%= payment_method.id %>'>
|
4
|
+
<img src="https://www.paypalobjects.com/en_US/i/btn/btn_xpressCheckout.gif" id="btnOpenFlow">
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
|
8
|
+
<script src="https://js.braintreegateway.com/js/braintree-2.32.1.min.js"></script>
|
9
|
+
|
10
|
+
<script type="text/javascript">
|
11
|
+
var checkoutFormId = '#update-cart';
|
12
|
+
var checkout;
|
13
|
+
SpreeBraintreeVzero.checkoutFormId = '#update-cart';
|
14
|
+
|
15
|
+
braintree.setup("<%= payment_method.client_token(current_order) %>", "paypal", {
|
16
|
+
container: "paypal-container",
|
17
|
+
singleUse: <%= payment_method.preferred_store_payments_in_vault.eql?('do_not_store') %>,
|
18
|
+
amount: <%= @order.total %>,
|
19
|
+
currency: "<%= current_currency %>",
|
20
|
+
locale: "en_us",
|
21
|
+
enableShippingAddress: true,
|
22
|
+
enableBillingAddress: true,
|
23
|
+
displayName: "<%= payment_method.preferred_paypal_display_name %>",
|
24
|
+
<% if payment_method.preferred_advanced_fraud_tools %>
|
25
|
+
dataCollector: {
|
26
|
+
kount: {
|
27
|
+
environment: "<%= payment_method.preferred_server %>"
|
28
|
+
<% if (kount_id = payment_method.preferred_kount_merchant_id).present? %>
|
29
|
+
,
|
30
|
+
merchantId: "<%= kount_id %>"
|
31
|
+
<% end %>
|
32
|
+
}
|
33
|
+
},
|
34
|
+
<% end %>
|
35
|
+
|
36
|
+
onReady: function (integration) {
|
37
|
+
SpreeBraintreeVzero.deviceData = integration.deviceData;
|
38
|
+
checkout = integration;
|
39
|
+
},
|
40
|
+
headless: true,
|
41
|
+
|
42
|
+
onPaymentMethodReceived: function (result) {
|
43
|
+
$('#paypal-container').hide()
|
44
|
+
$('#checkout-link').prop("disabled", true);
|
45
|
+
phone = result.details.phone
|
46
|
+
SpreeBraintreeVzero.addDeviceData();
|
47
|
+
|
48
|
+
if(shippingAddress = result.details.shippingAddress) {
|
49
|
+
$(checkoutFormId).append("<input type='hidden' name='order[ship_address][zipcode]' value='" + shippingAddress.postalCode + "'>");
|
50
|
+
$(checkoutFormId).append("<input type='hidden' name='order[ship_address][full_name]' value='" + shippingAddress.recipientName + "'>");
|
51
|
+
$(checkoutFormId).append("<input type='hidden' name='order[ship_address][firstname]' value='" + result.details.firstName + "'>");
|
52
|
+
$(checkoutFormId).append("<input type='hidden' name='order[ship_address][lastname]' value='" + result.details.lastName + "'>");
|
53
|
+
$(checkoutFormId).append("<input type='hidden' name='order[ship_address][address1]' value='" + shippingAddress.streetAddress + "'>");
|
54
|
+
$(checkoutFormId).append("<input type='hidden' name='order[ship_address][address2]' value='" + shippingAddress.extendedAddress + "'>");
|
55
|
+
$(checkoutFormId).append("<input type='hidden' name='order[ship_address][city]' value='" + shippingAddress.locality + "'>");
|
56
|
+
$(checkoutFormId).append("<input type='hidden' name='order[ship_address][country]' value='" + shippingAddress.countryCodeAlpha2 + "'>");
|
57
|
+
$(checkoutFormId).append("<input type='hidden' name='order[ship_address][state]' value='" + shippingAddress.region + "'>");
|
58
|
+
if(phone)
|
59
|
+
$(checkoutFormId).append("<input type='hidden' name='order[ship_address][phone]' value='" + phone + "'>");
|
60
|
+
}
|
61
|
+
|
62
|
+
if(billingAddress = result.details.billingAddress) {
|
63
|
+
$(checkoutFormId).append("<input type='hidden' name='order[bill_address][zipcode]' value='" + billingAddress.postalCode + "'>");
|
64
|
+
$(checkoutFormId).append("<input type='hidden' name='order[bill_address][firstname]' value='" + result.details.firstName + "'>");
|
65
|
+
$(checkoutFormId).append("<input type='hidden' name='order[bill_address][lastname]' value='" + result.details.lastName + "'>");
|
66
|
+
$(checkoutFormId).append("<input type='hidden' name='order[bill_address][address1]' value='" + billingAddress.streetAddress + "'>");
|
67
|
+
$(checkoutFormId).append("<input type='hidden' name='order[bill_address][address2]' value='" + billingAddress.extendedAddress + "'>");
|
68
|
+
$(checkoutFormId).append("<input type='hidden' name='order[bill_address][city]' value='" + billingAddress.locality + "'>");
|
69
|
+
$(checkoutFormId).append("<input type='hidden' name='order[bill_address][country]' value='" + billingAddress.countryCodeAlpha2 + "'>");
|
70
|
+
$(checkoutFormId).append("<input type='hidden' name='order[bill_address][state]' value='" + billingAddress.region + "'>");
|
71
|
+
if(phone)
|
72
|
+
$(checkoutFormId).append("<input type='hidden' name='order[bill_address][phone]' value='" + phone + "'>");
|
73
|
+
}
|
74
|
+
|
75
|
+
$(checkoutFormId).append("<input type='hidden' name='order[email]' value=" + result.details.email + ">");
|
76
|
+
$(checkoutFormId).append("<input type='hidden' name='paypal[payment_method_nonce]' value=" + result.nonce + ">");
|
77
|
+
$(checkoutFormId).append("<input type='hidden' name='checkout' value=true>");
|
78
|
+
|
79
|
+
$(checkoutFormId).submit();
|
80
|
+
}
|
81
|
+
});
|
82
|
+
|
83
|
+
document.querySelector('#btnOpenFlow').addEventListener('click', function () { checkout.paypal.initAuthFlow(); }, false);
|
84
|
+
</script>
|
85
|
+
<% else %>
|
86
|
+
|
87
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% @order.available_payment_methods.each do |method| %>
|
2
|
+
<% next unless method.kind_of?(Spree::Gateway::BraintreeVzeroBase) %>
|
3
|
+
|
4
|
+
<% if method.is_a?(Spree::Gateway::BraintreeVzeroPaypalExpress) %>
|
5
|
+
<span id="paypal-submit", class="btn btn-lg btn-success primary braintree-submit", style="display: none;" method_id="<%= method.id %>">
|
6
|
+
<%= Spree.t(:save_and_continue) %>
|
7
|
+
</span>
|
8
|
+
<% else %>
|
9
|
+
<%= submit_tag Spree.t(:save_and_continue), class: 'btn btn-lg btn-success primary braintree-submit', style: 'display: none;', method_id: method.id %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
// console.log(integration)
|
data/app/views/spree/checkout/payment/braintree_vzero/_hosted_fields_on_field_event_callback.js.erb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
// if (event.type === "focus") {
|
2
|
+
// console.log('focus');
|
3
|
+
// } else if (event.type === "blur") {
|
4
|
+
// console.log('blur');
|
5
|
+
// } else if (event.type === "fieldStateChange") {
|
6
|
+
// console.log('fieldStateChange');
|
7
|
+
// console.log(event.isValid); // true|false
|
8
|
+
// if (event.card) {
|
9
|
+
// console.log(event.card.type);
|
10
|
+
// // visa|master-card|american-express|diners-club|discover|jcb|unionpay|maestro
|
11
|
+
// }
|
12
|
+
// }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
// // Style all elements
|
2
|
+
// "input": {
|
3
|
+
// "font-size": "16pt",
|
4
|
+
// "color": "#3A3A3A"
|
5
|
+
// },
|
6
|
+
//
|
7
|
+
// // Styling a specific field
|
8
|
+
// ".number": {
|
9
|
+
// "font-family": "monospace"
|
10
|
+
// },
|
11
|
+
//
|
12
|
+
// // Styling element state
|
13
|
+
// ":focus": {
|
14
|
+
// "color": "blue"
|
15
|
+
// },
|
16
|
+
".valid": {
|
17
|
+
"color": "green"
|
18
|
+
},
|
19
|
+
".invalid": {
|
20
|
+
"color": "red"
|
21
|
+
},
|
22
|
+
//
|
23
|
+
// // Media queries
|
24
|
+
// // Note that these apply to the iframe, not the root window.
|
25
|
+
// "@media screen and (max-width: 700px)": {
|
26
|
+
// "input": {
|
27
|
+
// "font-size": "14pt"
|
28
|
+
// }
|
29
|
+
// }
|
@@ -0,0 +1,84 @@
|
|
1
|
+
<% display_payment_methods_list = !payment_method.try(:preferred_3dsecure) && (@methods = payment_method.customer_payment_methods(@order, payment_method_type)).any? %>
|
2
|
+
<% paypal = payment_method_type.eql?('paypal') %>
|
3
|
+
<% dropin = payment_method_type.eql?('dropin') %>
|
4
|
+
<% hosted = payment_method_type.eql?('custom') %>
|
5
|
+
|
6
|
+
<div class="card clearfix">
|
7
|
+
<div class="card-body bg-light">
|
8
|
+
<% if display_payment_methods_list %>
|
9
|
+
<%= label_tag 'saved_payment_methods', I18n.t("braintree.checkout.saved_payment_method.#{payment_method_type}") %>
|
10
|
+
<%= select_tag "saved_payment_methods_for_#{payment_method.id}", options_from_braintree_payments(@methods, true), class: 'form-control saved-payment-methods' %>
|
11
|
+
|
12
|
+
<% unless paypal %>
|
13
|
+
<div class="radio show-new-payment">
|
14
|
+
<label data-hook="braintree_payment_method_field">
|
15
|
+
<%= link_to Spree.t(dropin ? :add_new_payment_method : :add_new_credit_card), '', id: 'show-new-payment' %>
|
16
|
+
</label>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<br/>
|
21
|
+
|
22
|
+
<% if paypal %>
|
23
|
+
<div id="paypal-container">
|
24
|
+
<% else %>
|
25
|
+
<div class="<%= display_payment_methods_list ? 'new-braintree-payment-method' : '' %>">
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
<div class="col-xs-12" >
|
29
|
+
<div class="form-group">
|
30
|
+
<label for="email">Email address</label>
|
31
|
+
<%= email_field_tag :email, @order.email, class: 'form-control' %>
|
32
|
+
<span id="help-email" class="help-block"></span>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<% if hosted || dropin %>
|
37
|
+
<% if hosted %>
|
38
|
+
<div id="hosted-fields">
|
39
|
+
<%= label_tag 'card_number_label', (payment_method&.preferred_number_placeholder || 'Card Number') %>
|
40
|
+
<span class="required">*</span><br />
|
41
|
+
<p id="hosted-fields-number" class="form-control"></p>
|
42
|
+
|
43
|
+
<%= label_tag 'cvv_label', payment_method.try(:preferred_cvv_placeholder) || 'Cvv code' %>
|
44
|
+
<span class="required">*</span><br />
|
45
|
+
<p id="hosted-fields-cvv" class="form-control"></p>
|
46
|
+
|
47
|
+
<%= label_tag 'expiration_date_label', payment_method.try(:preferred_expiration_date_placeholder) || 'Card Expiration Date' %>
|
48
|
+
<span class="required">*</span><br />
|
49
|
+
<p id="hosted-fields-expiration-date" class="form-control"></p>
|
50
|
+
|
51
|
+
<% elsif dropin %>
|
52
|
+
<div class="input-group pay-group bt-drop-in-container">
|
53
|
+
<div id="drop-in"></div>
|
54
|
+
<% end %>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
|
58
|
+
<div class="col-xs-6">
|
59
|
+
<div class="input-group pay-group">
|
60
|
+
</div>
|
61
|
+
<div class="credit-card-pay-success hidden">
|
62
|
+
<%= Spree.t(:credit_card_veryfied_successfully) %>
|
63
|
+
</div>
|
64
|
+
<div class="credit-card-pay-errors hidden">
|
65
|
+
<%= Spree.t(:verify_credit_card_failed) %>
|
66
|
+
</div>
|
67
|
+
</div>
|
68
|
+
<% end %>
|
69
|
+
</div>
|
70
|
+
</div>
|
71
|
+
</div>
|
72
|
+
<hr/>
|
73
|
+
|
74
|
+
<% if hosted %>
|
75
|
+
<script src="https://js.braintreegateway.com/web/3.54.1/js/client.min.js"></script>
|
76
|
+
<script src="https://js.braintreegateway.com/web/3.54.1/js/hosted-fields.min.js"></script>
|
77
|
+
<script src="https://js.braintreegateway.com/web/3.54.1/js/three-d-secure.min.js"></script>
|
78
|
+
<% elsif dropin %>
|
79
|
+
<script src='https://js.braintreegateway.com/web/dropin/1.20.4/js/dropin.min.js'></script>
|
80
|
+
<% end %>
|
81
|
+
|
82
|
+
<%= render partial: 'spree/checkout/payment/braintree_vzero/three_d_secure',
|
83
|
+
locals: { payment_method: payment_method, hosted: hosted, dropin: dropin }
|
84
|
+
%>
|