ebanx/woocommerce-gateway-ebanx

Downloadable item orders are stuck on 'processing' when the payment is completed

Closed this issue · 2 comments

Hey folks,

I have an issue with orders with downloadable items. I'm currently using the latest Wordpress, WooCommerce and EBANX Gateway versions.

I've narrowed the issue down to this function call:

final public function update_payment($order, $data) {
$requestStatus = strtoupper($data->payment->status);
$status = array(
'CO' => 'Confirmed',
'CA' => 'Canceled',
'PE' => 'Pending',
'OP' => 'Opened'
);
$new_status = null;
switch ($requestStatus) {
case 'CO':
$new_status = 'processing';
break;
case 'CA':
$new_status = 'failed';
break;
case 'PE':
$new_status = 'on-hold';
break;
case 'OP':
$new_status = 'pending';
break;
}
if ($new_status !== $order->status) {
$paymentStatus = $status[$data->payment->status];
$order->add_order_note(sprintf(__('EBANX: The payment has been updated to: %s.', 'woocommerce-gateway-ebanx'), $paymentStatus));
}
}

Since you're manually changing the order status, and WC_Order::payment_complete was not used, the necessary actions are not being called, which results in the kind of issue I'm experiencing. This is easily fixed by adding a call to WC_Order::payment_complete.

Official method reference:

https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-order.php#L87-L99

Thanks!

Hey there,

The payment is completed, but the order is still being processed by the merchant. Therefore, the customer should see the order status as "processing" and not "completed" at this point.

Thanks for the response.

It's naive to assume that the next order status after the payment is "processing". For digital orders, by default, it's not (the old plugin, for example, did work as expected). This behavior also breaks custom order statuses, such as the ones set by WooCommerce Order Status Manager, which is an official plugin and depends on the actions/filters called by payment_complete().