You are here

public function CreditCardPaymentMethodBase::orderSave in Ubercart 8.4

Called when an order is being saved with this payment method.

Parameters

\Drupal\uc_order\OrderInterface $order: The order that is being saved.

Overrides PaymentMethodPluginBase::orderSave

File

payment/uc_credit/src/CreditCardPaymentMethodBase.php, line 576

Class

CreditCardPaymentMethodBase
Defines a base credit card payment method plugin implementation.

Namespace

Drupal\uc_credit

Code

public function orderSave(OrderInterface $order) {

  // Save only some limited, PCI compliant data.
  $cc_data = $order->payment_details;
  $cc_data['cc_number'] = substr($cc_data['cc_number'], -4);
  unset($cc_data['cc_cvv']);

  // Stuff the serialized and encrypted CC details into the array.
  $crypt = \Drupal::service('uc_store.encryption');
  $order->data->cc_data = $crypt
    ->encrypt(uc_credit_encryption_key(), base64_encode(serialize($cc_data)));
  uc_store_encryption_errors($crypt, 'uc_credit');
}