woocommerce / woocommerce-paypal-payments

https://wordpress.org/plugins/woocommerce-paypal-payments/
GNU General Public License v2.0
61 stars 47 forks source link

Critical error on pay for order page when we try to pay with ACDC gateway (3214) #2321

Closed Dinamiko closed 1 month ago

Dinamiko commented 1 month ago

When paying for an order on the Pay for Order endpoint with a saved credit card, the following fatal error happens:

Uncaught TypeError: WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint::order(): Argument #1 ($id) must be of type string, null given, called in ...

Steps to reproduce

Possible cause

Currently it does not implement the case when executing CaptureCardPayment::create_order in pay for order context, it gets an empty amount because it tries to get the purchase units from cart instead from order which is the case when in pay order context.

Suggested solution

Instead of getting purchase units from cart, get them from the order, to do so we need to pass the WC order as parameter into CaptureCardPayment::create_order and then check for the current context, if it is pay for order then get the purchase units from WC order.