/**
* Set entity fields to be assigned to the form.
*/
- protected function setEntityFields() {
+ protected function setEntityFields(): void {
$this->entityFields = [
'payment_processor_type_id' => [
'name' => 'payment_processor_type_id',
}
else {
$refreshURL = CRM_Utils_System::url('civicrm/admin/paymentProcessor/edit',
- "reset=1&action=add",
+ 'reset=1&action=add',
FALSE, NULL, FALSE
);
}
$this->_paymentProcessorDAO->id = $values['payment_processor_type_id'];
$this->_paymentProcessorDAO->find(TRUE);
}
- $this->updatePaymentProcessor($values, $domainID, FALSE);
$this->updatePaymentProcessor($values, $domainID, TRUE);
-
- $processor = civicrm_api3('payment_processor', 'getsingle', ['name' => $values['name'], 'is_test' => 0]);
- $errors = Civi\Payment\System::singleton()->checkProcessorConfig($processor);
+ $paymentProcessorID = $this->updatePaymentProcessor($values, $domainID, FALSE);
+ $processor = Civi\Payment\System::singleton()->getById($paymentProcessorID);
+ $errors = $processor->checkConfig();
if ($errors) {
CRM_Core_Session::setStatus($errors, ts('Payment processor configuration invalid'), 'error');
Civi::log()->error('Payment processor configuration invalid: ' . $errors);
*
* @throws \CRM_Core_Exception
*/
- public function updatePaymentProcessor(&$values, $domainID, $test) {
+ public function updatePaymentProcessor($values, $domainID, $test) {
if ($test) {
foreach (['user_name', 'password', 'signature', 'url_site', 'url_recur', 'url_api', 'url_button', 'subject'] as $field) {
$values[$field] = empty($values["test_{$field}"]) ? CRM_Utils_Array::value($field, $values) : $values["test_{$field}"];
}
$creditCards = json_encode($creditCards);
}
- else {
- $creditCards = "NULL";
- }
+
$params = array_merge([
'id' => $test ? $this->_testID : $this->_id,
'domain_id' => $domainID,
'payment_type' => $this->_paymentProcessorDAO->payment_type,
'payment_instrument_id' => $this->_paymentProcessorDAO->payment_instrument_id,
'financial_account_id' => $values['financial_account_id'],
- 'accepted_credit_cards' => $creditCards,
+ 'accepted_credit_cards' => $creditCards ?? NULL,
], $values);
- $result = civicrm_api4('PaymentProcessor', 'save', [
+ return civicrm_api4('PaymentProcessor', 'save', [
'records' => [$params],
- ]);
- // Pass autogenerated name back
- $values['name'] = $result->single()['name'];
+ ])->first()['id'];
}
/**