return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
-
/**
* Set default getlist parameters.
*
];
}
+/**
+ * Action payment.
+ *
+ * @param array $params
+ *
+ * @return array
+ * API result array.
+ *
+ * @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']]));
+ 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);
+}
+
+/**
+ * Action payment.
+ *
+ * @param array $params
+ */
+function _civicrm_api3_payment_processor_pay_spec(&$params) {
+ $params['payment_processor_id'] = [
+ 'api.required' => 1,
+ 'title' => ts('Payment processor'),
+ 'type' => CRM_Utils_Type::T_INT,
+ ];
+ $params['amount'] = [
+ 'api.required' => TRUE,
+ 'title' => ts('Amount to pay'),
+ 'type' => CRM_Utils_Type::T_MONEY,
+ ];
+}
+
/**
* Action refund.
*