Exemplo n.º 1
0
 public function verify(Borrower $borrower, User $user, $data)
 {
     $borrower->setActivationStatus($data['isEligibleByAdmin'] ? Borrower::ACTIVATION_APPROVED : Borrower::ACTIVATION_DECLINED);
     $borrower->save();
     if ($borrower->isActivationApproved()) {
         $this->borrowerMailer->sendApprovedConfirmationMail($borrower);
     } else {
         $this->borrowerMailer->sendDeclinedConfirmationMail($borrower);
         $this->siftScienceService->sendBorrowerDeclinedEvent($borrower);
     }
 }
Exemplo n.º 2
0
 public function applyForLoan(Borrower $borrower, $data)
 {
     $exchangeRate = ExchangeRateQuery::create()->findCurrent($borrower->getCountry()->getCurrency());
     $data['currencyCode'] = $borrower->getCountry()->getCurrencyCode();
     $loanCategory = CategoryQuery::create()->findOneById($data['categoryId']);
     $data['nativeAmount'] = $data['amount'];
     // TODO
     $data['amount'] = Converter::toUSD(Money::create($data['nativeAmount'], $data['currencyCode']), $exchangeRate)->getAmount();
     $loan = Loan::createFromData($data);
     $loan->setCategory($loanCategory)->setBorrower($borrower)->setStatus(Loan::OPEN);
     PropelDB::transaction(function ($con) use($loan) {
         $loan->save($con);
         $this->changeLoanStage($con, $loan, null, Loan::OPEN);
     });
     $this->borrowerMailer->sendLoanConfirmation($borrower, $loan);
     // TODO send mail to lenders
     $this->addToLoanIndex($loan);
 }