You are here

protected function StripePaymentMethodController::statusFromCardErrorCode in Stripe 7

Map a card error code to a Payment status.

@paran string $code A Stripe card error code.

Return value

PaymentStatusItem The Payment status matching the error code.

1 call to StripePaymentMethodController::statusFromCardErrorCode()
StripePaymentMethodController::execute in stripe_payment/includes/StripePaymentMethodController.inc
Execute a payment.

File

stripe_payment/includes/StripePaymentMethodController.inc, line 460
Stripe Payment controller class and helper code (classes and function).

Class

StripePaymentMethodController

Code

protected function statusFromCardErrorCode($code) {
  if (empty($code)) {
    return new PaymentStatusItem(STRIPE_PAYMENT_STATUS_UNKNOWN_ERROR);
  }
  $status = 'STRIPE_PAYMENT_STATUS_' . drupal_strtoupper($code);
  if (defined($status)) {
    return new PaymentStatusItem(constant($status));
  }
  else {
    return new PaymentStatusItem(STRIPE_PAYMENT_STATUS_UNKNOWN_ERROR);
  }
}