flowcommerce_spree 0.0.1 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +101 -24
  3. data/SPREE_FLOW.md +6 -28
  4. data/app/controllers/concerns/current_zone_loader_decorator.rb +40 -25
  5. data/app/controllers/flowcommerce_spree/inventory_controller.rb +23 -0
  6. data/app/controllers/flowcommerce_spree/orders_controller.rb +20 -0
  7. data/app/controllers/flowcommerce_spree/webhooks_controller.rb +23 -13
  8. data/app/controllers/users/sessions_controller_decorator.rb +28 -0
  9. data/app/helpers/spree/core/controller_helpers/flow_io_order_helper_decorator.rb +4 -9
  10. data/app/models/spree/address_decorator.rb +19 -0
  11. data/app/models/spree/app_configuration_decorator.rb +7 -0
  12. data/app/models/spree/calculator/flow_io.rb +61 -0
  13. data/app/models/spree/calculator/shipping/flow_io.rb +40 -0
  14. data/app/models/spree/flow_io_credit_card_decorator.rb +21 -0
  15. data/app/models/spree/flow_io_order_decorator.rb +163 -0
  16. data/app/models/spree/flow_io_product_decorator.rb +2 -2
  17. data/app/models/spree/flow_io_variant_decorator.rb +4 -2
  18. data/app/models/spree/gateway/flow_io.rb +153 -0
  19. data/app/models/spree/{credit_card_decorator.rb → payment_capture_event_decorator.rb} +1 -1
  20. data/app/models/spree/promotion_handler/coupon_decorator.rb +1 -1
  21. data/app/models/spree/zones/flow_io_product_zone_decorator.rb +8 -0
  22. data/app/models/tracking/setup_decorator.rb +40 -0
  23. data/app/overrides/spree/admin/order_sidebar_summary_flow_link.rb +13 -0
  24. data/app/overrides/spree/admin/products/order_price_flow_message.rb +9 -0
  25. data/app/serializers/api/v2/order_serializer_decorator.rb +20 -0
  26. data/app/services/flowcommerce_spree/import_experience_items.rb +1 -1
  27. data/app/services/flowcommerce_spree/order_sync.rb +81 -173
  28. data/app/services/flowcommerce_spree/order_updater.rb +78 -0
  29. data/app/services/flowcommerce_spree/webhooks/capture_upserted_v2.rb +76 -0
  30. data/app/services/flowcommerce_spree/webhooks/card_authorization_upserted_v2.rb +66 -0
  31. data/app/services/flowcommerce_spree/webhooks/experience_upserted_v2.rb +25 -0
  32. data/app/services/flowcommerce_spree/webhooks/fraud_status_changed.rb +35 -0
  33. data/app/services/flowcommerce_spree/webhooks/local_item_upserted.rb +40 -0
  34. data/app/views/spree/admin/payments/source_views/_flow_io_gateway.html.erb +21 -0
  35. data/config/rails_best_practices.yml +51 -0
  36. data/config/routes.rb +3 -1
  37. data/db/migrate/20201021755957_add_meta_to_spree_tables.rb +6 -4
  38. data/lib/flow/simple_gateway.rb +0 -36
  39. data/lib/flowcommerce_spree.rb +17 -3
  40. data/lib/flowcommerce_spree/engine.rb +33 -3
  41. data/lib/flowcommerce_spree/experience_service.rb +1 -27
  42. data/lib/flowcommerce_spree/logging_http_client.rb +33 -15
  43. data/lib/flowcommerce_spree/session.rb +16 -29
  44. data/lib/flowcommerce_spree/test_support.rb +7 -0
  45. data/lib/flowcommerce_spree/version.rb +1 -1
  46. data/lib/tasks/flowcommerce_spree.rake +4 -1
  47. metadata +90 -22
  48. data/app/mailers/spree/spree_order_mailer_decorator.rb +0 -24
  49. data/app/models/spree/gateway/spree_flow_gateway.rb +0 -116
  50. data/app/models/spree/line_item_decorator.rb +0 -15
  51. data/app/models/spree/order_decorator.rb +0 -179
  52. data/app/views/spree/order_mailer/confirm_email.html.erb +0 -86
  53. data/app/views/spree/order_mailer/confirm_email.text.erb +0 -38
  54. data/config/initializers/flowcommerce_spree.rb +0 -7
  55. data/lib/flow/error.rb +0 -73
  56. data/lib/flow/pay_pal.rb +0 -25
  57. data/lib/flowcommerce_spree/webhook_service.rb +0 -98
  58. data/lib/simple_csv_writer.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6893ddfb8f021ff6400c0bbe31fc6b2c532886892730a1c9097d172944a8eca8
4
- data.tar.gz: 9d3a1b190708053a5ad664588abe553617cf07a02ce6fb8f8b2b9d8d17b393a7
3
+ metadata.gz: ff1a7f69451b03b52d6422015450255988ac45f664a1bee62559e238e45f0a6b
4
+ data.tar.gz: d9fab8b6b5091b70235cde18b88dd0dc0988ed0d38946571236d9a828b0e6750
5
5
  SHA512:
6
- metadata.gz: 531a87c9a666b3057d16983c3e6168492ac124112a881821891e3bb2174f7e5589785301e023348f3bb06ef2ea105961f20a6a2aaa884e9845e92896973586d7
7
- data.tar.gz: c84a3cb370744c3313b04cdc513d38d70ea0aaa01e7e09470bdf768f77d41fdb0c4bb9df240bbe4fec58adc4068b96d64fa538a315d73e8a361a1f718ecc6b46
6
+ metadata.gz: 73f135866d3644fc4b9a92bc8003d88c28bdf220612e4823d2d1f04e190f3e0888f00c995e215b7efc9ebfa81bd9720b47b00e8f796bdad6b68391bb1852ec59
7
+ data.tar.gz: 8b2c6fe4c1d2987f4c467fb2f33afee8d0b4e15b7b6a12dddb44b28ab57c538e8c1dd9608604deca5170d70adfc011b0299ba00c7ba33c5b966a959878355a79
data/README.md CHANGED
@@ -11,32 +11,46 @@ All flowcommerce_spree code is located in the ./app and ./lib folders.
11
11
  gem 'flowcommerce_spree', git: 'https://github.com/mejuri-inc/flowcommerce_spree'
12
12
  ```
13
13
 
14
- - If the main application's Rails version is less than 4.2, add also to main application's Gemfile the `activerecord
15
- -postgres-json` gem (the mejuri-inc fork allows using a recent Rake version:
14
+ - If the main application's Rails version is less than 4.2, add also to main application's Gemfile the `activerecord
15
+ -postgres-json` gem (at least version 0.2.3):
16
16
 
17
17
  ```
18
- gem 'activerecord-postgres-json', git: 'https://github.com/mejuri-inc/activerecord-postgres-json'
18
+ gem 'activerecord-postgres-json', '>= 0.2.3'
19
19
  ```
20
-
21
20
 
22
21
  - Run `bundle install`.
23
22
 
24
- - Define this additional ENV variables. You will find them in
25
- [Flow console](https://console.flow.io/org_account_name/organization/integrations):
23
+ - Define these additional ENV variables.
24
+ - You will find FLOW_TOKEN, FLOW_ORGANIZATION and FLOW_BASE_COUNTRY in [Flow
25
+ console](https://console.flow.io/org_account_name/organization/integrations)
26
+ - To enable HTTP Basic authentication for securing the FlowcommerceSpree::WebhooksController, prepend
27
+ username:password@ to the hostname in your webhook URL.
28
+ By doing so, the credentials needed for authentication will be sent in the HTTP header.
29
+ For example: https://username:password@www.mywebhookurl.com
30
+ On the main app's backend side, the `username` and `password` values should be defined in the
31
+ FLOW_IO_WEBHOOK_USER and FLOW_IO_WEBHOOK_PASSWORD environment variables
26
32
 
27
33
  ```
28
34
  FLOW_TOKEN='SUPERsecretTOKEN' # API_KEY
29
35
  FLOW_ORGANIZATION='spree-app-sandbox'
30
36
  FLOW_BASE_COUNTRY='usa'
37
+ # The path to which the FlowcommerceSpree engine will be mounted (default, if this variable is missing, will be the
38
+ # '/flow' path)
39
+ FLOW_MOUNT_PATH='/flow'
40
+ # The following variables should be set for securing the FlowcommerceSpree::WebhooksControler
41
+ FLOW_IO_WEBHOOK_USER
42
+ FLOW_IO_WEBHOOK_PASSWORD
31
43
  ```
32
44
 
33
- - The only piece of code that is needed to enable payments with the FlowCommerce engine
45
+ - To enable payments with the FlowCommerce engine, the payment method `flow.io` with `Spree::Gateway::FlowIo` should be
46
+ added in the Spree Admin. This payment method is automatically registered in the gem in an after_initialize Rails
47
+ engine callback:
34
48
 
35
49
  ```
36
- # config/application.rb
50
+ # lib/flowcommerce_spree/engine.rb
37
51
  config.after_initialize do |app|
38
52
  # init Flow payments as an option
39
- app.config.spree.payment_methods << Spree::Gateway::Flow
53
+ app.config.spree.payment_methods << Spree::Gateway::FlowIo
40
54
  end
41
55
  ```
42
56
 
@@ -57,35 +71,98 @@ All flowcommerce_spree code is located in the ./app and ./lib folders.
57
71
  `serialize :flow_data, ActiveRecord::Coders::JSON.new(symbolize_keys: true)`
58
72
 
59
73
 
74
+ ## FlowcommerceSpree::Api module
60
75
 
61
- ## Flow API specific
62
-
63
- Classes that begin with Flow are responsible for communicating with flow API.
64
-
65
- ### Flow
66
-
67
- Helper class that offers low level flow api access and few helper methods.
76
+ This is a legacy module using the `curl` gem for making direct calls to flow.io API. It will be refactored out in
77
+ future versions of the gem in favor of using the official flow.io API client from the `flowcommerce` gem.
68
78
 
69
79
  ### FlowcommerceSpree::ExperienceService
70
80
 
71
81
  Responsible for selecting current experience. You have to define available experiences in flow console.
72
82
 
73
- ### Flow::Order
83
+ ### FlowcommerceSpree::OrderSync
74
84
 
75
85
  Maintain and synchronizes Spree::Order with Flow API.
76
86
 
77
- ### Flow::Session
87
+ ### FlowcommerceSpree::Session
78
88
 
79
89
  Every shop user has a session. This class helps in creating and maintaining session with Flow.
80
90
 
81
- ## Decorators
91
+ ### Decorators
92
+
93
+ Decorators are used extensively across the gem to modify or add behaviour of several Spree classes and modules. To
94
+ properly deal with the precedence in the Ruby ancestor chain, the `class_eval`, `include` and `prepend` methods are
95
+ being used, depending on the level of modification.
96
+
97
+ ### Spree::Gateway::FlowIo
98
+
99
+ Adapter for Spree, that allows using [Flow.io](https://www.flow.io) as payment gateway.
100
+ Flow is PCI compliant payment processor.
101
+
102
+
103
+ ## Gem Maintenance
104
+
105
+ ### Preparing a release
106
+
107
+ Merge all the pull requests that should make it into the new release into the `main` branch, then checkout and pull the
108
+ branch and run the `github_changelog_generator`, specifying the new version as a `--future-release` cli parameter:
109
+
110
+ ```
111
+ git checkout main
112
+ git pull
113
+
114
+ github_changelog_generator -u mejuri-inc -p flowcommerce_spree --future-release v0.0.2
115
+ ```
116
+
117
+ Then add the changes to `git`, commit and push the `Preparing the new release` commit directly into the `main` branch:
118
+
119
+ ```
120
+ git add .
121
+ git commit -m 'Preparing the new v0.0.2 release'
122
+ git push
123
+ ```
124
+
125
+ ### RubyGems credentials
126
+
127
+ Ensure you have the RubyGems credentials located in the `~/.gem/credentials` file.
128
+
129
+ ### Adding a gem owner
130
+
131
+ ```
132
+ gem owner flowcommerce_spree -a sebastian.deluca@mejuri.com
133
+ ```
134
+
135
+ ### Building a new gem version
136
+
137
+ Adjust the new gem version number in the `lib/flowcommerce_spree/version.rb` file. It is used when building the gem
138
+ by the following command:
139
+
140
+ ```
141
+ gem build flowcommerce_spree.gemspec
142
+ ```
143
+
144
+ Assuming the version was set to `0.0.1`,
145
+ a `flowcommerce_spree-0.0.1.gem` binary file will be generated at the root of the app (repo).
146
+
147
+ - The binary file shouldn't be added into the `git` tree, it will be pushed into the RubyGems and to the GitHub releases
148
+
149
+ ### Pushing a new gem release to RubyGems
82
150
 
83
- Decorators are found in ./app/flow/decorators folders and they decorate Spree models with Flow specific methods.
151
+ ```
152
+ gem push flowcommerce_spree-0.0.1.gem # don't forget to specify the correct version number
153
+ ```
84
154
 
85
- All methods are prefixed with ```flow_```.
155
+ ### Crafting the new release on GitHub
86
156
 
87
- ## Helper lib
157
+ On the [Releases page](https://github.com/mejuri-inc/flowcommerce_spree/releases) push the `Draft a new release` button.
88
158
 
89
- ### Spree::Flow::Gateway
159
+ The new release editing page opens, on which the following actions could be taken:
90
160
 
91
- Adapter for Spree, that allows using [Flow.io](https://www.flow.io) as payment gateway. Flow is PCI compliant payment processor.
161
+ - Choose the repo branch (default is `main`)
162
+ - Insert a tag version (usually, the tag should correspond to the gem's new version, v0.0.1, for example)
163
+ - the tag will be created by GitHub on the last commit into the chosen branch
164
+ - Fill the release Title and Description
165
+ - Attach the binary file with the generated gem version
166
+ - If the release is not yet ready for production, mark the `This is a pre-release` checkbox
167
+ - Press either the `Publish release`, or the `Save draft button` if you want to publish it later
168
+ - After publishing the release, the the binary gem file will be available on GitHub and could be removed locally
data/SPREE_FLOW.md CHANGED
@@ -2,40 +2,19 @@
2
2
 
3
3
  Integration of Spree with Flow, how it is done.
4
4
 
5
- I plan to be concise as possible, but cover all important topics.
5
+ ## Installation
6
6
 
7
- ## Instalation
8
-
9
- Add the following lines to `./config/application.rb` :
10
-
11
- ```
12
- config.to_prepare do
13
- # add all flow libs
14
- overload = Dir.glob('./app/flow/**/*.rb')
15
- overload.reverse.each { |c| require(c) }
16
- end
17
-
18
- config.after_initialize do |app|
19
- # init Flow payments as an option
20
- app.config.spree.payment_methods << Spree::Gateway::Flow
21
- end
22
- ```
23
-
24
- Additional configuration could be adjusted in the gem's initializer. For example, the following file could be created in the main application:
7
+ Additional configuration could be adjusted in the gem's initializer. For example, the following file could be created
8
+ in the main application, which would add additional attributes of spree_variants to be imported/exported to flow.io:
25
9
 
26
10
  ```
27
11
  # ./config/initializers/flowcommerce_spree.rb
28
12
 
29
- FlowcommerceSpree.configure do |c|
30
- c.experience_associator = FlowcommerceSpree::ExperienceAssociator
31
- end
13
+ FlowcommerceSpree::Config.additional_attributes =
14
+ { spree_variants: { country_of_origin: { import: true, export: :optional },
15
+ customs_description: { import: true, export: :optional, export_name: 'materials' } } }
32
16
  ```
33
17
 
34
- ### Configurable settings
35
-
36
- 1. experience_associator - this attribute could be assigned, if necessary, a service object to perform some
37
- additional association actions when upserting a FlowcommerceSpree::Experience model
38
-
39
18
  ## Things to take into account
40
19
 
41
20
  ActiveMerchant is not supporting sessions and orders, natively. If one wants
@@ -131,4 +110,3 @@ By default Flow Admin (on /admin/flow) is anybody that is Spree admin.
131
110
 
132
111
  This way we provide good frontend info, some integration notes in realtime as opposed to running
133
112
  rake tests to check for integrity of Flow integration.
134
-
@@ -3,29 +3,53 @@
3
3
  CurrentZoneLoader.module_eval do
4
4
  extend ActiveSupport::Concern
5
5
 
6
- def flow_zone # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
6
+ def current_zone
7
+ return @current_zone if defined?(@current_zone)
8
+
9
+ @current_zone = if (session_region_name = session['region']&.[]('name'))
10
+ Spree::Zones::Product.find_by(name: session_region_name, status: 'active')
11
+ end
12
+
13
+ @current_zone ||= if request_iso_code.present?
14
+ @current_zone = flow_zone
15
+ @current_zone ||= Spree::Country.find_by(iso: request_iso_code)&.product_zones&.active&.first
16
+ end
17
+
18
+ @current_zone ||= Spree::Zones::Product.find_by(name: 'International') ||
19
+ Spree::Zones::Product.new(name: 'International', taxon_ids: [], currencies: %w[USD CAD])
20
+
21
+ current_zone_name = @current_zone.name
22
+ session['region'] = { name: current_zone_name, available_currencies: @current_zone.available_currencies,
23
+ request_iso_code: request_iso_code }
24
+
25
+ Rails.logger.debug("Using product zone: #{current_zone_name}")
26
+ @current_zone
27
+ end
28
+
29
+ def flow_zone
7
30
  return unless Spree::Zones::Product.active
8
31
  .where("meta -> 'flow_data' ->> 'country' = ?",
9
32
  ISO3166::Country[request_iso_code]&.alpha3).exists?
10
33
 
11
- request_ip =
12
- if Rails.env.production?
13
- request.ip
14
- else
15
- Spree::Config[:debug_request_ip_address] || request.ip
16
- # Germany ip: 85.214.132.117, Sweden ip: 62.20.0.196, Moldova ip: 89.41.76.29
17
- end
18
- flow_io_session = FlowcommerceSpree::Session
19
- .new(ip: request_ip, visitor: visitor_id_for_flow_io)
20
- # :create method will issue a request to flow.io. The experience, contained in the
21
- # response, will be available in the session object - flow_io_session.experience
22
- flow_io_session.create
23
- zone = Spree::Zones::Product.active.find_by(name: flow_io_session.experience&.key&.titleize)
24
- session['_f60_session'] = flow_io_session.id if zone
34
+ request_ip = if Rails.env.production?
35
+ request.ip
36
+ else
37
+ Spree::Config[:debug_request_ip_address] || request.ip
38
+ # Germany ip: 85.214.132.117, Sweden ip: 62.20.0.196, Moldova ip: 89.41.76.29
39
+ end
40
+
41
+ # This will issue a session creation request to flow.io. The response will contain the Flow Experience key and
42
+ # the session_id
43
+ flow_io_session = FlowcommerceSpree::Session.create(ip: request_ip, visitor: visitor_id_for_flow_io)
44
+
45
+ if (zone = Spree::Zones::Product.active.find_by(name: flow_io_session.experience&.key&.titleize))
46
+ session['flow_session_id'] = flow_io_session.id
47
+ end
48
+
25
49
  zone
26
50
  end
27
51
 
28
- # composes an unique vistor id for FlowcommerceSpree::Session model
52
+ # composes an unique visitor id for FlowcommerceSpree::Session model
29
53
  def visitor_id_for_flow_io
30
54
  guest_token = cookies.signed[:guest_token]
31
55
  uid = if guest_token
@@ -37,13 +61,4 @@ CurrentZoneLoader.module_eval do
37
61
 
38
62
  "session-#{uid}"
39
63
  end
40
-
41
- def fetch_product_for_zone(product)
42
- Rails.cache.fetch(
43
- "product_zone_#{current_zone.name}_#{product.sku}", expires_in: 1.day,
44
- race_condition_ttl: 10.seconds, compress: true
45
- ) do
46
- Spree::Zones::Product.find_product_for_zone(product, current_zone)
47
- end
48
- end
49
64
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FlowcommerceSpree
4
+ class InventoryController < ActionController::Base
5
+ def online_stock_availability
6
+ items = params['items'] || []
7
+ response = items.inject([]) { |result, item| result << check_stock(item[:id], item[:qty].to_i) }
8
+ render json: { items: response }, status: :ok
9
+ end
10
+
11
+ private
12
+
13
+ def check_stock(flow_number, quantity)
14
+ variant = Spree::Variant.find_by(sku: flow_number)
15
+ return { id: flow_number, has_inventory: false } unless variant
16
+
17
+ { id: flow_number, has_inventory: variant.available_online?(quantity) }
18
+ rescue StandardError
19
+ Rails.logger.error "[!] FlowcommerceSpree::InventoryController#stock unexpected Error: #{$ERROR_INFO}"
20
+ { id: flow_number, has_inventory: false }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FlowcommerceSpree
4
+ class OrdersController < ApplicationController
5
+ wrap_parameters false
6
+
7
+ skip_before_action :setup_tracking, only: :order_completed
8
+
9
+ # proxy enpoint between flow and thankyou page.
10
+ # /flow/order_completed endpoint
11
+ def order_completed
12
+ order = Spree::Order.find_by number: params[:order], guest_token: params[:t]
13
+
14
+ flow_updater = FlowcommerceSpree::OrderUpdater.new(order: order)
15
+ flow_updater.complete_checkout
16
+
17
+ redirect_to "/thankyou?order=#{params[:order]}&t=#{params[:t]}"
18
+ end
19
+ end
20
+ end
@@ -2,24 +2,34 @@
2
2
 
3
3
  module FlowcommerceSpree
4
4
  class WebhooksController < ActionController::Base
5
+ wrap_parameters false
5
6
  respond_to :json
7
+ http_basic_authenticate_with name: FLOW_IO_WEBHOOK_USER, password: FLOW_IO_WEBHOOK_PASSWORD
6
8
 
7
- # forward all incoming requests to Flow WebhookService object
9
+ # forward incoming requests to respective Flow Webhooks Service objects
8
10
  # /flow/event-target endpoint
9
- def handle_flow_web_hook_event
10
- webhook_result = WebhookService.process(params[:webhook])
11
- result = {}
12
- result[:error] = webhook_result.full_messages.join("\n") if webhook_result.errors.any?
11
+ def handle_flow_io_event
12
+ %i[event_id organization discriminator].each_with_object(params) { |key, obj| obj.require(key) }
13
+ return unless organization_valid?
14
+
15
+ webhook_result = "FlowcommerceSpree::Webhooks::#{params['discriminator'].classify}".constantize.process(params)
16
+ @result = {}
17
+ @result[:error] = webhook_result.full_messages.join("\n") if webhook_result.errors.any?
13
18
  rescue StandardError => e
14
- result = { error: e.class.to_s, message: e.message, backtrace: e.backtrace }
19
+ @result = { error: e.class.to_s, message: e.message, backtrace: e.backtrace }
15
20
  ensure
16
- response_status = if result[:error]
17
- logger.info(result)
18
- :unprocessable_entity
19
- else
20
- :ok
21
- end
22
- render json: result.except(:backtrace), status: response_status
21
+ logger.info(@result) if (error = @result[:error])
22
+ render json: @result.except(:backtrace), status: error ? :unprocessable_entity : :ok
23
+ end
24
+
25
+ private
26
+
27
+ def organization_valid?
28
+ org = params[:organization]
29
+ return true if org == FlowcommerceSpree::ORGANIZATION
30
+
31
+ @result = { error: 'InvalidParam', message: "Organization '#{org}' is invalid!" }
32
+ false
23
33
  end
24
34
  end
25
35
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Users
4
+ SessionsController.class_eval do
5
+ # This endpoint is for returning to the FrontEnd the dynamic url to an external checkout, a flow.io url.
6
+ def checkout_url
7
+ flow_session_id = request.headers['flow-session-id']
8
+ return render json: { error: :session_id_missing }, status: 422 if flow_session_id.blank?
9
+
10
+ checkout_token =
11
+ FlowcommerceSpree::OrderSync.new(order: current_order, flow_session_id: flow_session_id).synchronize!
12
+ return render json: { error: :checkout_token_missing }, status: 422 if checkout_token.blank?
13
+
14
+ render json: { checkout_url: "https://checkout.flow.io/tokens/#{checkout_token}" }, status: 200
15
+ end
16
+
17
+ private
18
+
19
+ def add_optional_attrs(session_current)
20
+ session_current['user'] = current_user_attrs if current_user&.spree_api_key?
21
+ session_current['region'] = zone_attrs
22
+
23
+ external_checkout = current_zone.flow_io_active_experience?
24
+ session_current['external_checkout'] = external_checkout
25
+ session_current['flow_session_id'] = session['flow_session_id'] if external_checkout
26
+ end
27
+ end
28
+ end
@@ -12,16 +12,11 @@ module Spree
12
12
  update_meta = @current_order.zone_id ? nil : true
13
13
  @current_order.zone = current_zone
14
14
 
15
- if @current_order.zone&.flow_io_active_experience? && @current_order.flow_io_experience_key.nil?
16
- @current_order.flow_io_experience_from_zone
17
- order_flow_io_session_id = @current_order.flow_data['session_id']
18
- flow_io_session_id = session['_f60_session']
19
- if order_flow_io_session_id.present? && flow_io_session_id.blank?
20
- session['_f60_session'] = order_flow_io_session_id
21
- elsif flow_io_session_id.present?
22
- @current_order.flow_data['session_id'] = flow_io_session_id
15
+ if @current_order.zone&.flow_io_active_experience?
16
+ if @current_order.flow_io_experience_key.nil?
17
+ @current_order.flow_io_experience_from_zone
18
+ update_meta ||= true
23
19
  end
24
- update_meta = true
25
20
  end
26
21
 
27
22
  if @current_order.new_record?