/**
* Function to create a new payment
*/
public function createPaymentsAction() { try { $params =
$this->
Request()->
getParams();
unset($params['action'
]);
$repository =
$this->
get('models'
)->
getRepository(Payment::
class);
$existingModel =
$repository->
findByName($params['name'
]);
if ($existingModel) { throw new ORMException('The name is already in use.'
);
} if ($params['source'
] == 0
) { $params['source'
] = null;
} $paymentModel =
new Payment();
$countries =
$params['countries'
] ??
[];
$countryArray =
[];
foreach ($countries as $country) { $countryArray[] =
$this->
get('models'
)->
find(Country::
class,
$country['id'
]);
}