You are here

public function ExpressCheckout::doRefundTransaction in Commerce PayPal 8

RefundTransaction API Operation (NVP) request.

Builds the data for the request and make the request.

Parameters

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

array $extra: Extra data needed for this request, ex.: refund amount, refund type, etc....

Return value

array PayPal response data.

Overrides ExpressCheckoutInterface::doRefundTransaction

See also

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

1 call to ExpressCheckout::doRefundTransaction()
ExpressCheckout::refundPayment in src/Plugin/Commerce/PaymentGateway/ExpressCheckout.php
Refunds the given payment.

File

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

Class

ExpressCheckout
Provides the Paypal Express Checkout payment gateway.

Namespace

Drupal\commerce_paypal\Plugin\Commerce\PaymentGateway

Code

public function doRefundTransaction(PaymentInterface $payment, array $extra) {

  // Build a name-value pair array for this transaction.
  $nvp_data = [
    'METHOD' => 'RefundTransaction',
    'TRANSACTIONID' => $payment
      ->getRemoteId(),
    'REFUNDTYPE' => $extra['refund_type'],
    'AMT' => $extra['amount'],
    'CURRENCYCODE' => $payment
      ->getAmount()
      ->getCurrencyCode(),
  ];

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