feat: add payment method support for domain registration

Extended the EPP registrar module to include payment method fields `card_id` and `card_cvc`, allowing for direct payment processing during domain registration and renewal processes. This update enables more streamlined transactions by incorporating payment details directly within the domain provisioning workflow, addressing previous limitations that required separate payment handling.

This change introduces new configuration options for storing payment method details securely and modifies the domain registration and renewal XML requests to include these details as per the updated EPP standard. Ensure proper handling and storage of these sensitive details in compliance with applicable security standards.
This commit is contained in:
Kumi 2024-05-19 18:40:15 +02:00
parent 66c0c8e0e6
commit 0047b66f53
Signed by: kumi
GPG key ID: ECBCC9082395383F

188
ISNIC.php
View file

@ -1,4 +1,5 @@
<?php
/**
* Indera EPP registrar module for FOSSBilling (https://fossbilling.org/)
*
@ -16,35 +17,41 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
public function __construct($options)
{
if(isset($options['username'])) {
if (isset($options['username'])) {
$this->config['username'] = $options['username'];
}
if(isset($options['password'])) {
if (isset($options['password'])) {
$this->config['password'] = $options['password'];
}
if(isset($options['host'])) {
if (isset($options['host'])) {
$this->config['host'] = $options['host'];
}
if(isset($options['port'])) {
if (isset($options['port'])) {
$this->config['port'] = $options['port'];
}
if(isset($options['registrarprefix'])) {
if (isset($options['registrarprefix'])) {
$this->config['registrarprefix'] = $options['registrarprefix'];
}
if(isset($options['ssl_cert'])) {
if (isset($options['ssl_cert'])) {
$this->config['ssl_cert'] = $options['ssl_cert'];
}
if(isset($options['ssl_key'])) {
if (isset($options['ssl_key'])) {
$this->config['ssl_key'] = $options['ssl_key'];
}
if(isset($options['ssl_ca'])) {
if (isset($options['ssl_ca'])) {
$this->config['ssl_ca'] = $options['ssl_ca'];
}
if(isset($options['use_tls_12'])) {
if (isset($options['use_tls_12'])) {
$this->config['use_tls_12'] = (bool)$options['use_tls_12'];
} else {
$this->config['use_tls_12'] = false;
}
if (isset($options['card_id'])) {
$this->config['card_id'] = $options['card_id'];
}
if (isset($options['card_cvc'])) {
$this->config['card_cvc'] = $options['card_cvc'];
}
}
public function getTlds()
@ -57,52 +64,73 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
return array(
'label' => 'An EPP registry module allows registrars to manage and register domain names using the Extensible Provisioning Protocol (EPP). All details below are typically provided by the domain registry and are used to authenticate your account when connecting to the EPP server.',
'form' => array(
'username' => array('text', array(
'username' => array(
'text', array(
'label' => 'EPP Server Username',
'required' => true,
),
),
'password' => array('password', array(
'password' => array(
'password', array(
'label' => 'EPP Server Password',
'required' => true,
'renderPassword' => true,
),
),
'host' => array('text', array(
'host' => array(
'text', array(
'label' => 'EPP Server Host',
'required' => true,
),
),
'port' => array('text', array(
'port' => array(
'text', array(
'label' => 'EPP Server Port',
'required' => true,
),
),
'registrarprefix' => array('text', array(
'registrarprefix' => array(
'text', array(
'label' => 'Registrar Prefix',
'required' => true,
),
),
'ssl_cert' => array('text', array(
'ssl_cert' => array(
'text', array(
'label' => 'SSL Certificate Path',
'required' => true,
),
),
'ssl_key' => array('text', array(
'ssl_key' => array(
'text', array(
'label' => 'SSL Key Path',
'required' => true,
),
),
'ssl_ca' => array('text', array(
'ssl_ca' => array(
'text', array(
'label' => 'SSL CA Path',
'required' => false,
),
),
'use_tls_12' => array('radio', array(
'multiOptions' => array('1'=>'Yes', '0'=>'No'),
'use_tls_12' => array(
'radio', array(
'multiOptions' => array('1' => 'Yes', '0' => 'No'),
'label' => 'Use TLS 1.2 instead of 1.3',
),
),
'card_id' => array(
'text', array(
'label' => 'Card ID of the payment method',
'required' => true,
),
),
'card_cvc' => array(
'text', array(
'label' => 'Card CVC',
'required' => true,
),
),
),
);
}
@ -122,7 +150,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$from[] = '/{{ name }}/';
$to[] = htmlspecialchars($domain->getName());
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1) , 3));
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->config['registrarprefix'] . '-domain-check-' . $clTRID);
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
@ -144,14 +172,12 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->chkData;
$reason = (string)$r->cd[0]->reason;
if ($reason)
{
if ($reason) {
return false;
} else {
return true;
}
if (!empty($s))
{
if (!empty($s)) {
$this->logout();
}
@ -194,7 +220,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
$add = $rem = array();
$i = 0;
foreach($r->ns->hostObj as $ns) {
foreach ($r->ns->hostObj as $ns) {
$i++;
$ns = (string)$ns;
if (!$ns) {
@ -221,15 +247,15 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
if (!empty($add) || !empty($rem)) {
$from = $to = array();
$text = '';
foreach($add as $k => $v) {
$text.= '<domain:hostObj>' . $v . '</domain:hostObj>' . "\n";
foreach ($add as $k => $v) {
$text .= '<domain:hostObj>' . $v . '</domain:hostObj>' . "\n";
}
$from[] = '/{{ add }}/';
$to[] = (empty($text) ? '' : "<domain:add><domain:ns>\n{$text}</domain:ns></domain:add>\n");
$text = '';
foreach($rem as $k => $v) {
$text.= '<domain:hostObj>' . $v . '</domain:hostObj>' . "\n";
foreach ($rem as $k => $v) {
$text .= '<domain:hostObj>' . $v . '</domain:hostObj>' . "\n";
}
$from[] = '/{{ rem }}/';
@ -258,9 +284,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -309,9 +333,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->trnData;
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -381,9 +403,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$domain->setNs2(isset($ns[1]) ? $ns[1] : '');
$domain->setNs3(isset($ns[2]) ? $ns[2] : '');
$domain->setNs4(isset($ns[3]) ? $ns[3] : '');
}
catch(exception $e) {
} catch (exception $e) {
$domain = array(
'error' => $e->getMessage()
);
@ -424,9 +444,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</command>
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -441,7 +459,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
public function registerDomain(Registrar_Domain $domain)
{
$this->getLog()->debug('Registering domain: ' . $domain->getName(). ' for '.$domain->getRegistrationPeriod(). ' years');
$this->getLog()->debug('Registering domain: ' . $domain->getName() . ' for ' . $domain->getRegistrationPeriod() . ' years');
$client = $domain->getContactRegistrar();
$return = array();
@ -500,7 +518,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$from[] = '/{{ country }}/';
$to[] = htmlspecialchars($client->getCountry());
$from[] = '/{{ phonenumber }}/';
$to[] = htmlspecialchars('+'.$client->getTelCc().'.'.$client->getTel());
$to[] = htmlspecialchars('+' . $client->getTelCc() . '.' . $client->getTel());
$from[] = '/{{ email }}/';
$to[] = htmlspecialchars($client->getEmail());
$from[] = '/{{ authInfo }}/';
@ -605,28 +623,28 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$to[] = htmlspecialchars($domain->getName());
$from[] = '/{{ period }}/';
$to[] = htmlspecialchars($domain->getRegistrationPeriod());
if($domain->getNs1()) {
if ($domain->getNs1()) {
$from[] = '/{{ ns1 }}/';
$to[] = htmlspecialchars($domain->getNs1());
} else {
$from[] = '/{{ ns1 }}/';
$to[] = '';
}
if($domain->getNs2()) {
if ($domain->getNs2()) {
$from[] = '/{{ ns2 }}/';
$to[] = htmlspecialchars($domain->getNs2());
} else {
$from[] = '/{{ ns2 }}/';
$to[] = '';
}
if($domain->getNs3()) {
if ($domain->getNs3()) {
$from[] = '/{{ ns3 }}/';
$to[] = htmlspecialchars($domain->getNs3());
} else {
$from[] = '/{{ ns3 }}/';
$to[] = '';
}
if($domain->getNs4()) {
if ($domain->getNs4()) {
$from[] = '/{{ ns4 }}/';
$to[] = htmlspecialchars($domain->getNs4());
} else {
@ -673,13 +691,17 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</domain:authInfo>
</domain:create>
</create>
<extension>
<is-ext-domain:create>
<is-ext-domain:cardID>{{ card_id }}</is-ext-domain:cardID>
<is-ext-domain:cardCVC>{{ card_cvc }}</is-ext-domain:cardCVC>
</is-ext-domain:create>
</extension>
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -745,13 +767,17 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
<domain:period unit="y">1</domain:period>
</domain:renew>
</renew>
<extension>
<is-ext-domain:renew>
<is-ext-domain:cardID>{{ card_id }}</is-ext-domain:cardID>
<is-ext-domain:cardCVC>{{ card_cvc }}</is-ext-domain:cardCVC>
</is-ext-domain:renew>
</extension>
<clTRID>{{ clTRID }}</clTRID>
</command>
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -816,7 +842,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$from[] = '/{{ country }}/';
$to[] = htmlspecialchars($client->getCountry());
$from[] = '/{{ phonenumber }}/';
$to[] = htmlspecialchars('+'.$client->getTelCc().'.'.$client->getTel());
$to[] = htmlspecialchars('+' . $client->getTelCc() . '.' . $client->getTel());
$from[] = '/{{ email }}/';
$to[] = htmlspecialchars($client->getEmail());
$from[] = '/{{ clTRID }}/';
@ -853,9 +879,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</command>
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -900,13 +924,13 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
$dcontact = array();
$dcontact['registrant'] = (string)$r->registrant;
foreach($r->contact as $e) {
foreach ($r->contact as $e) {
$type = (string)$e->attributes()->type;
$dcontact[$type] = (string)$e;
}
$contact = array();
foreach($dcontact as $id) {
foreach ($dcontact as $id) {
if (isset($contact[$id])) {
continue;
}
@ -916,7 +940,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$from[] = '/{{ flag }}/';
$to[] = 1;
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1) , 3));
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->config['registrarprefix'] . '-contact-update-' . $clTRID);
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
@ -943,9 +967,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -990,13 +1012,13 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
$dcontact = array();
$dcontact['registrant'] = (string)$r->registrant;
foreach($r->contact as $e) {
foreach ($r->contact as $e) {
$type = (string)$e->attributes()->type;
$dcontact[$type] = (string)$e;
}
$contact = array();
foreach($dcontact as $id) {
foreach ($dcontact as $id) {
if (isset($contact[$id])) {
continue;
}
@ -1006,7 +1028,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$from[] = '/{{ flag }}/';
$to[] = 0;
$from[] = '/{{ clTRID }}/';
$clTRID = str_replace('.', '', round(microtime(1) , 3));
$clTRID = str_replace('.', '', round(microtime(1), 3));
$to[] = htmlspecialchars($this->config['registrarprefix'] . '-contact-update-' . $clTRID);
$xml = preg_replace($from, $to, '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
@ -1033,9 +1055,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -1084,9 +1104,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$this->logout();
}
return $eppcode;
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -1130,7 +1148,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $this->write($xml, __FUNCTION__);
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
$status = array();
foreach($r->status as $e) {
foreach ($r->status as $e) {
$st = (string)$e->attributes()->s;
if (!preg_match("/^client.+Prohibited$/i", $st)) {
continue;
@ -1140,7 +1158,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
$add = array();
foreach(array(
foreach (array(
'clientUpdateProhibited',
'clientDeleteProhibited',
'clientTransferProhibited'
@ -1152,8 +1170,8 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
if (!empty($add)) {
$text = '';
foreach($add as $st) {
$text.= '<domain:status s="' . $st . '" lang="en"></domain:status>' . "\n";
foreach ($add as $st) {
$text .= '<domain:status s="' . $st . '" lang="en"></domain:status>' . "\n";
}
$from[] = '/{{ add }}/';
$to[] = (empty($text) ? '' : "<domain:add>\n{$text}</domain:add>\n");
@ -1180,9 +1198,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -1226,7 +1242,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
$r = $this->write($xml, __FUNCTION__);
$r = $r->response->resData->children('urn:ietf:params:xml:ns:domain-1.0')->infData;
$status = array();
foreach($r->status as $e) {
foreach ($r->status as $e) {
$st = (string)$e->attributes()->s;
if (!preg_match("/^client.+Prohibited$/i", $st)) {
continue;
@ -1236,7 +1252,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
}
$rem = array();
foreach(array(
foreach (array(
'clientUpdateProhibited',
'clientDeleteProhibited',
'clientTransferProhibited'
@ -1248,8 +1264,8 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
if (!empty($rem)) {
$text = '';
foreach($rem as $st) {
$text.= '<domain:status s="' . $st . '" lang="en"></domain:status>' . "\n";
foreach ($rem as $st) {
$text .= '<domain:status s="' . $st . '" lang="en"></domain:status>' . "\n";
}
$from[] = '/{{ rem }}/';
$to[] = (empty($text) ? '' : "<domain:rem>\n{$text}</domain:rem>\n");
@ -1276,9 +1292,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
</epp>');
$r = $this->write($xml, __FUNCTION__);
}
}
catch(exception $e) {
} catch (exception $e) {
$return = array(
'error' => $e->getMessage()
);
@ -1313,7 +1327,7 @@ class Registrar_Adapter_ISNIC extends Registrar_AdapterAbstract
} else {
$tls = 'tlsv1.3';
}
$this->socket = stream_socket_client($tls."://{$host}:{$port}", $errno, $errmsg, $timeout, STREAM_CLIENT_CONNECT, $context);
$this->socket = stream_socket_client($tls . "://{$host}:{$port}", $errno, $errmsg, $timeout, STREAM_CLIENT_CONNECT, $context);
if (!$this->socket) {
throw new exception("Cannot connect to server '{$host}': {$errmsg}");