Closed clark-upserv closed 1 year ago
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.
Hello @clark-upserv! I know it has been a long time but I managed to take a look at the issue and I submitted another possible solution to this as a PR: https://github.com/solidusio/solidus_paypal_commerce_platform/pull/185. Let me know your thoughts and thanks for submitting the issue!
This fix will be included in the next release!
Fix released in 0.7.0 and 1.0.0.beta3.
Pull Request: https://github.com/upserv-io/solidus_paypal_commerce_platform/compare/master...fix-nil-auto-capture file:
app/models/solidus_paypal_commerce_platform/gateway.rb
method:create_order
code:issue: If, in the admin panel, the Auto Capture for PayPal is set to
Use app default
(see photo below), then there is possibility for errors.explanation: This is because the first line in the
create_order
method (intent = auto_capture ? "CAPTURE" : "AUTHORIZE"
) assumes that theauto_capture
argument will either betrue
orfalse
when in reality it can betrue
,false
, ornil
(ifnil
then we should be usingSpree::Config.auto_capture
).nuanced error: If, in the admin panel, the Auto Capture for PayPal is set to
Use app default
and the app default (Spree::Config.auto_capture
) is set to true, then thecreate_order
method (in its current form) will send "AUTHORIZE" to PayPal when really is should be sending "CAPTURE" to PayPal. So PayPal will authorize but will not capture. This causes a payment error during payment checkout which I am assuming is because solidus is expecting PayPal to capture, but PayPal did not.suggested solution (see below or view pull request here):
NOTE for this to work, the javascript_sdk_url method in payment_method.rb file (
app/models/solidus_paypal_commerce_platform/payment_method.rb
) needs to be updated as well: