You are here

protected function Sermepa::getStatusMapping in Commerce sermepa 8.2

Returns a mapping of Sermepa/Redsýs payment statuses to payment states.

Parameters

string $status: (optional) The Sermepa/Redsýs payment status.

Return value

array|string An array containing the Sermepa/Redsýs remote statuses as well as their corresponding states. if $status is specified, the corresponding state is returned.

1 call to Sermepa::getStatusMapping()
Sermepa::processRequest in src/Plugin/Commerce/PaymentGateway/Sermepa.php
Processes the notification request.

File

src/Plugin/Commerce/PaymentGateway/Sermepa.php, line 470

Class

Sermepa
Provides the Sermepa/Redsýs payment gateway.

Namespace

Drupal\commerce_sermepa\Plugin\Commerce\PaymentGateway

Code

protected function getStatusMapping($status = NULL) {

  /* @see \CommerceRedsys\Payment\Sermepa::getAvailableTransactionTypes */

  /* @see commerce/modules/payment/commerce_payment.workflows.yml */
  $mapping = [
    // Sermepa/Redsýs: Authorization.
    '0' => 'completed',
    // Sermepa/Redsýs: Pre-authorization.
    '1' => 'authorization',
    // Sermepa/Redsýs: Confirmation of preauthorization.
    '2' => 'authorization',
    // Sermepa/Redsýs: Automatic return.
    '3' => 'refunded',
    // Sermepa/Redsýs: Recurring transaction.
    '5' => 'completed',
    // Sermepa/Redsýs: Successive transaction.
    '6' => 'completed',
    // Sermepa/Redsýs: Pre-authentication.
    '7' => 'authorization',
    // Sermepa/Redsýs: Confirmation of pre-authentication.
    '8' => 'authorization',
    // Sermepa/Redsýs: Annulment of preauthorization.
    '9' => 'authorization_expired',
    // Sermepa/Redsýs: Authorization delayed.
    'O' => 'authorization',
    // Sermepa/Redsýs: Confirmation of authorization in deferred.
    'P' => 'authorization',
    // Sermepa/Redsýs: Delayed authorization Rescission.
    'Q' => 'authorization',
    // Sermepa/Redsýs: Initial recurring deferred released.
    'R' => 'completed',
    // Sermepa/Redsýs: Successively recurring deferred released.
    'S' => 'completed',
  ];

  // If a status was passed, return its corresponding payment state.
  if (isset($status) && isset($mapping[$status])) {
    return $mapping[$status];
  }
  return $mapping;
}