bug fix : replacing orders by donations and setting required field to allow post action in rest API for url donations. See issue #17700

This commit is contained in:
r3dge 2021-05-21 16:01:04 +02:00
parent 93501a1147
commit 67cab8c1f2

View File

@ -33,7 +33,7 @@ class Donations extends DolibarrApi
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
'socid'
'amount'
);
/**
@ -193,7 +193,7 @@ class Donations extends DolibarrApi
}*/
if ($this->don->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->don->error), $this->don->errors));
throw new RestException(500, "Error creating donation", array_merge(array($this->don->error), $this->don->errors));
}
return $this->don->id;
@ -355,7 +355,7 @@ class Donations extends DolibarrApi
private function _validate($data)
{
$don = array();
foreach (Orders::$FIELDS as $field) {
foreach (Donations::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, $field." field missing");
$don[$field] = $data[$field];