You are here

public function PayPalExpressCheckout::sendNvpRequest in Ubercart 8.4

Sends a request to the PayPal NVP API.

3 calls to PayPalExpressCheckout::sendNvpRequest()
PayPalExpressCheckout::buildRedirectForm in payment/uc_paypal/src/Plugin/Ubercart/PaymentMethod/PayPalExpressCheckout.php
Redirect to PayPal Express Checkout Mark Flow.
PayPalExpressCheckout::orderSubmit in payment/uc_paypal/src/Plugin/Ubercart/PaymentMethod/PayPalExpressCheckout.php
Called when an order is being submitted with this payment method.
PayPalExpressCheckout::submitExpressForm in payment/uc_paypal/src/Plugin/Ubercart/PaymentMethod/PayPalExpressCheckout.php
Submit callback for the express checkout button.

File

payment/uc_paypal/src/Plugin/Ubercart/PaymentMethod/PayPalExpressCheckout.php, line 410

Class

PayPalExpressCheckout
Defines the PayPal Express Checkout payment method.

Namespace

Drupal\uc_paypal\Plugin\Ubercart\PaymentMethod

Code

public function sendNvpRequest($params) {
  $host = $this->configuration['wpp_server'];
  $params += [
    'USER' => $this->configuration['api']['api_username'],
    'PWD' => $this->configuration['api']['api_password'],
    'SIGNATURE' => $this->configuration['api']['api_signature'],
    'VERSION' => '3.0',
  ];
  try {
    $response = \Drupal::httpClient()
      ->request('POST', $host, [
      'form_params' => $params,
    ]);
    parse_str($response
      ->getBody(), $output);
    return $output;
  } catch (TransferException $e) {
    \Drupal::logger('uc_paypal')
      ->error('NVP API request failed with HTTP error %error.', [
      '%error' => $e
        ->getMessage(),
    ]);
  }
}