/** * {@inheritdoc} */ public function deposit(FinancialTransactionInterface $transaction, $retry) { $data = $transaction->getExtendedData(); if ($transaction->getResponseCode() !== PluginInterface::RESPONSE_CODE_SUCCESS || $transaction->getReasonCode() !== PluginInterface::REASON_CODE_SUCCESS) { $e = new FinancialException('Peyment is not completed'); $e->setFinancialTransaction($transaction); throw $e; } // różnica kwoty zatwierdzonej i kwoty wymaganej musi być równa zero // && nazwa waluty musi się zgadzać if (Number::compare($transaction->getProcessedAmount(), $transaction->getRequestedAmount()) === 0 && $transaction->getPayment()->getPaymentInstruction()->getCurrency() == "BTC") { // wszystko ok // można zakakceptować zamówienie $event = new PaymentEvent($this->getName(), $transaction, $transaction->getPayment()->getPaymentInstruction()); $this->dispatcher->dispatch('deposit', $event); } else { // coś się nie zgadza, nie można tego zakaceptować $e = new FinancialException('The deposit has not passed validation'); $e->setFinancialTransaction($transaction); $transaction->setResponseCode('Unknown'); $transaction->setReasonCode($data->get('confirmations')); throw $e; } }