workarea-zipco 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintrc.json +35 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.github/workflows/ci.yml +64 -0
  7. data/.gitignore +23 -0
  8. data/.rubocop.yml +2 -0
  9. data/.stylelintrc.json +8 -0
  10. data/CHANGELOG.md +17 -0
  11. data/Gemfile +17 -0
  12. data/README.md +51 -0
  13. data/Rakefile +59 -0
  14. data/app/assets/images/zipco/.keep +0 -0
  15. data/app/assets/stylesheets/workarea/storefront/zipco/components/_zipco_icon.scss +7 -0
  16. data/app/controllers/storefront/checkout/place_order_controller.decorator +11 -0
  17. data/app/controllers/storefront/zipco_controller.rb +96 -0
  18. data/app/controllers/storefront/zipco_landing_controller.rb +6 -0
  19. data/app/helpers/.keep +0 -0
  20. data/app/mailers/.keep +0 -0
  21. data/app/models/checkout.decorator +33 -0
  22. data/app/models/workarea/order.decorator +52 -0
  23. data/app/models/workarea/order/status/zip_referred.rb +13 -0
  24. data/app/models/workarea/payment.decorator +30 -0
  25. data/app/models/workarea/payment/authorize/zipco.rb +66 -0
  26. data/app/models/workarea/payment/capture/zipco.rb +58 -0
  27. data/app/models/workarea/payment/purchase/zipco.rb +66 -0
  28. data/app/models/workarea/payment/refund/zipco.rb +59 -0
  29. data/app/models/workarea/payment/tender/zipco.rb +13 -0
  30. data/app/models/workarea/search/admin/admin.decorator +7 -0
  31. data/app/services/workarea/zipco/checkout.rb +48 -0
  32. data/app/services/workarea/zipco/order.rb +188 -0
  33. data/app/services/workarea/zipco/setup.rb +37 -0
  34. data/app/view_models/workarea/storefront/checkout/payment_view_model.decorator +17 -0
  35. data/app/view_models/workarea/storefront/order_view_model.decorator +11 -0
  36. data/app/view_models/workarea/storefront/zipco_view_model.rb +18 -0
  37. data/app/views/workarea/admin/orders/tenders/_zipco.html.haml +4 -0
  38. data/app/views/workarea/storefront/checkouts/_zipco_payment.html.haml +10 -0
  39. data/app/views/workarea/storefront/order_mailer/tenders/_zipco.html.haml +4 -0
  40. data/app/views/workarea/storefront/order_mailer/tenders/_zipco.text.erb +1 -0
  41. data/app/views/workarea/storefront/orders/_zipco_order_message.html.haml +2 -0
  42. data/app/views/workarea/storefront/orders/tenders/_zipco.html.haml +6 -0
  43. data/app/views/workarea/storefront/zipco/_zipco_tagline.html.haml +4 -0
  44. data/app/views/workarea/storefront/zipco_landing/show.html.haml +4 -0
  45. data/bin/rails +25 -0
  46. data/config/initializers/appends.rb +24 -0
  47. data/config/initializers/workarea.rb +15 -0
  48. data/config/locales/en.yml +38 -0
  49. data/config/routes.rb +5 -0
  50. data/lib/workarea/zipco.rb +48 -0
  51. data/lib/workarea/zipco/bogus_gateway.rb +160 -0
  52. data/lib/workarea/zipco/engine.rb +10 -0
  53. data/lib/workarea/zipco/gateway.rb +113 -0
  54. data/lib/workarea/zipco/response.rb +29 -0
  55. data/lib/workarea/zipco/version.rb +5 -0
  56. data/test/dummy/.ruby-version +1 -0
  57. data/test/dummy/Rakefile +6 -0
  58. data/test/dummy/app/assets/config/manifest.js +3 -0
  59. data/test/dummy/app/assets/images/.keep +0 -0
  60. data/test/dummy/app/assets/javascripts/application.js +14 -0
  61. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  62. data/test/dummy/app/controllers/application_controller.rb +2 -0
  63. data/test/dummy/app/controllers/concerns/.keep +0 -0
  64. data/test/dummy/app/helpers/application_helper.rb +2 -0
  65. data/test/dummy/app/jobs/application_job.rb +2 -0
  66. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  67. data/test/dummy/app/models/concerns/.keep +0 -0
  68. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  69. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  70. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  71. data/test/dummy/bin/bundle +3 -0
  72. data/test/dummy/bin/rails +4 -0
  73. data/test/dummy/bin/rake +4 -0
  74. data/test/dummy/bin/setup +28 -0
  75. data/test/dummy/bin/update +28 -0
  76. data/test/dummy/bin/yarn +11 -0
  77. data/test/dummy/config.ru +5 -0
  78. data/test/dummy/config/application.rb +34 -0
  79. data/test/dummy/config/boot.rb +5 -0
  80. data/test/dummy/config/environment.rb +5 -0
  81. data/test/dummy/config/environments/development.rb +52 -0
  82. data/test/dummy/config/environments/production.rb +83 -0
  83. data/test/dummy/config/environments/test.rb +45 -0
  84. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  85. data/test/dummy/config/initializers/assets.rb +14 -0
  86. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  87. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  88. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  89. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  90. data/test/dummy/config/initializers/inflections.rb +16 -0
  91. data/test/dummy/config/initializers/mime_types.rb +4 -0
  92. data/test/dummy/config/initializers/workarea.rb +5 -0
  93. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  94. data/test/dummy/config/locales/en.yml +33 -0
  95. data/test/dummy/config/puma.rb +34 -0
  96. data/test/dummy/config/routes.rb +5 -0
  97. data/test/dummy/config/spring.rb +6 -0
  98. data/test/dummy/db/seeds.rb +2 -0
  99. data/test/dummy/lib/assets/.keep +0 -0
  100. data/test/dummy/log/.keep +0 -0
  101. data/test/integration/workarea/storefront/zipco_integration_test.rb +250 -0
  102. data/test/models/workarea/order/zipco_queries_test.rb +35 -0
  103. data/test/models/workarea/payment/zipco_payment_integration_test.rb +89 -0
  104. data/test/services/workarea/zipco/checkout_test.rb +43 -0
  105. data/test/services/workarea/zipco/order_test.rb +102 -0
  106. data/test/services/workarea/zipco/setup_test.rb +65 -0
  107. data/test/teaspoon_env.rb +6 -0
  108. data/test/test_helper.rb +10 -0
  109. data/test/view_models/workarea/storefront/zipco_view_model_test.rb +55 -0
  110. data/workarea-zipco.gemspec +19 -0
  111. metadata +167 -0
@@ -0,0 +1,65 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Zipco
5
+ class CheckoutTest < Workarea::TestCase
6
+ setup :set_models
7
+
8
+ def set_models
9
+ @user = create_user
10
+ @product = create_product(variants: [{ sku: 'SKU', regular: 5.to_m }])
11
+ @order = create_order(zipco_order_id: "1234", items: [{ product_id: @product.id, sku: 'SKU' }])
12
+ payment = create_payment(id: @order.id)
13
+ @checkout = Workarea::Checkout.new(@order, @user)
14
+ create_shipping_service(name: "test shipping")
15
+
16
+ step = Workarea::Checkout::Steps::Addresses.new(@checkout)
17
+
18
+ step.update(
19
+ shipping_address: {
20
+ first_name: 'Ben',
21
+ last_name: 'Crouse',
22
+ street: '22 S. 3rd St.',
23
+ city: 'Philadelphia',
24
+ region: 'PA',
25
+ postal_code: '19106',
26
+ country: 'US',
27
+ phone_number: '2159251800'
28
+ },
29
+ billing_address: {
30
+ first_name: 'Ben',
31
+ last_name: 'Crouse',
32
+ street: '22 S. 3rd St.',
33
+ city: 'Philadelphia',
34
+ region: 'PA',
35
+ postal_code: '19106',
36
+ country: 'US',
37
+ phone_number: '2159251800'
38
+ }
39
+ )
40
+ end
41
+
42
+ def test_set_checkout_data
43
+ Zipco::Setup.new(@checkout).set_checkout_data
44
+ @checkout.order.reload
45
+
46
+ order = @checkout.order
47
+ payment = Workarea::Payment.find(order.id)
48
+
49
+ assert(order.zipco_order_id.present?)
50
+ assert(payment.zipco.present?)
51
+ end
52
+
53
+ def test_redirect_uri
54
+ data = Zipco::Setup.new(@checkout).redirect_uri
55
+ assert_equal(expected_redirect_uri, data)
56
+ end
57
+
58
+ private
59
+
60
+ def expected_redirect_uri
61
+ "https://account.sandbox.zipmoney.com.au/?co=co_P9GOgSVE9qMnL0VA6Jy8z6&m=aa7bd4b9-f270-4eba-94b7-a64e95f6b13f"
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,6 @@
1
+ require 'workarea/testing/teaspoon'
2
+
3
+ Teaspoon.configure do |config|
4
+ config.root = Workarea::Zipco::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,55 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ module Storefront
5
+ class ZipcoViewModelTest < TestCase
6
+ def order
7
+ @order ||= create_order(email: 'test@workarea.com')
8
+ end
9
+
10
+ def payment
11
+ @payment ||=
12
+ create_payment(id: order.id).tap do |payment|
13
+ payment.set_address(
14
+ first_name: 'Ben',
15
+ last_name: 'Crouse',
16
+ street: '22 S. 3rd St.',
17
+ city: 'Philadelphia',
18
+ region: 'PA',
19
+ postal_code: '19106',
20
+ country: 'US',
21
+ phone_number: '2159251800'
22
+ )
23
+
24
+ payment.set_credit_card(
25
+ number: '1',
26
+ month: 1,
27
+ year: Time.current.year + 1,
28
+ cvv: '999',
29
+ amount: 5.to_m
30
+ )
31
+ end
32
+ end
33
+
34
+ def test_show?
35
+ wa_payment = payment
36
+ view_model = Workarea::Storefront::ZipcoViewModel.new(nil, { order: order })
37
+ refute(view_model.show?)
38
+
39
+ wa_payment.set_address(
40
+ first_name: 'Paul',
41
+ last_name: 'Hogan',
42
+ street: '22 S. 3rd St.',
43
+ city: 'Queensland',
44
+ region: 'NT',
45
+ postal_code: '19106',
46
+ country: 'AU',
47
+ phone_number: '2159251800'
48
+ )
49
+
50
+ view_model = Workarea::Storefront::ZipcoViewModel.new(nil, { order: order })
51
+ assert(view_model.show?)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,19 @@
1
+ $:.push File.expand_path("lib", __dir__)
2
+
3
+ # Maintain your gem's version:
4
+ require "workarea/zipco/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "workarea-zipco"
9
+ spec.version = Workarea::Zipco::VERSION
10
+ spec.authors = ["Jeff Yucis"]
11
+ spec.email = ["jyucis@workarea.com"]
12
+ spec.homepage = ""
13
+ spec.summary = "Zip.co Payments for Workarea Ecommerce."
14
+ spec.description = "Zip.com payment processor integration for Workarea Ecommerce."
15
+
16
+ spec.files = `git ls-files`.split("\n")
17
+
18
+ spec.add_dependency 'workarea', '>= 3.4.x'
19
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: workarea-zipco
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: 2020-03-19 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.4.x
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.4.x
27
+ description: Zip.com payment processor integration for Workarea Ecommerce.
28
+ email:
29
+ - jyucis@workarea.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".eslintrc.json"
35
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
36
+ - ".github/ISSUE_TEMPLATE/documentation-request.md"
37
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
38
+ - ".github/workflows/ci.yml"
39
+ - ".gitignore"
40
+ - ".rubocop.yml"
41
+ - ".stylelintrc.json"
42
+ - CHANGELOG.md
43
+ - Gemfile
44
+ - README.md
45
+ - Rakefile
46
+ - app/assets/images/zipco/.keep
47
+ - app/assets/stylesheets/workarea/storefront/zipco/components/_zipco_icon.scss
48
+ - app/controllers/storefront/checkout/place_order_controller.decorator
49
+ - app/controllers/storefront/zipco_controller.rb
50
+ - app/controllers/storefront/zipco_landing_controller.rb
51
+ - app/helpers/.keep
52
+ - app/mailers/.keep
53
+ - app/models/checkout.decorator
54
+ - app/models/workarea/order.decorator
55
+ - app/models/workarea/order/status/zip_referred.rb
56
+ - app/models/workarea/payment.decorator
57
+ - app/models/workarea/payment/authorize/zipco.rb
58
+ - app/models/workarea/payment/capture/zipco.rb
59
+ - app/models/workarea/payment/purchase/zipco.rb
60
+ - app/models/workarea/payment/refund/zipco.rb
61
+ - app/models/workarea/payment/tender/zipco.rb
62
+ - app/models/workarea/search/admin/admin.decorator
63
+ - app/services/workarea/zipco/checkout.rb
64
+ - app/services/workarea/zipco/order.rb
65
+ - app/services/workarea/zipco/setup.rb
66
+ - app/view_models/workarea/storefront/checkout/payment_view_model.decorator
67
+ - app/view_models/workarea/storefront/order_view_model.decorator
68
+ - app/view_models/workarea/storefront/zipco_view_model.rb
69
+ - app/views/workarea/admin/orders/tenders/_zipco.html.haml
70
+ - app/views/workarea/storefront/checkouts/_zipco_payment.html.haml
71
+ - app/views/workarea/storefront/order_mailer/tenders/_zipco.html.haml
72
+ - app/views/workarea/storefront/order_mailer/tenders/_zipco.text.erb
73
+ - app/views/workarea/storefront/orders/_zipco_order_message.html.haml
74
+ - app/views/workarea/storefront/orders/tenders/_zipco.html.haml
75
+ - app/views/workarea/storefront/zipco/_zipco_tagline.html.haml
76
+ - app/views/workarea/storefront/zipco_landing/show.html.haml
77
+ - bin/rails
78
+ - config/initializers/appends.rb
79
+ - config/initializers/workarea.rb
80
+ - config/locales/en.yml
81
+ - config/routes.rb
82
+ - lib/workarea/zipco.rb
83
+ - lib/workarea/zipco/bogus_gateway.rb
84
+ - lib/workarea/zipco/engine.rb
85
+ - lib/workarea/zipco/gateway.rb
86
+ - lib/workarea/zipco/response.rb
87
+ - lib/workarea/zipco/version.rb
88
+ - package.json
89
+ - test/dummy/.ruby-version
90
+ - test/dummy/Rakefile
91
+ - test/dummy/app/assets/config/manifest.js
92
+ - test/dummy/app/assets/images/.keep
93
+ - test/dummy/app/assets/javascripts/application.js
94
+ - test/dummy/app/assets/stylesheets/application.css
95
+ - test/dummy/app/controllers/application_controller.rb
96
+ - test/dummy/app/controllers/concerns/.keep
97
+ - test/dummy/app/helpers/application_helper.rb
98
+ - test/dummy/app/jobs/application_job.rb
99
+ - test/dummy/app/mailers/application_mailer.rb
100
+ - test/dummy/app/models/concerns/.keep
101
+ - test/dummy/app/views/layouts/application.html.erb
102
+ - test/dummy/app/views/layouts/mailer.html.erb
103
+ - test/dummy/app/views/layouts/mailer.text.erb
104
+ - test/dummy/bin/bundle
105
+ - test/dummy/bin/rails
106
+ - test/dummy/bin/rake
107
+ - test/dummy/bin/setup
108
+ - test/dummy/bin/update
109
+ - test/dummy/bin/yarn
110
+ - test/dummy/config.ru
111
+ - test/dummy/config/application.rb
112
+ - test/dummy/config/boot.rb
113
+ - test/dummy/config/environment.rb
114
+ - test/dummy/config/environments/development.rb
115
+ - test/dummy/config/environments/production.rb
116
+ - test/dummy/config/environments/test.rb
117
+ - test/dummy/config/initializers/application_controller_renderer.rb
118
+ - test/dummy/config/initializers/assets.rb
119
+ - test/dummy/config/initializers/backtrace_silencers.rb
120
+ - test/dummy/config/initializers/content_security_policy.rb
121
+ - test/dummy/config/initializers/cookies_serializer.rb
122
+ - test/dummy/config/initializers/filter_parameter_logging.rb
123
+ - test/dummy/config/initializers/inflections.rb
124
+ - test/dummy/config/initializers/mime_types.rb
125
+ - test/dummy/config/initializers/workarea.rb
126
+ - test/dummy/config/initializers/wrap_parameters.rb
127
+ - test/dummy/config/locales/en.yml
128
+ - test/dummy/config/puma.rb
129
+ - test/dummy/config/routes.rb
130
+ - test/dummy/config/spring.rb
131
+ - test/dummy/db/seeds.rb
132
+ - test/dummy/lib/assets/.keep
133
+ - test/dummy/log/.keep
134
+ - test/integration/workarea/storefront/zipco_integration_test.rb
135
+ - test/models/workarea/order/zipco_queries_test.rb
136
+ - test/models/workarea/payment/zipco_payment_integration_test.rb
137
+ - test/services/workarea/zipco/checkout_test.rb
138
+ - test/services/workarea/zipco/order_test.rb
139
+ - test/services/workarea/zipco/setup_test.rb
140
+ - test/teaspoon_env.rb
141
+ - test/test_helper.rb
142
+ - test/view_models/workarea/storefront/zipco_view_model_test.rb
143
+ - workarea-zipco.gemspec
144
+ - yarn.lock
145
+ homepage: ''
146
+ licenses: []
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubygems_version: 3.0.6
164
+ signing_key:
165
+ specification_version: 4
166
+ summary: Zip.co Payments for Workarea Ecommerce.
167
+ test_files: []