You are here

protected function Payflow::getExpirationDate in Commerce PayPal 8

Formats the expiration date from the provided payment details.

PayPal requires the expiration date to be in MMYY format. Using a four-digit year (MMYYYY) will cause some banks to decline transactions because the expiration date is considered invalid. For example, 072018 will be interpreted as 0720 instead of 0718.

Parameters

array $payment_details: The payment details.

Return value

string The expiration date, in the MMYY format.

1 call to Payflow::getExpirationDate()
Payflow::createPaymentMethod in src/Plugin/Commerce/PaymentGateway/Payflow.php
Creates a payment method with the given payment details.

File

src/Plugin/Commerce/PaymentGateway/Payflow.php, line 181

Class

Payflow
Provides the PayPal Payflow payment gateway.

Namespace

Drupal\commerce_paypal\Plugin\Commerce\PaymentGateway

Code

protected function getExpirationDate(array $payment_details) {
  $date = \DateTime::createFromFormat('Y', $payment_details['expiration']['year']);
  return $payment_details['expiration']['month'] . $date
    ->format('y');
}