Name

WWW::CNic::Cookbook - The WWW::CNic Cookbook

Description

This document provides a fairly complete explanation of how to implement basic Registrar-Registry functions with CentralNic using \*(C`WWW::CNic\*(C'.

This document is a work in progress, if you want to see something in it that isn't, or find an error, please let us know by e-mailing [email protected].

Test Mode

The Toolkit can be told to run in test mode, that is, to use a non-live copy of the database so that any changes made don't affect the live domains.

To enable test mode, simply set the \*(C`test\*(C' argument on the constructor, like so:

        my $query = WWW::CNic->new(test => 1, ... );

You will also need to supply test account credentials rather than production account credentials. These can be obtained from the Registrar Console.

Getting Information about Domains

Getting a Suffix List

CentralNic's range of available domain names changes occasionally and you may want to periodically update the list of domains we support. You can use the \*(C`suffixes\*(C' command to retrieve an array containing all the domain suffixes CentralNic supports.

use WWW::CNic;

# create a request object: my $query = WWW::CNic->new( command => 'suffixes', );

# execute the query to return a response object: my $response = $query->execute;

# use the suffixes() method to get a list of suffixes: my @suffixes = $response->suffixes;

This can be shortened to:

use WWW::CNic;

my @suffixes = WWW::CNic->new(command=>'suffixes')->execute->suffixes;

Doing a Domain Availability Search

The traditional method for checking the availability of a domain name is to query the registry's whois server, and do a pattern match against the response looking for indications that the domain is registered. This is not an optimal approach for several reasons - firstly, the whois protocol was never designed for it. Secondly, the lack of a whois record does not signify availability. It also can't handle multiple lookups very well.

The \*(C`search\*(C' function is a very powerful way to check on the availability of a domain name. It allows you to check the availability of a domain name across one, several or all of CentralNic's suffixes.

Here's how you might do a check against a particular domain name:

use WWW::CNic;

my $domain = 'example'; my $suffix = 'uk.com';

my $query = WWW::CNic->new( command => 'search', domain => $domain, );

$query->set(suffixlist => [$suffix]);

my $response = $query->execute;

if ($response->is_registered($suffix)) { printf("domain is registered to %s\n", $response->registrant($suffix));

} else { print "domain is available.\n";

}

Notice the extra step (using the \*(C`set()\*(C' method), where we set the 'suffixlist' parameter to be an anonymous array containing the single suffix we want to check. Omitting this step would make the query check against all CentralNic suffixes.

The response object returned has a method \*(C`is_registered()\*(C' which returns true if the domain is already registered. Additionally, you can use the \*(C`registrant($suffix)\*(C' and \*(C`expiry($suffix)\*(C' methods to get the registrant name and a \s-1UNIX\s0 timestamp of the expiry date respectively.

Getting Detailed Information About a Domain

Prior to submitting a modification, you may wish to get detailed information about a domain name to present to your users. The \*(C`whois\*(C' command allows the lookup of the same detailed information that a whois server provides.

For example:

use WWW::CNic;

my $domain = 'example.uk.com';

my $query = WWW::CNic->new( command => 'whois', domain => $domain, );

my $response = $query->execute;

print "Domain: $domain\n";

my %tech_handle = %{$response->response('thandle')}; printf("Tech Handle: %s (%s)\n", $tech_handle{userid}, $tech_handle{name});

my $dns = $response->response('dns'); foreach my $server(@{$dns}) { if (ref($server) eq 'ARRAY') { my ($name, $ipv4) = @{$server}; print "Server: $name ($ipv4)\n";

} else { print "Server: $server\n";

} }

The response object contains values for the following keys:

registrant the domain's registrant created registration date expires expiry date status status (e.g. Live, On Hold, Pending Deletion etc) chandle Client Handle bhandle Technical Handle thandle Billing Handle dns DNS Servers

The \*(C`registrant\*(C' and \*(C`status\*(C' keys are just strings. The \*(C`created\*(C' and \*(C`expires\*(C' keys are \s-1UNIX\s0 timestamps. The \*(C`chandle\*(C', \*(C`thandle\*(C' and \*(C`bhandle\*(C' keys are all references to hashes with the following keys:

userid name company addr street1 street2 street3 city sp postcode country phone fax email

These values can be accessed in the following way:

# get the tech handle: my $tech_handle = $response->response('thandle');

print $tech_handle->{addr};

# and so on for the other keys

The \*(C`dns\*(C' key is an array. Elements in the array may be either a plain scalar containing the \s-1DNS\s0 hostname of the server, or an anonymous array containing the \s-1DNS\s0 hostname and \s-1IPV4\s0 address in that order. Use the \*(C`ref()\*(C' function to work out which.

Address data: handles in the CentralNic database follow one of two \*(L"styles\*(R": old-style handles have flat address data (stored in the \*(C`address\*(C' property), but new-style handles have separate properties for street, city and state/province. All handles will have at least a non-empty \*(C`address\*(C' property (for new-style handles this is created by flattening the \*(C`street1\*(C', \*(C`street2\*(C'... properties). All new-style handles will have a non-empty \*(C`street1\*(C' property.

Retrieving the Transfer Code For a Domain Name

use WWW::CNic;

my $query = WWW::CNic->new( command => 'auth_info', domain => 'example.uk.com', username => $handle, password => $passwd, );

my $response = $query->execute;

if ($response->is_error) { printf("Error: %s\n", $response->error);

} else { printf("Transfer code: %s\n", $response->auth_code);

}

This command is used to retrieve the transfer code for a domain name. Those registrars who use our \s-1EPP\s0 system are required to provide a security code when they initiate a transfer request, which they get from the registrant, who in turn gets it from the losing registrar. Registrars are required to provide this code to registrants upon request.

Getting Detailed Information About a Handle

This command can be used to retrieve information about a handle for which you are the sponsor. You are the sponsor of a handle if you created it as part of a domain registration or modification process, or it is associated with a domain name for which you are Billing Handle.

use WWW::CNic;

my $query = WWW::CNic->new( command => 'handle_info', username => $handle, password => $passwd, );

$query->set(handle => 'H12345');

my $response = $query->execute;

if ($response->is_error) { printf("Error: %s\n", $response->error);

} else { foreach my $key (qw(name company address street1 street2 street3 city sp postcode country tel fax email visible)) { printf("%s: %s\n", $key, $response->response($key)); }

}

The \*(C`visible\*(C' value is a binary value (1 or 0) that indicates whether this handle's details are show in \s-1WHOIS\s0 records for domains with which it is associated.

Address data: handles in the CentralNic database follow one of two \*(L"styles\*(R": old-style handles have flat address data (stored in the \*(C`address\*(C' property), but new-style handles have separate properties for street, city and state/province. All handles will have at least a non-empty \*(C`address\*(C' property (for new-style handles this is created by flattening the \*(C`street1\*(C', \*(C`street2\*(C'... properties). All new-style handles will have a non-empty \*(C`street1\*(C' property.

Creating New Domains and Handles

Creating a Handle

If you are going to be registering multiple domains, you should create a new handle and use that to register the domains using its \s-1ID\s0, rather than supply new contact details for each registration, which will result in a new client handle being created each time.

To do so, use the \*(C`create_handle\*(C' command:

use WWW::CNic;

my $query = WWW::CNic->new( command => 'create_handle', username => $handle, password => $passwd, );

$query->set(handle => { name => 'John Doe', company => 'Example, Inc', street1 => 'Example House', street2 => 'Example Street', city => 'London', sp => 'England', postcode=> 'EC1 123', country => 'UK', phone => '+44.8700170900', fax => '+44.8700170901', email => '[email protected]', });

# make the handle hidden on whois records: $query->set(visible => 0);

my $response = $query->execute;

if ($response->is_success) { printf("New handle created with ID %s\n", $response->handle);

} else { printf("Error: %s\n", $response->error);

}

The \*(C`handle\*(C' parameter must be a reference to a hash containing the following keys:

name company street1 street2 street3 city sp postcode country phone fax email

Only \*(C`name\*(C', \*(C`country\*(C' and \*(C`email\*(C' are mandatory. The \*(C`phone\*(C' and \*(C`fax\*(C' fields can be in any format, but we request that you use the e164a format:

+AA.BBB(xCC)

where \*(C`AA\*(C' is the dialling code for the country in question, \*(C`BBB\*(C' is the phone number without a local dialling prefix (eg, for the \s-1UK\s0, emit the leading zero), and \*(C`CC\*(C' is an optional extension.

\*(C`street1\*(C', \*(C`street2\*(C' and \*(C`street3\*(C' are street address lines, \*(C`city\*(C' is the postal city/town and \*(C`sp\*(C' is the state, province or county.

The \*(C`country\*(C' field must be a valid \s-1ISO3166\s0 2-character country code.

The \*(C`visible\*(C' parameter controls whether the handle's contact details are shown on whois records for domain names to which it is associated. By default, the value of \*(C`visible\*(C' is 1. A value of 0 hides the handle from whois records.

You can use the \*(C`handle()\*(C' method to return the \s-1ID\s0 of the created handle, for use when registering.

Registering a Domain Name

We require that you use \s-1SSL\s0 when making registration and modification requests. WWW::CNic supports \s-1SSL\s0 communications transparently, since it uses \*(C`LWP\*(C' to do all \s-1HTTP\s0 communication. \*(C`LWP\*(C' will handle \s-1SSL\s0 if the \*(C`Crypt::SSLeay\*(C' or \*(C`IO::Socket::SSL\*(C' modules have been installed.

use WWW::CNic;

my $query = WWW::CNic->new( command => 'register', domain => 'example.uk.com', username => $handle, password => $passwd, );

$query->set( registrant => 'Example, Inc', chandle => $chandle, thandle => $thandle, period => 2, );

# Set DNS servers

$query->set(dns => ['ns0.example.com', 'ns1.example.com']);

# OR

$query->set(url => 'http://www.example.com/');

my $response = $query->execute;

if ($response->is_success) { printf("Domain registered at price %01.2f\n", $response->amount);

} else { printf("Error: %s\n", $response->error);

}

\s-1IMPORTANT\s0 \s-1NOTE:\s0 the details you enter for the Client Handle (\*(C`chandle\*(C') should be the contact details of your customer.

In order to make a registration transaction, you need to supply the \*(C`username\*(C' and \*(C`password\*(C' parameters - these correspond to your Registrar Handle's \s-1ID\s0 and password. Your password is \*(C`crypt()\*(C'ed before it is sent.

You need to set a range of extra parameters to register a domain. These are explained below.

1.

\*(C`registrant\*(C' - the name of the domain's registrant. This is a text string corresponding to your customer's name and/or organisation. It should not be a handle \s-1ID\s0.

2.

\*(C`chandle\*(C' - the Client Handle. The Client Handle should correspond to your customer's contact details.

3.

\*(C`thandle\*(C' - the Technical Handle. This may take two values. It can be a scalar containing the Handle \s-1ID\s0 of an existing handle, or "\*(C`chandle\*(C'" to set it to be whatever \*(C`chandle\*(C' is.

4.

\*(C`dns\*(C' - the \s-1DNS\s0 servers for the domain. This can either be an anonymous array of \s-1DNS\s0 hostnames, or a reference to hash such as that below: my $dns = { 'ns0.example.com' => '192.168.1.1', 'ns1.example.com' => '192.168.1.2', }; If you have specified default \s-1DNS\s0 servers using the Registrar Console you can set $dns to be '\*(C`defaults\*(C'' and the system will use these.

5.

\*(C`url\*(C' - if this parameter is provided and is not empty, it will be used to set a simple web forwarding for the domain instead of any \s-1DNS\s0 servers provided.

6.

\*(C`period\*(C' - the registration period for the domain name. This is an integer number of years and must be between 2 and 10, or 100. If this field is omitted the domain will be registered for 2 years.

The response object for this command has all the usual methods (as documented in WWW::CNic::Response), plus the \*(C`amount()\*(C' method, which returns the price in Sterling for the domain.

\s-1NB\s0: In addition to specifying a handle \s-1ID\s0 or "\*(C`chandle\*(C'" in the \*(C`chandle\*(C' and \*(C`thandle\*(C' fields, it is also possible to use an anonymous hash to supply the details of a new handle. However this is a legacy feature for compatibility with older versions of WWW::CNic and its use is not recommended.

Modifying Domain Names and Handles

Modifying a Domain Name

You can use \*(C`WWW::CNic\*(C' to do real-time modification of a domain. The procedure is somewhat similar to that of registration.

use WWW::CNic;

my $query = WWW::CNic->new( command => 'modify', domain => 'example.uk.com', username => $handle, password => $passwd, );

$query->set( thandle => $handle, dns => { drop => 'all', add => ['ns0.example.com', 'ns1.example.com'], } url => 'drop', );

my $response = $query->execute;

if ($response->is_success) { print "Domain modified OK.\n";

} else { printf("Error, could not modify domain: %s\n", $response->error);

}

The \*(C`modify\*(C' command allows you to add and remove \s-1DNS\s0 servers and to change the Technical Handle. You can set two parameters for the transaction:

1.

\*(C`thandle\*(C' corresponds to a new Technical Handle.

2.

\*(C`dns\*(C' must be an anonymous hash (or a reference to a hash) with two keys: \*(C`add\*(C' and \*(C`drop\*(C'. Their values are anonymous arrays of \s-1DNS\s0 hostnames. When dropping \s-1DNS\s0 servers, you can use the string 'all' to indicate that you want to delete all the previously delegated \s-1DNS\s0 servers (this doesn't affect any servers you might add during the same transaction). \s-1NB\s0: In addition to specifying a handle \s-1ID\s0 in the \*(C`thandle\*(C' field, it is also possible to use an anonymous hash to supply the details of a new handle. However this usage is not recommended.

3.

\*(C`url\*(C' is an optional element containing a new \s-1URL\s0 to which to forward the domain. If this parameter is set, then the \*(C`dns\*(C' parameter is ignored, and any existing \s-1DNS\s0 servers are removed from the domain. If this parameter contains the special keyword 'drop' then the web forwarding will be removed, and the domain will be 'parked'.

Modifying a Handle

When a handle is created by the \*(C`create_handle\*(C' or \*(C`register\*(C' commands, or via other interfaces such as the Registrar Console, it is associated with your account. This allows you to update the contact details for that handle.

\s-1IMPORTANT\s0: this command must not be used to completely change the contact details for a handle for a domain name. Instead you should use the \*(C`modify\*(C' function to change the \s-1ID\s0 of the handle on the domain name (see above). This function is only for incremental changes to contact details.

use WWW::CNic;

my $query = WWW::CNic->new( command => 'modify_handle', username => $handle, password => $passwd, );

$query->set( handle => 'H12345', name => 'John Doe', company => 'Example, Inc', street1 => 'Example House', street2 => 'Example Street', city => 'London', sp => 'England', postcode => 'EC1 123', country => 'UK', phone => '+44.8700170900', fax => '+44.8700170901', email => '[email protected]', visible => 0, );

my $response = $query->execute;

if ($response->is_success) { print "Handle modified OK.\n";

} else { printf("Error, could not modify handle: %s\n", $response->error);

}

You can change the following values:

name company street1 street2 street3 city sp postcode country phone fax email visible

The meaning of these fields is identical to those described in the \*(L"Creating a Handle\*(R" section. Note that \*(C`name\*(C', \*(C`country\*(C' and \*(C`email\*(C' are all mandatory and cannot be blank.

Renewing a Domain Name

use WWW::CNic; use strict;

my $query = WWW::CNic->new( command => 'issue_renewals', username => $handle, password => $passwd );

$query->set( domains => ['example1.uk.com', 'example2.uk.com'], period => 2, # 2 years );

my $response = $query->execute;

if ($response->is_success) { print "Domain(s) renewed.\n";

} else { printf("Error: %s\n", $response->error);

}

You can issue advance renewals for domains using this command. You simply set a \*(C`domains\*(C' parameter to be an anonymous array of domain names, or a reference to an array (eg \*(C`\@domains\*(C').

Under normal circumstances, a renewal invoice or proforma is not issued right away, but is queued until the end of the day. If you want to generate a renewal invoice immediately, set the \*(C`immediate\*(C' parameter, like so:

$query->set(immediate => 1);

my $response = $query->execute;

if ($response->is_success) { printf( "%s #%d issued at a value of %01.2f.\n", ($response->invoice > 0 ? 'Invoice' : 'Pro forma'), ($response->invoice > 0 ? $response->invoice : $response->proforma), $response->amount );

} else { printf("Error: %s\n", $response->error);

}

Deleting a Domain Name

my $query = WWW::CNic->new( command => 'delete', domain => $domain, username => $handle, password => $password, );

my $response = $query->execute;

if ($response->is_success) { print "Domain has been deleted.\n";

} else { printf("Error: %s\n", $response->error);

}

Using this service, you can delete an unwanted domain name. However, you must supply a reason code in order for the deletion to take place. The currently available codes are listed below:

Code Meaning R1 Payment not received R2 Fraudulent Registration R3 Domain no longer required by registrant R4 Domain registered in error

In accordance with our policy, an e-mail will be sent to the domain's Client Handle informing them that the domain has been deleted.

Requesting Reactivation of a Domain Name

Domains that are on the \*(L"Pending Deletion\*(R" status may be reactivated upon request. This function provides a way to automatically submit a reactivation request. When we receive your request, it will be processed by a member of our Domain Administration team. The domain will then be placed back on the \*(L"Live\*(R" status, and a registration or renewal invoice will be re-issed.

my $query = WWW::CNic->new( command => 'reactivate', domain => $domain, username => $handle, password => $password, );

$query->set('email', '[email protected]'); $query->set('period', 1); # renewal period in years

my $response = $query->execute;

if ($response->is_success) { print "Reactivation request accepted.\n";

} else { printf("Error: %s\n", $response->error);

}

If you specify an \*(C`email\*(C' parameter, our administrators will send a notification to that address. \*(C`period\*(C' may be any integer between 1 and 10.

Pushing a Domain Name To Another Registrar

You may request that a domain name on your account be \*(L"pushed\*(R" to another registrar account. A domain name may only be pushed if:

the domain name is on your account
there are no unpaid registration or renewal fees against it

my $query = WWW::CNic->new( command => 'push_domain', username => $handle, password => $password, domain => $domain, handle => $gaining_handle_id, );

my $response = $query->execute;

if ($response->is_success) { print "Domain transferred OK.\n";

} else { printf("Error: %s\n", $response->error);

}

If the transaction is successful, the domain name will be immediately removed from your account.

If you are also listed as Technical Contact for the domain name, then this handle will also be changed to the gaining registrar account.

This command will also transfer sponsorship of the client and/or technical handles for the domain name, but only if these handles are not associated with any other domains on your account. Where a handle is associated with domains on multiple registrar accounts, the handle becomes \*(L"unsponsored\*(R".

We will send an e-mail to the gaining registrar notifying them of the domain transfer.

Transferring Domain Names

Starting a Domain Transfer

You can start a transfer process for one or more domain names using the \*(C`start_transfer\*(C' command. However, there are \*(L"out-of-band\*(R" authorisations that must take place before a transfer is completed. The procedure for domain transfers is as follows:

1. The gaining registrar submits a transfer request. At this point, the transfer status is \*(C`new\*(C'.

2. Our system sees the new request and sends an authorisation message to the losing registrar. The status of the transfer is now \*(C`pending\*(C'.

3. The losing registrar may then explicitly approve or reject the transfer request within 5 days. The status of the transfer is now either \*(C`approved\*(C' or \*(C`rejected\*(C'.

4. If the transfer was rejected, the gaining registrar is notified.

5. If the transfer was approved, the object is transferred to the gaining registrar. If the Technical Contact for the domain name matches the losing registrar, then this is also changed to the gaining registrar.

6. If the transfer was not submitted with the \*(C`authinfo\*(C' parameter, and is not explicitly approved or rejected by the losing registrar within five calendar days, then the transfer is automatically marked as \*(C`rejected\*(C'. The transfer may still be actioned if the gaining registrar can acquire written authorisation (ideally on company letterhead) from the Registrant.

7. If the transfer was submitted with the \*(C`authinfo\*(C' parameter, and is not explicitly approved or rejected by the losing registrar within five calendar days, then the transfer is approved as per 5 above.

my $query = WWW::CNic->new( command => 'start_transfer', username => $handle, password => $password, );

$query->set(domains => ['example.uk.com']); $query->set(authinfo => ['abc123xyz']); # optional

my $response = $query->execute;

if ($response->is_success) { print "Transfer request has been accepted.";

} else { printf("Error: %s\n", $response->error);

}

Getting a List of Pending Transfers

my $query = WWW::CNic->new( use_ssl => 1, command => 'poll_transfers', username => $handle, password => $password, );

my $response = $query->execute;

if ($response->is_error) { printf("Error: %s\n", $response->error); }

foreach my $transfer ($response->transfers) { printf("Domain: %s\n", $transfer->{domain});

if ($transfer->{type} eq 'in') { printf("\tLosing handle: %s (email %s)\n", $transfer->{losing_id}, $transfer->{losing_email});

} elsif ($transfer->{type} eq 'out') { printf("\tGaining handle: %s (email %s)\n", $transfer->{gaining_id}, $transfer->{gaining_email});

}

printf( "\tTransfer initiated on %s\n", scalar(localtime($transfer->{initiated})) );

printf( "\tTransfer expires on on %s\n", scalar(localtime($transfer->{actiondate})) );

}

The \*(C`transfers()\*(C' method returns an array of hashrefs containing transfer information. If there are no transfers, then the array will be empty.

Cancelling a Domain Transfer

my $query = WWW::CNic->new( use_ssl => 1, command => 'cancel_transfer', username => $handle, password => $password, domain => 'example.uk.com', );

my $response = $query->execute;

if ($response->is_success) { print "Transfer cancelled.\n";

} else { printf("Error: %s\n", $response->error);

}

If you are the gaining registrar for a domain transfer, you can cancel the request before it is approved or rejected by the losing registrar. If the transfer has already been approved or rejected, then the server will return an error.

Checking the Status of a Domain Transfer

my $query = WWW::CNic->new( use_ssl => 1, command => 'check_transfer', username => $handle, password => $password, domain => 'example.uk.com', );

my $response = $query->execute;

if ($response->is_success) { printf("The transfer status of example.uk.com is '%s'\n", $response->status);

} else { printf("Error: %s\n", $response->error);

}

This lets you query the status of a domain name transfer. The returned status is a string and is one of: \*(C`pending\*(C', \*(C`cancelled\*(C', \*(C`approved\*(C', \*(C`rejected\*(C'. If there have been other transfer requests in the past, the server will return the status of the most recent one.

If there are no transfers for the domain name, or you are not the gaining handle, the server will return an error.

Approving a Domain Transfer

my $query = WWW::CNic->new( use_ssl => 1, command => 'approve_transfer', username => $handle, password => $password, domain => 'example.uk.com', );

my $response = $query->execute;

if ($response->is_success) { print "Transfer approved.\n";

} else { printf("Error: %s\n", $response->error);

}

If there are no transfers for the domain name, or you are not the losing handle, the server will return an error.

Rejecting a Domain Transfer

my $query = WWW::CNic->new( use_ssl => 1, command => 'reject_transfer', username => $handle, password => $password, domain => 'example.uk.com', );

my $response = $query->execute;

if ($response->is_success) { print "Transfer rejected.\n";

} else { printf("Error: %s\n", $response->error);

}

If there are no transfers for the domain name, or you are not the losing handle, the server will return an error.

Account Management

Getting a List of Upcoming Renewals

use WWW::CNic; use POSIX qw(strftime);

my $months = 3;

my $query = WWW::CNic->new( use_ssl => 1, command => 'renewals', username => $handle, password => $passwd, months => $months );

my $response = $query->execute;

if ($response->is_success) { foreach my $domain ($response->domains) { printf( "Domain %s expires on %s and will cost %01.2f", $domain, strftime('%d/%m/%Y', localtime($response->expiry($domain))), $response->amount($domain) ); }

} else { printf("Error, couldn't get list of upcoming renewals: %s\n", $response->error);

}

This command lets you retrieve a list of domain names due for renewal in the last $months months. You can use the \*(C`amount\*(C' and \*(C`expiry\*(C' methods to retrieve the renewal price and expiry date for each domain.

Getting a Domain List

use WWW::CNic; use POSIX qw(strftime);

my $query = WWW::CNic->new( use_ssl => 1, command => 'list_domains', username => $handle, password => $passwd, );

$query->set( offset => 5, length => 10, orderby => 'name' );

my $response = $query->execute;

if ($response->is_success) { foreach my $domain ($response->domains) { printf( "%s: %s - %s (%s)\n", $domain, strftime('%d/%m/%Y', localtime($response->regdate($domain))), strftime('%d/%m/%Y', localtime($response->expirydate($domain))), $response->status($domain), ); }

} else { printf("Error: %s\n", $response->error);

}

You can use this command to retrieve a list of domains against your handle. The response object returned has methods allowing the retrieval of the registration date and expiry date and status. The \*(C`offset\*(C' and \*(C`length\*(C' parameters work in the SQL-ish way you'd expect. The \*(C`orderby\*(C' parameter can be \*(C`name\*(C', \*(C`regdate\*(C' or \*(C`expirydate\*(C'.

Getting Pricing Information

use WWW::CNic; use strict;

my $query = WWW::CNic->new( use_ssl => 1, command => 'get_pricing', username => $handle, password => $password, );

$query->set(type => 'renewal');

my $response = $query->execute;

if ($response->is_success) { printf("the price we pay for renewals of uk.com domains is %.2f\n", $response->response('uk.com'));

} else { printf("Error: %s\n", $response->error);

}

This command allows you to retrieve pricing information for your registrar account. You must specify a \*(C`type\*(C' parameter, which can be either '\*(C`registration\*(C'' (the default) or '\*(C`renewal\*(C''.

Listing Outstanding Domains

use WWW::CNic; use strict;

my $query = WWW::CNic->new( use_ssl => 1, command => 'list_outstanding_domains', username => $handle, password => $password, );

my $response = $query->execute;

if ($response->is_error) { printf("Error: %s\n", $response->error); }

foreach my $domain ($response->domains) { printf( "Domain: %s\n". "\tExpired: %s\n". "\tDocument: %s #%d\n". "\tIssued on: %s\n". "\tAmount: %s%01.2f\n". "\tType: %s\n". "\tYears: %s\n". "\tBatch: %d\n\n", $domain->{domain}, $domain->{expiry}, ($domain->{invoice} > 0 ? 'Invoice' : 'Pro forma'), ($domain->{invoice} > 0 ? $domain->{invoice} : $domain->{proforma}), $domain->{date}, $domain->{currency}, $domain->{amount}, $domain->{type}, $domain->{years}, $domain->{batch}, ); }

This command retrieves a list of all unpaid invoice items for domain names on your account. Each registration or renewal causes on item to be added to an invoice (or pro forma invoice for VAT-paying registrars).

You can combine this function with the one below to automatically submit payment advice for invoices (you still need to send us the actual money!).

Submitting Payment Advice

use WWW::CNic; use strict;

my $query = WWW::CNic->new( use_ssl => 1, command => 'submit_payment_batch', username => $handle, password => $password, );

$query->set('method', 'CH'); # CH for a cheque, BA for a bank transfer $query->set('domains', \@domains);

my $response = $query->execute;

if ($response->is_error) { printf("Error: %s\n", $response->error); }

printf( "Payment Batch #%d created for %d items at %s%01.2f (plus %s%01.2f VAT)\n", $response->response('batch'), $response->response('items'), $response->response('currency'), $response->response('amount'), $response->response('currency'), $response->response('vat'), );

You can use this function to submit advice about a payment for outstanding domain registrations and renewals. Combining this function with the function above allows you to retrieve a list of outstanding domain names, filter them based on whether or not you've received payment or a deletion request from your customer, and generate a payment batch that can be associated with a cheque or wire transfer issued by your company.

Please note that you will need to factor in the amount of \s-1VAT\s0 (if applicable) - this amount is available in the response object.

Feedback

We're always keen to find out about how people are using our Toolkit system, and we're happy to accept any comments, suggestions or problems you might have. If you want to get in touch, please e-mail [email protected].

Copyright

This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See Also

  • <http://toolkit.centralnic.com/>

  • WWW::CNic

  • WWW::CNic::Simple