You are here

public function ExpressCheckout::doCapture in Commerce PayPal 8

DoCapture API Operation (NVP) request.

Builds the data for the request and make the request.

Parameters

\Drupal\commerce_payment\Entity\PaymentInterface $payment: The payment.

int $amount_number: The amount number to be captured.

Return value

array PayPal response data.

Overrides ExpressCheckoutInterface::doCapture

See also

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

1 call to ExpressCheckout::doCapture()
ExpressCheckout::capturePayment in src/Plugin/Commerce/PaymentGateway/ExpressCheckout.php
Captures the given authorized payment.

File

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

Class

ExpressCheckout
Provides the Paypal Express Checkout payment gateway.

Namespace

Drupal\commerce_paypal\Plugin\Commerce\PaymentGateway

Code

public function doCapture(PaymentInterface $payment, $amount) {
  $order = $payment
    ->getOrder();

  // Build a name-value pair array for this transaction.
  $nvp_data = [
    'METHOD' => 'DoCapture',
    'AUTHORIZATIONID' => $payment
      ->getRemoteId(),
    'AMT' => $amount,
    'CURRENCYCODE' => $payment
      ->getAmount()
      ->getCurrencyCode(),
    'INVNUM' => $order
      ->getOrderNumber(),
    'COMPLETETYPE' => 'Complete',
  ];

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