public function approveAndDeposit(FinancialTransactionInterface $transaction, $retry)
 {
     $data = $transaction->getExtendedData();
     if (0 != $data->get('code')) {
         $transaction->setResponseCode(self::RESPONSE_CODE_FAILED);
         $transaction->setReasonCode($data->get('error'));
         $transaction->setState(FinancialTransactionInterface::STATE_FAILED);
         $this->logger->info(sprintf('Payment failed with error code %s. Error: %s', $data->get('code'), $data->get('error')));
         $ex = new FinancialException(sprintf('Payment failed with error code %s. Error: %s', $data->get('code'), $data->get('error')));
         $ex->setFinancialTransaction($transaction);
         throw $ex;
     }
     $transaction->setReferenceNumber($data->get('order_id'));
     if (17 == $data->get('response_code')) {
         $transaction->setResponseCode(self::RESPONSE_CODE_CANCELED);
         $transaction->setReasonCode('Payment canceled');
     } elseif (0 != $data->get('response_code')) {
         $transaction->setResponseCode(self::RESPONSE_CODE_FAILED);
         $transaction->setReasonCode(sprintf('Response code: %s', $data->get('response_code')));
         $this->logger->info(sprintf('Payment failed with error response_code %s. Error: %s', $data->get('response_code'), $data->get('error')));
     } else {
         $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
         $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS);
         $transaction->setProcessedAmount($data->get('sub_amount') / 100);
     }
 }
 public function approveAndDeposit(FinancialTransactionInterface $transaction, $retry)
 {
     /** @var $payment \Jms\Payment\CoreBundle\Model\PaymentInterface */
     $payment = $transaction->getPayment();
     $transaction->setProcessedAmount($payment->getTargetAmount());
     $transaction->setState(FinancialTransactionInterface::STATE_SUCCESS);
     $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
     $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS);
 }
 function approveAndDeposit(FinancialTransactionInterface $transaction, $retry)
 {
     try {
         $this->responseClient->isValid();
         $transaction->setReferenceNumber($this->responseClient->getOrderNumber());
         $transaction->setProcessedAmount($transaction->getPayment()->getApprovingAmount());
         $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
         $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS);
     } catch (ActionRequiredException $e) {
         $actionRequest = new ActionRequiredException('User has not yet authorized the transaction.');
         $actionRequest->setFinancialTransaction($transaction);
         $actionRequest->setAction(new VisitUrl($this->getRedirectUrl($transaction)));
         throw $actionRequest;
     }
 }
 /**
  * @param BatchResponse $response
  * @param FinancialTransactionInterface $transaction
  * @throws FinancialException
  */
 private function handleUnsuccessfulResponse(BatchResponse $response, FinancialTransactionInterface $transaction)
 {
     $transaction->setResponseCode($response->getErrorCode());
     $transaction->setReasonCode($response->getStatusError());
     $ex = new FinancialException('Ogone-Response was not successful: ' . $response->getErrorDescription());
     $ex->setFinancialTransaction($transaction);
     throw $ex;
 }
 /**
  * {@inheritdoc}
  */
 public function approve(FinancialTransactionInterface $transaction, $retry)
 {
     $data = $transaction->getExtendedData();
     $this->checkExtendedDataBeforeApproveAndDeposit($data);
     if ((int) $data->get('confirmations') >= 6) {
         $transaction->setReferenceNumber($data->get('transaction_hash'));
         $transaction->setProcessedAmount($data->get('value'));
         $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
         $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS);
     } else {
         $e = new FinancialException('Payment status unknow: ' . $data->get('confirmations'));
         $e->setFinancialTransaction($transaction);
         $transaction->setResponseCode('Unknown');
         $transaction->setReasonCode($data->get('confirmations'));
         throw $e;
     }
 }
 /**
  * @param Response $response
  * @param FinancialTransactionInterface $transaction
  * @throws \JMS\Payment\CoreBundle\Plugin\Exception\FinancialException
  */
 protected function throwUnlessSuccessResponse(Response $response, FinancialTransactionInterface $transaction)
 {
     if ($response->isSuccess()) {
         return;
     }
     $transaction->setResponseCode($response->getErrorResponseCode());
     $transaction->setReasonCode($response->getErrorReasonCode());
     $ex = new FinancialException('Stripe-Response was not successful: ' . $response->getErrorMessage());
     $ex->setFinancialTransaction($transaction);
     throw $ex;
 }
 /**
  * {@inheritdoc}
  */
 public function approve(FinancialTransactionInterface $transaction, $retry)
 {
     $data = $transaction->getExtendedData();
     $this->checkExtendedDataBeforeApproveAndDeposit($data);
     if ($data->get('sStatus') == self::STATUS_COMPLETED || $data->get('sId') == self::TEST_ID && $data->get('sStatus') == self::STATUS_TEST_SUCCESS) {
         $transaction->setReferenceNumber($data->get('sId'));
         $transaction->setProcessedAmount($data->get('fAmount'));
         $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
         $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS);
     } else {
         $e = new FinancialException('Payment status unknow: ' . $data->get('sStatus'));
         $e->setFinancialTransaction($transaction);
         $transaction->setResponseCode('Unknown');
         $transaction->setReasonCode($data->get('sStatus'));
         throw $e;
     }
 }
 /**
  * @param FinancialTransactionInterface $transaction
  */
 private function process(FinancialTransactionInterface $transaction)
 {
     $transaction->setProcessedAmount($transaction->getRequestedAmount());
     $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
     $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS);
 }
 /**
  * @param stdClass $response
  * @param FinancialTransactionInterface $transaction
  * @throws \JMS\Payment\CoreBundle\Plugin\Exception\FinancialException
  * @return null
  */
 protected function throwUnlessSuccessResponse($response, FinancialTransactionInterface $transaction)
 {
     if (!empty($response->error)) {
         $transaction->setResponseCode('Failed');
         $transaction->setReasonCode($response->error);
         $ex = new FinancialException('Bitpay request was not successful: ' . $response->error);
         $ex->setFinancialTransaction($transaction);
         throw $ex;
     }
 }
 /**
  * @param \JMS\Payment\CoreBundle\Model\FinancialTransactionInterface $transaction
  * @param \JMS\Payment\PaypalBundle\Client\Response $response
  * @return null
  * @throws \JMS\Payment\CoreBundle\Plugin\Exception\FinancialException
  */
 protected function throwUnlessSuccessResponse(Response $response, FinancialTransactionInterface $transaction)
 {
     if ($response->isSuccess()) {
         return;
     }
     $transaction->setResponseCode($response->body->get('ACK'));
     $transaction->setReasonCode($response->body->get('L_ERRORCODE0'));
     $ex = new FinancialException('PayPal-Response was not successful: ' . $response);
     $ex->setFinancialTransaction($transaction);
     throw $ex;
 }
 /**
  * {@inheritdoc}
  */
 public function approve(FinancialTransactionInterface $transaction, $retry)
 {
     $data = $transaction->getExtendedData();
     $this->checkExtendedDataBeforeApproveAndDeposit($data);
     if ($data->get('ok_txn_status') == CallbackResponse::STATUS_COMPLETED) {
         $transaction->setReferenceNumber(OkPayClient::REF_NUM_PREFIX . $data->get("ok_txn_id"));
         $transaction->setProcessedAmount($data->get('ok_txn_gross'));
         $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
         $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS);
     } else {
         $e = new FinancialException('Payment status unknow: ' . $data->get('ok_txn_status'));
         $e->setFinancialTransaction($transaction);
         $transaction->setResponseCode('Unknown');
         $transaction->setReasonCode($data->get('ok_txn_status'));
         throw $e;
     }
 }