Module Catalogue
The five endpoints managing which modules exist and which ones run.
Overview
Everywhere WISECP speaks to the outside world is a module: taking payment, registering domains, sending mail and messages, checking for fraud, and the product types. This article answers which modules exist and which are running.
Six groups exist and they are not picked the same way. The payment and product groups run several modules at once, while the mail, domain and message groups pick one. The fraud group turns each module on by itself.
That difference reaches the endpoints: the group-wide pick sits on one and the per-module switch on another. Which applies is decided by the group.
Reference
Listing a Group's Modules
Returns the modules in a group along with the group's live picks.
active or passive.curl 'https://panel.example.com/api/v1/admin/modules/payment?status=active' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.example.com/api/v1/admin/modules/payment?status=active', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const { data, meta } = await res.json();
console.log(meta.active, meta.card_storage_module);$ch = curl_init('https://panel.example.com/api/v1/admin/modules/payment?status=active');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Six groups exist: payment, registrars, mail, sms, fraud, product. Anything else gives 404.
foreach (['payment', 'registrars', 'mail', 'sms', 'fraud', 'product'] as $g)
$all[$g] = Api::Modules()->GetModules(['group' => $g])['meta']['active'];Reading One Module
Returns a module's summary, its fields and what it can do.
curl 'https://panel.example.com/api/v1/admin/modules/payment/Stripe' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.example.com/api/v1/admin/modules/${group}/${key}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const { data } = await res.json();
if (data.capabilities.has_test_connection) showTestButton();$ch = curl_init('https://panel.example.com/api/v1/admin/modules/' . $group . '/' . $key);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Build a form from the capabilities first: not every module has fields or a connection test.
$m = Api::Modules()->GetModule(['group' => $group, 'module' => $key])['data'];
if (! $m['capabilities']['has_config_fields']) $form = null;Choosing a Group's Live Modules
Writes which modules a group uses.
curl -X PUT 'https://panel.example.com/api/v1/admin/modules/payment/activation' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"modules":["Free","Stripe"],"card_storage_module":"Stripe"}'const now = await fetch('https://panel.example.com/api/v1/admin/modules/payment', {
headers: { Authorization: `Bearer ${apiKey}` },
}).then((r) => r.json());
const res = await fetch('https://panel.example.com/api/v1/admin/modules/payment/activation', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ modules: [...now.meta.active, 'Stripe'] }),
});$ch = curl_init('https://panel.example.com/api/v1/admin/modules/payment/activation');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['modules' => $keys]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// The list REPLACES the set: sending one key turns every other payment module off.
$live = Api::Modules()->GetModules(['group' => 'payment'])['meta']['active'];
Api::Modules()->UpdateModuleActivation([
'group' => 'payment', 'modules' => array_values(array_unique([...$live, 'Stripe'])),
]);Turning One Module On and Off
Turns a fraud or product module on and off one at a time.
curl -X PUT 'https://panel.example.com/api/v1/admin/modules/fraud/MaxMind/status' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"enabled":1}'const res = await fetch(`https://panel.example.com/api/v1/admin/modules/${group}/${key}/status`, {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ enabled: 1 }),
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/modules/' . $group . '/' . $key . '/status');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['enabled' => 1]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// On a fraud module OPENING checks the credentials first; write the settings BEFORE that.
Api::Modules()->UpdateModuleSettings([
'group' => 'fraud', 'module' => $key, 'settings' => ['license_key' => $lic],
]);
Api::Modules()->SetModuleStatus(['group' => 'fraud', 'module' => $key, 'enabled' => 1]);Removing a Module
Takes a module's files off the server.
curl -X DELETE 'https://panel.example.com/api/v1/admin/modules/payment/Stripe' \
-H "Authorization: Bearer $API_KEY"const res = await fetch(`https://panel.example.com/api/v1/admin/modules/${group}/${key}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${apiKey}` },
});
const body = await res.json();$ch = curl_init('https://panel.example.com/api/v1/admin/modules/' . $group . '/' . $key);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// It takes the settings and the credentials too; export the configuration and keep it first.
$cfg = Api::Modules()->GetModuleConfig(['group' => $group, 'module' => $key])['data'];
file_put_contents("$key.json", json_encode($cfg));
Api::Modules()->DeleteModule(['group' => $group, 'module' => $key]);Pitfalls
On the payment and product groups the list you send replaces the old one. Sending only the module you meant to add turns the others off, and clients stop seeing those payment methods. Read the list first and add to it.
The fraud modules refuse the group-pick endpoint and answer activation_not_supported; they open one at a time. The product group takes both roads. Sort the group first when writing a general management tool.
Naming the payment module that keeps cards adds it to the live list even when it was not there. Writing one field can open a payment method to clients. Read the live list in the answer and compare it against the set you expected.
Opening a fraud module checks its credentials, and the call comes back with module_error when one is missing. Order matters during setup: write the settings first and open afterwards. The other way round fails, and the error comes from the module itself.
The removal endpoint deletes the module's directory, and the settings and credentials go with it. When the files come away only in part the answer is removal_failed and a half-removed directory stays behind. Export the configuration before removing.
Related Articles
Merci pour votre retour !
Notre équipe d'assistance est disponible 24h/24 pour tout ce que vous ne trouvez pas ci-dessus.