protected function getAmount($params = []) {
if (!CRM_Utils_Rule::numeric($params['amount'])) {
CRM_Core_Error::deprecatedWarning('Passing Amount value that is not numeric is deprecated please report this in gitlab');
- return filter_var($params['amount'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
+ return CRM_Utils_Money::formatUSLocaleNumericRounded(filter_var($params['amount'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), 2);
}
- return $params['amount'];
+ return CRM_Utils_Money::formatUSLocaleNumericRounded($params['amount'], 2);
}
/**
* URL to notify outcome of transaction.
*/
protected function getNotifyUrl() {
- $url = CRM_Utils_System::url(
+ $url = CRM_Utils_System::getNotifyUrl(
'civicrm/payment/ipn/' . $this->_paymentProcessor['id'],
[],
TRUE,
* the result in an nice formatted array (or an error object - but throwing exceptions is preferred)
*/
protected function doDirectPayment(&$params) {
+ CRM_Core_Error::deprecatedFunctionWarning('doPayment');
+ return $params;
+ }
+
+ /**
+ * Calling this from outside the payment subsystem is deprecated - use doPayment.
+ * @deprecated
+ *
+ * @param array $params
+ * Assoc array of input parameters for this transaction.
+ * @param string $component
+ *
+ * @return array
+ * the result in an nice formatted array (or an error object - but throwing exceptions is preferred)
+ */
+ protected function doTransferCheckout(&$params, $component = 'contribute') {
+ CRM_Core_Error::deprecatedFunctionWarning('doPayment');
return $params;
}
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
public function doPayment(&$params, $component = 'contribute') {
+ $propertyBag = \Civi\Payment\PropertyBag::cast($params);
$this->_component = $component;
$statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate');
// If we have a $0 amount, skip call to processor and set payment_status to Completed.
// Conceivably a processor might override this - perhaps for setting up a token - but we don't
- // have an example of that at the mome.
- if ($params['amount'] == 0) {
+ // have an example of that at the moment.
+ if ($propertyBag->getAmount() == 0) {
$result['payment_status_id'] = array_search('Completed', $statuses);
+ $result['payment_status'] = 'Completed';
return $result;
}
if ($this->_paymentProcessor['billing_mode'] == 4) {
+ CRM_Core_Error::deprecatedFunctionWarning('doPayment', 'doTransferCheckout');
$result = $this->doTransferCheckout($params, $component);
if (is_array($result) && !isset($result['payment_status_id'])) {
$result['payment_status_id'] = array_search('Pending', $statuses);
+ $result['payment_status'] = 'Pending';
}
}
else {
+ CRM_Core_Error::deprecatedFunctionWarning('doPayment', 'doDirectPayment');
$result = $this->doDirectPayment($params, $component);
if (is_array($result) && !isset($result['payment_status_id'])) {
if (!empty($params['is_recur'])) {
// See comment block.
$result['payment_status_id'] = array_search('Pending', $statuses);
+ $result['payment_status'] = 'Pending';
}
else {
$result['payment_status_id'] = array_search('Completed', $statuses);
+ $result['payment_status'] = 'Completed';
}
}
}