You are here

protected function Checkout::mapPaymentState in Commerce PayPal 8

Map a PayPal payment state to a local one.

Parameters

string $type: The payment type. One of "authorize" or "capture".

string $remote_state: The PayPal remote payment state.

Return value

string The corresponding local payment state.

2 calls to Checkout::mapPaymentState()
Checkout::capturePayment in src/Plugin/Commerce/PaymentGateway/Checkout.php
Captures the given authorized payment.
Checkout::createPayment in src/Plugin/Commerce/PaymentGateway/Checkout.php
Creates a payment.

File

src/Plugin/Commerce/PaymentGateway/Checkout.php, line 753

Class

Checkout
Provides the PayPal Checkout payment gateway.

Namespace

Drupal\commerce_paypal\Plugin\Commerce\PaymentGateway

Code

protected function mapPaymentState($type, $remote_state) {
  $mapping = [
    'authorize' => [
      'created' => 'authorization',
      'pending' => 'pending',
      'voided' => 'authorization_voided',
      'expired' => 'authorization_expired',
    ],
    'capture' => [
      'completed' => 'completed',
      'pending' => 'pending',
      'partially_refunded' => 'partially_refunded',
    ],
  ];
  return isset($mapping[$type][$remote_state]) ? $mapping[$type][$remote_state] : '';
}