You are here

public function CheckoutSdk::refundPayment in Commerce PayPal 8

Refunds a captured payment, by ID.

Parameters

string $capture_id: The PayPal-generated ID for the captured payment to refund.

array $parameters: (optional An array of parameters to pass as the request body.

Return value

\Psr\Http\Message\ResponseInterface The HTTP response.

Overrides CheckoutSdkInterface::refundPayment

File

src/CheckoutSdk.php, line 199

Class

CheckoutSdk
Provides a replacement of the PayPal SDK.

Namespace

Drupal\commerce_paypal

Code

public function refundPayment($capture_id, array $parameters = []) {
  $options = [
    'headers' => [
      'Content-Type' => 'application/json',
    ],
  ];
  if ($parameters) {
    $options['json'] = $parameters;
  }
  return $this->client
    ->post(sprintf('/v2/payments/captures/%s/refund', $capture_id), $options);
}