Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/Net/DRI/Protocol/EPP/Extensions/CentralNic/Fee.pm
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,16 @@ sub fee_set_parse
} elsif ($name eq 'fee')
# Fees are kind of loosely defined based on free text description field with refundable also possible. This will total it up and concat the description and refundable fields but its only human readable
{
$set->{fee} = 0 unless exists $set->{fee};
$set->{fee} += $content->textContent();
$set->{fee} = '0.00' unless exists $set->{fee};
$set->{fee} = sprintf("%.2f", ($set->{'fee'} + $content->textContent())); # wasn't appending x.00 for some reason. Using this way to avoid such problem :p
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could use a perl module to check the numbre of decimal points based on currency?

$set->{description} = '' unless exists $set->{description};
if ($content->hasAttribute('description'))
{
$set->{description} = "\n" . $content->getAttribute('description');
my $d = lc $content->getAttribute('description');
$d =~ s/ /_/g;
$d = 'early_access_fee' if $d =~ m/early_access/;
$set->{"fee_$d"} = 0 + $content->textContent();
$set->{"fee_$d"} = $content->textContent();
}
if ($content->hasAttribute('refundable') && $content->getAttribute('refundable') eq '1') {
$set->{description} .= "Refundable"; #TODO remove in regext-fee (0.12?), the description shold not contain these
Expand Down Expand Up @@ -536,7 +536,7 @@ sub transform_parse
} elsif ($name =~ m/^(fee|balance|creditLimit)/)
{
my $k= ($1 eq 'creditLimit') ? 'credit_limit' : $1;
$p{$k}=0+$content->textContent();
$p{$k}=$content->textContent();
}
}
$rinfo->{domain}->{$oname}->{fee}=\%p;
Expand Down
10 changes: 5 additions & 5 deletions lib/Net/DRI/Protocol/EPP/Extensions/Fee.pm
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,16 @@ sub fee_element_parse
return unless $content;
# Fees are kind of loosely defined based on free text description field with refundable, applied, grace-period also possible.
# The main fee is the total of them all, its not necessarily correct, but there you have it.
$set->{fee} = 0 unless exists $set->{fee};
$set->{fee} += $content->textContent();
$set->{fee} = '0.00' unless exists $set->{fee};
$set->{fee} = sprintf("%.2f", ($set->{'fee'} + $content->textContent())); # wasn't appending x.00 for some reason. Using this way to avoid such problem :p
my $d = 'default';
if ($content->hasAttribute('description'))
{
$set->{description} = (!$set->{description} ? '' : $set->{description} . ",") . $content->getAttribute('description');
$d = lc $content->getAttribute('description');
$d =~ s/ /_/g;
$d = 'early_access_fee' if $d =~ m/early_access/;
$set->{"fee_$d"} = 0 + $content->textContent();
$set->{"fee_$d"} = $content->textContent();
$set->{$d}->{description} = $content->getAttribute('description');
push @{$set->{fee_types}}, $d;
}
Expand All @@ -283,7 +283,7 @@ sub fee_element_parse
$set->{applied} = $content->getAttribute('applied');
$set->{$d}->{applied} = $content->getAttribute('applied');
}
$set->{$d}->{fee} = 0+$content->textContent();
$set->{$d}->{fee} = $content->textContent();
return;
}

Expand Down Expand Up @@ -486,7 +486,7 @@ sub transform_parse
} elsif ($name =~ m/^(fee|balance|creditLimit|credit)/)
{
my $k= ($1 eq 'creditLimit') ? 'credit_limit' : $1;
$p{$k}=0+$content->textContent();
$p{$k}=$content->textContent();
$p{'description'} = $content->getAttribute('description') if $content->hasAttribute('description');
}
}
Expand Down
6 changes: 3 additions & 3 deletions t/Net/DRI/Protocol/EPP/Extensions/AFNIC_gTLD.t
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ is($d->{domain},'foobar.paris','domain_check get_info(domain)');
is($d->{price_avail},1,'domain_check parse fee (price_avail)');
is($d->{premium},0,'domain_check parse premium');
is($d->{currency},'USD','domain_check get_info(currency)');
is($d->{command}->{create}->{fee_registration_fee},10.00,'domain_check get_info(fee_registration_fee)');
is($d->{command}->{create}->{fee_application_fee},500.00,'domain_check get_info(fee_application_fee)');
is($d->{command}->{create}->{fee},510.00,'domain_check get_info(fee)'); # fees are added together for the total. this is debateable!
is($d->{command}->{create}->{fee_registration_fee},'10.00','domain_check get_info(fee_registration_fee)');
is($d->{command}->{create}->{fee_application_fee},'500.00','domain_check get_info(fee_application_fee)');
is($d->{command}->{create}->{fee},'510.00','domain_check get_info(fee)'); # fees are added together for the total. this is debateable!
is($d->{command}->{create}->{description},'Registration Fee (Refundable) (Grace=>P5D),Application Fee (Applied=>immediate)','domain_check get_info(description)'); # descriptions melded into a string
is($d->{command}->{create}->{phase},'sunrise','domain_check get_info(phase)');
is($d->{command}->{create}->{sub_phase},undef,'domain_check get_info(sub_phase)');
Expand Down
35 changes: 17 additions & 18 deletions t/Net/DRI/Protocol/EPP/Extensions/CentralNic/Fee-0.11.t
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ is($d->{action},'create','domain_check multi get_info(action) 1/4');
is($d->{phase},'sunrise','domain_check multi get_info(phase) 1/4');
is($d->{sub_phase},undef,'domain_check multi get_info(sub_phase) 1/4');
#is($d->{duration}->years(),'1','domain_check multi get_info(duration) 1/4');
is($d->{fee},5.00,'domain_check multi get_info(fee) 1/4');
#is($d->{fee_application_fee},5.00,'domain_check multi parse fee (fee_application_fee) 1/4');
is($d->{fee_registration_fee},5.00,'domain_check multi parse fee (fee_registration_fee) 1/4');
is($d->{fee},'5.00','domain_check multi get_info(fee) 1/4');
is($d->{fee_registration_fee},'5.00','domain_check multi parse fee (fee_registration_fee) 1/4');
is($d->{grace_period},'P5D','domain_check multi parse fee (grace_period) 1/4');
is($d->{refundable},'1','domain_check multi parse fee (refundable) 1/4');
$d = shift @{$dri->get_info('fee','domain','holidays.space')};
Expand All @@ -84,7 +83,7 @@ is($d->{action},'create','domain_check multi get_info(action) 2/4');
is($d->{phase},'claims','domain_check multi get_info(phase) 2/4');
is($d->{sub_phase},'landrush','domain_check multi get_info(sub_phase) 2/4');
is($d->{duration}->years(),'2','domain_check multi get_info(duration) 2/4');
is($d->{fee},5.00,'domain_check multi get_info(fee) 2/4');
is($d->{fee},'5.00','domain_check multi get_info(fee) 2/4');
$d = shift @{$dri->get_info('fee','domain','hotels.space')};
is($d->{domain},'hotels.space','domain_check multi get_info(domain) 3/4');
is($d->{premium},0,'domain_check multi parse premium 3/4');
Expand All @@ -99,9 +98,9 @@ is($d->{reason},'minimum period is 2 years.','domain_check multi parse fee (reas
# Note: we can no longer check different types in one command - so create only here
is($dri->get_info('is_premium','domain','hotels.space'),0,'domain_check_multi get_info (is_premium) undef');
is($dri->get_info('price_duration','domain','tourism.space')->years(),1,'domain_check get_info (price_duration)');
is($dri->get_info('create_price','domain','holidays.space'),5.00,'domain_check_multi get_info (create_price)');
#is($dri->get_info('transfer_price','domain','hotels.space'),12.50,'domain_check_multi get_info (transfer_price)');
#is($dri->get_info('restore_price','domain','restaurants.space'),25,'domain_check_multi get_info (restore_price)');
is($dri->get_info('create_price','domain','holidays.space'),'5.00','domain_check_multi get_info (create_price)');
#is($dri->get_info('transfer_price','domain','hotels.space'),'12.50','domain_check_multi get_info (transfer_price)');
#is($dri->get_info('restore_price','domain','restaurants.space'),'25.00','domain_check_multi get_info (restore_price)');

####################################################################################################
### Copied From fee-0.9 tests an manually adjusted
Expand All @@ -119,9 +118,9 @@ is($d->{premium},1,'Fee extension: domain_check single parse premium');
is($d->{class},'premium','Fee extension: domain_check single parse class');
is($d->{currency},'EUR','Fee extension: domain_check single parse currency');
is($d->{action},'renew','Fee extension: domain_check single parse action');
is($d->{duration}->years(),2,'Fee extension: domain_check singe parse duration');
is($d->{duration}->years(),2,'Fee extension: domain_check single parse duration');
is($d->{grace_period},'P5D','domain_check multi single fee (grace_period) 1/4');
is($d->{fee},650.00,'Fee extension: domain_check single parse fee');
is($d->{fee},'650.00','Fee extension: domain_check single parse fee');


$dri->cache_clear();
Expand All @@ -137,8 +136,8 @@ is($d->{premium},1,'Fee extension: domain_check_price single parse premium');
is($d->{currency},'USD','Fee extension: domain_check_price single parse currency');
is($d->{action},'create','Fee extension: domain_check_price single parse action');
is($d->{duration}->years(),2,'Fee extension: domain_check_price single parse duration');
is($d->{fee_registration_fee},5000.00,'Fee extension: domain_check_price single parse fee (fee_registration_fee)');
is($d->{fee},5000.00,'Fee extension: domain_check_price single parse fee');
is($d->{fee_registration_fee},'5000.00','Fee extension: domain_check_price single parse fee (fee_registration_fee)');
is($d->{fee},'5000.00','Fee extension: domain_check_price single parse fee');
is($d->{phase},'sunrise','Fee extension: domain_check_price single parse phase');

# using the standardised methods
Expand All @@ -148,10 +147,10 @@ isa_ok($dri->get_info('price_duration'),'DateTime::Duration','domain_check get_i
is($dri->get_info('price_duration')->years(),2,'domain_check get_info (price_duration)');
is($dri->get_info('price_currency'),'USD','domain_check get_info (price_currency)');
is($dri->get_info('price_category'),'premium','domain_check get_info (price_currency)');
is($dri->get_info('create_price'),5000,'domain_check get_info (create_price)');
#is($dri->get_info('renew_price'),9.95,'domain_check get_info (renew_price) undef');
#is($dri->get_info('transfer_price'),9.95,'domain_check get_info (transfer_price) undef');
#is($dri->get_info('restore_price'),9.95,'domain_check get_info (restore_price) undef');
is($dri->get_info('create_price'),'5000.00','domain_check get_info (create_price)');
#is($dri->get_info('renew_price'),'9.95','domain_check get_info (renew_price) undef');
#is($dri->get_info('transfer_price'),'9.95','domain_check get_info (transfer_price) undef');
#is($dri->get_info('restore_price'),'9.95','domain_check get_info (restore_price) undef');

## domain create
$R2=$E1.'<response>'.r().'<resData><domain:creData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd"><domain:name>exdomain.space</domain:name><domain:crDate>1999-04-03T22:00:00.0Z</domain:crDate><domain:exDate>2001-04-03T22:00:00.0Z</domain:exDate></domain:creData></resData><extension><fee:creData xmlns:fee="urn:ietf:params:xml:ns:fee-0.11" xsi:schemaLocation="urn:ietf:params:xml:ns:fee-0.11 fee-0.11.xsd"><fee:currency>USD</fee:currency><fee:period unit="y">1</fee:period><fee:fee>5.00</fee:fee><fee:balance>-5.00</fee:balance><fee:creditLimit>1000.00</fee:creditLimit></fee:creData></extension>'.$TRID.'</response>'.$E2;
Expand All @@ -167,9 +166,9 @@ is($rc->is_success(),1,'domain_create is is_success');
is($dri->get_info('action'),'create','domain_create get_info (action)');
$d=$rc->get_data('fee');
is($d->{currency},'USD','Fee extension: domain_create parse currency');
is($d->{fee},5.00,'Fee extension: domain_create parse fee');
is($d->{balance},-5.00,'Fee extension: domain_create parse balance');
is($d->{credit_limit},1000.00,'Fee extension: domain_create parse credit limit');
is($d->{fee},'5.00','Fee extension: domain_create parse fee');
is($d->{balance},'-5.00','Fee extension: domain_create parse balance');
is($d->{credit_limit},'1000.00','Fee extension: domain_create parse credit limit');

####################################################################################################
exit 0;
16 changes: 8 additions & 8 deletions t/Net/DRI/Protocol/EPP/Extensions/CentralNic/Fee-0.4.t
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ $d = shift @{$dri->get_info('fee')};
is($d->{domain},'example.wiki','Fee extension: domain_check single parse domain');
is($d->{currency},'EUR','Fee extension: domain_check single parse currency');
is($d->{action},'transfer','Fee extension: domain_check single parse action');
is($d->{duration}->years(),2,'Fee extension: domain_check singe parse duration');
is($d->{fee},'2.50','Fee extension: domain_check singe parse fee');
is($d->{duration}->years(),2,'Fee extension: domain_check single parse duration');
is($d->{fee},'2.50','Fee extension: domain_check single parse fee');
$R2=$E1.'<response>'.r().'<resData><domain:chkData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"><domain:cd><domain:name avail="0">example.bar</domain:name><domain:reason>In use</domain:reason></domain:cd></domain:chkData></resData><extension><fee:chkData xmlns:fee="urn:ietf:params:xml:ns:fee-0.4"><fee:domain>example.bar</fee:domain><fee:currency>EUR</fee:currency><fee:action phase="claims" subphase="landrush">create</fee:action><fee:period unit="y">2</fee:period><fee:fee>5.00</fee:fee></fee:chkData></extension>'.$TRID.'</response>'.$E2;
$rc=$dri->domain_check('example.bar',{fee=>{currency=>'EUR',action=>'create',phase=>'claims',sub_phase=>'landrush',duration=>$dri->local_object('duration','years',2)}});
is_string($R1,$E1.'<command><check><domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd"><domain:name>example.bar</domain:name></domain:check></check><extension><fee:check xmlns:fee="urn:ietf:params:xml:ns:fee-0.4" xsi:schemaLocation="urn:ietf:params:xml:ns:fee-0.4 fee-0.4.xsd"><fee:domain>example.bar</fee:domain><fee:currency>EUR</fee:currency><fee:action phase="claims" subphase="landrush">create</fee:action><fee:period unit="y">2</fee:period></fee:check></extension><clTRID>ABC-12345</clTRID></command>'.$E2,'Fee extension: domain_check build');
Expand All @@ -63,8 +63,8 @@ is($d->{currency},'EUR','Fee extension: domain_check single parse currency');
is($d->{action},'create','Fee extension: domain_check single parse action');
is($d->{phase},'claims','Fee extension: domain_check single parse phase');
is($d->{sub_phase},'landrush','Fee extension: domain_check single parse sub_phase');
is($d->{duration}->years(),2,'Fee extension: domain_check singe parse duration');
is($d->{fee},'5.00','Fee extension: domain_check singe parse fee');
is($d->{duration}->years(),2,'Fee extension: domain_check single parse duration');
is($d->{fee},'5.00','Fee extension: domain_check single parse fee');
# using the standardised methods
is($dri->get_info('is_premium'),undef,'domain_check get_info (is_premium) undef'); # NOT SUPPORTED
isa_ok($dri->get_info('price_duration'),'DateTime::Duration','domain_check get_info (price_duration) is DateTime::Duration');
Expand Down Expand Up @@ -215,7 +215,7 @@ is($rc->is_success(),1,'domain_create is is_success');
is($dri->get_info('action'),'create','domain_create get_info (action)');
$d=$rc->get_data('fee');
is($d->{currency},'USD','Fee extension: domain_create parse currency');
is($d->{fee},5.00,'Fee extension: domain_create parse fee');
is($d->{fee},'5.00','Fee extension: domain_create parse fee');

## Renew
$R2=$E1.'<response>'.r().'<resData><domain:renData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd"><domain:name>example.space</domain:name><domain:exDate>2005-04-03T22:00:00.0Z</domain:exDate></domain:renData></resData><extension><fee:renData xmlns:fee="urn:ietf:params:xml:ns:fee-0.4" xsi:schemaLocation="urn:ietf:params:xml:ns:fee-0.4 fee-0.4.xsd"><fee:currency>USD</fee:currency><fee:fee>5.00</fee:fee></fee:renData></extension>'.$TRID.'</response>'.$E2;
Expand All @@ -224,7 +224,7 @@ is_string($R1,$E1.'<command><renew><domain:renew xmlns:domain="urn:ietf:params:x
is($rc->is_success(),1,'domain_renew is is_success');
$d=$rc->get_data('fee');
is($d->{currency},'USD','Fee extension: domain_renew parse currency');
is($d->{fee},5.00,'Fee extension: domain_renew parse fee');
is($d->{fee},'5.00','Fee extension: domain_renew parse fee');

## Transfer
$R2=$E1.'<response>'.r().'<resData><domain:trnData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd"><domain:name>example.space</domain:name><domain:trStatus>pending</domain:trStatus><domain:reID>ClientX</domain:reID><domain:reDate>2000-06-08T22:00:00.0Z</domain:reDate><domain:acID>ClientY</domain:acID><domain:acDate>2000-06-13T22:00:00.0Z</domain:acDate><domain:exDate>2002-09-08T22:00:00.0Z</domain:exDate></domain:trnData></resData><extension><fee:trnData xmlns:fee="urn:ietf:params:xml:ns:fee-0.4" xsi:schemaLocation="urn:ietf:params:xml:ns:fee-0.4 fee-0.4.xsd"><fee:currency>USD</fee:currency><fee:fee>5.00</fee:fee></fee:trnData></extension>'.$TRID.'</response>'.$E2;
Expand All @@ -233,7 +233,7 @@ is_string($R1,$E1.'<command><transfer op="request"><domain:transfer xmlns:domain
is($rc->is_success(),1,'domain_transfer is is_success');
$d=$rc->get_data('fee');
is($d->{currency},'USD','Fee extension: domain_transfer parse currency');
is($d->{fee},5.00,'Fee extension: domain_transfer parse fee');
is($d->{fee},'5.00','Fee extension: domain_transfer parse fee');

## Update
$R2=$E1.'<response>'.r().'<extension><fee:updData xmlns:fee="urn:ietf:params:xml:ns:fee-0.4" xsi:schemaLocation="urn:ietf:params:xml:ns:fee-0.4 fee-0.4.xsd"><fee:currency>USD</fee:currency><fee:fee>5.00</fee:fee></fee:updData></extension>'.$TRID.'</response>'.$E2;
Expand All @@ -245,7 +245,7 @@ is_string($R1,$E1.'<command><update><domain:update xmlns:domain="urn:ietf:params
is($rc->is_success(),1,'domain_update is is_success');
$d=$rc->get_data('fee');
is($d->{currency},'USD','Fee extension: domain_transfer parse currency');
is($d->{fee},5.00,'Fee extension: domain_transfer parse fee');
is($d->{fee},'5.00','Fee extension: domain_transfer parse fee');
### END: EPP Transform Commands ###
####################################################################################################

Expand Down
Loading