workarea-flow_io 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.eslintignore +2 -0
- data/.eslintrc.json +37 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/workflows/ci.yml +90 -0
- data/.gitignore +21 -0
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -0
- data/.stylelintrc.json +12 -0
- data/CHANGELOG.md +200 -0
- data/Gemfile +19 -0
- data/LICENSE +52 -0
- data/README.md +200 -0
- data/Rakefile +59 -0
- data/app/assets/javascripts/workarea/storefront/flow_io/adapters/flow_io_adapter.js +61 -0
- data/app/assets/javascripts/workarea/storefront/flow_io/configuration.js.erb +10 -0
- data/app/assets/javascripts/workarea/storefront/flow_io/flow.js +91 -0
- data/app/assets/stylesheets/flow_io/storefront/country_picker.scss +189 -0
- data/app/controllers/workarea/admin/application_controller.decorator +5 -0
- data/app/controllers/workarea/admin/catalog_categories_controller.decorator +9 -0
- data/app/controllers/workarea/admin/flow_imports_controller.rb +9 -0
- data/app/controllers/workarea/admin/orders_controller.decorator +6 -0
- data/app/controllers/workarea/admin/pricing_skus_controller.decorator +7 -0
- data/app/controllers/workarea/admin/search_settings_controller.decorator +27 -0
- data/app/controllers/workarea/storefront/application_controller.decorator +80 -0
- data/app/controllers/workarea/storefront/checkouts_controller.decorator +38 -0
- data/app/controllers/workarea/storefront/flow_io_webhook_controller.rb +49 -0
- data/app/controllers/workarea/storefront/recent_views_controller.decorator +15 -0
- data/app/controllers/workarea/storefront/searches_controller.decorator +11 -0
- data/app/helpers/workarea/admin/flow_helper.rb +13 -0
- data/app/helpers/workarea/storefront/flow_analytics_helper.rb +23 -0
- data/app/helpers/workarea/storefront/flow_content_helper.rb +21 -0
- data/app/middleware/workarea/flow_io/session_middleware.rb +68 -0
- data/app/models/workarea/address.decorator +12 -0
- data/app/models/workarea/catalog/category.decorator +8 -0
- data/app/models/workarea/checkout.decorator +26 -0
- data/app/models/workarea/flow_io/experience_geo.rb +18 -0
- data/app/models/workarea/flow_io/experience_summary.rb +15 -0
- data/app/models/workarea/flow_io/import.rb +31 -0
- data/app/models/workarea/flow_io/imported_item.rb +124 -0
- data/app/models/workarea/flow_io/local_item.rb +28 -0
- data/app/models/workarea/flow_io/localized_price.rb +30 -0
- data/app/models/workarea/flow_io/price.rb +12 -0
- data/app/models/workarea/flow_io/price_with_base.rb +7 -0
- data/app/models/workarea/flow_io/webhook/shared_secret.rb +12 -0
- data/app/models/workarea/flow_price_adjustment_set.rb +80 -0
- data/app/models/workarea/fulfillment.decorator +63 -0
- data/app/models/workarea/order.decorator +39 -0
- data/app/models/workarea/order/item.decorator +43 -0
- data/app/models/workarea/payment.decorator +11 -0
- data/app/models/workarea/payment/authorize/flow_payment.rb +48 -0
- data/app/models/workarea/payment/capture/flow_payment.rb +35 -0
- data/app/models/workarea/payment/flow_payment_data.rb +25 -0
- data/app/models/workarea/payment/flow_payment_operation.rb +20 -0
- data/app/models/workarea/payment/purchase/flow_payment.rb +44 -0
- data/app/models/workarea/payment/refund/flow_payment.rb +42 -0
- data/app/models/workarea/payment/store_flow_credit_card.rb +34 -0
- data/app/models/workarea/payment/tender.decorator +8 -0
- data/app/models/workarea/payment/tender/flow_payment.rb +15 -0
- data/app/models/workarea/payment/transaction.decorator +12 -0
- data/app/models/workarea/pricing/calculators/flow_localization_calculator.rb +30 -0
- data/app/models/workarea/pricing/calculators/item_calculator.decorator +39 -0
- data/app/models/workarea/pricing/collection.decorator +113 -0
- data/app/models/workarea/pricing/order_totals.decorator +53 -0
- data/app/models/workarea/pricing/price.decorator +17 -0
- data/app/models/workarea/pricing/price_distributor.decorator +51 -0
- data/app/models/workarea/pricing/request.decorator +17 -0
- data/app/models/workarea/pricing/shipping_totals.decorator +24 -0
- data/app/models/workarea/pricing/sku.decorator +46 -0
- data/app/models/workarea/search/settings.decorator +8 -0
- data/app/models/workarea/search/storefront/product.decorator +25 -0
- data/app/models/workarea/shipping.decorator +28 -0
- data/app/queries/workarea/order_metrics.decorator +23 -0
- data/app/queries/workarea/search/product_search.decorator +14 -0
- data/app/queries/workarea/search/storefront_search/response.decorator +40 -0
- data/app/services/workarea/flow_io/checkout.rb +242 -0
- data/app/services/workarea/flow_io/checkout_token_form.rb +36 -0
- data/app/services/workarea/flow_io/countries.rb +14 -0
- data/app/services/workarea/flow_io/detailed_shipping_notification_form.rb +84 -0
- data/app/services/workarea/flow_io/experiences.rb +24 -0
- data/app/services/workarea/flow_io/fulfillment_cancellation_form.rb +40 -0
- data/app/services/workarea/flow_io/item.rb +122 -0
- data/app/services/workarea/flow_io/item_importer.rb +108 -0
- data/app/services/workarea/flow_io/line_item_form.rb +72 -0
- data/app/services/workarea/flow_io/order_put_form.rb +62 -0
- data/app/services/workarea/flow_io/price_applier.rb +81 -0
- data/app/services/workarea/flow_io/price_applier/item_applier.rb +157 -0
- data/app/services/workarea/flow_io/routing_contraints.rb +10 -0
- data/app/services/workarea/flow_io/session.rb +90 -0
- data/app/services/workarea/flow_io/webhook.rb +28 -0
- data/app/services/workarea/flow_io/webhook/experience_deleted_v2.rb +9 -0
- data/app/services/workarea/flow_io/webhook/experience_upserted_v2.rb +9 -0
- data/app/services/workarea/flow_io/webhook/order_upserted_v2.rb +36 -0
- data/app/services/workarea/flow_io/webhook_request_signature.rb +19 -0
- data/app/view_models/workarea/admin/flow_imports_view_model.rb +36 -0
- data/app/view_models/workarea/storefront/cart_view_model.decorator +27 -0
- data/app/view_models/workarea/storefront/content_blocks/category_summary_view_model.decorator +11 -0
- data/app/view_models/workarea/storefront/content_blocks/product_insights_view_model.decorator +11 -0
- data/app/view_models/workarea/storefront/content_blocks/product_list_view_model.decorator +13 -0
- data/app/view_models/workarea/storefront/order_item_view_model.decorator +35 -0
- data/app/view_models/workarea/storefront/order_view_model.decorator +51 -0
- data/app/view_models/workarea/storefront/product_templates/option_set_view_model.decorator +20 -0
- data/app/view_models/workarea/storefront/product_templates/package_view_model.decorator +14 -0
- data/app/view_models/workarea/storefront/product_view_model.decorator +15 -0
- data/app/view_models/workarea/storefront/product_view_model/cache_key.decorator +7 -0
- data/app/view_models/workarea/storefront/recommendations_view_model.decorator +20 -0
- data/app/view_models/workarea/storefront/user_activity_view_model.decorator +18 -0
- data/app/views/workarea/admin/catalog_categories/edit.html.haml +85 -0
- data/app/views/workarea/admin/facets/_price_inputs.html.haml +50 -0
- data/app/views/workarea/admin/flow_imports/index.html.haml +44 -0
- data/app/views/workarea/admin/orders/_flow.html.haml +22 -0
- data/app/views/workarea/admin/orders/_flow_aux_navigation.html.haml +2 -0
- data/app/views/workarea/admin/orders/flow.html.haml +109 -0
- data/app/views/workarea/admin/orders/tenders/_flow_payment.html.haml +3 -0
- data/app/views/workarea/admin/pricing_skus/_cards.html.haml +83 -0
- data/app/views/workarea/admin/pricing_skus/flow.html.haml +60 -0
- data/app/views/workarea/admin/search_settings/show.html.haml +55 -0
- data/app/views/workarea/admin/shared/_flow_imports_link.html.haml +1 -0
- data/app/views/workarea/storefront/_flow_io_country_picker.html.haml +2 -0
- data/app/views/workarea/storefront/_flow_io_country_picker_javascript.html.haml +1 -0
- data/app/views/workarea/storefront/order_mailer/tenders/_flow_payment.html.haml +2 -0
- data/app/views/workarea/storefront/order_mailer/tenders/_flow_payment.text.erb +1 -0
- data/app/views/workarea/storefront/orders/tenders/_flow_payment.html.haml +3 -0
- data/app/views/workarea/storefront/products/_pricing.html.haml +41 -0
- data/app/workers/workarea/flow_io/delete_items.rb +30 -0
- data/app/workers/workarea/flow_io/fetch_import.rb +34 -0
- data/app/workers/workarea/flow_io/fulfillment_cancellation.rb +14 -0
- data/app/workers/workarea/flow_io/item_exporter.rb +47 -0
- data/app/workers/workarea/flow_io/process_import.rb +28 -0
- data/app/workers/workarea/flow_io/shipping_notifications.rb +13 -0
- data/bin/rails +25 -0
- data/config/initializers/appends.rb +39 -0
- data/config/initializers/freedom_patches.rb +23 -0
- data/config/initializers/middleware.rb +11 -0
- data/config/initializers/payment_proxy.rb +5 -0
- data/config/initializers/rack_attack.rb +15 -0
- data/config/initializers/scheduled_jobs.rb +9 -0
- data/config/initializers/workarea.rb +101 -0
- data/config/initializers/workarea_i18n.rb +11 -0
- data/config/locales/en.yml +72 -0
- data/config/routes.rb +21 -0
- data/lib/active_merchant/billing/bogus_flow_gateway.rb +16 -0
- data/lib/active_merchant/billing/flow_gateway.rb +48 -0
- data/lib/tasks/flow_io.rake +117 -0
- data/lib/workarea/flow_io.rb +73 -0
- data/lib/workarea/flow_io/bogus_client.rb +57 -0
- data/lib/workarea/flow_io/bogus_client/checkout_tokens.rb +25 -0
- data/lib/workarea/flow_io/bogus_client/experiences.rb +152 -0
- data/lib/workarea/flow_io/bogus_client/fulfillments.rb +9 -0
- data/lib/workarea/flow_io/bogus_client/items.rb +11 -0
- data/lib/workarea/flow_io/bogus_client/orders.rb +499 -0
- data/lib/workarea/flow_io/bogus_client/organizations.rb +42 -0
- data/lib/workarea/flow_io/bogus_client/proxy_client.rb +29 -0
- data/lib/workarea/flow_io/bogus_client/sessions.rb +115 -0
- data/lib/workarea/flow_io/bogus_client/shipping_notifications.rb +10 -0
- data/lib/workarea/flow_io/bogus_client/webhook_settings.rb +11 -0
- data/lib/workarea/flow_io/bogus_client/webhooks.rb +11 -0
- data/lib/workarea/flow_io/controller_log_subscriber.rb +21 -0
- data/lib/workarea/flow_io/engine.rb +8 -0
- data/lib/workarea/flow_io/http_handler.rb +27 -0
- data/lib/workarea/flow_io/version.rb +5 -0
- data/lib/workarea/freedom_patches/flow_io.rb +53 -0
- data/package.json +9 -0
- data/script/admin_ci +9 -0
- data/script/ci +11 -0
- data/script/core_ci +9 -0
- data/script/plugins_ci +9 -0
- data/script/storefront_ci +9 -0
- data/test/dummy/.ruby-version +1 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +28 -0
- data/test/dummy/bin/update +28 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +32 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +52 -0
- data/test/dummy/config/environments/production.rb +88 -0
- data/test/dummy/config/environments/test.rb +45 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/assets.rb +14 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/content_security_policy.rb +25 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/workarea.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/puma.rb +34 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/package.json +5 -0
- data/test/factories/workarea/flow_io.rb +136 -0
- data/test/factories/workarea/flow_io/euro_order_upserted_payload.rb +581 -0
- data/test/fixtures/files/example.csv +14 -0
- data/test/integration/workarea/admin/flow_imports_integration_test.rb +20 -0
- data/test/integration/workarea/admin/flow_order_integration_test.rb +37 -0
- data/test/integration/workarea/admin/search_settings_integration_test.decorator +44 -0
- data/test/integration/workarea/flow_locale_integration_test.rb +34 -0
- data/test/integration/workarea/storefront/copying_guest_order_integration_test.decorator +113 -0
- data/test/integration/workarea/storefront/flow_io_order_redirect_test.rb +55 -0
- data/test/integration/workarea/storefront/flow_io_session_integration_test.rb +122 -0
- data/test/integration/workarea/storefront/flow_io_webhooks/order_integration_test.rb +750 -0
- data/test/integration/workarea/storefront/flow_webhook_rack_attack_integration_test.rb +54 -0
- data/test/integration/workarea/storefront/search_integration_test.decorator +51 -0
- data/test/javascripts/flow_spec.js +39 -0
- data/test/javascripts/spec_helper.js +3 -0
- data/test/models/workarea/address_test.decorator +20 -0
- data/test/models/workarea/checkout_test.decorator +20 -0
- data/test/models/workarea/flow_io/imported_item_test.rb +50 -0
- data/test/models/workarea/fulfillment_test.decorator +12 -0
- data/test/models/workarea/oms_fulfillment_test.decorator +14 -0
- data/test/models/workarea/order/item_test.decorator +46 -0
- data/test/models/workarea/order_test.decorator +16 -0
- data/test/models/workarea/payment/flow_payment_integration_test.rb +163 -0
- data/test/models/workarea/price_adjustment_set_flow_test.rb +8 -0
- data/test/models/workarea/pricing/calculators/flow_localization_calculator_test.rb +152 -0
- data/test/models/workarea/pricing/calculators/item_calculator_test.decorator +59 -0
- data/test/models/workarea/pricing/collection_test.decorator +140 -0
- data/test/models/workarea/pricing/order_totals_test.rb +247 -0
- data/test/models/workarea/pricing/price_distributor_test.decorator +21 -0
- data/test/models/workarea/pricing/sku_test.decorator +113 -0
- data/test/models/workarea/shipping_test.decorator +70 -0
- data/test/queries/workarea/flow_order_metrics_test.rb +104 -0
- data/test/services/workarea/commit_shipments_test.decorator +14 -0
- data/test/services/workarea/flow_io/checkout_test.rb +43 -0
- data/test/services/workarea/flow_io/detailed_shipping_notification_form_test.rb +145 -0
- data/test/services/workarea/flow_io/experiences_test.rb +14 -0
- data/test/services/workarea/flow_io/fulfillment_cancellation_form_test.rb +46 -0
- data/test/services/workarea/flow_io/item_importer_test.rb +357 -0
- data/test/services/workarea/flow_io/item_test.rb +72 -0
- data/test/services/workarea/flow_io/line_item_form_test.rb +34 -0
- data/test/services/workarea/flow_io/order_put_form_test.rb +48 -0
- data/test/services/workarea/flow_io/price_applier_test.rb +916 -0
- data/test/support/flow_fixtures.rb +1362 -0
- data/test/support/webhook_integration_test.rb +43 -0
- data/test/support/workarea/flow_bogus_client_support.rb +18 -0
- data/test/support/workarea/flow_io_vcr_config.rb +22 -0
- data/test/system/workarea/admin/search_fulfillment_system_test.decorator +25 -0
- data/test/system/workarea/storefront/analytics_system_test.decorator +28 -0
- data/test/system/workarea/storefront/flow_cart_recommendations_system_test.rb +70 -0
- data/test/system/workarea/storefront/users_flow_orders_system_test.rb +25 -0
- data/test/teaspoon_env.rb +6 -0
- data/test/test_helper.rb +27 -0
- data/test/vcr_cassettes/payment/flow/auth_capture.yml +188 -0
- data/test/vcr_cassettes/payment/flow/auth_capture_refund.yml +249 -0
- data/test/vcr_cassettes/payment/flow/auth_void.yml +188 -0
- data/test/vcr_cassettes/payment/flow/purchase_refund.yml +249 -0
- data/test/vcr_cassettes/payment/flow/store_auth.yml +127 -0
- data/test/vcr_cassettes/payment/flow/store_purchase.yml +188 -0
- data/test/view_models/workarea/storefront/cart_view_model_test.decorator +19 -0
- data/test/view_models/workarea/storefront/order_item_view_model_test.decorator +24 -0
- data/test/view_models/workarea/storefront/order_view_model_test.decorator +41 -0
- data/test/view_models/workarea/storefront/package_view_model_test.decorator +11 -0
- data/test/workers/workarea/flow_io/delete_items_test.rb +37 -0
- data/test/workers/workarea/flow_io/fetch_import_test.rb +41 -0
- data/test/workers/workarea/flow_io/item_exporter_test.rb +47 -0
- data/test/workers/workarea/flow_io/process_import_test.rb +25 -0
- data/workarea-flow_io.gemspec +20 -0
- metadata +375 -0
@@ -0,0 +1,750 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Storefront
|
5
|
+
module FlowIoWebHooks
|
6
|
+
class OrderIntegrationTest < Workarea::IntegrationTest
|
7
|
+
include Workarea::FlowIo::WebhookIntegrationTest
|
8
|
+
include Workarea::FlowIo::FlowFixtures
|
9
|
+
|
10
|
+
setup :setup_shared_secret
|
11
|
+
|
12
|
+
def test_order_update
|
13
|
+
product = create_product(variants: [{ sku: '386555310-9', regular: 5.00 }])
|
14
|
+
product_2 = create_product(variants: [{ sku: '332477498-5', regular: 5.00 }])
|
15
|
+
|
16
|
+
_shipping_service = create_shipping_service
|
17
|
+
|
18
|
+
order = create_order(id: '6F3A2186EB', experience: canada_experience)
|
19
|
+
|
20
|
+
order.add_item(product_id: product.id, sku: '386555310-9', quantity: 1)
|
21
|
+
order.add_item(product_id: product_2.id, sku: '332477498-5', quantity: 1)
|
22
|
+
|
23
|
+
post_signed storefront.flow_io_webhook_path, params: order_upserted
|
24
|
+
shipping = Workarea::Shipping.find_or_create_by(order_id: order.id)
|
25
|
+
|
26
|
+
assert(response.ok?)
|
27
|
+
assert_equal({ "status" => 200 }, JSON.parse(response.body))
|
28
|
+
assert_equal(200, response.status)
|
29
|
+
|
30
|
+
order.reload
|
31
|
+
assert_equal("flow-test@weblinc.com", order.email)
|
32
|
+
assert_equal(171.55.to_m, order.total_price)
|
33
|
+
|
34
|
+
assert_equal(Money.from_amount(180.00, "CAD"), order.flow_total_value)
|
35
|
+
assert_equal(Money.from_amount(232.31, "CAD"), order.flow_total_price)
|
36
|
+
assert_equal(Money.from_amount(9.29, "CAD"), order.flow_shipping_total)
|
37
|
+
assert_equal(Money.from_amount(43.02, "CAD"), order.flow_tax_total)
|
38
|
+
|
39
|
+
assert(order.placed?)
|
40
|
+
|
41
|
+
payment = Payment.find(order.id)
|
42
|
+
|
43
|
+
assert(payment.address.valid?)
|
44
|
+
assert_equal(1, payment.tenders.size)
|
45
|
+
assert_equal(1, payment.tenders.first.transactions.size)
|
46
|
+
|
47
|
+
tender = payment.tenders.first
|
48
|
+
assert_equal(171.55.to_m, tender.amount)
|
49
|
+
|
50
|
+
shipping.reload
|
51
|
+
assert(shipping.address.valid?)
|
52
|
+
|
53
|
+
assert_equal(3, shipping.price_adjustments.size)
|
54
|
+
assert_equal(3, shipping.flow_price_adjustments.size)
|
55
|
+
assert_equal(6.86.to_m, shipping.shipping_total)
|
56
|
+
assert_equal("paid", shipping.delivery_duty)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_order_update_no_billing_address
|
60
|
+
product = create_product(variants: [{ sku: '386555310-9', regular: 5.00 }])
|
61
|
+
product_2 = create_product(variants: [{ sku: '332477498-5', regular: 5.00 }])
|
62
|
+
|
63
|
+
_shipping_service = create_shipping_service
|
64
|
+
|
65
|
+
order = create_order(id: '6F3A2186EB', experience: canada_experience)
|
66
|
+
|
67
|
+
order.add_item(product_id: product.id, sku: '386555310-9', quantity: 1)
|
68
|
+
order.add_item(product_id: product_2.id, sku: '332477498-5', quantity: 1)
|
69
|
+
|
70
|
+
shipping = Workarea::Shipping.find_or_create_by(order_id: order.id)
|
71
|
+
|
72
|
+
Workarea::Pricing.perform(order, shipping)
|
73
|
+
|
74
|
+
params = canadian_webhook_payload
|
75
|
+
params[:order][:payments].first.delete(:address)
|
76
|
+
|
77
|
+
post_signed storefront.flow_io_webhook_path, params: params.to_json
|
78
|
+
|
79
|
+
order.reload
|
80
|
+
payment = Payment.find(order.id)
|
81
|
+
|
82
|
+
assert(payment.address.valid?)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_order_update_with_discounts
|
86
|
+
create_canadian_cart_with_order_discount
|
87
|
+
|
88
|
+
post_signed storefront.flow_io_webhook_path, params: canadian_discount_webhook_payload.to_json
|
89
|
+
|
90
|
+
assert response.ok?
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_order_not_found
|
94
|
+
post_signed storefront.flow_io_webhook_path, params: invalid_order_params
|
95
|
+
refute(response.ok?)
|
96
|
+
|
97
|
+
message = JSON.parse(response.body)
|
98
|
+
assert_equal(
|
99
|
+
"Document(s) not found for class Workarea::Order with id(s) 95F11ED6B6.",
|
100
|
+
message["problem"]
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_order_placed_in_different_currency
|
105
|
+
order = create_order(id: '6F3A2186EB', experience: canada_experience)
|
106
|
+
_cart = create_cart(order: order)
|
107
|
+
|
108
|
+
post_signed storefront.flow_io_webhook_path, params: euro_order_placed_payload(order: order)
|
109
|
+
|
110
|
+
order.reload
|
111
|
+
|
112
|
+
assert_equal 'EUR', order.currency
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
def invalid_order_params
|
118
|
+
{
|
119
|
+
"event_id": "evt-1fd430fd2d8e4add80073232261ddf40",
|
120
|
+
"timestamp": "2018-08-21T14:09:22.386Z",
|
121
|
+
"organization": "workarea-sandbox",
|
122
|
+
"order": {
|
123
|
+
"id": "ord-aa4c6f6d45e84bca9e3e35496306407e",
|
124
|
+
"number": "ord-aa4c6f6d45e84bca9e3e35496306407e",
|
125
|
+
"customer": {
|
126
|
+
"name": {
|
127
|
+
"first": "Eric",
|
128
|
+
"last": "Pigeon"
|
129
|
+
},
|
130
|
+
"phone": "4847447524",
|
131
|
+
"email": "epigeon@weblinc.com",
|
132
|
+
"address": {
|
133
|
+
"name": {
|
134
|
+
"first": "Eric",
|
135
|
+
"last": "Pigeon"
|
136
|
+
},
|
137
|
+
"streets": [
|
138
|
+
"22 S 2rd st"
|
139
|
+
],
|
140
|
+
"city": "Philadelphia",
|
141
|
+
"postal": "19104",
|
142
|
+
"country": "BEL"
|
143
|
+
}
|
144
|
+
},
|
145
|
+
"delivered_duty": "paid",
|
146
|
+
"destination": {
|
147
|
+
"streets": [
|
148
|
+
"22 S 2rd st"
|
149
|
+
],
|
150
|
+
"city": "Philadelphia",
|
151
|
+
"postal": "19104",
|
152
|
+
"country": "BEL",
|
153
|
+
"contact": {
|
154
|
+
"name": {
|
155
|
+
"first": "Eric",
|
156
|
+
"last": "Pigeon"
|
157
|
+
},
|
158
|
+
"email": "epigeon@weblinc.com",
|
159
|
+
"phone": "4847447524"
|
160
|
+
}
|
161
|
+
},
|
162
|
+
"expires_at": "2018-08-21T15:09:20.858Z",
|
163
|
+
"items": [
|
164
|
+
{
|
165
|
+
"number": "103832230-8",
|
166
|
+
"name": "Incredible Steel Clock",
|
167
|
+
"quantity": 2,
|
168
|
+
"local": {
|
169
|
+
"experience": {
|
170
|
+
"id": "exp-72464b1f651d49fe8108dcabf4678942",
|
171
|
+
"key": "europe",
|
172
|
+
"name": "Europe"
|
173
|
+
},
|
174
|
+
"prices": [
|
175
|
+
{
|
176
|
+
"currency": "EUR",
|
177
|
+
"amount": 98.95,
|
178
|
+
"label": "98,95 €",
|
179
|
+
"base": {
|
180
|
+
"amount": 109.3,
|
181
|
+
"currency": "USD",
|
182
|
+
"label": "US$109.30"
|
183
|
+
},
|
184
|
+
"includes": {
|
185
|
+
"key": "vat",
|
186
|
+
"label": "Includes VAT"
|
187
|
+
},
|
188
|
+
"key": "localized_item_price"
|
189
|
+
}
|
190
|
+
],
|
191
|
+
"rates": [],
|
192
|
+
"spot_rates": [],
|
193
|
+
"status": "included",
|
194
|
+
"attributes": {
|
195
|
+
"msrp": "109.95",
|
196
|
+
"regular_price": "98.95",
|
197
|
+
"Material": "Concrete",
|
198
|
+
"sale_price": "97.95",
|
199
|
+
"product_id": "C18998E465",
|
200
|
+
"Color": "orange",
|
201
|
+
"fulfillment_method": "physical"
|
202
|
+
},
|
203
|
+
"price_attributes": {
|
204
|
+
"msrp": {
|
205
|
+
"currency": "EUR",
|
206
|
+
"amount": 109.95,
|
207
|
+
"label": "109,95 €",
|
208
|
+
"base": {
|
209
|
+
"amount": 121.45,
|
210
|
+
"currency": "USD",
|
211
|
+
"label": "US$121.45"
|
212
|
+
}
|
213
|
+
},
|
214
|
+
"regular_price": {
|
215
|
+
"currency": "EUR",
|
216
|
+
"amount": 98.95,
|
217
|
+
"label": "98,95 €",
|
218
|
+
"base": {
|
219
|
+
"amount": 109.3,
|
220
|
+
"currency": "USD",
|
221
|
+
"label": "US$109.30"
|
222
|
+
}
|
223
|
+
},
|
224
|
+
"sale_price": {
|
225
|
+
"currency": "EUR",
|
226
|
+
"amount": 97.95,
|
227
|
+
"label": "97,95 €",
|
228
|
+
"base": {
|
229
|
+
"amount": 108.19,
|
230
|
+
"currency": "USD",
|
231
|
+
"label": "US$108.19"
|
232
|
+
}
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
}
|
237
|
+
],
|
238
|
+
"deliveries": [
|
239
|
+
{
|
240
|
+
"id": "del-610c437776054bf98eecf9a20991846a",
|
241
|
+
"items": [
|
242
|
+
{
|
243
|
+
"number": "103832230-8",
|
244
|
+
"quantity": 2,
|
245
|
+
"price": {
|
246
|
+
"currency": "EUR",
|
247
|
+
"amount": 98.95,
|
248
|
+
"base": {
|
249
|
+
"amount": 109.3,
|
250
|
+
"currency": "USD"
|
251
|
+
}
|
252
|
+
},
|
253
|
+
"attributes": {
|
254
|
+
"base_amount": "109.3",
|
255
|
+
"base_currency": "USD"
|
256
|
+
}
|
257
|
+
}
|
258
|
+
],
|
259
|
+
"options": [
|
260
|
+
{
|
261
|
+
"id": "opt-146ee0350247406a99bd56c0f508adf8",
|
262
|
+
"cost": {
|
263
|
+
"currency": "EUR",
|
264
|
+
"amount": 7.06,
|
265
|
+
"label": "7,06 €",
|
266
|
+
"base": {
|
267
|
+
"amount": 7.8,
|
268
|
+
"currency": "USD",
|
269
|
+
"label": "US$7.80"
|
270
|
+
}
|
271
|
+
},
|
272
|
+
"delivered_duty": "unpaid",
|
273
|
+
"price": {
|
274
|
+
"currency": "EUR",
|
275
|
+
"amount": 10,
|
276
|
+
"label": "10,00 €",
|
277
|
+
"base": {
|
278
|
+
"amount": 10.52,
|
279
|
+
"currency": "USD",
|
280
|
+
"label": "US$10.52"
|
281
|
+
}
|
282
|
+
},
|
283
|
+
"service": {
|
284
|
+
"id": "landmark-global",
|
285
|
+
"carrier": {
|
286
|
+
"id": "landmark"
|
287
|
+
},
|
288
|
+
"name": "Global"
|
289
|
+
},
|
290
|
+
"tier": {
|
291
|
+
"id": "tie-6b992ea6b5c448b1bd033332fdd9dd45",
|
292
|
+
"integration": "information",
|
293
|
+
"name": "Standard Shipping",
|
294
|
+
"services": [
|
295
|
+
"landmark-global"
|
296
|
+
],
|
297
|
+
"strategy": "lowest_cost",
|
298
|
+
"visibility": "public",
|
299
|
+
"currency": "EUR",
|
300
|
+
"display": {
|
301
|
+
"estimate": {
|
302
|
+
"type": "calculated",
|
303
|
+
"label": "4 Business Days"
|
304
|
+
}
|
305
|
+
}
|
306
|
+
},
|
307
|
+
"window": {
|
308
|
+
"from": "2018-08-27T00:00:00.000Z",
|
309
|
+
"to": "2018-08-27T00:00:00.000Z",
|
310
|
+
"timezone": "UTC",
|
311
|
+
"label": "4 Business Days"
|
312
|
+
},
|
313
|
+
"cost_details": [
|
314
|
+
{
|
315
|
+
"source": "ratecard",
|
316
|
+
"currency": "EUR",
|
317
|
+
"amount": 7.06,
|
318
|
+
"label": "7,06 €",
|
319
|
+
"components": [
|
320
|
+
{
|
321
|
+
"key": "ratecard_base_cost",
|
322
|
+
"currency": "EUR",
|
323
|
+
"amount": 7.06,
|
324
|
+
"label": "7,06 €",
|
325
|
+
"base": {
|
326
|
+
"amount": 7.8,
|
327
|
+
"currency": "USD",
|
328
|
+
"label": "US$7.80"
|
329
|
+
}
|
330
|
+
}
|
331
|
+
],
|
332
|
+
"base": {
|
333
|
+
"amount": 7.8,
|
334
|
+
"currency": "USD",
|
335
|
+
"label": "US$7.80"
|
336
|
+
}
|
337
|
+
}
|
338
|
+
],
|
339
|
+
"rule_outcome": {
|
340
|
+
"price": {
|
341
|
+
"amount": 10,
|
342
|
+
"currency": "EUR",
|
343
|
+
"label": "10,00 €"
|
344
|
+
},
|
345
|
+
"discriminator": "flat_rate"
|
346
|
+
},
|
347
|
+
"weight": {
|
348
|
+
"gravitational": {
|
349
|
+
"value": "2",
|
350
|
+
"units": "pound"
|
351
|
+
},
|
352
|
+
"dimensional": {
|
353
|
+
"value": "2.12",
|
354
|
+
"units": "inch"
|
355
|
+
}
|
356
|
+
}
|
357
|
+
},
|
358
|
+
{
|
359
|
+
"id": "opt-5b7ce144d8374dd5864e410747dcd0c3",
|
360
|
+
"cost": {
|
361
|
+
"currency": "EUR",
|
362
|
+
"amount": 7.06,
|
363
|
+
"label": "7,06 €",
|
364
|
+
"base": {
|
365
|
+
"amount": 7.8,
|
366
|
+
"currency": "USD",
|
367
|
+
"label": "US$7.80"
|
368
|
+
}
|
369
|
+
},
|
370
|
+
"delivered_duty": "paid",
|
371
|
+
"price": {
|
372
|
+
"currency": "EUR",
|
373
|
+
"amount": 10,
|
374
|
+
"label": "10,00 €",
|
375
|
+
"base": {
|
376
|
+
"amount": 10.52,
|
377
|
+
"currency": "USD",
|
378
|
+
"label": "US$10.52"
|
379
|
+
}
|
380
|
+
},
|
381
|
+
"service": {
|
382
|
+
"id": "landmark-global",
|
383
|
+
"carrier": {
|
384
|
+
"id": "landmark"
|
385
|
+
},
|
386
|
+
"name": "Global"
|
387
|
+
},
|
388
|
+
"tier": {
|
389
|
+
"id": "tie-6b992ea6b5c448b1bd033332fdd9dd45",
|
390
|
+
"integration": "information",
|
391
|
+
"name": "Standard Shipping",
|
392
|
+
"services": [
|
393
|
+
"landmark-global"
|
394
|
+
],
|
395
|
+
"strategy": "lowest_cost",
|
396
|
+
"visibility": "public",
|
397
|
+
"currency": "EUR",
|
398
|
+
"display": {
|
399
|
+
"estimate": {
|
400
|
+
"type": "calculated",
|
401
|
+
"label": "4 Business Days"
|
402
|
+
}
|
403
|
+
}
|
404
|
+
},
|
405
|
+
"window": {
|
406
|
+
"from": "2018-08-27T00:00:00.000Z",
|
407
|
+
"to": "2018-08-27T00:00:00.000Z",
|
408
|
+
"timezone": "UTC",
|
409
|
+
"label": "4 Business Days"
|
410
|
+
},
|
411
|
+
"cost_details": [
|
412
|
+
{
|
413
|
+
"source": "ratecard",
|
414
|
+
"currency": "EUR",
|
415
|
+
"amount": 7.06,
|
416
|
+
"label": "7,06 €",
|
417
|
+
"components": [
|
418
|
+
{
|
419
|
+
"key": "ratecard_base_cost",
|
420
|
+
"currency": "EUR",
|
421
|
+
"amount": 7.06,
|
422
|
+
"label": "7,06 €",
|
423
|
+
"base": {
|
424
|
+
"amount": 7.8,
|
425
|
+
"currency": "USD",
|
426
|
+
"label": "US$7.80"
|
427
|
+
}
|
428
|
+
}
|
429
|
+
],
|
430
|
+
"base": {
|
431
|
+
"amount": 7.8,
|
432
|
+
"currency": "USD",
|
433
|
+
"label": "US$7.80"
|
434
|
+
}
|
435
|
+
}
|
436
|
+
],
|
437
|
+
"rule_outcome": {
|
438
|
+
"price": {
|
439
|
+
"amount": 10,
|
440
|
+
"currency": "EUR",
|
441
|
+
"label": "10,00 €"
|
442
|
+
},
|
443
|
+
"discriminator": "flat_rate"
|
444
|
+
},
|
445
|
+
"weight": {
|
446
|
+
"gravitational": {
|
447
|
+
"value": "2",
|
448
|
+
"units": "pound"
|
449
|
+
},
|
450
|
+
"dimensional": {
|
451
|
+
"value": "2.12",
|
452
|
+
"units": "inch"
|
453
|
+
}
|
454
|
+
}
|
455
|
+
}
|
456
|
+
],
|
457
|
+
"center": {
|
458
|
+
"id": "cen-394b1db3c61a495c964dd1fe60969160",
|
459
|
+
"key": "center-workarea"
|
460
|
+
},
|
461
|
+
"discriminator": "physical_delivery"
|
462
|
+
}
|
463
|
+
],
|
464
|
+
"selections": [
|
465
|
+
"opt-5b7ce144d8374dd5864e410747dcd0c3"
|
466
|
+
],
|
467
|
+
"prices": [
|
468
|
+
{
|
469
|
+
"key": "subtotal",
|
470
|
+
"currency": "EUR",
|
471
|
+
"amount": 197.9,
|
472
|
+
"label": "197,90 €",
|
473
|
+
"base": {
|
474
|
+
"amount": 218.6,
|
475
|
+
"currency": "USD",
|
476
|
+
"label": "US$218.60"
|
477
|
+
},
|
478
|
+
"components": [
|
479
|
+
{
|
480
|
+
"key": "vat_item_price",
|
481
|
+
"currency": "EUR",
|
482
|
+
"amount": 34.34,
|
483
|
+
"label": "34,34 €",
|
484
|
+
"base": {
|
485
|
+
"amount": 37.92,
|
486
|
+
"currency": "USD",
|
487
|
+
"label": "US$37.92"
|
488
|
+
},
|
489
|
+
"name": "VAT on item price"
|
490
|
+
},
|
491
|
+
{
|
492
|
+
"key": "vat_duties_item_price",
|
493
|
+
"currency": "EUR",
|
494
|
+
"amount": 4.1,
|
495
|
+
"label": "4,10 €",
|
496
|
+
"base": {
|
497
|
+
"amount": 4.52,
|
498
|
+
"currency": "USD",
|
499
|
+
"label": "US$4.52"
|
500
|
+
},
|
501
|
+
"name": "VAT on duties on item price"
|
502
|
+
},
|
503
|
+
{
|
504
|
+
"key": "item_price",
|
505
|
+
"currency": "EUR",
|
506
|
+
"amount": 162.48,
|
507
|
+
"label": "162,48 €",
|
508
|
+
"base": {
|
509
|
+
"amount": 179.48,
|
510
|
+
"currency": "USD",
|
511
|
+
"label": "US$179.48"
|
512
|
+
},
|
513
|
+
"name": "Item price"
|
514
|
+
},
|
515
|
+
{
|
516
|
+
"key": "rounding",
|
517
|
+
"currency": "EUR",
|
518
|
+
"amount": 1.08,
|
519
|
+
"label": "1,08 €",
|
520
|
+
"base": {
|
521
|
+
"amount": 1.2,
|
522
|
+
"currency": "USD",
|
523
|
+
"label": "US$1.20"
|
524
|
+
},
|
525
|
+
"name": "Rounding"
|
526
|
+
},
|
527
|
+
{
|
528
|
+
"key": "vat_subsidy",
|
529
|
+
"currency": "EUR",
|
530
|
+
"amount": -4.1,
|
531
|
+
"label": "-4,10 €",
|
532
|
+
"base": {
|
533
|
+
"amount": -4.52,
|
534
|
+
"currency": "USD",
|
535
|
+
"label": "-US$4.52"
|
536
|
+
},
|
537
|
+
"name": "VAT subsidy"
|
538
|
+
}
|
539
|
+
],
|
540
|
+
"name": "Item subtotal"
|
541
|
+
},
|
542
|
+
{
|
543
|
+
"key": "duty",
|
544
|
+
"currency": "EUR",
|
545
|
+
"amount": 20.33,
|
546
|
+
"label": "20,33 €",
|
547
|
+
"base": {
|
548
|
+
"amount": 22.46,
|
549
|
+
"currency": "USD",
|
550
|
+
"label": "US$22.46"
|
551
|
+
},
|
552
|
+
"components": [
|
553
|
+
{
|
554
|
+
"key": "duties_item_price",
|
555
|
+
"currency": "EUR",
|
556
|
+
"amount": 19.48,
|
557
|
+
"label": "19,48 €",
|
558
|
+
"base": {
|
559
|
+
"amount": 21.52,
|
560
|
+
"currency": "USD",
|
561
|
+
"label": "US$21.52"
|
562
|
+
},
|
563
|
+
"name": "Duties on item price"
|
564
|
+
},
|
565
|
+
{
|
566
|
+
"key": "duties_freight",
|
567
|
+
"currency": "EUR",
|
568
|
+
"amount": 0.85,
|
569
|
+
"label": "0,85 €",
|
570
|
+
"base": {
|
571
|
+
"amount": 0.94,
|
572
|
+
"currency": "USD",
|
573
|
+
"label": "US$0.94"
|
574
|
+
},
|
575
|
+
"name": "Duties on freight"
|
576
|
+
}
|
577
|
+
],
|
578
|
+
"name": "Duties"
|
579
|
+
},
|
580
|
+
{
|
581
|
+
"key": "shipping",
|
582
|
+
"currency": "EUR",
|
583
|
+
"amount": 10,
|
584
|
+
"label": "10,00 €",
|
585
|
+
"base": {
|
586
|
+
"amount": 10.52,
|
587
|
+
"currency": "USD",
|
588
|
+
"label": "US$10.52"
|
589
|
+
},
|
590
|
+
"components": [
|
591
|
+
{
|
592
|
+
"key": "vat_freight",
|
593
|
+
"currency": "EUR",
|
594
|
+
"amount": 1.48,
|
595
|
+
"label": "1,48 €",
|
596
|
+
"base": {
|
597
|
+
"amount": 1.64,
|
598
|
+
"currency": "USD",
|
599
|
+
"label": "US$1.64"
|
600
|
+
},
|
601
|
+
"name": "VAT on freight"
|
602
|
+
},
|
603
|
+
{
|
604
|
+
"key": "vat_duties_freight",
|
605
|
+
"currency": "EUR",
|
606
|
+
"amount": 0.18,
|
607
|
+
"label": "0,18 €",
|
608
|
+
"base": {
|
609
|
+
"amount": 0.2,
|
610
|
+
"currency": "USD",
|
611
|
+
"label": "US$0.20"
|
612
|
+
},
|
613
|
+
"name": "VAT on duties on freight"
|
614
|
+
},
|
615
|
+
{
|
616
|
+
"key": "shipping",
|
617
|
+
"currency": "EUR",
|
618
|
+
"amount": 10,
|
619
|
+
"label": "10,00 €",
|
620
|
+
"base": {
|
621
|
+
"amount": 10.52,
|
622
|
+
"currency": "USD",
|
623
|
+
"label": "US$10.52"
|
624
|
+
},
|
625
|
+
"name": "Shipping"
|
626
|
+
},
|
627
|
+
{
|
628
|
+
"key": "vat_subsidy",
|
629
|
+
"currency": "EUR",
|
630
|
+
"amount": -1.66,
|
631
|
+
"label": "-1,66 €",
|
632
|
+
"base": {
|
633
|
+
"amount": -1.84,
|
634
|
+
"currency": "USD",
|
635
|
+
"label": "-US$1.84"
|
636
|
+
},
|
637
|
+
"name": "VAT subsidy"
|
638
|
+
}
|
639
|
+
],
|
640
|
+
"name": "Shipping"
|
641
|
+
}
|
642
|
+
],
|
643
|
+
"total": {
|
644
|
+
"currency": "EUR",
|
645
|
+
"amount": 228.23,
|
646
|
+
"label": "228,23 €",
|
647
|
+
"base": {
|
648
|
+
"amount": 251.58,
|
649
|
+
"currency": "USD",
|
650
|
+
"label": "US$251.58"
|
651
|
+
}
|
652
|
+
},
|
653
|
+
"attributes": {
|
654
|
+
"number": "95F11ED6B6"
|
655
|
+
},
|
656
|
+
"merchant_of_record": "flow",
|
657
|
+
"experience": {
|
658
|
+
"key": "europe",
|
659
|
+
"discriminator": "experience_reference"
|
660
|
+
},
|
661
|
+
"submitted_at": "2018-08-21T14:09:22.137Z",
|
662
|
+
"lines": [
|
663
|
+
{
|
664
|
+
"item_number": "103832230-8",
|
665
|
+
"quantity": 2,
|
666
|
+
"price": {
|
667
|
+
"currency": "EUR",
|
668
|
+
"amount": 98.95,
|
669
|
+
"label": "98,95 €",
|
670
|
+
"base": {
|
671
|
+
"amount": 109.3,
|
672
|
+
"currency": "USD",
|
673
|
+
"label": "US$109.30"
|
674
|
+
}
|
675
|
+
},
|
676
|
+
"total": {
|
677
|
+
"currency": "EUR",
|
678
|
+
"amount": 197.9,
|
679
|
+
"label": "197,90 €",
|
680
|
+
"base": {
|
681
|
+
"amount": 218.6,
|
682
|
+
"currency": "USD",
|
683
|
+
"label": "US$218.60"
|
684
|
+
}
|
685
|
+
}
|
686
|
+
}
|
687
|
+
],
|
688
|
+
"promotions": {
|
689
|
+
"applied": [],
|
690
|
+
"available": []
|
691
|
+
},
|
692
|
+
"payments": [
|
693
|
+
{
|
694
|
+
"id": "opm-6896b7bcf0da431e83f06f6518bac10d",
|
695
|
+
"type": "card",
|
696
|
+
"merchant_of_record": "flow",
|
697
|
+
"reference": "aut-TDAxTeCVtkUwFp2EkGi2l4HrjDjGNqVj",
|
698
|
+
"description": "VISA ending with 1111",
|
699
|
+
"total": {
|
700
|
+
"currency": "EUR",
|
701
|
+
"amount": 228.23,
|
702
|
+
"label": "228,23 €",
|
703
|
+
"base": {
|
704
|
+
"amount": 251.58,
|
705
|
+
"currency": "USD",
|
706
|
+
"label": "US$251.58"
|
707
|
+
}
|
708
|
+
},
|
709
|
+
"attributes": {},
|
710
|
+
"address": {
|
711
|
+
"name": {
|
712
|
+
"first": "Eric",
|
713
|
+
"last": "Pigeon"
|
714
|
+
},
|
715
|
+
"streets": [
|
716
|
+
"22 S 2rd st"
|
717
|
+
],
|
718
|
+
"city": "Philadelphia",
|
719
|
+
"postal": "19104",
|
720
|
+
"country": "BEL"
|
721
|
+
},
|
722
|
+
"date": "2018-08-21T14:09:21.709Z"
|
723
|
+
}
|
724
|
+
],
|
725
|
+
"balance": {
|
726
|
+
"currency": "EUR",
|
727
|
+
"amount": 0,
|
728
|
+
"label": "0,00 €",
|
729
|
+
"base": {
|
730
|
+
"amount": 0,
|
731
|
+
"currency": "USD",
|
732
|
+
"label": "US$0.00"
|
733
|
+
}
|
734
|
+
}
|
735
|
+
},
|
736
|
+
"discriminator": "order_upserted_v2"
|
737
|
+
}.to_json
|
738
|
+
end
|
739
|
+
|
740
|
+
def order_upserted
|
741
|
+
canadian_webhook_payload.to_json
|
742
|
+
end
|
743
|
+
|
744
|
+
def setup_shared_secret
|
745
|
+
FlowIo::Webhook::SharedSecret.first_or_create!
|
746
|
+
end
|
747
|
+
end
|
748
|
+
end
|
749
|
+
end
|
750
|
+
end
|