本文整理汇总了PHP中api::setCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP api::setCategory方法的具体用法?PHP api::setCategory怎么用?PHP api::setCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api
的用法示例。
在下文中一共展示了api::setCategory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: acumulus_inject_gateway
function acumulus_inject_gateway($vars)
{
$vars = array_merge($vars, getAddonVars());
if ($vars['filename'] != 'configgateways') {
return;
}
$api = new api($vars['code'], $vars['username'], $vars['password']);
$api->setCategory('picklists')->setAction('picklist_accounts');
$api->execute();
$response = $api->getResponse();
if ($api->hasErrors()) {
$response = array();
$response['accounts'] = array();
$response['accounts']['account'] = array();
$response['accounts']['account'][] = array('accountid' => '', 'accountnumber' => 'API errors', 'accountdescription' => null);
foreach ($api->getErrors() as $error) {
$response['accounts']['account'][] = array('accountid' => '', 'accountnumber' => $error['code'], 'accountdescription' => $error['message']);
}
}
$inject = '<script>';
$gatewayQuery = mysql_query('SELECT name.gateway, acumulus_account.value AS acumulus_account FROM tblpaymentgateways AS name LEFT JOIN tblpaymentgateways AS acumulus_account ON acumulus_account.setting = "acumulusAccount" AND acumulus_account.gateway = name.gateway WHERE name.setting = "name"');
while ($gatewayFetch = mysql_fetch_assoc($gatewayQuery)) {
$inject .= '$(\'#Payment-Gateway-Config-' . $gatewayFetch['gateway'] . '\').find(\'tr:last\').before(\'<tr><td class="fieldlabel">Acumulus rekening</td><td class="fieldarea"><select name="field[acumulusAccount]">';
foreach ($response['accounts']['account'] as $action) {
$inject .= '<option value="' . $action['accountid'] . '" ' . ($gatewayFetch['acumulus_account'] == $action['accountid'] ? 'selected="selected"' : '') . '>' . $action['accountnumber'] . '' . (is_string($action['accountdescription']) ? ' - ' . $action['accountdescription'] : '') . '</option>';
}
$inject .= '</select>Voeg alle facturen met deze betaalmethode toe aan een bepaalde rekening, <a href="https://wiki.acumulus.nl/index.php?page=payment-service-provider" target="_blank">zie hier waarom</a>.</td></tr>\');';
}
$inject .= '</script>';
return $inject;
}
示例2: updateCustomer
/**
* Updates a customer at Acumulus
* @param $vars : $vars from the hook for API credentials
* @param $clientid : clientid to update
* @param null $customerid : customerid at Acumulus to update
* @throws Exception
* @return $customerid : new/updated customerid at Acumulus
*/
function updateCustomer($vars, $clientid, $customerid = null)
{
global $whmcs;
$whmcs->load_function('invoice');
$clientQuery = mysql_query('SELECT tblclients.*, tblcustomfieldsvalues.value AS vatnumber FROM tblclients LEFT JOIN tblcustomfieldsvalues ON tblclients.id = tblcustomfieldsvalues.relid AND tblcustomfieldsvalues.fieldid = (SELECT id FROM tblcustomfields WHERE type = "client" AND fieldname = "' . $vars['vat_field'] . '" LIMIT 1) WHERE tblclients.id = ' . $clientid . ' LIMIT 1');
if (mysql_num_rows($clientQuery) != 1) {
throw new Exception('Failed to receive client ' . $clientid);
}
$clientFetch = mysql_fetch_assoc($clientQuery);
$api = new api($vars['code'], $vars['username'], $vars['password']);
$api->setCategory('contacts')->setAction('contact_manage');
if (isset($vars['debug']) && $vars['debug'] == 'on') {
$api->enableDebug($vars['debug_email']);
}
if ($clientFetch['acumulusid'] != null) {
$api->setParam('contact/contactid', $clientFetch['acumulusid']);
}
if ($customerid != null) {
$api->setParam('contact/contactid', $customerid);
}
if ($clientFetch['country'] == 'NL') {
$api->setParam('contact/contactlocationcode', 1);
} elseif (inEurope($clientFetch['country'])) {
$api->setParam('contact/contactlocationcode', 2);
} else {
$api->setParam('contact/contactlocationcode', 3);
}
$taxData = getTaxRate(1, $clientQuery['state'], $clientQuery['country']);
$api->setParams(array('contact' => array('contactemail' => $clientFetch['email'], 'contacttype' => 1, 'overwriteifexists' => 1, 'contactname1' => ucfirst($clientFetch['firstname']) . ' ' . $clientFetch['lastname'], 'contactname2' => '', 'contactperson' => '', 'contactsalutation' => '', 'contactaddress1' => $clientFetch['address1'], 'contactaddress2' => $clientFetch['address2'], 'contactpostalcode' => $clientFetch['postcode'], 'contactcity' => $clientFetch['city'], 'contactcountrycode' => inEurope($clientFetch['country']) ? $clientFetch['country'] : '', 'contactvatnumber' => $clientFetch['vatnumber'], 'contactvatratebase' => $clientFetch['taxexempt'] == 'on' ? -1 : round($taxData['rate']), 'contacttelephone' => $clientFetch['phonenumber'], 'contactfax' => '', 'contactsepaincassostatus' => 'FRST', 'contactinvoicetemplateid' => '', 'contactstatus' => 1)));
if (!empty($clientFetch['companyname'])) {
$api->setParams(array('contact' => array('contactname1' => $clientFetch['companyname'], 'contactperson' => ucfirst($clientFetch['firstname']) . ' ' . $clientFetch['lastname'])));
}
$api->execute();
$response = $api->getResponse();
if ($api->hasErrors()) {
$errors = '';
foreach ($api->getErrors() as $error) {
$errors = $error['code'] . ' - ' . $error['message'] . ', ';
}
logActivity('Acumulus API error(s): ' . substr($errors, 0, -2));
return false;
} else {
mysql_query('UPDATE tblclients SET acumulusid = ' . $response['contact']['contactid'] . ' WHERE id = ' . $clientid . ' LIMIT 1');
return $response['contact']['contactid'];
}
}
示例3: acumulus_sync_vat
function acumulus_sync_vat($vars)
{
$taxQuery = select_query('tbltax');
while ($taxFetch = mysql_fetch_assoc($taxQuery)) {
$api = new api($vars['code'], $vars['username'], $vars['password']);
$api->setCategory('lookups')->setAction('lookup_vatinfo');
$api->setParam('vatcountry', $taxFetch['country']);
$api->execute();
$response = $api->getResponse();
foreach ($response['vatinfo']['vat'] as $vat) {
if ($vat['vattype'] == 'normal') {
update_query('tbltax', array('taxrate' => $vat['vatrate']), array('id' => $taxFetch['id']));
}
}
}
}