public function credit(FinancialTransactionInterface $transaction, $retry)
 {
     $data = $transaction->getExtendedData();
     $approveTransaction = $transaction->getCredit()->getPayment()->getApproveTransaction();
     $parameters = array();
     if (Number::compare($transaction->getRequestedAmount(), $approveTransaction->getProcessedAmount()) !== 0) {
         $parameters['REFUNDTYPE'] = 'Partial';
         $parameters['AMT'] = $this->client->convertAmountToPaypalFormat($transaction->getRequestedAmount());
         $parameters['CURRENCYCODE'] = $transaction->getCredit()->getPaymentInstruction()->getCurrency();
     }
     $response = $this->client->requestRefundTransaction($data->get('authorization_id'), $parameters);
     $this->throwUnlessSuccessResponse($response, $transaction);
     $transaction->setReferenceNumber($response->body->get('REFUNDTRANSACTIONID'));
     $transaction->setProcessedAmount($response->body->get('NETREFUNDAMT'));
     $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
 }
 protected function constructFinancialTransactionResult(FinancialTransactionInterface $transaction, $status, $reasonCode)
 {
     $this->financialTransaction = $transaction;
     $this->credit = $transaction->getCredit();
     $this->payment = $transaction->getPayment();
     $this->paymentInstruction = null !== $this->credit ? $this->credit->getPaymentInstruction() : $this->payment->getPaymentInstruction();
     $this->status = $status;
     $this->reasonCode = $reasonCode;
     $this->recoverable = false;
 }