/** * Once a DID has been purchased and payment has been received from the customer, this * function then asks the DID provider to actually provision the DID to us. */ function purchase() { require_once PATH_MODULES . "voip_did_plugin/voip_did_plugin.inc.php"; $plugin = new voip_did_plugin(); $plugin->account_id = $this->account_id; return $plugin->purchase($this->id, $this->did); }
/** * Once a DID has been purchased and payment has been received from the customer, this * function then asks the DID provider to actually provision the DID to us. * */ function purchase() { $this->config(); # include the magrathea/telnet classes include_once PATH_INCLUDES . "telnet/magrathea.inc.php"; $bOk = false; $t = new magrathea(); $ret = $t->login($this->server, $this->user, $this->pass); if ($ret !== false) { if ($t->activate(substr($this->did, 5)) === false) { $this->log_message('purchase', 'Error while calling activate'); } else { echo "activated"; # Set the destination of the DID if ($t->set(substr($this->did, 5), $this->did . "@" . $this->host) === false) { $this->log_message('purchase', 'Error while calling set'); } else { $bOk = true; echo "set!"; } } } else { $this->log_message('purchase', 'Error during login: server=' . $this->server . " user="******"*****@*****.**", "magrathea plugin", "purchase {$this->id} on did {$this->did}"); require_once PATH_MODULES . "voip_did_plugin/voip_did_plugin.inc.php"; $plugin = new voip_did_plugin(); $plugin->account_id = $this->account_id; return $plugin->purchase($this->id, $this->did); }
/** * Once a DID has been purchased and payment has been received from the customer, this * function then asks the DID provider to actually provision the DID to us. * * sub BuyDIDByNumber ($UserID,$Password,$DIDNumber,$SIPorIAX, $Flag) */ function purchase() { $this->config(); # include the soap classes include_once(PATH_INCLUDES."nusoap/lib/nusoap.php"); $bOk = false; $client = new soapclient("http://didx.org/cgi-bin/WebBuyDIDServer.cgi", false); $err = $client->getError(); if ($err) { global $C_debug; $C_debug->error('DIDX.php', 'purchase', 'Could not acquire information from DIDx.org'); } else { $params = array( 'UserID' => $this->user, 'Password' => $this->pass, 'DIDNumber' => $this->did, 'SIPorIAX' => $this->did."@".$this->host, 'Flag' => 1 /* SIP version */ ); $result = $client->call('BuyDIDByNumber', $params, 'http://didx.org/BuyDID'); if (is_array($result)) { while ((list($k,$v)=each($result)) !== false) { if (is_array($v)) { if ($v[0] < 0) { # error occured, let's log it! $this->log_message('purchase', 'SOAP Response: '.$this->codes[$v[0]]); } else { $bOk = true; } } } } else { if ($result < 0) { # error occured, let's log it! $this->log_message('purchase', 'SOAP Response: '.$this->codes[$result]); } else { $bOk = true; } } } if ($bOk == false) { $this->log_message('purchase', $this->did.':SOAP Request for purchasing DID failed:'.$result); return false; } require_once(PATH_MODULES."voip_did_plugin/voip_did_plugin.inc.php"); $plugin = new voip_did_plugin; $plugin->account_id = $this->account_id; return $plugin->purchase($this->id, $this->did); }