workarea-stripe 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.eslintrc +36 -0
  4. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  5. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  6. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  7. data/.gitignore +19 -0
  8. data/CHANGELOG.md +67 -0
  9. data/CODE_OF_CONDUCT.md +3 -0
  10. data/CONTRIBUTING.md +3 -0
  11. data/Gemfile +8 -0
  12. data/LICENSE +52 -0
  13. data/README.md +90 -0
  14. data/Rakefile +60 -0
  15. data/app/assets/javascripts/workarea/storefront/stripe/config.js.erb +29 -0
  16. data/app/assets/javascripts/workarea/storefront/stripe/modules/bogus_stripe_elements.js +55 -0
  17. data/app/assets/javascripts/workarea/storefront/stripe/modules/stripe_elements.js +113 -0
  18. data/app/assets/stylesheets/workarea/stripe/components/_checkout_payment_stripe.scss +19 -0
  19. data/app/controllers/workarea/storefront/users/credit_cards_controller.decorator +10 -0
  20. data/app/models/workarea/checkout/credit_card_params.decorator +30 -0
  21. data/app/models/workarea/checkout/steps/payment.decorator +16 -0
  22. data/app/models/workarea/payment.decorator +18 -0
  23. data/app/models/workarea/payment/authorize/credit_card.decorator +24 -0
  24. data/app/models/workarea/payment/credit_card.decorator +27 -0
  25. data/app/models/workarea/payment/purchase/credit_card.decorator +24 -0
  26. data/app/models/workarea/payment/store_credit_card.decorator +54 -0
  27. data/app/views/workarea/storefront/checkouts/_stripe_dialog.html.haml +2 -0
  28. data/app/views/workarea/storefront/checkouts/_stripe_form.html.haml +19 -0
  29. data/app/views/workarea/storefront/stripe/_stripe_js.html.haml +1 -0
  30. data/app/views/workarea/storefront/users/credit_cards/_stripe_form.html.haml +12 -0
  31. data/app/views/workarea/storefront/users/credit_cards/new.html.haml +42 -0
  32. data/bin/rails +20 -0
  33. data/config/initializers/appends.rb +33 -0
  34. data/config/initializers/workarea.rb +9 -0
  35. data/config/routes.rb +2 -0
  36. data/lib/active_merchant/billing/bogus_stripe_gateway.rb +29 -0
  37. data/lib/workarea/stripe.rb +46 -0
  38. data/lib/workarea/stripe/engine.rb +8 -0
  39. data/lib/workarea/stripe/version.rb +5 -0
  40. data/test/dummy/Rakefile +6 -0
  41. data/test/dummy/app/assets/config/manifest.js +4 -0
  42. data/test/dummy/app/assets/images/.keep +0 -0
  43. data/test/dummy/app/assets/javascripts/application.js +13 -0
  44. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  45. data/test/dummy/app/controllers/application_controller.rb +3 -0
  46. data/test/dummy/app/controllers/concerns/.keep +0 -0
  47. data/test/dummy/app/helpers/application_helper.rb +2 -0
  48. data/test/dummy/app/jobs/application_job.rb +2 -0
  49. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  50. data/test/dummy/app/models/concerns/.keep +0 -0
  51. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  52. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  53. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  54. data/test/dummy/bin/bundle +3 -0
  55. data/test/dummy/bin/rails +4 -0
  56. data/test/dummy/bin/rake +4 -0
  57. data/test/dummy/bin/setup +30 -0
  58. data/test/dummy/bin/update +26 -0
  59. data/test/dummy/bin/yarn +11 -0
  60. data/test/dummy/config.ru +5 -0
  61. data/test/dummy/config/application.rb +30 -0
  62. data/test/dummy/config/boot.rb +5 -0
  63. data/test/dummy/config/cable.yml +10 -0
  64. data/test/dummy/config/environment.rb +5 -0
  65. data/test/dummy/config/environments/development.rb +51 -0
  66. data/test/dummy/config/environments/production.rb +88 -0
  67. data/test/dummy/config/environments/test.rb +44 -0
  68. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  69. data/test/dummy/config/initializers/assets.rb +14 -0
  70. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  71. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  72. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  73. data/test/dummy/config/initializers/inflections.rb +16 -0
  74. data/test/dummy/config/initializers/mime_types.rb +4 -0
  75. data/test/dummy/config/initializers/workarea.rb +5 -0
  76. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  77. data/test/dummy/config/locales/en.yml +33 -0
  78. data/test/dummy/config/puma.rb +56 -0
  79. data/test/dummy/config/routes.rb +5 -0
  80. data/test/dummy/config/secrets.yml +32 -0
  81. data/test/dummy/config/spring.rb +6 -0
  82. data/test/dummy/db/seeds.rb +2 -0
  83. data/test/dummy/lib/assets/.keep +0 -0
  84. data/test/dummy/log/.keep +0 -0
  85. data/test/dummy/package.json +5 -0
  86. data/test/integration/workarea/storefront/place_order_integration_test.decorator +19 -0
  87. data/test/integration/workarea/storefront/users/credit_cards_integration_test.decorator +26 -0
  88. data/test/models/workarea/checkout/credit_card_params_test.rb +10 -0
  89. data/test/models/workarea/checkout/steps/payment_test.decorator +21 -0
  90. data/test/models/workarea/payment/authorize/credit_card_test.decorator +24 -0
  91. data/test/models/workarea/payment/capture_test.decorator +10 -0
  92. data/test/models/workarea/payment/credit_card_integration_test.decorator +26 -0
  93. data/test/models/workarea/payment/purchase/credit_card_test.decorator +25 -0
  94. data/test/models/workarea/payment/refund/credit_card_test.decorator +20 -0
  95. data/test/models/workarea/payment/refund_test.decorator +10 -0
  96. data/test/models/workarea/payment/store_credit_card_test.decorator +9 -0
  97. data/test/models/workarea/payment_test.decorator +20 -0
  98. data/test/support/stripe_public_key.rb +1 -0
  99. data/test/system/workarea/storefront/analytics_system_test.decorator +5 -0
  100. data/test/system/workarea/storefront/credit_cards_system_test.decorator +5 -0
  101. data/test/system/workarea/storefront/digital_products_system_test.decorator +67 -0
  102. data/test/system/workarea/storefront/guest_checkout_system_test.decorator +107 -0
  103. data/test/system/workarea/storefront/logged_in_checkout_system_test.decorator +5 -0
  104. data/test/system/workarea/storefront/no_js_system_test.decorator +5 -0
  105. data/test/system/workarea/storefront/stripe_payment_system_test.rb +97 -0
  106. data/test/teaspoon_env.rb +6 -0
  107. data/test/test_helper.rb +10 -0
  108. data/test/workers/workarea/send_refund_email_test.decorator +29 -0
  109. data/workarea-stripe.gemspec +21 -0
  110. metadata +171 -0
@@ -0,0 +1,5 @@
1
+ decorate Workarea::Storefront::LoggedInCheckoutSystemTest, with: :stripe do
2
+ def test_failed_payment_authorization
3
+ skip 'Stripe always returns a valid payment token'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ decorate Workarea::Storefront::NoJsSystemTest, with: :stripe do
2
+ def test_successfully_completing_checkout
3
+ skip 'Stripe will not work without javascript.'
4
+ end
5
+ end
@@ -0,0 +1,97 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class StripePaymentSystemTest < Workarea::SystemTest
6
+ include Storefront::SystemTest
7
+
8
+ setup :setup_checkout_specs
9
+ setup :start_guest_checkout
10
+
11
+ def fill_in_stripe_credit_card
12
+ page.evaluate_script('WORKAREA.bogusStripeElements.disable()')
13
+
14
+ page.driver.browser.switch_to.frame "stripe-payment-frame"
15
+
16
+ find('input[name="cardnumber"]').set('4111111111111111')
17
+ find('input[name="exp-date"]').set('12/21')
18
+ find('input[name="cvc"]').set('999')
19
+ find('input[name="postal"]').set('19143')
20
+
21
+ page.driver.browser.switch_to.default_content
22
+ end
23
+
24
+ def test_successfully_checking_out
25
+ assert_current_path(storefront.checkout_addresses_path)
26
+ fill_in_email
27
+ fill_in_shipping_address
28
+ uncheck 'same_as_shipping'
29
+ fill_in_billing_address
30
+ click_button t('workarea.storefront.checkouts.continue_to_shipping')
31
+
32
+ assert_current_path(storefront.checkout_shipping_path)
33
+ assert(page.has_content?('Success'))
34
+
35
+ click_button t('workarea.storefront.checkouts.shipping_instructions_prompt')
36
+ instruction = 'Doorbeel broken, please knock'
37
+ fill_in :shipping_instructions, with: instruction
38
+
39
+ click_button t('workarea.storefront.checkouts.continue_to_payment')
40
+
41
+ assert_current_path(storefront.checkout_payment_path)
42
+
43
+ assert(page.has_content?('Success'))
44
+
45
+ assert(page.has_content?('22 S. 3rd St.'))
46
+ assert(page.has_content?('Philadelphia'))
47
+ assert(page.has_content?('PA'))
48
+ assert(page.has_content?('19106'))
49
+ assert(page.has_content?('Ground'))
50
+
51
+ assert(page.has_content?('Integration Product'))
52
+ assert(page.has_content?('SKU'))
53
+
54
+ assert(page.has_content?('$5.00')) # Subtotal
55
+ assert(page.has_content?('$7.00')) # Shipping
56
+ assert(page.has_content?('$0.84')) # Tax
57
+ assert(page.has_content?('$12.84')) # Total
58
+
59
+ assert(page.has_content?(instruction))
60
+
61
+ fill_in_stripe_credit_card
62
+ click_button t('workarea.storefront.checkouts.place_order')
63
+ wait_for_xhr
64
+
65
+ assert_current_path(storefront.checkout_confirmation_path)
66
+
67
+ assert(page.has_content?('Success'))
68
+ assert(page.has_content?(t('workarea.storefront.flash_messages.order_placed')))
69
+ assert(page.has_content?(Order.first.id))
70
+
71
+ assert(page.has_content?('22 S. 3rd St.'))
72
+ assert(page.has_content?('Philadelphia'))
73
+ assert(page.has_content?('PA'))
74
+ assert(page.has_content?('19106'))
75
+ assert(page.has_content?('Ground'))
76
+
77
+ assert(page.has_content?('1019 S. 47th St.'))
78
+ assert(page.has_content?('Philadelphia'))
79
+ assert(page.has_content?('PA'))
80
+ assert(page.has_content?('19143'))
81
+
82
+ assert(page.has_content?('Visa'))
83
+ assert(page.has_content?('1111'))
84
+
85
+ assert(page.has_content?(instruction))
86
+
87
+ assert(page.has_content?('Integration Product'))
88
+ assert(page.has_content?('SKU'))
89
+
90
+ assert(page.has_content?('$5.00')) # Subtotal
91
+ assert(page.has_content?('$7.00')) # Shipping
92
+ assert(page.has_content?('$0.84')) # Tax
93
+ assert(page.has_content?('$12.84')) # Total
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,6 @@
1
+ require 'workarea/testing/teaspoon'
2
+
3
+ Teaspoon.configure do |config|
4
+ config.root = Workarea::Stripe::Engine.root
5
+ Workarea::Teaspoon.apply(config)
6
+ end
@@ -0,0 +1,10 @@
1
+ # Configure Rails Environment
2
+ ENV['RAILS_ENV'] = 'test'
3
+
4
+ require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
5
+ require 'rails/test_help'
6
+ require 'workarea/test_help'
7
+
8
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
9
+ # to be shown.
10
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
@@ -0,0 +1,29 @@
1
+ module Workarea
2
+ decorate SendRefundEmailTest, with: :stripe do
3
+ def payment
4
+ @payment ||= begin
5
+ profile = create_payment_profile
6
+ payment = create_payment(id: order.id, profile_id: profile.id)
7
+ payment.set_address(
8
+ first_name: 'Ben',
9
+ last_name: 'Crouse',
10
+ street: '22 S. 3rd St.',
11
+ city: 'Philadelphia',
12
+ region: 'PA',
13
+ postal_code: '19106',
14
+ country: 'US',
15
+ phone_number: '2159251800'
16
+ )
17
+
18
+ payment.set_credit_card(
19
+ number: '1',
20
+ month: 1,
21
+ year: Time.current.year + 1,
22
+ cvv: '999',
23
+ amount: 5.to_m
24
+ )
25
+ payment
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require 'workarea/stripe/version'
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = 'workarea-stripe'
9
+ s.version = Workarea::Stripe::VERSION
10
+ s.authors = ["Jeff Yucis"]
11
+ s.email = ["jyucis@weblinc.com"]
12
+ s.homepage = "https://github.com/workarea-commerce/workarea-stripe"
13
+ s.summary = "Stripe payment processor integration for the Workarea Commerce Platform"
14
+ s.description = "Stripe payment processor integration for the Workarea Commerce Platform"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+
18
+ s.license = 'Business Software License'
19
+
20
+ s.add_dependency 'workarea', '~> 3.x', '>= 3.2.0'
21
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: workarea-stripe
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Yucis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: workarea
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.x
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.2.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 3.x
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.2.0
33
+ description: Stripe payment processor integration for the Workarea Commerce Platform
34
+ email:
35
+ - jyucis@weblinc.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".editorconfig"
41
+ - ".eslintrc"
42
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
43
+ - ".github/ISSUE_TEMPLATE/documentation-request.md"
44
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
45
+ - ".gitignore"
46
+ - CHANGELOG.md
47
+ - CODE_OF_CONDUCT.md
48
+ - CONTRIBUTING.md
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - app/assets/javascripts/workarea/storefront/stripe/config.js.erb
54
+ - app/assets/javascripts/workarea/storefront/stripe/modules/bogus_stripe_elements.js
55
+ - app/assets/javascripts/workarea/storefront/stripe/modules/stripe_elements.js
56
+ - app/assets/stylesheets/workarea/stripe/components/_checkout_payment_stripe.scss
57
+ - app/controllers/workarea/storefront/users/credit_cards_controller.decorator
58
+ - app/models/workarea/checkout/credit_card_params.decorator
59
+ - app/models/workarea/checkout/steps/payment.decorator
60
+ - app/models/workarea/payment.decorator
61
+ - app/models/workarea/payment/authorize/credit_card.decorator
62
+ - app/models/workarea/payment/credit_card.decorator
63
+ - app/models/workarea/payment/purchase/credit_card.decorator
64
+ - app/models/workarea/payment/store_credit_card.decorator
65
+ - app/views/workarea/storefront/checkouts/_stripe_dialog.html.haml
66
+ - app/views/workarea/storefront/checkouts/_stripe_form.html.haml
67
+ - app/views/workarea/storefront/stripe/_stripe_js.html.haml
68
+ - app/views/workarea/storefront/users/credit_cards/_stripe_form.html.haml
69
+ - app/views/workarea/storefront/users/credit_cards/new.html.haml
70
+ - bin/rails
71
+ - config/initializers/appends.rb
72
+ - config/initializers/workarea.rb
73
+ - config/routes.rb
74
+ - lib/active_merchant/billing/bogus_stripe_gateway.rb
75
+ - lib/workarea/stripe.rb
76
+ - lib/workarea/stripe/engine.rb
77
+ - lib/workarea/stripe/version.rb
78
+ - test/dummy/Rakefile
79
+ - test/dummy/app/assets/config/manifest.js
80
+ - test/dummy/app/assets/images/.keep
81
+ - test/dummy/app/assets/javascripts/application.js
82
+ - test/dummy/app/assets/stylesheets/application.css
83
+ - test/dummy/app/controllers/application_controller.rb
84
+ - test/dummy/app/controllers/concerns/.keep
85
+ - test/dummy/app/helpers/application_helper.rb
86
+ - test/dummy/app/jobs/application_job.rb
87
+ - test/dummy/app/mailers/application_mailer.rb
88
+ - test/dummy/app/models/concerns/.keep
89
+ - test/dummy/app/views/layouts/application.html.erb
90
+ - test/dummy/app/views/layouts/mailer.html.erb
91
+ - test/dummy/app/views/layouts/mailer.text.erb
92
+ - test/dummy/bin/bundle
93
+ - test/dummy/bin/rails
94
+ - test/dummy/bin/rake
95
+ - test/dummy/bin/setup
96
+ - test/dummy/bin/update
97
+ - test/dummy/bin/yarn
98
+ - test/dummy/config.ru
99
+ - test/dummy/config/application.rb
100
+ - test/dummy/config/boot.rb
101
+ - test/dummy/config/cable.yml
102
+ - test/dummy/config/environment.rb
103
+ - test/dummy/config/environments/development.rb
104
+ - test/dummy/config/environments/production.rb
105
+ - test/dummy/config/environments/test.rb
106
+ - test/dummy/config/initializers/application_controller_renderer.rb
107
+ - test/dummy/config/initializers/assets.rb
108
+ - test/dummy/config/initializers/backtrace_silencers.rb
109
+ - test/dummy/config/initializers/cookies_serializer.rb
110
+ - test/dummy/config/initializers/filter_parameter_logging.rb
111
+ - test/dummy/config/initializers/inflections.rb
112
+ - test/dummy/config/initializers/mime_types.rb
113
+ - test/dummy/config/initializers/workarea.rb
114
+ - test/dummy/config/initializers/wrap_parameters.rb
115
+ - test/dummy/config/locales/en.yml
116
+ - test/dummy/config/puma.rb
117
+ - test/dummy/config/routes.rb
118
+ - test/dummy/config/secrets.yml
119
+ - test/dummy/config/spring.rb
120
+ - test/dummy/db/seeds.rb
121
+ - test/dummy/lib/assets/.keep
122
+ - test/dummy/log/.keep
123
+ - test/dummy/package.json
124
+ - test/integration/workarea/storefront/place_order_integration_test.decorator
125
+ - test/integration/workarea/storefront/users/credit_cards_integration_test.decorator
126
+ - test/models/workarea/checkout/credit_card_params_test.rb
127
+ - test/models/workarea/checkout/steps/payment_test.decorator
128
+ - test/models/workarea/payment/authorize/credit_card_test.decorator
129
+ - test/models/workarea/payment/capture_test.decorator
130
+ - test/models/workarea/payment/credit_card_integration_test.decorator
131
+ - test/models/workarea/payment/purchase/credit_card_test.decorator
132
+ - test/models/workarea/payment/refund/credit_card_test.decorator
133
+ - test/models/workarea/payment/refund_test.decorator
134
+ - test/models/workarea/payment/store_credit_card_test.decorator
135
+ - test/models/workarea/payment_test.decorator
136
+ - test/support/stripe_public_key.rb
137
+ - test/system/workarea/storefront/analytics_system_test.decorator
138
+ - test/system/workarea/storefront/credit_cards_system_test.decorator
139
+ - test/system/workarea/storefront/digital_products_system_test.decorator
140
+ - test/system/workarea/storefront/guest_checkout_system_test.decorator
141
+ - test/system/workarea/storefront/logged_in_checkout_system_test.decorator
142
+ - test/system/workarea/storefront/no_js_system_test.decorator
143
+ - test/system/workarea/storefront/stripe_payment_system_test.rb
144
+ - test/teaspoon_env.rb
145
+ - test/test_helper.rb
146
+ - test/workers/workarea/send_refund_email_test.decorator
147
+ - workarea-stripe.gemspec
148
+ homepage: https://github.com/workarea-commerce/workarea-stripe
149
+ licenses:
150
+ - Business Software License
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubygems_version: 3.0.4
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: Stripe payment processor integration for the Workarea Commerce Platform
171
+ test_files: []