Update Post Status On Woocommerce Payment Complete

Have you considered the WooCommerce action woocommerce_order_status_completed which is called when the order status is changed to wc-completed? It is called with the order id and the order object (instance of WC_Order) from which you can get the details of the order.

error code: 523