Merge pull request #21360 from eileenmcnaughton/case_pdf
[civicrm-core.git] / CRM / Member / Form.php
index ea71c00f11c6efc4720a59d33541be6d0b251b40..9ec7b8be7a7ed2f252d81842bac82d656c6926f8 100644 (file)
@@ -568,4 +568,27 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment {
     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'));
+  }
+
 }