Jump to content

Module Renew provisioning module command does not update client/product status to Active and remove Termination date


Recommended Posts

When a Renew module command is issued, the application is being reactivated at the endpoint, but the billing is not reactivated in the W. This is because the Renew command does not update the client/product status back to Active and remove the Termination date. In contrast, when issuing unsuspend, the client/product status is set back to Active.

I was thinking of adding some additional localapi requests to update the related serviceid record to set the billing status as active and clear the termination date.

In what place of the code would be the best placement for this or is there as better approach? I could not find a suitable hook, although premodulerenew showed up, but this action should happen after the module action and not before.

function sampleprovisioningmodule_Renew(array $params)
{
    try {
        // post to the endpoint
        $targetApi = new EndpointNotifier($params);
        $success = $targetApi->postToApi($params, 'renew');

        if( !$success ) {
            return 'Failed to post to Endpoint, action not completed';
        }
    } catch (Exception $e) {
        // Record the error in WHMCS's module log.
        logModuleCall(
            'sampleprovisioningmodule',
            __FUNCTION__,
            $params,
            $e->getMessage(),
            $e->getTraceAsString()
        );

        return $e->getMessage();
    }

    return 'success';
}

Addendum. I suppose that once it is established where the code could be slotted in, the local api code could live in a related provisioning module library php, such as with the EndpointNotifier,php. Essentially add a PostModuleActions.php to the library that has desired actions and call from the related sampleprovisioningmodule_Renew code.
 

// Require any libraries needed for the module to function.
require_once __DIR__ . '/lib/EndpointNotifier.php';
require_once __DIR__ . '/lib/PostModuleActions.php';

 

Edited by TBroMEM
Add addendum
Link to comment
Share on other sites

If per chance AfterModuleCreate is triggered after a successful Renew command is issued from provisioning module, then I suppose I can add code there. I could not find a hook labeled AfterModuleRenew, but another community post seemed to indicate that the same hook is triggered after successful Renew.

Link to comment
Share on other sites

WHMCS Support confirmed that the AfterModuleCreate is only triggered after the Create command. The only hook alternative would be to use PreModuleRenew, but given there is no other companion hook, if used it would assume that the Renew action was successful.

Back to my previous ask, if code were to be added that triggers immediately after Renew function, where should the code be placed, and it should it call a distinct provisioning module /lib php?

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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