31,034
edits
Tag: 2017 source edit |
Tag: 2017 source edit |
||
| Line 45: | Line 45: | ||
The parameter are used by the page to find the amount to ask for the payment from the object information retrieved in URL. | The parameter are used by the page to find the amount to ask for the payment from the object information retrieved in URL. | ||
Then the page search the list of all available payment modes by calling '''getValidOnlinePaymentMethods()'''. | Then the page search the list of all available payment modes by calling the function '''getValidOnlinePaymentMethods()'''. This functions is calling all the hooks named '''getValidPayment''' of external modules. | ||
This means you must | |||
So any payment module must first complete this list with its own ID. For this, the module must implement the hook '''getValidPayment''' of the context '''newpayment'''. | |||
This means you must add this in the hook file (See the page [[Module development]] for more information on how to make a new virgin module with its hook file): | |||
<syntaxhighlight lang="PHP"> | <syntaxhighlight lang="PHP"> | ||
$hookmanager | public function getValidPayment($parameters, &$object, &$action, $hookmanager) | ||
{ | |||
global $langs; | |||
$error = 0; // Error counter | |||
$error = ""; | |||
if (array_key_exists("paymentmethod", $parameters) && (empty($parameters["paymentmethod"]) || $parameters["paymentmethod"] == 'payplug') && isModEnabled('payplugdolicloud')) { | |||
$validpaymentmethod['mypaymentcode'] = 'valid'; | |||
} | |||
if (!$error) { | |||
$this->results["validpaymentmethod"] = $validpaymentmethod; | |||
return 0; | |||
} else { | |||
$this->errors[] = $error; | |||
return -1; | |||
} | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||