The commit and shipping_preference parameters rely on checking the Order checkout_steps.
https://github.com/solidusio-contrib/solidus_paypal_commerce_platform/blob/19c00c68220fa9b7490dcc6497030809cbbfda03/app/models/solidus_paypal_commerce_platform/payment_method.rb#L67
https://github.com/solidusio-contrib/solidus_paypal_commerce_platform/blob/19c00c68220fa9b7490dcc6497030809cbbfda03/app/models/solidus_paypal_commerce_platform/payment_method.rb#L77
The checkout_steps get set here, attempting to use the order's checkout_steps, otherwise the Spree::Order model. However, order.checkout_steps returns an array of strings, and ::Spree::Order.checkout_steps.keys returns an array of symbols. As the conditionals currently rely on strings, the conditionals work incorrectly when relying on the Order model for checkout steps. This happens for example on the product page where no @order is given.
https://github.com/solidusio-contrib/solidus_paypal_commerce_platform/blob/19c00c68220fa9b7490dcc6497030809cbbfda03/app/models/solidus_paypal_commerce_platform/payment_method.rb#L65
This is a simple fix, however, the shipping_preference param might be dropped due to issue #149 and the javascript_sdk_url method changes a lot due to the #148 PR. So this issue can wait until these get resolved to avoid conflicts.
The
commitandshipping_preferenceparameters rely on checking theOrdercheckout_steps.https://github.com/solidusio-contrib/solidus_paypal_commerce_platform/blob/19c00c68220fa9b7490dcc6497030809cbbfda03/app/models/solidus_paypal_commerce_platform/payment_method.rb#L67
https://github.com/solidusio-contrib/solidus_paypal_commerce_platform/blob/19c00c68220fa9b7490dcc6497030809cbbfda03/app/models/solidus_paypal_commerce_platform/payment_method.rb#L77
The
checkout_stepsget set here, attempting to use theorder'scheckout_steps, otherwise theSpree::Ordermodel. However,order.checkout_stepsreturns an array of strings, and::Spree::Order.checkout_steps.keysreturns an array of symbols. As the conditionals currently rely on strings, the conditionals work incorrectly when relying on theOrdermodel for checkout steps. This happens for example on the product page where no@orderis given.https://github.com/solidusio-contrib/solidus_paypal_commerce_platform/blob/19c00c68220fa9b7490dcc6497030809cbbfda03/app/models/solidus_paypal_commerce_platform/payment_method.rb#L65
This is a simple fix, however, the
shipping_preferenceparam might be dropped due to issue #149 and thejavascript_sdk_urlmethod changes a lot due to the #148 PR. So this issue can wait until these get resolved to avoid conflicts.