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
As admin create order manually selecting an existing customer
Copy the "Customer payment page" link
As customer paste the previous link
Select ACDC gateway select saved card or enter new one and pay
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.
When paying for an order on the Pay for Order endpoint with a saved credit card, the following fatal error happens:
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.