TalerConfig
extends CommonObject
in package
Class for TalerConfig.
Table of Contents
Constants
- STATUS_CANCELED = 9
- STATUS_DRAFT = 0
- STATUS_VALIDATED = 1
- PLACEHOLDER_AUTH_HASH = '__AUTH_HASH__'
- PLACEHOLDER_CALLBACK_URL = '__CALLBACK_URL__'
- WEBHOOK_ID_PREFIX = 'talerbarr_'
Properties
- $date_creation : mixed
- $element : string
- $entity : mixed
- $expiration : mixed
- $fields : mixed
- $fk_bank_account : mixed
- $fk_default_customer : mixed
- $fk_user_creat : mixed
- $fk_user_modif : mixed
- $isextrafieldmanaged : int<0, 1>
- $ismultientitymanaged : int<0, 1>|string
- $module : string
- $picto : string
- $rowid : mixed
- $status : mixed
- $sync_on_paid : mixed
- $syncdirection : mixed
- $table_element : string
- $taler_currency_alias : mixed
- $talermerchanturl : mixed
- $talertoken : mixed
- $tms : mixed
- $username : mixed
- $currencyAlias : string|null
- $talerMerchantClient : TalerMerchantClient
Methods
- __construct() : mixed
- Constructor
- buildInstanceBase() : string
- Build instance/private base URL.
- cancel() : int<-1, 1>
- Set cancel status
- create() : int<-1, max>
- Create object into database
- createFromClone() : self|int<-1, -1>
- Clone an object into another one
- delete() : int<-1, 1>
- Delete object in database
- deleteLine() : mixed
- Delete a line of object in database
- doScheduledJob() : int
- Action executed by scheduler CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' Use public function doScheduledJob($param1, $param2, ...) to get parameters
- fetch() : int<-1, 1>
- Load object in memory from the database
- fetchAll() : array<int, self>|int<-1, -1>
- Load list of objects in memory from the database.
- fetchLines() : int<-1, 1>
- Load object lines in memory from the database
- fetchSingletonVerified() : self|null
- Return the single config row for current entity if it exists, and verify it before returning. If none or invalid, return null.
- generateDocument() : mixed
- Create a document onto disk according to template module.
- getCurrencyAlias() : string
- Retrieve configured Taler currency alias for the active entity.
- getDolibarrCurrency() : string
- Return Dolibarr base currency code in uppercase (fallback EUR).
- getKanbanView() : mixed
- Return a thumb for kanban views
- getLabelStatus() : string
- Return the label of the status
- getLibStatut() : string
- Return the label of the status
- getLinesArray() : mixed
- Create an array of lines
- getNextNumRef() : mixed
- Returns the reference to the following non used object depending on the active numbering module.
- getNomUrl() : mixed
- Return a link to the object card (with optionally the picto)
- getTooltipContentArray() : array{optimize?: string, picto?: string, ref?: string}
- getTooltipContentArray
- info() : void
- Load the info information in the object
- initAsSpecimen() : int
- Initialize object with example values Id must be 0 if object instance is a specimen
- LibStatut() : mixed
- Return the label of a given status
- mapCurrencyFromTaler() : string
- Map a Taler-reported currency into a Dolibarr currency code.
- mapCurrencyToTaler() : string
- Map a Dolibarr currency into the Taler-facing code.
- normalizeMerchantUrl() : string
- Normalize a merchant URL: - trim - if no scheme, default to https:// - collapse spaces
- reopen() : int<-1, 1>
- Set back to validated status
- setDraft() : int<0, 1>
- Set draft status
- talerMerchantClient() : TalerMerchantClient
- Getter for talerMerhcantClient
- update() : int<-1, 1>
- Update object into database
- validate() : int<-1, 1>
- Validate object
- validateField() : bool
- Return validation test result for a field.
- verifyConfig() : bool
- Verify current config by calling merchant endpoints.
- buildWebhookPayloads() : array<int, array<string, mixed>>
- Build webhook payloads from the module JSON definition.
- configureMerchantWebhooks() : string|null
- Provision (or refresh) all module-owned webhooks on the merchant backend.
- getWebhookDefinitionFile() : string
- Absolute path to webhook definition JSON file.
- getWebhookTemplateDir() : string
- Absolute path to the webhook templates directory.
- getWebhookTemplateFile() : string
- Compute absolute path to a webhook template file (basename only).
- isUrlOk() : bool
- Lightweight HTTP GET using Dolibarr's getURLContent.
- loadWebhookTemplate() : array<string, mixed>|null
- Load and decode a webhook template JSON file.
- normalizeCurrencyAliasField() : void
- Normalise optional currency alias before persisting.
- primeCurrencyAlias() : void
- Update static currency alias cache from provided config.
- replaceWebhookPlaceholders() : string
- Replace placeholders (auth hash, callback URL) in template fragments.
- resolveWebhookUrl() : string|null
- Resolve the target URL for a webhook definition entry.
Constants
STATUS_CANCELED
public
mixed
STATUS_CANCELED
= 9
STATUS_DRAFT
public
mixed
STATUS_DRAFT
= 0
STATUS_VALIDATED
public
mixed
STATUS_VALIDATED
= 1
PLACEHOLDER_AUTH_HASH
private
mixed
PLACEHOLDER_AUTH_HASH
= '__AUTH_HASH__'
PLACEHOLDER_CALLBACK_URL
private
mixed
PLACEHOLDER_CALLBACK_URL
= '__CALLBACK_URL__'
WEBHOOK_ID_PREFIX
private
mixed
WEBHOOK_ID_PREFIX
= 'talerbarr_'
Properties
$date_creation
public
mixed
$date_creation
$element
public
string
$element
= 'talerconfig'
ID to identify managed object.
$entity
public
mixed
$entity
$expiration
public
mixed
$expiration
$fields
public
mixed
$fields
= array("rowid" => array("type" => "integer", "label" => "TechnicalID", "enabled" => "1", 'position' => 1, 'notnull' => 1, "visible" => "0", "noteditable" => "1", "index" => "1", "css" => "left", "comment" => "Id"), "entity" => array("type" => "integer", "label" => "Entity", "enabled" => "1", 'position' => 2, 'notnull' => 1, "visible" => "0", "default" => "1", "index" => "1"), "date_creation" => array("type" => "datetime", "label" => "DateCreation", "enabled" => "1", 'position' => 500, 'notnull' => 1, "visible" => "-2"), "tms" => array("type" => "timestamp", "label" => "DateModification", "enabled" => "1", 'position' => 501, 'notnull' => 0, "visible" => "-2"), "fk_user_creat" => array("type" => "integer:User:user/class/user.class.php", "label" => "UserAuthor", "picto" => "user", "enabled" => "1", 'position' => 510, 'notnull' => 1, "visible" => "-2", "csslist" => "tdoverflowmax150"), "fk_user_modif" => array("type" => "integer:User:user/class/user.class.php", "label" => "UserModif", "picto" => "user", "enabled" => "1", 'position' => 511, 'notnull' => -1, "visible" => "-2", "csslist" => "tdoverflowmax150"), "status" => array("type" => "integer", "label" => "Status", "enabled" => "1", 'position' => 2000, 'notnull' => 1, "visible" => "1", "index" => "1", "arrayofkeyval" => array("0" => "Draft", "1" => "Validated", "9" => "Canceled"), "validate" => "1"), "talermerchanturl" => array("type" => "varchar(2048)", "label" => "TalerMerchantURL", "enabled" => "1", 'position' => 0, 'notnull' => 1, "visible" => "1", "comment" => "Url of the Taler Merchant"), "username" => array("type" => "varchar(128)", "label" => "Username", "enabled" => "1", 'position' => 0, 'notnull' => 1, "visible" => "1", "comment" => "Instance name"), "expiration" => array("type" => "timestamp", "label" => "Expiration", "enabled" => "1", 'position' => 0, 'notnull' => 1, "visible" => "1", "comment" => "Epoch expiration of token"), "talertoken" => array("type" => "varchar(128)", "label" => "TalerToken", "enabled" => "1", 'position' => 0, 'notnull' => 1, "visible" => "1", "comment" => "Token received from merchant"), "taler_currency_alias" => array("type" => "varchar(16)", "label" => "TalerCurrencyAlias", "enabled" => "1", 'position' => 0, 'notnull' => 0, "visible" => "1", "help" => "TalerCurrencyAliasHelp", "comment" => "Currency code to treat as Dolibarr base currency when talking to Taler"), "syncdirection" => array("type" => "boolean", "label" => "SyncDirection", "enabled" => "1", 'position' => 0, 'notnull' => 0, "visible" => "1", "default" => "1", "comment" => "True from Taler, false from Dolibarr"), "sync_on_paid" => array("type" => "integer", "label" => "SyncTiming", "enabled" => "1", 'position' => 0, 'notnull' => 0, "visible" => "1", "default" => "0", "arrayofkeyval" => array("0" => "SyncAtOrderCreated", "1" => "SyncAtOrderPaid"), "comment" => "When pulling from Taler, choose whether to sync at order creation or upon payment", "help" => "SyncTimingHelp"), "fk_bank_account" => ["type" => "integer:Account:compta/bank/class/account.class.php", "label" => "BankAccount", "enabled" => "1", "visible" => "1", "notnull" => 1, "index" => 1, "comment" => "Destination bank account for wired settlement"], "fk_default_customer" => ["type" => "integer:Societe:societe/class/societe.class.php", "label" => "TalerDefaultCustomer", "enabled" => "1", "visible" => "1", "notnull" => 0, "index" => 1, "comment" => "Fallback customer for autogenerated Taler orders"])
Tags
$fk_bank_account
public
mixed
$fk_bank_account
$fk_default_customer
public
mixed
$fk_default_customer
$fk_user_creat
public
mixed
$fk_user_creat
$fk_user_modif
public
mixed
$fk_user_modif
$isextrafieldmanaged
public
int<0, 1>
$isextrafieldmanaged
= 0
Does object support extrafields ? 0=No, 1=Yes
$ismultientitymanaged
public
int<0, 1>|string
$ismultientitymanaged
= 1
Does this object support multicompany module ? 0=No test on entity, 1=Test with field entity in local table, 'field@table'=Test entity into the field@table (example 'fk_soc@societe')
$module
public
string
$module
= 'talerbarr'
ID of module.
$picto
public
string
$picto
= 'fa-file'
String with name of icon for talerconfig. Must be a 'fa-xxx' fontawesome code (or 'fa-xxx_fa_color_size') or 'talerconfig@talerbarr' if picto is file 'img/object_talerconfig.png'.
$rowid
public
mixed
$rowid
$status
public
mixed
$status
$sync_on_paid
public
mixed
$sync_on_paid
$syncdirection
public
mixed
$syncdirection
$table_element
public
string
$table_element
= 'talerbarr_talerconfig'
Name of table without prefix where object is stored. This is also the key used for extrafields management (so extrafields know the link to the parent table).
$taler_currency_alias
public
mixed
$taler_currency_alias
$talermerchanturl
public
mixed
$talermerchanturl
$talertoken
public
mixed
$talertoken
$tms
public
mixed
$tms
$username
public
mixed
$username
$currencyAlias
private
static string|null
$currencyAlias
= \null
$talerMerchantClient
private
TalerMerchantClient
$talerMerchantClient
Methods
__construct()
Constructor
public
__construct(DoliDB $db) : mixed
Parameters
- $db : DoliDB
-
Database handler
buildInstanceBase()
Build instance/private base URL.
public
static buildInstanceBase(string $baseUrl, string $username) : string
For 'admin' -> {base}/private/ For others -> {base}/instances/{username}/
Parameters
- $baseUrl : string
-
Merchant base URL (with scheme), e.g. "https://merchant.example".
- $username : string
-
Instance name (e.g. "admin" or an instance id).
Return values
string —URL ending with a trailing slash.
cancel()
Set cancel status
public
cancel(User $user[, mixed $notrigger = 0 ]) : int<-1, 1>
Parameters
- $user : User
-
Object user that modify @param int<0,1> $notrigger 1=Does not execute triggers, 0=Execute triggers
- $notrigger : mixed = 0
Return values
int<-1, 1> —Return integer <0 if KO, 0=Nothing done, >0 if OK
create()
Create object into database
public
create(User $user[, int<0, 1> $notrigger = 0 ]) : int<-1, max>
Parameters
- $user : User
-
User that creates
- $notrigger : int<0, 1> = 0
-
0=launch triggers after, 1=disable triggers
Return values
int<-1, max> —Return integer <0 if KO, Id of created object if OK
createFromClone()
Clone an object into another one
public
createFromClone(User $user, int $fromid) : self|int<-1, -1>
Parameters
- $user : User
-
User that creates
- $fromid : int
-
Id of object to clone
Return values
self|int<-1, -1> —New object created, <0 if KO
delete()
Delete object in database
public
delete(User $user[, int<0, 1> $notrigger = 0 ]) : int<-1, 1>
Parameters
- $user : User
-
User that deletes
- $notrigger : int<0, 1> = 0
-
0=launch triggers, 1=disable triggers
Return values
int<-1, 1> —Return integer <0 if KO, >0 if OK
deleteLine()
Delete a line of object in database
public
deleteLine(User $user, mixed $idline[, mixed $notrigger = 0 ]) : mixed
Parameters
- $user : User
-
User that delete @param int $idline Id of line to delete @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers @return int<-2,1> >0 if OK, <0 if KO
- $idline : mixed
- $notrigger : mixed = 0
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' Use public function doScheduledJob($param1, $param2, ...) to get parameters
public
doScheduledJob() : int
Return values
int —0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
fetch()
Load object in memory from the database
public
fetch(int $id[, string $ref = null ][, int<0, 1> $noextrafields = 0 ][, int<0, 1> $nolines = 0 ]) : int<-1, 1>
Parameters
- $id : int
-
Id object
- $ref : string = null
-
Ref
- $noextrafields : int<0, 1> = 0
-
0=Default to load extrafields, 1=No extrafields
- $nolines : int<0, 1> = 0
-
0=Default to load lines, 1=No lines
Return values
int<-1, 1> —Return integer <0 if KO, 0 if not found, >0 if OK
fetchAll()
Load list of objects in memory from the database.
public
fetchAll([string $sortorder = '' ][, string $sortfield = '' ][, int<0, max> $limit = 1000 ][, int<0, max> $offset = 0 ][, string $filter = '' ][, string $filtermode = 'AND' ]) : array<int, self>|int<-1, -1>
Using a fetchAll() with limit = 0 is a very bad practice. Instead try to forge yourself an optimized SQL request with your own loop with start and stop pagination.
Parameters
- $sortorder : string = ''
-
Sort Order
- $sortfield : string = ''
-
Sort field
- $limit : int<0, max> = 1000
-
Limit the number of lines returned
- $offset : int<0, max> = 0
-
Offset
- $filter : string = ''
-
Filter as an Universal Search string. Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
- $filtermode : string = 'AND'
-
No longer used
Return values
array<int, self>|int<-1, -1> —<0 if KO, array of pages if OK
fetchLines()
Load object lines in memory from the database
public
fetchLines([int<0, 1> $noextrafields = 0 ]) : int<-1, 1>
Parameters
- $noextrafields : int<0, 1> = 0
-
0=Default to load extrafields, 1=No extrafields
Return values
int<-1, 1> —Return integer <0 if KO, 0 if not found, >0 if OK
fetchSingletonVerified()
Return the single config row for current entity if it exists, and verify it before returning. If none or invalid, return null.
public
static fetchSingletonVerified(DoliDB $db[, string|null &$error = null ]) : self|null
Parameters
- $db : DoliDB
-
Database handler.
- $error : string|null = null
-
Filled with a human-readable reason if verification fails.
Return values
self|null —Loaded and (if possible) verified config, or null.
generateDocument()
Create a document onto disk according to template module.
public
generateDocument(mixed $modele, Translate $outputlangs[, mixed $hidedetails = 0 ][, mixed $hidedesc = 0 ][, mixed $hideref = 0 ][, mixed $moreparams = null ]) : mixed
@param string $modele Force template to use ('' to not force)
Parameters
- $modele : mixed
- $outputlangs : Translate
-
object lang a utiliser pour traduction @param int<0,1> $hidedetails Hide details of lines @param int<0,1> $hidedesc Hide description @param int<0,1> $hideref Hide ref @param ?array<string,string> $moreparams Array to provide more information @return int 0 if KO, 1 if OK
- $hidedetails : mixed = 0
- $hidedesc : mixed = 0
- $hideref : mixed = 0
- $moreparams : mixed = null
getCurrencyAlias()
Retrieve configured Taler currency alias for the active entity.
public
static getCurrencyAlias() : string
Return values
string —Uppercase alias (empty string when none configured)
getDolibarrCurrency()
Return Dolibarr base currency code in uppercase (fallback EUR).
public
static getDolibarrCurrency() : string
Return values
stringgetKanbanView()
Return a thumb for kanban views
public
getKanbanView([string $option = '' ][, mixed $arraydata = null ]) : mixed
Parameters
- $option : string = ''
-
Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) @param ?array<string,mixed> $arraydata Array of data @return string HTML Code for Kanban thumb.
- $arraydata : mixed = null
getLabelStatus()
Return the label of the status
public
getLabelStatus([mixed $mode = 0 ]) : string
@param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
Parameters
- $mode : mixed = 0
Return values
string —Label of status
getLibStatut()
Return the label of the status
public
getLibStatut([mixed $mode = 0 ]) : string
@param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
Parameters
- $mode : mixed = 0
Return values
string —Label of status
getLinesArray()
Create an array of lines
public
getLinesArray() : mixed
@return CommonObjectLine[]|int array of lines if OK, <0 if KO
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
public
getNextNumRef() : mixed
@return string Object free reference
getNomUrl()
Return a link to the object card (with optionally the picto)
public
getNomUrl([mixed $withpicto = 0 ][, string $option = '' ][, mixed $notooltip = 0 ][, mixed $morecss = '' ][, mixed $save_lastsearch_value = -1 ]) : mixed
@param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
Parameters
- $withpicto : mixed = 0
- $option : string = ''
-
On what the link point to ('nolink', ...) @param int $notooltip 1=Disable tooltip @param string $morecss Add more css on link @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking @return string String with URL
- $notooltip : mixed = 0
- $morecss : mixed = ''
- $save_lastsearch_value : mixed = -1
getTooltipContentArray()
getTooltipContentArray
public
getTooltipContentArray(array<string, string> $params) : array{optimize?: string, picto?: string, ref?: string}
Parameters
- $params : array<string, string>
-
Params to construct tooltip data
Tags
Return values
array{optimize?: string, picto?: string, ref?: string}info()
Load the info information in the object
public
info(int $id) : void
Parameters
- $id : int
-
Id of object
initAsSpecimen()
Initialize object with example values Id must be 0 if object instance is a specimen
public
initAsSpecimen() : int
Return values
intLibStatut()
Return the label of a given status
public
LibStatut(mixed $status[, int<0, 6> $mode = 0 ]) : mixed
@param int $status Id status
Parameters
- $status : mixed
- $mode : int<0, 6> = 0
-
0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto @return string Label of status
mapCurrencyFromTaler()
Map a Taler-reported currency into a Dolibarr currency code.
public
static mapCurrencyFromTaler(string $currency) : string
Parameters
- $currency : string
-
Currency code received from Taler
Return values
string —Uppercase currency suitable for Dolibarr
mapCurrencyToTaler()
Map a Dolibarr currency into the Taler-facing code.
public
static mapCurrencyToTaler(string $currency) : string
Parameters
- $currency : string
-
Dolibarr currency code
Return values
string —Uppercase currency to send to Taler
normalizeMerchantUrl()
Normalize a merchant URL: - trim - if no scheme, default to https:// - collapse spaces
public
static normalizeMerchantUrl(string $url) : string
Parameters
- $url : string
-
Raw user-provided URL (may be missing scheme).
Return values
string —Normalized URL, or empty string if input is empty.
reopen()
Set back to validated status
public
reopen(User $user[, mixed $notrigger = 0 ]) : int<-1, 1>
Parameters
- $user : User
-
Object user that modify @param int<0,1> $notrigger 1=Does not execute triggers, 0=Execute triggers
- $notrigger : mixed = 0
Return values
int<-1, 1> —Return integer <0 if KO, 0=Nothing done, >0 if OK
setDraft()
Set draft status
public
setDraft(User $user[, mixed $notrigger = 0 ]) : int<0, 1>
Parameters
- $user : User
-
Object user that modify @param int<0,1> $notrigger 1=Does not execute triggers, 0=Execute triggers
- $notrigger : mixed = 0
Return values
int<0, 1> —Return integer <0 if KO, >0 if OK
talerMerchantClient()
Getter for talerMerhcantClient
public
talerMerchantClient() : TalerMerchantClient
Return values
TalerMerchantClientupdate()
Update object into database
public
update(User $user[, int<0, 1> $notrigger = 0 ]) : int<-1, 1>
Parameters
- $user : User
-
User that modifies
- $notrigger : int<0, 1> = 0
-
0=launch triggers after, 1=disable triggers
Return values
int<-1, 1> —Return integer <0 if KO, >0 if OK
validate()
Validate object
public
validate(User $user[, mixed $notrigger = 0 ]) : int<-1, 1>
Parameters
- $user : User
-
User making status change @param int<0,1> $notrigger 1=Does not execute triggers, 0= execute triggers
- $notrigger : mixed = 0
Return values
int<-1, 1> —Return integer <=0 if OK, 0=Nothing done, >0 if KO
validateField()
Return validation test result for a field.
public
validateField(array<string, array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int<-2, 5>|string, noteditable?: int<0, 1>, default?: int<0, 1>|string, index?: int, foreignkey?: string, searchall?: int<0, 1>, isameasure?: int<0, 1>, css?: string, csslist?: string, help?: string, showoncombobox?: int<0, 2>, disabled?: int<0, 1>, arrayofkeyval?: array, comment?: string, validate?: int<0, 1>}> $fields, string $fieldKey, string $fieldValue) : bool
Need MAIN_ACTIVATE_VALIDATION_RESULT to be called.
Parameters
-
$fields
: array<string, array{type: string, label: string, enabled: int<0, 2>|string, position: int, notnull?: int, visible: int<-2, 5>|string, noteditable?: int<0, 1>, default?: int<0, 1>|string, index?: int, foreignkey?: string, searchall?: int<0, 1>, isameasure?: int<0, 1>, css?: string, csslist?: string, help?: string, showoncombobox?: int<0, 2>, disabled?: int<0, 1>, arrayofkeyval?: array
, comment?: string, validate?: int<0, 1>}> -
Array of properties of field to show
- $fieldKey : string
-
Key of attribute
- $fieldValue : string
-
value of attribute
Return values
bool —Return false if fail, true on success, set $this->error for error message
verifyConfig()
Verify current config by calling merchant endpoints.
public
verifyConfig([string|null &$error = null ]) : bool
Checks:
- talermerchanturl is a valid/normalized URL and /config returns 200
- /config currency matches Dolibarr currency (or configured alias)
- username is URL-safe
- GET {base}/{private|instances/{username}}/private/categories with Authorization works (200)
Parameters
- $error : string|null = null
-
Filled on failure
Return values
boolbuildWebhookPayloads()
Build webhook payloads from the module JSON definition.
private
buildWebhookPayloads() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>configureMerchantWebhooks()
Provision (or refresh) all module-owned webhooks on the merchant backend.
private
configureMerchantWebhooks() : string|null
Reads webhook definitions from webhook/webhooks.json, deletes any existing talerbarr_* webhooks, then recreates the set from the JSON file.
Return values
string|null —null on success; otherwise a human-readable error message.
getWebhookDefinitionFile()
Absolute path to webhook definition JSON file.
private
static getWebhookDefinitionFile() : string
Return values
stringgetWebhookTemplateDir()
Absolute path to the webhook templates directory.
private
static getWebhookTemplateDir() : string
Return values
stringgetWebhookTemplateFile()
Compute absolute path to a webhook template file (basename only).
private
static getWebhookTemplateFile(string $template) : string
Parameters
- $template : string
-
Template filename (relative, e.g. "pay.json").
Return values
stringisUrlOk()
Lightweight HTTP GET using Dolibarr's getURLContent.
private
static isUrlOk(string $url, array<string|int, mixed> $headers, int &$httpcode, string &$err) : bool
Parameters
- $url : string
-
Absolute URL to GET.
- $headers : array<string|int, mixed>
-
List of header strings (e.g., ["Accept: application/json"]).
- $httpcode : int
-
Filled with HTTP status code (200, 404, ...).
- $err : string
-
Filled with transport error details if any (cURL code/message).
Return values
bool —True if an HTTP response was received (http code > 0).
loadWebhookTemplate()
Load and decode a webhook template JSON file.
private
loadWebhookTemplate(string $template) : array<string, mixed>|null
Parameters
- $template : string
-
Template filename.
Return values
array<string, mixed>|null —Decoded template, null if missing/invalid.
normalizeCurrencyAliasField()
Normalise optional currency alias before persisting.
private
normalizeCurrencyAliasField() : void
primeCurrencyAlias()
Update static currency alias cache from provided config.
private
static primeCurrencyAlias(self|null $cfg) : void
Parameters
- $cfg : self|null
-
Config instance (null resets to empty)
replaceWebhookPlaceholders()
Replace placeholders (auth hash, callback URL) in template fragments.
private
static replaceWebhookPlaceholders(string $value, string $authHash, string $callback) : string
Parameters
- $value : string
-
Template string potentially containing placeholders.
- $authHash : string
-
sha256 hash of the merchant token.
- $callback : string
-
Full webhook callback URL.
Return values
stringresolveWebhookUrl()
Resolve the target URL for a webhook definition entry.
private
resolveWebhookUrl(array<string, mixed> $entry) : string|null
Parameters
- $entry : array<string, mixed>
-
Webhook definition chunk.