return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
-
/**
* Set default getlist parameters.
*
*
* @return array
* API result array.
- * @throws CiviCRM_API3_Exception
+ *
+ * @throws \API_Exception
*/
function civicrm_api3_payment_processor_pay($params) {
$processor = Civi\Payment\System::singleton()->getById($params['payment_processor_id']);
$processor->setPaymentProcessor(civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $params['payment_processor_id']]));
- $result = $processor->doPayment($params);
+ try {
+ $result = $processor->doPayment($params);
+ }
+ catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
+ $code = $e->getErrorCode();
+ $errorData = $e->getErrorData();
+ if (empty($code)) {
+ $code = 'EXTERNAL_FAILURE';
+ }
+ throw new API_Exception('Payment failed', $code, $errorData, $e);
+ }
return civicrm_api3_create_success(array($result), $params);
}
];
$params['amount'] = [
'api.required' => TRUE,
- 'title' => ts('Amount to refund'),
+ 'title' => ts('Amount to pay'),
'type' => CRM_Utils_Type::T_MONEY,
];
}