Jump to content
  • 0

Transfer Sync - Update domain status


sod20

Question

Hi, 

I've develop a Registrar Module based on development guide example. The problem is that I don't get at all how "Sync" and "TransferSync" functions works. Specially TransferSync. 

Does TransferSync update domain information by itself or do I have to update domain information on database?

I'm asking because there was a domain that was transfer then function executed but it didn't change domain status from "Pending Transfer" to "Active". 

After a research I found that maybe  the error was that I just passed part of the required information. Is that so?

For example, when the result of the transfer was success I just sent variables 'completed' and 'expirydate' on return array.

return array(
     'completed' => true,
     'expirydate' => '2017-10-15',
);

In the same way, when transfer could not be done. I returned the other variables

return array( 
     'failed' => true, 
     'reason' => 'Authinfo expired',
);

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
23 hours ago, sod20 said:

Does TransferSync update domain information by itself or do I have to update domain information on database? 

You need to return the information.

23 hours ago, sod20 said:

but it didn't change domain status from "Pending Transfer" to "Active".  

I guess it didn't complete then 😉

Try posting your TransferSync function  here.

Link to comment
Share on other sites

  • 0
1 hour ago, DennisMidjord said:

You need to return the information.

I guess it didn't complete then 😉

Try posting your TransferSync function  here.

I checked on the other Registrar and transfer was process was complete.

Today another transfer was complete, I'd changed TransferSync function to this, it didn't work. I'm thinking on using Models (https://docs.whmcs.com/Using_Models) and update information when it is complete.

function TransferSync($params) {
    if(trim($params['api_url']) == '') {
        return array(
            'error' => "URL API undefined",
        );
    }
    $apikey = $params['apikey'];
    $sld = $params['sld'];
    $tld = $params['tld'];
    $url = $params['api_url']."/transferSync";
    try {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER,
            array (
                'Content-Type: application/json',
                'apiKey: ' . $apikey
            )
        );
        $api_response = curl_exec($ch);
        $response = json_decode($api_response);
        curl_close($ch);
        $return_response = [
            'completed' => false,
            'failed'    => false,
        ];
        if ($response->result == 'success') {
            if ($response->transfercomplete) {
                $return_response['completed'] = true;
                $return_response['expirydate'] = $response->expirydate;
            } else if ($response->transferfailed) {
                $return_response['failed'] = true;
                $return_response['reason'] = $response->reason;
            }
        }
        return $return_response;
    } catch (\Exception $e) {
        return array (
            'error' => $e->getMessage(),
        );
    }
}
Link to comment
Share on other sites

  • 0
15 hours ago, DennisMidjord said:

If you do that, I hardly doubt it will trigger the DomainTransferCompleted event, meaning the client will not receive an email. You'll just be updating the database entry.

Are you sure that your if lines are actually executing? Try dumping $response.

Yes, I did. Response object was fine. I'm also using  WHMCS localAPI to send email to clients. I took the decision of send and email to them  with authinfo changes of request.

I just basically created another template or used default according to  situation.

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
Answer this question...

×   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