You are here

public function ExpressCheckout::doExpressCheckoutDetails in Commerce PayPal 8

GetExpressCheckoutDetails API Operation (NVP) request.

Builds the data for the request and make the request.

Parameters

\Drupal\commerce_order\Entity\OrderInterface $order: The order.

Return value

array PayPal response data.

Overrides ExpressCheckoutInterface::doExpressCheckoutDetails

See also

https://developer.paypal.com/docs/classic/api/merchant/GetExpressCheckou...

1 call to ExpressCheckout::doExpressCheckoutDetails()
ExpressCheckout::onReturn in src/Plugin/Commerce/PaymentGateway/ExpressCheckout.php
Processes the "return" request.

File

src/Plugin/Commerce/PaymentGateway/ExpressCheckout.php, line 704

Class

ExpressCheckout
Provides the Paypal Express Checkout payment gateway.

Namespace

Drupal\commerce_paypal\Plugin\Commerce\PaymentGateway

Code

public function doExpressCheckoutDetails(OrderInterface $order) {

  // Build NVP data for PayPal API request.
  $order_express_checkout_data = $order
    ->getData('paypal_express_checkout');
  $amount = $this->rounder
    ->round($order
    ->getTotalPrice());
  if ($order_express_checkout_data['capture']) {
    $payment_action = 'Sale';
  }
  else {
    $payment_action = 'Authorization';
  }
  $nvp_data = [
    'METHOD' => 'DoExpressCheckoutPayment',
    'TOKEN' => $order_express_checkout_data['token'],
    'PAYMENTREQUEST_0_AMT' => $amount
      ->getNumber(),
    'PAYMENTREQUEST_0_CURRENCYCODE' => $amount
      ->getCurrencyCode(),
    'PAYMENTREQUEST_0_INVNUM' => $order
      ->getOrderNumber(),
    'PAYERID' => $order_express_checkout_data['payerid'],
    'PAYMENTREQUEST_0_PAYMENTACTION' => $payment_action,
  ];

  // Make the PayPal NVP API request.
  return $this
    ->doRequest($nvp_data, $order);
}