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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 771cd46e87b5da70e1d9145ea38a084154a2329002598538b01da3f116409526
|
4
|
+
data.tar.gz: 84ab1f12fd88cce62738419cc2de7cde03f73c1999d1b4b26c8160ce41fba489
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 177d2a5421ae0e22794b8b8e5333b0ee0788f2f97654ee9f48c2571a6dcb07c3ee423be13f0ca84a624d8cc7edf0012fa2e6ac0ec5577632b2efacd4045ea63a
|
7
|
+
data.tar.gz: e10a7db15dfa14c87648c1e8b26954442dd3471456bd25418f81d2fb5c0db72f7bc1557cd1c2e2e904eb997092958188182200e2148e54a4b2974e39a44114e5
|
data/.codeclimate.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
sudo: required
|
2
|
+
dist: trusty
|
3
|
+
|
4
|
+
language: ruby
|
5
|
+
|
6
|
+
env:
|
7
|
+
- DB=postgres
|
8
|
+
- DB=mysql
|
9
|
+
|
10
|
+
gemfile:
|
11
|
+
- gemfiles/spree_3_5.gemfile
|
12
|
+
- gemfiles/spree_3_5_spree_auth_devise.gemfile
|
13
|
+
- gemfiles/spree_3_7.gemfile
|
14
|
+
- gemfiles/spree_3_7_spree_auth_devise.gemfile
|
15
|
+
- gemfiles/spree_4_0.gemfile
|
16
|
+
- gemfiles/spree_4_0_spree_auth_devise.gemfile
|
17
|
+
- gemfiles/spree_master.gemfile
|
18
|
+
- gemfiles/spree_master_spree_auth_devise.gemfile
|
19
|
+
|
20
|
+
script:
|
21
|
+
- bundle exec rake test_app
|
22
|
+
- bundle exec rake spec
|
23
|
+
- bundle exec codeclimate-test-reporter
|
24
|
+
|
25
|
+
rvm:
|
26
|
+
- 2.3.8
|
27
|
+
- 2.4.4
|
28
|
+
- 2.5.1
|
29
|
+
|
30
|
+
matrix:
|
31
|
+
allow_failures:
|
32
|
+
- gemfile: gemfiles/spree_master.gemfile
|
33
|
+
- gemfile: gemfiles/spree_master_spree_auth_devise.gemfile
|
34
|
+
exclude:
|
35
|
+
- rvm: 2.3.8
|
36
|
+
gemfile: gemfiles/spree_4_0.gemfile
|
37
|
+
- rvm: 2.3.8
|
38
|
+
gemfile: gemfiles/spree_4_0_spree_auth_devise.gemfile
|
39
|
+
- rvm: 2.3.8
|
40
|
+
gemfile: gemfiles/spree_master.gemfile
|
41
|
+
- rvm: 2.3.8
|
42
|
+
gemfile: gemfiles/spree_master_spree_auth_devise.gemfile
|
43
|
+
- rvm: 2.4.4
|
44
|
+
gemfile: gemfiles/spree_4_0.gemfile
|
45
|
+
- rvm: 2.4.4
|
46
|
+
gemfile: gemfiles/spree_4_0_spree_auth_devise.gemfile
|
47
|
+
- rvm: 2.4.4
|
48
|
+
gemfile: gemfiles/spree_master.gemfile
|
49
|
+
- rvm: 2.4.4
|
50
|
+
gemfile: gemfiles/spree_master_spree_auth_devise.gemfile
|
51
|
+
- rvm: 2.5.1
|
52
|
+
gemfile: gemfiles/spree_3_5.gemfile
|
53
|
+
- rvm: 2.5.1
|
54
|
+
gemfile: gemfiles/spree_3_5_spree_auth_devise.gemfile
|
55
|
+
|
56
|
+
|
57
|
+
addons:
|
58
|
+
apt:
|
59
|
+
packages:
|
60
|
+
- mysql-server-5.6
|
61
|
+
- mysql-client-core-5.6
|
62
|
+
- mysql-client-5.6
|
63
|
+
postgresql: 9.4
|
data/Appraisals
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
appraise 'spree-3-5' do
|
2
|
+
ENV['WITHOUT_SPREE_AUTH_DEVISE'] = 'true'
|
3
|
+
|
4
|
+
gem 'spree', '~> 3.5.0'
|
5
|
+
end
|
6
|
+
|
7
|
+
appraise 'spree-3-5-spree-auth-devise' do
|
8
|
+
gem 'spree', '~> 3.5.0'
|
9
|
+
gem 'spree_auth_devise', '~> 3.3.0'
|
10
|
+
end
|
11
|
+
|
12
|
+
appraise 'spree-3-7' do
|
13
|
+
ENV['WITHOUT_SPREE_AUTH_DEVISE'] = 'true'
|
14
|
+
|
15
|
+
gem 'spree', '~> 3.7.1'
|
16
|
+
end
|
17
|
+
|
18
|
+
appraise 'spree-3-7-spree-auth-devise' do
|
19
|
+
gem 'spree', '~> 3.7.1'
|
20
|
+
gem 'spree_auth_devise', '~> 3.3.0'
|
21
|
+
end
|
22
|
+
|
23
|
+
appraise 'spree-4-0' do
|
24
|
+
ENV['WITHOUT_SPREE_AUTH_DEVISE'] = 'true'
|
25
|
+
|
26
|
+
gem 'spree', '~> 4.0.0'
|
27
|
+
end
|
28
|
+
|
29
|
+
appraise 'spree-4-0-spree-auth-devise' do
|
30
|
+
gem 'spree', '~> 4.0.0'
|
31
|
+
gem 'spree_auth_devise', '~> 4.0.0'
|
32
|
+
end
|
33
|
+
|
34
|
+
appraise 'spree-master' do
|
35
|
+
ENV['WITHOUT_SPREE_AUTH_DEVISE'] = 'true'
|
36
|
+
|
37
|
+
gem 'spree', github: 'spree/spree', branch: 'master'
|
38
|
+
gem 'rails-controller-testing'
|
39
|
+
end
|
40
|
+
|
41
|
+
appraise 'spree-master-spree-auth-devise' do
|
42
|
+
gem 'spree', github: 'spree/spree', branch: 'master'
|
43
|
+
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
|
44
|
+
gem 'rails-controller-testing'
|
45
|
+
end
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
In the spirit of [free software][1], **everyone** is encouraged to help improve this project.
|
4
|
+
|
5
|
+
Here are some ways *you* can contribute:
|
6
|
+
|
7
|
+
* by using prerelease versions
|
8
|
+
* by reporting [bugs][2]
|
9
|
+
* by suggesting new features
|
10
|
+
* by writing or editing documentation
|
11
|
+
* by writing specifications
|
12
|
+
* by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
|
13
|
+
* by refactoring code
|
14
|
+
* by resolving [issues][2]
|
15
|
+
* by reviewing patches
|
16
|
+
|
17
|
+
Starting point:
|
18
|
+
|
19
|
+
* Fork the repo
|
20
|
+
* Clone your repo
|
21
|
+
* Run `bundle install`
|
22
|
+
* Run `bundle exec rake test_app` to create the test application in `spec/dummy`
|
23
|
+
* Make your changes
|
24
|
+
* Ensure specs pass by running `bundle exec rspec spec`
|
25
|
+
* Submit your pull request
|
26
|
+
|
27
|
+
[1]: http://www.fsf.org/licensing/essays/free-sw.html
|
28
|
+
[2]: https://github.com/spark-solutions/spree_braintree_vzero/issues
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gem 'spree', github: 'spree/spree', branch: 'master'
|
3
|
+
|
4
|
+
# Provides basic authentication functionality for testing parts of your engine
|
5
|
+
unless ENV['WITHOUT_SPREE_AUTH_DEVISE'] == 'true'
|
6
|
+
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
|
7
|
+
end
|
8
|
+
|
9
|
+
gem 'pg'
|
10
|
+
gem 'mysql2'
|
11
|
+
gem 'webmock', '>= 2.3.1'
|
12
|
+
gem 'rails-controller-testing'
|
13
|
+
|
14
|
+
gemspec
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2015-2019 Spark Solutions Sp. z o.o.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# Braintree v.zero extension for Spree Commerce
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/spree-contrib/spree_braintree_vzero.svg?branch=master)](https://travis-ci.org/spree-contrib/spree_braintree_vzero) [![Code Climate](https://codeclimate.com/repos/560308aa6956801375000a4e/badges/9874199a656054d613cd/gpa.svg)](https://codeclimate.com/repos/560308aa6956801375000a4e/feed)
|
4
|
+
|
5
|
+
This is the official Braintree v.zero extension for [Spree](https://spreecommerce.org). It supports:
|
6
|
+
* [Braintree Hosted Fields](https://github.com/spree-contrib/spree_braintree_vzero/wiki/1.-Hosted-Fields) - style the credit card form to match your UI with full PCI compliance
|
7
|
+
* [PayPal Express Checkout](https://github.com/spree-contrib/spree_braintree_vzero/wiki/2.-PayPal-Express) - the fastest way for buyers to pay with PayPal - available on Spree for the first time
|
8
|
+
* [Braintree Drop-in UI](http://github.com/spree-contrib/spree_braintree_vzero/wiki/3.-Drop-in-UI) - start accepting payments ASAP
|
9
|
+
|
10
|
+
Behind-the-scenes, this extension uses [Braintree Ruby SDK](https://github.com/braintree/braintree_ruby).
|
11
|
+
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
1. Add this extension to your Gemfile with this line:
|
16
|
+
|
17
|
+
#### Spree >= 3.1
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'spree_braintree_vzero', '~> 3.5'
|
21
|
+
```
|
22
|
+
|
23
|
+
#### Spree 3.0 and Spree 2.x
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'spree_braintree_vzero', github: 'spree-contrib/spree_braintree_vzero', branch: 'X-X-stable'
|
27
|
+
```
|
28
|
+
|
29
|
+
The `branch` option is important: it must match the version of Spree you're using.
|
30
|
+
For example, use `3-0-stable` if you're using Spree `3-0-stable` or any `3.0.x` version.
|
31
|
+
|
32
|
+
2. Install the gem using Bundler:
|
33
|
+
```ruby
|
34
|
+
bundle install
|
35
|
+
```
|
36
|
+
|
37
|
+
3. Copy & run migrations
|
38
|
+
```ruby
|
39
|
+
bundle exec rails g spree_braintree_vzero:install
|
40
|
+
```
|
41
|
+
|
42
|
+
4. Restart your server
|
43
|
+
|
44
|
+
If your server was running, restart it so that it can find the assets properly.
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
## Heroku installation (optional)
|
49
|
+
|
50
|
+
Additional to migrations the gem adds a cron task (via the [Whenever gem](https://github.com/javan/whenever)) which is needed for updating transaction states from _submited for settlement_ to _settled_ ([Braintree v.zero transaction states](https://developers.braintreepayments.com/guides/transactions/ruby#status)). To run on Heroku you have to add a task to [Heroku Scheduler](https://devcenter.heroku.com/articles/scheduler):
|
51
|
+
|
52
|
+
```
|
53
|
+
rake spree_braintree_vzero:update_states
|
54
|
+
```
|
55
|
+
|
56
|
+
Recommended frequency is every 6 hours.
|
57
|
+
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
If you'd like to contribute, please take a look at the
|
62
|
+
[instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
|
63
|
+
pull request.
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
Spree Braintree V.zero is copyright © 2015-2020
|
68
|
+
[Spark Solutions Sp. z o.o.][spark]. It is free software,
|
69
|
+
and may be redistributed under the terms specified in the
|
70
|
+
[LICENCE](LICENSE) file.
|
71
|
+
|
72
|
+
[LICENSE]: https://github.com/spark-solutions/spree_braintree_vzero/blob/master/LICENSE
|
73
|
+
|
74
|
+
## About Spark Solutions
|
75
|
+
[![Spark Solutions](http://sparksolutions.co/wp-content/uploads/2015/01/logo-ss-tr-221x100.png)][spark]
|
76
|
+
|
77
|
+
Spree Braintree V.zero is maintained by [Spark Solutions Sp. z o.o.](http://sparksolutions.co?utm_source=github) and funded by [PayPal, Inc.](http://paypal.com)
|
78
|
+
The names and logos are trademarks of PayPal, inc.
|
79
|
+
|
80
|
+
We are passionate about open source software.
|
81
|
+
We are [available for hire][spark].
|
82
|
+
|
83
|
+
[spark]:http://sparksolutions.co?utm_source=github
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'spree/testing_support/extension_rake'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new
|
8
|
+
|
9
|
+
task :default do
|
10
|
+
if Dir['spec/dummy'].empty?
|
11
|
+
Rake::Task[:test_app].invoke
|
12
|
+
Dir.chdir('../../')
|
13
|
+
end
|
14
|
+
Rake::Task[:spec].invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Generates a dummy app for testing'
|
18
|
+
task :test_app do
|
19
|
+
ENV['LIB_NAME'] = 'spree_braintree_vzero'
|
20
|
+
Rake::Task['extension:test_app'].invoke
|
21
|
+
end
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
$(function() {
|
2
|
+
var SpreePayments = {
|
3
|
+
init: function() {
|
4
|
+
this.applyMaskOnDescriptorName()
|
5
|
+
this.toggleAdvancedPreferences()
|
6
|
+
},
|
7
|
+
applyMaskOnDescriptorName: function() {
|
8
|
+
$('[id*="_preferred_descriptor_name"]').mask('***/*?*****************')
|
9
|
+
},
|
10
|
+
toggleAdvancedPreferences: function() {
|
11
|
+
$('#advanced-preferences-heading').on('click', function() {
|
12
|
+
$('#advanced-preferences').slideToggle()
|
13
|
+
$('#advanced-preferences').toggleClass('collapsed')
|
14
|
+
$('span.icon', $(this)).toggleClass('icon-chevron-down')
|
15
|
+
})
|
16
|
+
}
|
17
|
+
}
|
18
|
+
SpreePayments.init()
|
19
|
+
})
|
@@ -0,0 +1,81 @@
|
|
1
|
+
// Placeholder manifest file.
|
2
|
+
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
|
3
|
+
//= require maskedinput/jquery.maskedinput.min
|
4
|
+
//= require spree/backend/payments
|
5
|
+
|
6
|
+
SpreeBraintreeVzero = {
|
7
|
+
updateSaveAndContinueVisibility: function() {
|
8
|
+
if (this.isButtonHidden()) {
|
9
|
+
$(this).trigger('hideSaveAndContinue')
|
10
|
+
} else {
|
11
|
+
$(this).trigger('showSaveAndContinue')
|
12
|
+
}
|
13
|
+
},
|
14
|
+
isButtonHidden: function () {
|
15
|
+
if(this.paypal) return false;
|
16
|
+
paymentMethod = this.checkedPaymentMethod();
|
17
|
+
return (!$('#use_existing_card_yes:checked').length && SpreeBraintreeVzero.paymentMethodID && paymentMethod.val() == SpreeBraintreeVzero.paymentMethodID);
|
18
|
+
},
|
19
|
+
checkedPaymentMethod: function() {
|
20
|
+
return $('form#new_payment input[type="radio"][name="payment[payment_method_id]"]:checked');
|
21
|
+
},
|
22
|
+
hideSaveAndContinue: function() {
|
23
|
+
$("[data-hook=buttons]").hide();
|
24
|
+
$(".new-braintree-payment-method").show();
|
25
|
+
$(".show-new-payment").hide();
|
26
|
+
},
|
27
|
+
showSaveAndContinue: function() {
|
28
|
+
$("[data-hook=buttons]").show();
|
29
|
+
$(".new-braintree-payment-method").hide();
|
30
|
+
$(".show-new-payment").show();
|
31
|
+
},
|
32
|
+
setSaveAndContinueVisibility: function() {
|
33
|
+
if($('#saved_payment_methods_for_' + SpreeBraintreeVzero.paymentMethodID).val())
|
34
|
+
SpreeBraintreeVzero.showSaveAndContinue();
|
35
|
+
else
|
36
|
+
SpreeBraintreeVzero.updateSaveAndContinueVisibility();
|
37
|
+
},
|
38
|
+
enableSubmitButton: function() {
|
39
|
+
$('.braintree-submit:disabled').attr('disabled', false).removeClass('disabled').addClass('primary');
|
40
|
+
},
|
41
|
+
setPaypalButtonDispay: function() {
|
42
|
+
submitButton = $('button[type="submit"]:not(.braintree-submit)');
|
43
|
+
paymentMethod = this.checkedPaymentMethod();
|
44
|
+
submitButton.attr('disabled', false);
|
45
|
+
if(!SpreeBraintreeVzero.paymentMethodID || (paymentMethod.val() != SpreeBraintreeVzero.paymentMethodID))
|
46
|
+
return;
|
47
|
+
if(SpreeBraintreeVzero.paypal && SpreeBraintreeVzero.paypal_empty)
|
48
|
+
submitButton.attr('disabled', true);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
$(document).ready(function() {
|
53
|
+
SpreeBraintreeVzero.checkedPaymentMethod().trigger('click');
|
54
|
+
paymentMethods = $('form#new_payment input[type="radio"]').click(function (e) {
|
55
|
+
SpreeBraintreeVzero.setSaveAndContinueVisibility();
|
56
|
+
SpreeBraintreeVzero.setPaypalButtonDispay();
|
57
|
+
});
|
58
|
+
$('.saved-payment-methods').change(function (e) {
|
59
|
+
if($(this).val())
|
60
|
+
SpreeBraintreeVzero.showSaveAndContinue();
|
61
|
+
else {
|
62
|
+
if(!SpreeBraintreeVzero.paypal)
|
63
|
+
SpreeBraintreeVzero.hideSaveAndContinue();
|
64
|
+
}
|
65
|
+
});
|
66
|
+
$('#show-new-payment').click(function (e) {
|
67
|
+
e.preventDefault();
|
68
|
+
$('#saved_payment_methods_for_' + SpreeBraintreeVzero.paymentMethodID).val('')
|
69
|
+
SpreeBraintreeVzero.updateSaveAndContinueVisibility();
|
70
|
+
});
|
71
|
+
$('button[name="button"]:not(.braintree-submit)').click(function (e) {
|
72
|
+
if($('form#new_payment').length) {
|
73
|
+
e.preventDefault();
|
74
|
+
token = $('#saved_payment_methods_for_' + SpreeBraintreeVzero.paymentMethodID).val()
|
75
|
+
if(token)
|
76
|
+
$('form#new_payment').append("<input type='hidden' name='payment_method_token]' value=" + token + ">");
|
77
|
+
$('form#new_payment').submit();
|
78
|
+
}
|
79
|
+
});
|
80
|
+
SpreeBraintreeVzero.setSaveAndContinueVisibility();
|
81
|
+
})
|
@@ -0,0 +1,68 @@
|
|
1
|
+
//= require spree/frontend
|
2
|
+
|
3
|
+
SpreeBraintreeVzero = {
|
4
|
+
updateSaveAndContinueVisibility: function() {
|
5
|
+
if (this.isButtonHidden()) {
|
6
|
+
$(this).trigger('hideSaveAndContinue')
|
7
|
+
} else {
|
8
|
+
$(this).trigger('showSaveAndContinue')
|
9
|
+
}
|
10
|
+
},
|
11
|
+
isButtonHidden: function () {
|
12
|
+
paymentMethod = this.checkedPaymentMethod();
|
13
|
+
return (!$('#use_existing_card_yes:checked').length && SpreeBraintreeVzero.paymentMethodID && paymentMethod.val() == SpreeBraintreeVzero.paymentMethodID);
|
14
|
+
},
|
15
|
+
checkedPaymentMethod: function() {
|
16
|
+
return $('div[data-hook="checkout_payment_step"] input[type="radio"][name="order[payments_attributes][][payment_method_id]"]:checked');
|
17
|
+
},
|
18
|
+
hideSaveAndContinue: function() {
|
19
|
+
this.enableSubmitButton();
|
20
|
+
if(!$('div[data-hook="checkout_payment_step"]').length) return
|
21
|
+
$(SpreeBraintreeVzero.checkoutFormId + ' .form-buttons .btn').hide();
|
22
|
+
$("[method_id='" + SpreeBraintreeVzero.paymentMethodID + "']").show();
|
23
|
+
$(".new-braintree-payment-method").show();
|
24
|
+
$(".show-new-payment").hide();
|
25
|
+
},
|
26
|
+
showSaveAndContinue: function() {
|
27
|
+
this.enableSubmitButton();
|
28
|
+
if(!$('div[data-hook="checkout_payment_step"]').length) return
|
29
|
+
$("[method_id='" + SpreeBraintreeVzero.paymentMethodID + "']").hide();
|
30
|
+
$('[name="commit"]:not(.braintree-submit)').show();
|
31
|
+
$(".new-braintree-payment-method").hide();
|
32
|
+
$(".show-new-payment").show();
|
33
|
+
},
|
34
|
+
setSaveAndContinueVisibility: function() {
|
35
|
+
if($('#saved_payment_methods_for_' + SpreeBraintreeVzero.paymentMethodID).val())
|
36
|
+
SpreeBraintreeVzero.showSaveAndContinue();
|
37
|
+
else
|
38
|
+
SpreeBraintreeVzero.updateSaveAndContinueVisibility();
|
39
|
+
},
|
40
|
+
enableSubmitButton: function() {
|
41
|
+
$('.btn:disabled').attr('disabled', false).removeClass('disabled').addClass('primary');
|
42
|
+
},
|
43
|
+
addDeviceData: function() {
|
44
|
+
if(SpreeBraintreeVzero.deviceData)
|
45
|
+
$(SpreeBraintreeVzero.checkoutFormId).append("<input type='hidden' name='device_data' value=" + SpreeBraintreeVzero.deviceData + ">");
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
$(document).ready(function() {
|
50
|
+
paymentMethods = $('div[data-hook="checkout_payment_step"] input[type="radio"]').click(function (e) {
|
51
|
+
SpreeBraintreeVzero.setSaveAndContinueVisibility();
|
52
|
+
});
|
53
|
+
$('.saved-payment-methods').change(function (e) {
|
54
|
+
if($(this).val())
|
55
|
+
SpreeBraintreeVzero.showSaveAndContinue();
|
56
|
+
else
|
57
|
+
SpreeBraintreeVzero.hideSaveAndContinue();
|
58
|
+
});
|
59
|
+
$('#show-new-payment').click(function (e) {
|
60
|
+
e.preventDefault();
|
61
|
+
$('#saved_payment_methods_for_' + SpreeBraintreeVzero.paymentMethodID).val('')
|
62
|
+
SpreeBraintreeVzero.updateSaveAndContinueVisibility();
|
63
|
+
});
|
64
|
+
$('.braintree-submit, [name="commit"]').click(function(e) {
|
65
|
+
SpreeBraintreeVzero.addDeviceData();
|
66
|
+
});
|
67
|
+
SpreeBraintreeVzero.setSaveAndContinueVisibility();
|
68
|
+
})
|