Jump to content

Payment Gateway - Refunds


Davor

Recommended Posts

Hello,

I'm creating for myself the Payment Gateway for Paddle and now I have some doubts how to proceed with refunds because refunds with Paddle are not automatic, but they need to be approved by Paddle team.

So, now, when I make a refund in WHMCS, in the Payment Gateway code in the "paddle_refund" I send this request to the Paddle API and I don't get success or denied response immediately, but I need to return true or false from this function. And if I return false in the WHMCS portal it is displayed the error message that is something wrong, but if I return true the refund gets accepted in WHMCS, but the refund is not yet processed by Paddle. What is the best practice in this case? Or can I return some status like "Processing" in the function "paddle_refund" in the Payment Gateway code?

Then in the WHMCS hook I'm waiting for the response from Paddle. This is not the problem, but what to do, what to return in "paddle_refund" function?

 

Thanks,

Davor

Link to comment
Share on other sites

Don't think there is a logic for pending and no hook to intercept it seems .   I think doing your own refund logic might be needed here.  A new refund tab or like "pre-refund" button on the refund tab that kicks off the first stage .  Then the whmcs refund checks the API for refund status and completes if successful .  That is presuming their API supports checking refund status.   You basically need to visit the refund tab twice in this case, once to kick off the process and once to complete whmcs side.   I am actually not sure there is an WHMCS API that can do refunds.  UpdateInvoice with status of refunded might work but not sure. 

Link to comment
Share on other sites

I would return false in the refund function and change the error message to its own text via javascript using the AdminAreaFooterOutput hook, maybe even change the CSS class so that the notice doesn't appear in red. 

After you received the callback from Paddle, you process the refund properly. It would also be useful to notify the staff about the output of the refund, for this you can either create a ticket or use the WHMCS notification system.

In order to continue to use the normal refund function from WHMCS, I would add a second argument to the function, such as:

function paddle_refund ($params, $fromCallback = null) {
    if ($fromCallback) {
      ....
      return [ 'status' => 'success' ];
    } else {
      ....
      return [ 'status' => 'error' ];
    }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated