workarea-global_e 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintrc.json +37 -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 +77 -0
  7. data/.gitignore +20 -0
  8. data/.rubocop.yml +2 -0
  9. data/.ruby-version +1 -0
  10. data/CHANGELOG.md +261 -0
  11. data/Gemfile +16 -0
  12. data/README.md +39 -0
  13. data/Rakefile +59 -0
  14. data/app/assets/javascripts/workarea/storefront/global_e/modules/checkout_info_validator.js +122 -0
  15. data/app/assets/javascripts/workarea/storefront/global_e/modules/suppress_price_ranges.js +19 -0
  16. data/app/controllers/workarea/admin/country_exceptions_controller.rb +67 -0
  17. data/app/controllers/workarea/admin/fixed_prices_controller.rb +89 -0
  18. data/app/controllers/workarea/admin/orders_controller.decorator +6 -0
  19. data/app/controllers/workarea/storefront/application_controller.decorator +30 -0
  20. data/app/controllers/workarea/storefront/checkouts_controller.decorator +22 -0
  21. data/app/controllers/workarea/storefront/ge_checkouts_controller.rb +10 -0
  22. data/app/controllers/workarea/storefront/global_e_controller.rb +42 -0
  23. data/app/controllers/workarea/storefront/globale/api_controller.rb +108 -0
  24. data/app/controllers/workarea/storefront/globale/refund_controller.rb +65 -0
  25. data/app/controllers/workarea/storefront/users/logins_controller.decorator +13 -0
  26. data/app/helpers/workarea/admin/global_e_helpers.rb +28 -0
  27. data/app/models/workarea/address.decorator +11 -0
  28. data/app/models/workarea/catalog/product.decorator +14 -0
  29. data/app/models/workarea/fulfillment/status/partially_refunded.rb +13 -0
  30. data/app/models/workarea/fulfillment/status/refunded.rb +15 -0
  31. data/app/models/workarea/fulfillment.decorator +55 -0
  32. data/app/models/workarea/global_e/country_exception.rb +37 -0
  33. data/app/models/workarea/global_e/fixed_price.rb +93 -0
  34. data/app/models/workarea/global_e/order_api_events.rb +29 -0
  35. data/app/models/workarea/order/item.decorator +46 -0
  36. data/app/models/workarea/order/status/pending_global_e_fraud_check.rb +12 -0
  37. data/app/models/workarea/order.decorator +64 -0
  38. data/app/models/workarea/payment/status/global_e_appoved.rb +9 -0
  39. data/app/models/workarea/payment/status/pending_global_e_fraud_check.rb +9 -0
  40. data/app/models/workarea/payment/tender/global_e_payment.rb +16 -0
  41. data/app/models/workarea/payment.decorator +10 -0
  42. data/app/models/workarea/price_adjustment.decorator +13 -0
  43. data/app/models/workarea/price_adjustment_set.decorator +25 -0
  44. data/app/models/workarea/pricing/calculators/item_calculator.decorator +48 -0
  45. data/app/models/workarea/pricing/collection.decorator +90 -0
  46. data/app/models/workarea/pricing/discount/appliation_group.decorator +16 -0
  47. data/app/models/workarea/pricing/discount/international_item_proxy.rb +27 -0
  48. data/app/models/workarea/pricing/discount/international_order.rb +29 -0
  49. data/app/models/workarea/pricing/discount.decorator +65 -0
  50. data/app/models/workarea/pricing/price_distributor.decorator +37 -0
  51. data/app/models/workarea/pricing/request.decorator +17 -0
  52. data/app/models/workarea/pricing/sku.decorator +17 -0
  53. data/app/models/workarea/search/admin/order.decorator +11 -0
  54. data/app/models/workarea/shipping/sku.decorator +23 -0
  55. data/app/models/workarea/shipping.decorator +11 -0
  56. data/app/models/workarea/user.decorator +10 -0
  57. data/app/seeds/workarea/global_e_seeds.rb +66 -0
  58. data/app/services/workarea/create_fulfillment.decorator +12 -0
  59. data/app/services/workarea/global_e/address_details.rb +218 -0
  60. data/app/services/workarea/global_e/api/notify_order_refunded.rb +45 -0
  61. data/app/services/workarea/global_e/api/perform_order_payment.rb +46 -0
  62. data/app/services/workarea/global_e/api/remove_restricted_products.rb +28 -0
  63. data/app/services/workarea/global_e/api/send_order_to_merchant/item_pricer.rb +147 -0
  64. data/app/services/workarea/global_e/api/send_order_to_merchant/save_user.rb +59 -0
  65. data/app/services/workarea/global_e/api/send_order_to_merchant.rb +359 -0
  66. data/app/services/workarea/global_e/api/update_order_shipping_info.rb +38 -0
  67. data/app/services/workarea/global_e/api/update_order_status/canceled.rb +42 -0
  68. data/app/services/workarea/global_e/api/update_order_status.rb +28 -0
  69. data/app/services/workarea/global_e/attribute.rb +44 -0
  70. data/app/services/workarea/global_e/brand.rb +19 -0
  71. data/app/services/workarea/global_e/cart_user_details.rb +34 -0
  72. data/app/services/workarea/global_e/category.rb +19 -0
  73. data/app/services/workarea/global_e/checkout_cart_info.rb +358 -0
  74. data/app/services/workarea/global_e/custom_product_attribute.rb +19 -0
  75. data/app/services/workarea/global_e/discount.rb +215 -0
  76. data/app/services/workarea/global_e/merchant/brand.rb +21 -0
  77. data/app/services/workarea/global_e/merchant/category.rb +21 -0
  78. data/app/services/workarea/global_e/merchant/customer.rb +36 -0
  79. data/app/services/workarea/global_e/merchant/customer_details.rb +201 -0
  80. data/app/services/workarea/global_e/merchant/discount.rb +127 -0
  81. data/app/services/workarea/global_e/merchant/international_details.rb +296 -0
  82. data/app/services/workarea/global_e/merchant/order.rb +425 -0
  83. data/app/services/workarea/global_e/merchant/order_refund.rb +103 -0
  84. data/app/services/workarea/global_e/merchant/original_order.rb +28 -0
  85. data/app/services/workarea/global_e/merchant/parcel_tracking.rb +31 -0
  86. data/app/services/workarea/global_e/merchant/payment_details.rb +161 -0
  87. data/app/services/workarea/global_e/merchant/product.rb +222 -0
  88. data/app/services/workarea/global_e/merchant/refund_product.rb +69 -0
  89. data/app/services/workarea/global_e/merchant/response_info.rb +115 -0
  90. data/app/services/workarea/global_e/merchant_cart_product_attribute.rb +21 -0
  91. data/app/services/workarea/global_e/order_status.rb +20 -0
  92. data/app/services/workarea/global_e/order_status_details.rb +79 -0
  93. data/app/services/workarea/global_e/order_status_reason.rb +20 -0
  94. data/app/services/workarea/global_e/parcel.rb +53 -0
  95. data/app/services/workarea/global_e/product.rb +612 -0
  96. data/app/services/workarea/global_e/product_meta_data.rb +13 -0
  97. data/app/services/workarea/global_e/tracking_details.rb +23 -0
  98. data/app/services/workarea/global_e/update_order_dispatch_exception.rb +46 -0
  99. data/app/services/workarea/global_e/update_order_dispatch_request.rb +108 -0
  100. data/app/services/workarea/global_e/user_id_number_type.rb +21 -0
  101. data/app/services/workarea/global_e/users_details.rb +151 -0
  102. data/app/services/workarea/global_e/vat_category.rb +20 -0
  103. data/app/services/workarea/global_e/vat_rate_type.rb +27 -0
  104. data/app/services/workarea/save_order_analytics.decorator +18 -0
  105. data/app/view_models/workarea/admin/order_view_model.decorator +13 -0
  106. data/app/view_models/workarea/storefront/cart_view_model.decorator +7 -0
  107. data/app/view_models/workarea/storefront/order_item_view_model.decorator +16 -0
  108. data/app/view_models/workarea/storefront/order_view_model.decorator +45 -0
  109. data/app/view_models/workarea/storefront/product_view_model.decorator +35 -0
  110. data/app/views/workarea/admin/catalog_products/_country_exceptions_card.html.haml +31 -0
  111. data/app/views/workarea/admin/catalog_products/_global_e_attributes.html.haml +3 -0
  112. data/app/views/workarea/admin/catalog_products/_global_e_fields.html.haml +4 -0
  113. data/app/views/workarea/admin/country_exceptions/edit.html.haml +48 -0
  114. data/app/views/workarea/admin/country_exceptions/index.html.haml +47 -0
  115. data/app/views/workarea/admin/country_exceptions/new.html.haml +44 -0
  116. data/app/views/workarea/admin/fixed_prices/edit.html.haml +73 -0
  117. data/app/views/workarea/admin/fixed_prices/index.html.haml +55 -0
  118. data/app/views/workarea/admin/fixed_prices/new.html.haml +70 -0
  119. data/app/views/workarea/admin/orders/_global_e.html.haml +27 -0
  120. data/app/views/workarea/admin/orders/attributes.html.haml +131 -0
  121. data/app/views/workarea/admin/orders/global_e.html.haml +110 -0
  122. data/app/views/workarea/admin/orders/show.html.haml +27 -0
  123. data/app/views/workarea/admin/orders/tenders/_global_e_payment.html.haml +3 -0
  124. data/app/views/workarea/admin/pricing_skus/_cards.html.haml +98 -0
  125. data/app/views/workarea/storefront/cart_items/create.html.haml +71 -0
  126. data/app/views/workarea/storefront/carts/_pricing.html.haml +14 -0
  127. data/app/views/workarea/storefront/carts/show.html.haml +187 -0
  128. data/app/views/workarea/storefront/ge_checkouts/show.html.haml +1 -0
  129. data/app/views/workarea/storefront/global_e/_country_picker.html.haml +1 -0
  130. data/app/views/workarea/storefront/global_e/_head.html.haml +10 -0
  131. data/app/views/workarea/storefront/orders/_summary.html.haml +275 -0
  132. data/app/views/workarea/storefront/orders/tenders/_global_e_payment.html.haml +3 -0
  133. data/app/views/workarea/storefront/products/_pricing.html.haml +49 -0
  134. data/app/views/workarea/storefront/products/_restricted_item_text.html.haml +1 -0
  135. data/app/views/workarea/storefront/users/orders/_summary.html.haml +22 -0
  136. data/app/workers/workarea/global_e/update_order_dispatch.rb +28 -0
  137. data/app/workers/workarea/save_user_order_details.decorator +9 -0
  138. data/bin/rails +25 -0
  139. data/config/initializers/appends.rb +46 -0
  140. data/config/initializers/seeds.rb +1 -0
  141. data/config/initializers/workarea.rb +64 -0
  142. data/config/locales/en.yml +105 -0
  143. data/config/routes.rb +31 -0
  144. data/lib/workarea/global_e/engine.rb +10 -0
  145. data/lib/workarea/global_e/error.rb +8 -0
  146. data/lib/workarea/global_e/version.rb +5 -0
  147. data/lib/workarea/global_e.rb +58 -0
  148. data/script/admin_ci +5 -0
  149. data/script/ci +8 -0
  150. data/script/core_ci +5 -0
  151. data/script/plugins_ci +5 -0
  152. data/script/storefront_ci +5 -0
  153. data/test/dummy/.ruby-version +1 -0
  154. data/test/dummy/Rakefile +6 -0
  155. data/test/dummy/app/assets/config/manifest.js +3 -0
  156. data/test/dummy/app/assets/images/.keep +0 -0
  157. data/test/dummy/app/assets/javascripts/application.js +14 -0
  158. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  159. data/test/dummy/app/controllers/application_controller.rb +2 -0
  160. data/test/dummy/app/controllers/concerns/.keep +0 -0
  161. data/test/dummy/app/helpers/application_helper.rb +2 -0
  162. data/test/dummy/app/jobs/application_job.rb +2 -0
  163. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  164. data/test/dummy/app/models/concerns/.keep +0 -0
  165. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  166. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  167. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  168. data/test/dummy/bin/bundle +3 -0
  169. data/test/dummy/bin/rails +4 -0
  170. data/test/dummy/bin/rake +4 -0
  171. data/test/dummy/bin/setup +28 -0
  172. data/test/dummy/bin/update +28 -0
  173. data/test/dummy/bin/yarn +11 -0
  174. data/test/dummy/config/application.rb +23 -0
  175. data/test/dummy/config/boot.rb +5 -0
  176. data/test/dummy/config/environment.rb +5 -0
  177. data/test/dummy/config/environments/development.rb +52 -0
  178. data/test/dummy/config/environments/production.rb +83 -0
  179. data/test/dummy/config/environments/test.rb +45 -0
  180. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  181. data/test/dummy/config/initializers/assets.rb +14 -0
  182. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  183. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  184. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  185. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  186. data/test/dummy/config/initializers/inflections.rb +16 -0
  187. data/test/dummy/config/initializers/mime_types.rb +4 -0
  188. data/test/dummy/config/initializers/workarea.rb +5 -0
  189. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  190. data/test/dummy/config/locales/en.yml +33 -0
  191. data/test/dummy/config/puma.rb +34 -0
  192. data/test/dummy/config/routes.rb +5 -0
  193. data/test/dummy/config/secrets.yml +18 -0
  194. data/test/dummy/config/spring.rb +6 -0
  195. data/test/dummy/config.ru +5 -0
  196. data/test/dummy/db/seeds.rb +2 -0
  197. data/test/dummy/lib/assets/.keep +0 -0
  198. data/test/dummy/log/.keep +0 -0
  199. data/test/factories/workarea/global_e_factories.rb +836 -0
  200. data/test/integration/workarea/admin/catalog_product_country_exceptions_integration_test.rb +81 -0
  201. data/test/integration/workarea/admin/global_e_jump_to_integration_test.rb +20 -0
  202. data/test/integration/workarea/admin/pricing_sku_fixed_prices_integration_test.rb +83 -0
  203. data/test/integration/workarea/storefront/global_e_api/receive_order_integration_test.rb +278 -0
  204. data/test/integration/workarea/storefront/global_e_api/receive_order_refund_integration_test.rb +25 -0
  205. data/test/integration/workarea/storefront/global_e_api/receive_payment_integration_test.rb +34 -0
  206. data/test/integration/workarea/storefront/global_e_api/receive_shipping_info_integration_test.rb +29 -0
  207. data/test/integration/workarea/storefront/global_e_api/remove_restricted_products_integration_test.rb +27 -0
  208. data/test/integration/workarea/storefront/global_e_api/update_order_status_integration_test.rb +29 -0
  209. data/test/integration/workarea/storefront/global_e_checkout_cart_info/fixed_pricing_test.rb +438 -0
  210. data/test/integration/workarea/storefront/global_e_checkout_cart_info/gift_card_test.rb +63 -0
  211. data/test/integration/workarea/storefront/global_e_checkout_cart_info_integration_test.rb +660 -0
  212. data/test/integration/workarea/storefront/global_e_checkouts_integration_test.rb +71 -0
  213. data/test/integration/workarea/storefront/users/global_e_logins_integration_test.rb +20 -0
  214. data/test/models/workarea/catalog/product_global_e_test.rb +13 -0
  215. data/test/models/workarea/fixed_pricing_test.rb +117 -0
  216. data/test/models/workarea/global_e/country_exception_test.rb +36 -0
  217. data/test/models/workarea/payment_test.decorator +31 -0
  218. data/test/models/workarea/pricing/calculators/item_calculator_fixed_prices_test.rb +83 -0
  219. data/test/models/workarea/pricing/collection_fixed_prices_test.rb +83 -0
  220. data/test/models/workarea/pricing/price_distributor_test.decorator +21 -0
  221. data/test/models/workarea/pricing/sku_fixed_price_test.rb +133 -0
  222. data/test/support/workarea/global_e_support.rb +18 -0
  223. data/test/system/workarea/admin/global_e_system_test.rb +21 -0
  224. data/test/system/workarea/storefront/global_e_cart_system_test.rb +48 -0
  225. data/test/system/workarea/storefront/global_e_order_history_system_test.rb +43 -0
  226. data/test/teaspoon_env.rb +6 -0
  227. data/test/test_helper.rb +9 -0
  228. data/test/view_models/workarea/admin/global_e_order_view_model_test.rb +22 -0
  229. data/test/workers/workarea/global_e/update_order_dispatch_test.rb +64 -0
  230. data/test/workers/workarea/global_e_save_user_order_details_test.rb +41 -0
  231. data/workarea-global_e.gemspec +16 -0
  232. metadata +293 -0
@@ -0,0 +1,28 @@
1
+ module Workarea
2
+ module GlobalE
3
+ class UpdateOrderDispatch
4
+ include Sidekiq::Worker
5
+
6
+ def perform(id, tracking_number)
7
+ domain = GlobalE.domains[GlobalE.environment]
8
+ path = "/Order/UpdateOrderDispatchV2?merchantGUID=#{GlobalE.merchant_guid}"
9
+
10
+ dispatch = UpdateOrderDispatchRequest.new(id, tracking_number: tracking_number)
11
+ uri = URI("#{domain}#{path}")
12
+
13
+ http = Net::HTTP.new(uri.host, uri.port).tap do |net_http|
14
+ net_http.use_ssl = true
15
+ end
16
+
17
+ post = Net::HTTP::Post.new(path).tap do |request|
18
+ request['Content-Type'] = 'application/json'
19
+ request.body = dispatch.to_json
20
+ end
21
+
22
+ response = http.request(post)
23
+
24
+ raise response.body unless response.is_a? Net::HTTPSuccess
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ module Workarea
2
+ decorate SaveUserOrderDetails, with: :global_e do
3
+ decorated do
4
+ sidekiq_options(
5
+ sidekiq_options["enqueue_on"].merge(ignore_if: -> { self.global_e? })
6
+ )
7
+ end
8
+ end
9
+ end
data/bin/rails ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/workarea/global_e/engine', __dir__)
7
+ APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
8
+
9
+ # Set up gems listed in the Gemfile.
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
11
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
+
13
+ require "rails"
14
+ # Pick the frameworks you want:
15
+ require "active_model/railtie"
16
+ require "active_job/railtie"
17
+ # require "active_record/railtie"
18
+ # require "active_storage/engine"
19
+ require "action_controller/railtie"
20
+ require "action_mailer/railtie"
21
+ require "action_view/railtie"
22
+ # require "action_cable/engine"
23
+ require "sprockets/railtie"
24
+ require "rails/test_unit/railtie"
25
+ require 'rails/engine/commands'
@@ -0,0 +1,46 @@
1
+ Workarea.append_partials(
2
+ 'storefront.document_head',
3
+ 'workarea/storefront/global_e/head'
4
+ )
5
+
6
+ Workarea.append_partials(
7
+ 'storefront.footer_help',
8
+ 'workarea/storefront/global_e/country_picker'
9
+ )
10
+
11
+ Workarea.append_javascripts(
12
+ "storefront.modules",
13
+ "workarea/storefront/global_e/modules/suppress_price_ranges"
14
+ )
15
+
16
+ if Rails.env.test? || Rails.env.development?
17
+ Workarea.append_javascripts(
18
+ "storefront.modules",
19
+ "workarea/storefront/global_e/modules/checkout_info_validator"
20
+ )
21
+ end
22
+
23
+ Workarea.append_partials(
24
+ 'admin.order_cards',
25
+ 'workarea/admin/orders/global_e'
26
+ )
27
+
28
+ Workarea.append_partials(
29
+ 'admin.catalog_product_cards',
30
+ 'workarea/admin/catalog_products/country_exceptions_card'
31
+ )
32
+
33
+ Workarea.append_partials(
34
+ 'storefront.product_details',
35
+ 'workarea/storefront/products/restricted_item_text'
36
+ )
37
+
38
+ Workarea.append_partials(
39
+ 'admin.product_attributes_card',
40
+ 'workarea/admin/catalog_products/global_e_attributes'
41
+ )
42
+
43
+ Workarea.append_partials(
44
+ 'admin.product_fields',
45
+ 'workarea/admin/catalog_products/global_e_fields'
46
+ )
@@ -0,0 +1 @@
1
+ Workarea.config.seeds.insert_after('Workarea::ProductsSeeds', 'Workarea::GlobalESeeds')
@@ -0,0 +1,64 @@
1
+ Workarea.configure do |config|
2
+ config.tender_types.prepend(:global_e_payment)
3
+ config.order_status_calculators.unshift("Workarea::Order::Status::PendingGlobalEFraudCheck")
4
+ config.payment_status_calculators.unshift(
5
+ "Workarea::Payment::Status::PendingGlobalEFraudCheck",
6
+ "Workarea::Payment::Status::GlobalEApproved"
7
+ )
8
+ config.fulfillment_status_calculators.unshift(
9
+ "Workarea::Fulfillment::Status::Refunded",
10
+ "Workarea::Fulfillment::Status::PartiallyRefunded"
11
+ )
12
+
13
+ config.global_e = ActiveSupport::Configurable::Configuration.new
14
+
15
+ config.global_e.domains = {
16
+ "qa" => "https://connect-qa.bglobale.com",
17
+ "qa-int" => "https://connect.bglobale.com/",
18
+ "staging" => "https://connect2.bglobale.com",
19
+ "production" => "https://api.global-e.com"
20
+ }
21
+
22
+ config.global_e.enabled = true
23
+ config.global_e.javascript_source = nil
24
+ config.global_e.css_source = nil
25
+ config.global_e.merchant_guid = nil
26
+
27
+ config.global_e.currencies = ["AFN", "DZD", "ARS", "AMD", "AWG", "AUD", "AZN",
28
+ "BSD", "BHD", "THB", "PAB", "BBD", "BZD", "BMD", "BOB", "BRL", "BND", "BGN",
29
+ "BIF", "CAD", "CVE", "KYD", "XOF", "XAF", "XPF", "CLP", "COP", "KMF", "CDF",
30
+ "BAM", "NIO", "CRC", "HRK", "CUP", "CZK", "GMD", "DKK", "MKD", "DJF", "STD",
31
+ "DOP", "VND", "XCD", "EGP", "ETB", "EUR", "FKP", "FJD", "HUF", "GHS", "HTG",
32
+ "PYG", "GNF", "GYD", "HKD", "UAH", "ISK", "INR", "IRR", "IQD", "ILS", "JMD",
33
+ "JOD", "KES", "PGK", "LAK", "KWD", "MWK", "AOA", "MMK", "GEL", "LBP", "ALL",
34
+ "HNL", "SLL", "LRD", "LYD", "SZL", "LSL", "MGA", "MYR", "MUR", "MXN", "MDL",
35
+ "MAD", "MZN", "NGN", "ERN", "NAD", "NPR", "ANG", "BYN", "RON", "TWD", "NZD",
36
+ "BTN", "KPW", "NOK", "MRO", "TOP", "PKR", "MOP", "UYU", "PHP", "GBP", "BWP",
37
+ "QAR", "GTQ", "ZAR", "OMR", "KHR", "MVR", "IDR", "RUB", "RWF", "SHP", "SAR",
38
+ "RSD", "SCR", "SGD", "PEN", "SBD", "KGS", "SOS", "TJS", "LKR", "SDG", "SRD",
39
+ "SEK", "CHF", "SYP", "BDT", "WST", "TZS", "KZT", "TTD", "MNT", "TND", "TRY",
40
+ "TMT", "AED", "UGX", "USD", "UZS", "VUV", "KRW", "YER", "JPY", "CNY", "ZMW",
41
+ "ZWL", "PLN",
42
+ ]
43
+
44
+ config.global_e.countries = ["AL", "DZ", "AS", "AD", "AI", "AG", "AR", "AM",
45
+ "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM",
46
+ "BT", "BO", "BQ", "BA", "BW", "BR", "VG", "BN", "BG", "KH", "CA", "CV", "KY",
47
+ "CL", "CN", "CO", "KM", "CK", "CR", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ",
48
+ "DM", "DO", "TP", "EC", "EG", "SV", "ER", "EE", "ET", "MK", "FK", "FO", "FJ",
49
+ "FI", "FR", "GF", "PF", "TF", "GE", "DE", "GI", "GR", "GL", "GD", "GP", "GU",
50
+ "GT", "GG", "GN", "GW", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ",
51
+ "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KR", "KW",
52
+ "KG", "LA", "LV", "LB", "LS", "LY", "LI", "LT", "LU", "MO", "MG", "MW", "MY",
53
+ "MV", "MT", "MH", "MQ", "MR", "MU", "MX", "FM", "MD", "MC", "MN", "ME", "MS",
54
+ "MA", "MZ", "NA", "NR", "NP", "NL", "AN", "NC", "NZ", "NI", "NG", "NU", "MP",
55
+ "NO", "OM", "PK", "PW", "PA", "PG", "PY", "PE", "PH", "PL", "PT", "PR", "QA",
56
+ "RE", "RO", "RU", "KN", "LC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SG",
57
+ "SK", "SI", "SB", "ZA", "ES", "LK", "BL", "MF", "SD", "SR", "SZ", "SE", "CH",
58
+ "TW", "TZ", "TH", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UA", "AE", "GB",
59
+ "US", "UY", "UZ", "VU", "VA", "VE", "VN", "VI", "WF", "ZM", "ZW"
60
+ ]
61
+
62
+ config.global_e.shipping_discount_types = ["Workarea::Pricing::Discount::Shipping"]
63
+ config.global_e.free_gift_discount_types = ["Workarea::Pricing::Discount::FreeGift"]
64
+ end
@@ -0,0 +1,105 @@
1
+ en:
2
+ workarea:
3
+ admin:
4
+ catalog_products:
5
+ cards:
6
+ country_exceptions:
7
+ add_country_exceptions: Add country exceptions
8
+ button: Manage Country Exceptions
9
+ manage_country_exceptions: Manage Country Exceptions
10
+ no_country_exceptions: No country exceptions.
11
+ title: Country Exceptions
12
+ edit:
13
+ global_e_forbidden: Yes
14
+ not_global_e_forbidden: No
15
+ country_exceptions:
16
+ global_e_forbidden: GlobalE Forbidden
17
+ edit:
18
+ page_title: Edit country exception on %{product}
19
+ flash_messages:
20
+ create_error: There was a problem creating your Country Exception.
21
+ deleted: Your Country Exception has been deleted.
22
+ saved: Your Country Exception has been saved.
23
+ update_error: There was a problem updating your Country Exception.
24
+ index:
25
+ add_new: Add New
26
+ heading: Manage Country Exceptions
27
+ page_title: Country Exceptions for %{product}
28
+ new:
29
+ create_country_exception: Create country exception
30
+ page_title: New country exception on %{product}
31
+ fields:
32
+ currency: Currency
33
+ vat_rate: VAT Rate
34
+ restricted: Restricted
35
+ fixed_prices:
36
+ active: Active
37
+ country: Country
38
+ fixed_price_description: >
39
+ Fixed prices allow you to specify country or currency for that price. A fixed price that doesn't
40
+ specify a currency will be the default price for any country that uses that currency. If a fixed
41
+ price is present, users browsing or shipping to that country or using the specified currency will
42
+ see the fixed price. If no fixed price is present, the default price will display using global
43
+ normal price conversion.
44
+ currency: Currency
45
+ flash_messages:
46
+ create_error: There was a problem creating your Fixed Price.
47
+ deleted: "%{sku} fixed price has been deleted."
48
+ saved: Your SKU has been saved.
49
+ update_error: There was a problem updating your Fixed Price.
50
+ index:
51
+ button: Add new fixed price
52
+ label: Fixed Prices
53
+ msrp: MSRP
54
+ new:
55
+ create_fixed_price: Create Fixed Price
56
+ regular_price: Regular price
57
+ sale_price: Sale price
58
+ sale_price_default: "(defaults to regular)"
59
+ title: Fixed prices for %{sku}
60
+ orders:
61
+ attributs:
62
+ items:
63
+ nonadjusted_pricing: Nonadjusted Pricing
64
+ cards:
65
+ global_e:
66
+ button: View Global E
67
+ global_e_id: 'GlobalE ID:'
68
+ international_shipping_total: 'Shipping Total:'
69
+ international_subtotal_price: 'Subtotal:'
70
+ title: Global-E
71
+ total_duties_price: 'Taxes and Duties:'
72
+ total_price: 'Total Price:'
73
+ global_e:
74
+ global_e_id: 'GlobalE ID:'
75
+ international_totals: International Totals
76
+ items:
77
+ international_pricing: International Pricing
78
+ products: Products
79
+ quantity: Quantity
80
+ title: Items
81
+ title: "%{name} Details"
82
+ transacting_currency: Transacting currency
83
+ tax_and_duties: Taxes and Duties
84
+ pricing_skus:
85
+ cards:
86
+ fixed_prices:
87
+ button: Manage Fixed Prices
88
+
89
+ country_exception:
90
+ errors:
91
+ country_must_be_unique: Country needs to be unique per product
92
+ restricted_or_vat_rate_required: Vat rate or restricted required
93
+
94
+ fixed_price:
95
+ errors:
96
+ currency_must_be_unique: Currency needs to be unique per sku
97
+ country_must_be_unique: Country needs to be unique per sku
98
+ currency_and_regular_mistmatch: Regular price and currency fields do not match
99
+ invalid_currency: Invalid currency
100
+ invalid_fixed_price_currency: Fixed price needs to be in a foreign currency
101
+ sale_and_regular_currency_mismatch: Regular price and sale price currencies do not match
102
+
103
+ storefront:
104
+ products:
105
+ restricted_item_message: This item isn't available for purchase in your country
data/config/routes.rb ADDED
@@ -0,0 +1,31 @@
1
+ Workarea::Storefront::Engine.routes.draw do
2
+ resource :ge_checkout, only: :show
3
+ get 'get-checkout-cart-info', to: 'global_e#get_checkout_cart_info', as: 'global_e_checkout_cart_info'
4
+
5
+ namespace :globale do
6
+ post :receive_order, controller: :api
7
+ # TODO hack alias
8
+ post :performorderpayment, to: 'api#receive_payment'
9
+ post :receive_payment, controller: :api
10
+ post :update_order_status, controller: :api
11
+ post :receive_shipping_info, controller: :api
12
+ post :remove_restricted_products, controller: :api
13
+ post :receive_order_refund, controller: :refund
14
+ end
15
+ end
16
+
17
+ Workarea::Admin::Engine.routes.draw do
18
+ resources :orders, only: [] do
19
+ member do
20
+ get :global_e
21
+ end
22
+ end
23
+
24
+ resources :pricing_skus, only: [] do
25
+ resources :fixed_prices, except: :show
26
+ end
27
+
28
+ resources :catalog_products, only: [] do
29
+ resources :country_exceptions, except: :show
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ require 'workarea/global_e'
2
+
3
+ module Workarea
4
+ module GlobalE
5
+ class Engine < ::Rails::Engine
6
+ include Workarea::Plugin
7
+ isolate_namespace Workarea::GlobalE
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Workarea
2
+ module GlobalE
3
+ class Error < StandardError; end
4
+ class InsufficientInventory < Error; end
5
+ class InventoryCaptureFailure < Error; end
6
+ class UnpurchasableOrder < Error; end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Workarea
2
+ module GlobalE
3
+ VERSION = "1.2.1"
4
+ end
5
+ end
@@ -0,0 +1,58 @@
1
+ require 'workarea'
2
+ require 'workarea/storefront'
3
+ require 'workarea/admin'
4
+
5
+ require 'workarea/global_e/engine'
6
+ require 'workarea/global_e/version'
7
+ require 'workarea/global_e/error'
8
+
9
+ module Workarea
10
+ module GlobalE
11
+ def self.config
12
+ Workarea.config.global_e
13
+ end
14
+
15
+ def self.enabled?
16
+ config.enabled && javascript_source.present? && css_source.present?
17
+ end
18
+
19
+ def self.javascript_source
20
+ config.javascript_source
21
+ end
22
+
23
+ def self.css_source
24
+ config.css_source
25
+ end
26
+
27
+ def self.merchant_guid
28
+ config.merchant_guid
29
+ end
30
+
31
+ def self.shipping_discount_types
32
+ config.shipping_discount_types
33
+ end
34
+
35
+ def self.environment
36
+ (config.environment || Rails.env)
37
+ .to_s
38
+ .downcase
39
+ .presence_in(domains.keys) || "qa"
40
+ end
41
+
42
+ def self.domains
43
+ config.domains
44
+ end
45
+
46
+ def self.free_gift_discount_types
47
+ config.free_gift_discount_types
48
+ end
49
+
50
+ def self.report_error(error)
51
+ if defined? ::Raven
52
+ Raven.capture_exception error
53
+ else
54
+ Rails.logger.debug error
55
+ end
56
+ end
57
+ end
58
+ end
data/script/admin_ci ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler
4
+ bundle update
5
+ CI=true bin/rails app:workarea:test:admin
data/script/ci ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler
4
+ bundle update
5
+
6
+ CI=true bundle exec workarea-lint
7
+ CI=true bundle exec workarea-audit
8
+ CI=true bin/rails test test/**/*_test.rb
data/script/core_ci ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler
4
+ bundle update
5
+ CI=true bin/rails app:workarea:test:core
data/script/plugins_ci ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler
4
+ bundle update
5
+ CI=true bin/rails app:workarea:test:plugins
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler
4
+ bundle update
5
+ CI=true bin/rails app:workarea:test:storefront
@@ -0,0 +1 @@
1
+ 2.4.4
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
File without changes
@@ -0,0 +1,14 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
File without changes
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag 'application', media: 'all' %>
9
+ <%= javascript_include_tag 'application' %>
10
+ </head>
11
+
12
+ <body>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
4
+
5
+ # path to your application root.
6
+ APP_ROOT = File.expand_path('..', __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
13
+ # This script is a starting point to setup your application.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system! 'bin/rails log:clear tmp:clear'
25
+
26
+ puts "\n== Restarting application server =="
27
+ system! 'bin/rails restart'
28
+ end
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
4
+
5
+ # path to your application root.
6
+ APP_ROOT = File.expand_path('..', __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
13
+ # This script is a way to update your development environment automatically.
14
+ # Add necessary update steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system! 'bin/rails log:clear tmp:clear'
25
+
26
+ puts "\n== Restarting application server =="
27
+ system! 'bin/rails restart'
28
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path('..', __dir__)
3
+ Dir.chdir(APP_ROOT) do
4
+ begin
5
+ exec "yarnpkg", *ARGV
6
+ rescue Errno::ENOENT
7
+ $stderr.puts "Yarn executable was not detected in the system."
8
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9
+ exit 1
10
+ end
11
+ end