src/Payum/Paypal/ProCheckout/Nvp/Action/RefundAction.php
public function execute($request)
    {
        /** @var $request Refund */
        RequestNotSupportedException::assertSupports($this, $request);

        $details = ArrayObject::ensureArrayObject($request->getModel());

        if (null === $details['RESULT']) {
            return;
        }

        $refundableTrxTypes = array(Api::TRXTYPE_SALE, Api::TRXTYPE_DELAYED_CAPUTER, Api::TRXTYPE_VOICE_AUTHORIZATION);
        if (false == in_array($details['TRXTYPE'], $refundableTrxTypes)) {
            throw new LogicException(sprintf(
                'You cannot refund transaction with type %s. Only these types could be refunded: %s',
                $details['TRXTYPE'],
                implode(', ', $refundableTrxTypes)
            ));
        }

        $details->validateNotEmpty(array('PNREF'), true);

        $details['PURCHASE_TRXTYPE'] = $details['TRXTYPE'];
        $details['TRXTYPE'] = null;

        $details['PURCHASE_RESULT'] = $details['RESULT'];
        $details['RESULT'] = null;

        $details['ORIGID'] = $details['PNREF'];

        $details->replace($this->api->doCredit($details->toUnsafeArray()));
    }
public function execute($request)
    {
        /** @var $request Refund */
        RequestNotSupportedException::assertSupports($this, $request);

        $details = ArrayObject::ensureArrayObject($request->getModel());

        if (null === $details['RESULT']) {
            return;
        }

        $refundableTrxTypes = array(Api::TRXTYPE_SALE, Api::TRXTYPE_DELAYED_CAPUTER, Api::TRXTYPE_VOICE_AUTHORIZATION);
        if (false == in_array($details['TRXTYPE'], $refundableTrxTypes)) {
            throw new LogicException(sprintf(
                'You cannot refund transaction with type %s. Only these types could be refunded: %s',
                $details['TRXTYPE'],
                implode(', ', $refundableTrxTypes)
            ));
        }

        $details->validateNotEmpty(array('PNREF'), true);

        $details['PURCHASE_TRXTYPE'] = $details['TRXTYPE'];
        $details['TRXTYPE'] = null;

        $details['PURCHASE_RESULT'] = $details['RESULT'];
        $details['RESULT'] = null;

        $details['ORIGID'] = $details['PNREF'];

        $details->replace($this->api->doCredit($details->toUnsafeArray()));
    }
{@inheritDoc}