/**
  * This method executes a credit transaction against a Credit.
  *
  * @param FinancialTransactionInterface $transaction
  * @param $retry
  * @throws \JMS\Payment\CoreBundle\Plugin\Exception\FinancialException
  */
 public function credit(FinancialTransactionInterface $transaction, $retry)
 {
     $data = $transaction->getExtendedData();
     // refund transaction
     $response = $this->client->refund($data->get('charge_id'), $transaction->getRequestedAmount());
     $this->throwUnlessSuccessResponse($response, $transaction);
     // complete the transaction
     $transaction->setReferenceNumber($response->getResponse()->id);
     $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
     $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS);
     $refund = array_pop($response->getResponse()->refunds);
     $transaction->setProcessedAmount($this->client->convertAmountFromStripeFormat($refund->getResponse()->amount));
 }