* @param array $formValues
*
* @return array
+ * @throws \API_Exception
*/
protected function setPriceSetParameters(array $formValues): array {
// process price set and get total amount and line items.
$priceSetDetails = $this->getPriceSetDetails($formValues);
$this->_priceSet = $priceSetDetails[$this->_priceSetId];
$this->order = new CRM_Financial_BAO_Order();
- $this->order->setPriceSelectionFromUnfilteredInput($formValues);
- $this->order->setPriceSetID($this->getPriceSetID($formValues));
$this->order->setForm($this);
- if ($priceSetDetails[$this->order->getPriceSetID()]['is_quick_config'] && isset($formValues['total_amount'])) {
- // Amount overrides only permitted on quick config.
- // Possibly Order object should enforce this...
+ $this->order->setPriceSelectionFromUnfilteredInput($formValues);
+ if (isset($formValues['total_amount'])) {
$this->order->setOverrideTotalAmount((float) $formValues['total_amount']);
}
$this->order->setOverrideFinancialTypeID((int) $formValues['financial_type_id']);
return (int) $this->getSubmittedValue('payment_instrument_id') ?: $this->_paymentProcessor['object']->getPaymentInstrumentID();
}
+ /**
+ * Get the last 4 numbers of the card.
+ *
+ * @return int|null
+ */
+ protected function getPanTruncation(): ?int {
+ $card = $this->getSubmittedValue('credit_card_number');
+ return $card ? (int) substr($card, -4) : NULL;
+ }
+
+ /**
+ * Get the card_type_id.
+ *
+ * This value is the integer representing the option value for
+ * the credit card type (visa, mastercard). It is stored as part of the
+ * payment record in civicrm_financial_trxn.
+ *
+ * @return int|null
+ */
+ protected function getCardTypeID(): ?int {
+ return CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'card_type_id', $this->getSubmittedValue('credit_card_type'));
+ }
+
}