When I try and issue a refund for my customer it says error 4001 what should I do as the customer says that they need it as soon as possible
Has the order finished processing, or is it still saying PENDING? You can't refund an order until the payment clears, if the order says PENDING, you will have to wait for it to clear, or to be declined, in which case a refund will not be needed.
Does the item still say "not paid", or "pending" , if so, you can't refund it
If not , try using a browser, or another browser, and do "cancel", as that cancels and refunds in full.
Your customer still may not get the refund for a few weeks, depending on their card/payment provider.