Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription is not created #253

Open
Tracked by #305
styrken opened this issue Jun 1, 2022 · 5 comments
Open
Tracked by #305

Subscription is not created #253

styrken opened this issue Jun 1, 2022 · 5 comments
Labels

Comments

@styrken
Copy link
Contributor

styrken commented Jun 1, 2022

Hi great people,

I have added this gem to a newly created store. The store uses https://github.com/solidusio/solidus_starter_frontend

So i had to add the form manually, but that's ok.

My issue is now, that the subscription is not created when user purchases a variant. Here the log of data posted to populate.


Started POST "/orders/populate" for 127.0.0.1 at 2022-06-01 09:28:38 +0200
Processing by Spree::OrdersController#populate as HTML
  Parameters: {"authenticity_token"=>"[FILTERED]", "subscription-interval"=>"10", "variant_id"=>"36", "quantity"=>"1", "button"=>"", "subscription_line_item"=>{"interval_length"=>"1", "interval_units"=>"month", "quantity"=>"1", "subscribable_id"=>"36"}}
  Spree::Store Load (1.4ms)  SELECT "spree_stores".* FROM "spree_stores" WHERE ("spree_stores"."url" = $1 OR "spree_stores"."default" = $2) ORDER BY "spree_stores"."default" ASC LIMIT $3  [["url", "localhost"], ["default", true], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  Spree::User Load (0.7ms)  SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = $1 ORDER BY "spree_users"."id" ASC LIMIT $2  [["id", 1], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  Spree::Order Load (0.5ms)  SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = $1 AND "spree_orders"."guest_token" = $2 AND "spree_orders"."store_id" = $3 AND "spree_orders"."user_id" = $4 LIMIT $5  [["currency", "USD"], ["guest_token", "QcrP616iaM9LUf6ag8dB_A"], ["store_id", 1], ["user_id", 1], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  Spree::Order Load (0.5ms)  SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = $1 AND "spree_orders"."frontend_viewable" = $2 AND "spree_orders"."store_id" = $3 ORDER BY "spree_orders"."created_at" DESC LIMIT $4  [["user_id", 1], ["frontend_viewable", true], ["store_id", 1], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  Spree::User Load (0.5ms)  SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  TRANSACTION (0.5ms)  BEGIN
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  Spree::Store Load (0.5ms)  SELECT "spree_stores".* FROM "spree_stores" WHERE "spree_stores"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  Spree::Order Exists? (0.6ms)  SELECT 1 AS one FROM "spree_orders" WHERE "spree_orders"."number" = $1 LIMIT $2  [["number", "R638376007"], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  CACHE Spree::Order Exists? (0.0ms)  SELECT 1 AS one FROM "spree_orders" WHERE "spree_orders"."number" = $1 LIMIT $2  [["number", "R638376007"], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  Spree::Order Create (0.8ms)  INSERT INTO "spree_orders" ("number", "state", "user_id", "email", "created_at", "updated_at", "currency", "last_ip_address", "created_by_id", "guest_token", "store_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING "id"  [["number", "R638376007"], ["state", "cart"], ["user_id", 1], ["email", "admin@example.com"], ["created_at", "2022-06-01 07:28:38.309386"], ["updated_at", "2022-06-01 07:28:38.309386"], ["currency", "USD"], ["last_ip_address", "127.0.0.1"], ["created_by_id", 1], ["guest_token", "QcrP616iaM9LUf6ag8dB_A"], ["store_id", 1]]
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  TRANSACTION (0.7ms)  COMMIT
  ↳ app/controllers/spree/orders_controller.rb:51:in `populate'
  Spree::Role Load (0.4ms)  SELECT "spree_roles".* FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1  [["user_id", 1]]
  ↳ app/controllers/spree/orders_controller.rb:52:in `populate'
  Spree::Variant Load (0.5ms)  SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."deleted_at" IS NULL AND "spree_variants"."id" = $1 LIMIT $2  [["id", 36], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:54:in `populate'
  Spree::LineItem Load (0.5ms)  SELECT "spree_line_items".* FROM "spree_line_items" WHERE "spree_line_items"."order_id" = $1 ORDER BY "spree_line_items"."created_at" ASC, "spree_line_items"."id" ASC  [["order_id", 10]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  TRANSACTION (0.4ms)  BEGIN
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Product Load (0.6ms)  SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."id" = $1 LIMIT $2  [["id", 6], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::TaxCategory Load (0.5ms)  SELECT "spree_tax_categories".* FROM "spree_tax_categories" WHERE "spree_tax_categories"."deleted_at" IS NULL AND "spree_tax_categories"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Country Load (0.5ms)  SELECT "spree_countries".* FROM "spree_countries" WHERE "spree_countries"."iso" = $1 LIMIT $2  [["iso", ""], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Country Load (0.4ms)  SELECT "spree_countries".* FROM "spree_countries" WHERE "spree_countries"."id" IS NULL LIMIT $1  [["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Price Load (0.5ms)  SELECT "spree_prices".* FROM "spree_prices" WHERE "spree_prices"."deleted_at" IS NULL AND "spree_prices"."variant_id" = $1 ORDER BY country_iso IS NULL, "spree_prices"."updated_at" DESC, "spree_prices"."id" DESC  [["variant_id", 36]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::LineItem Create (0.6ms)  INSERT INTO "spree_line_items" ("variant_id", "order_id", "quantity", "price", "created_at", "updated_at", "cost_price", "tax_category_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id"  [["variant_id", 36], ["order_id", 10], ["quantity", 1], ["price", "29.99"], ["created_at", "2022-06-01 07:28:38.324866"], ["updated_at", "2022-06-01 07:28:38.324866"], ["cost_price", "27.0"], ["tax_category_id", 1]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Product Load (0.7ms)  SELECT "spree_products".* FROM "spree_products" INNER JOIN "spree_variants" ON "spree_products"."id" = "spree_variants"."product_id" WHERE "spree_variants"."id" = $1 LIMIT $2  [["id", 36], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Variant Load (0.4ms)  SELECT "spree_variants".* FROM "spree_variants" INNER JOIN "spree_assemblies_parts" ON "spree_variants"."id" = "spree_assemblies_parts"."part_id" WHERE "spree_variants"."deleted_at" IS NULL AND "spree_assemblies_parts"."assembly_id" = $1  [["assembly_id", 6]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Order Update (0.8ms)  UPDATE "spree_orders" SET "updated_at" = $1 WHERE "spree_orders"."id" = $2  [["updated_at", "2022-06-01 07:28:38.326196"], ["id", 10]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  TRANSACTION (0.6ms)  COMMIT
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  TRANSACTION (0.4ms)  BEGIN
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Shipment Load (0.5ms)  SELECT "spree_shipments".* FROM "spree_shipments" WHERE "spree_shipments"."order_id" = $1  [["order_id", 10]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Payment Load (0.5ms)  SELECT "spree_payments".* FROM "spree_payments" WHERE "spree_payments"."order_id" = $1 AND "spree_payments"."state" = $2 ORDER BY "spree_payments"."created_at" ASC  [["order_id", 10], ["state", "completed"]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Adjustment Load (0.5ms)  SELECT "spree_adjustments".* FROM "spree_adjustments" WHERE "spree_adjustments"."adjustable_id" = $1 AND "spree_adjustments"."adjustable_type" = $2  [["adjustable_id", 17], ["adjustable_type", "Spree::LineItem"]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Adjustment Load (0.6ms)  SELECT "spree_adjustments".* FROM "spree_adjustments" WHERE "spree_adjustments"."adjustable_id" = $1 AND "spree_adjustments"."adjustable_type" = $2 ORDER BY "spree_adjustments"."created_at" ASC  [["adjustable_id", 10], ["adjustable_type", "Spree::Order"]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Order Exists? (0.7ms)  SELECT 1 AS one FROM "spree_orders" WHERE "spree_orders"."number" = $1 AND "spree_orders"."id" != $2 LIMIT $3  [["number", "R638376007"], ["id", 10], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Order Update (0.7ms)  UPDATE "spree_orders" SET "item_total" = $1, "total" = $2, "updated_at" = $3, "item_count" = $4 WHERE "spree_orders"."id" = $5  [["item_total", "29.99"], ["total", "29.99"], ["updated_at", "2022-06-01 07:28:38.340161"], ["item_count", 1], ["id", 10]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  TRANSACTION (0.6ms)  COMMIT
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Order Update (0.6ms)  UPDATE "spree_orders" SET "shipment_total" = $1 WHERE "spree_orders"."id" = $2  [["shipment_total", "0.0"], ["id", 10]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Promotion Load (2.7ms)  SELECT DISTINCT "spree_promotions".* FROM "spree_promotions" INNER JOIN "spree_promotion_actions" ON "spree_promotion_actions"."deleted_at" IS NULL AND "spree_promotion_actions"."promotion_id" = "spree_promotions"."id" INNER JOIN "spree_orders_promotions" ON "spree_orders_promotions"."promotion_id" = "spree_promotions"."id" WHERE ("spree_promotions"."starts_at" IS NULL OR "spree_promotions"."starts_at" < '2022-06-01 07:28:38.343812') AND ("spree_promotions"."expires_at" IS NULL OR "spree_promotions"."expires_at" > '2022-06-01 07:28:38.343812') AND "spree_orders_promotions"."order_id" = $1  [["order_id", 10]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Promotion Load (1.0ms)  SELECT DISTINCT "spree_promotions".* FROM "spree_promotions" INNER JOIN "spree_promotion_actions" ON "spree_promotion_actions"."deleted_at" IS NULL AND "spree_promotion_actions"."promotion_id" = "spree_promotions"."id" WHERE "spree_promotions"."apply_automatically" = $1 AND ("spree_promotions"."starts_at" IS NULL OR "spree_promotions"."starts_at" < '2022-06-01 07:28:38.348071') AND ("spree_promotions"."expires_at" IS NULL OR "spree_promotions"."expires_at" > '2022-06-01 07:28:38.348071')  [["apply_automatically", true]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  TRANSACTION (0.4ms)  BEGIN
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Payment Load (0.6ms)  SELECT "spree_payments".* FROM "spree_payments" WHERE "spree_payments"."order_id" = $1 AND "spree_payments"."state" = $2 ORDER BY "spree_payments"."created_at" ASC  [["order_id", 10], ["state", "completed"]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  Spree::Order Exists? (0.7ms)  SELECT 1 AS one FROM "spree_orders" WHERE "spree_orders"."number" = $1 AND "spree_orders"."id" != $2 LIMIT $3  [["number", "R638376007"], ["id", 10], ["LIMIT", 1]]
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
  TRANSACTION (0.6ms)  COMMIT
  ↳ app/controllers/spree/orders_controller.rb:62:in `populate'
Redirected to http://localhost:3000/cart
Completed 302 Found in 70ms (ActiveRecord: 25.5ms | Allocations: 45193)

Installed solidus gems:

gem 'solidus_core'
gem 'solidus_api'
gem 'solidus_backend'
gem 'solidus_sample'
gem 'solidus_support'

gem 'deface'
gem 'solidus_auth_devise'
gem 'solidus_paypal_commerce_platform'
gem 'solidus_subscriptions', github: 'solidusio-contrib/solidus_subscriptions', branch: 'master'
gem 'solidus_reports', github: 'solidusio-contrib/solidus_reports'
gem 'solidus_product_assembly', github: 'solidusio-contrib/solidus_product_assembly', branch: 'master'
gem 'solidus_editor', github: 'solidusio-contrib/solidus_editor', branch: 'master'

subscription_line_item is present with the required params. Do i need to do something extra in OrdersController ?

@styrken
Copy link
Contributor Author

styrken commented Jun 1, 2022

Not sure if thats the issue, but it seems like the decorators in lib folder is not loaded

@styrken
Copy link
Contributor Author

styrken commented Jun 1, 2022

@kennyadsl
Copy link
Member

kennyadsl commented Jun 1, 2022

Thanks for reporting. It's still WIP how to behave for this kind of decorators. What would it be the expected behavior here in your opinion?

@styrken
Copy link
Contributor Author

styrken commented Jun 1, 2022

I actually made a piece of code that required the decorators but to my surprise it was still not working. So there is something weird going on.

When copying the code it worked fine.

@stale
Copy link

stale bot commented Jul 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. It might be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants