PayPal\Api\Capture::refundCapturedPayment PHP Method

refundCapturedPayment() public method

Refunds a captured payment, by ID. Include an amount object in the JSON request body.
public refundCapturedPayment ( RefundRequest $refundRequest, ApiContext $apiContext = null, PayPalRestCall $restCall = null ) : DetailedRefund
$refundRequest RefundRequest
$apiContext PayPal\Rest\ApiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
$restCall PayPal\Transport\PayPalRestCall is the Rest Call Service that is used to make rest calls
return DetailedRefund
    public function refundCapturedPayment($refundRequest, $apiContext = null, $restCall = null)
    {
        ArgumentValidator::validate($this->getId(), "Id");
        ArgumentValidator::validate($refundRequest, 'refundRequest');
        $payLoad = $refundRequest->toJSON();
        $json = self::executeCall("/v1/payments/capture/{$this->getId()}/refund", "POST", $payLoad, null, $apiContext, $restCall);
        $ret = new DetailedRefund();
        $ret->fromJson($json);
        return $ret;
    }