public function getInvitee($username) { $lender = LenderQuery::create()->useUserQuery()->filterByUsername($username)->endUse()->findOne(); $lenderInviteVisit = InviteVisitQuery::create()->findOneById(Session::get('lenderInviteVisitId')); if (!$lender) { return Redirect::route('/'); } $ycAccountCredit = TransactionQuery::create()->filterByUserId(Setting::get('site.YCAccountId'))->getTotalBalance(); if ($ycAccountCredit->getAmount() < 5000) { return View::make('lender.invite-inactive'); } if (!Auth::check()) { $lenderInvite = $shareType = null; if (Request::query('h')) { $lenderInvite = InviteQuery::create()->filterByLender($lender)->findOneByHash(Request::query('h')); $shareType = $lenderInvite ? 1 : null; } else { $shareType = Request::query('s') ?: 0; } $isNewVisit = !$lenderInviteVisit || $lenderInviteVisit->getLenderId() != $lender->getId(); if ($isNewVisit && $shareType !== null) { $lenderInviteVisit = $this->lenderService->addLenderInviteVisit($lender, $shareType, $lenderInvite); Session::put('lenderInviteVisitId', $lenderInviteVisit->getId()); return Redirect::route('lender:invitee', ['username' => $lender->getUser()->getUsername()]); } } return View::make('lender.invitee', compact('lender')); }
public function __construct() { $google = new \Google_Client(); $google->setClientId(Setting::get('google.clientId')); $google->setClientSecret(Setting::get('google.clientSecret')); $this->google = $google; }
public function maximumPeriod() { $maximumMonths = Setting::get('loan.maximumPeriod'); if ($this->borrower->getCountry()->getInstallmentPeriod() == Loan::WEEKLY_INSTALLMENT) { $maximumMonths = ceil($maximumMonths / 12 * 52); } return $maximumMonths; }
public function makePayment(Payment $payment, $data = []) { if (empty($data['stripeToken'])) { throw new \Exception('Missing Stripe Token.'); } $stripeTransaction = new StripeTransaction(); $stripeTransaction->setAmount($payment->getCreditAmount())->setDonationAmount($payment->getDonationAmount())->setTransactionFee($payment->getTransactionFee())->setTotalAmount($payment->getTotalAmount())->setStatus('START')->setPaymentId($payment->getId()); $stripeTransaction->save(); \Stripe::setApiKey(Setting::get('stripe.secretKey')); $paymentError = $charge = null; try { $charge = \Stripe_Charge::create(array("amount" => $payment->getTotalAmount()->getAmountInCents(), "currency" => "usd", "card" => $data['stripeToken'])); } catch (Stripe_CardError $e) { $paymentError = new PaymentError('Your Card Information is not correct.'); } catch (Stripe_InvalidRequestError $e) { $paymentError = new PaymentError('Invalid parameters give to stripe.'); } catch (Stripe_AuthenticationError $e) { $paymentError = new PaymentError('Stripe Authentication failed.'); } catch (Stripe_ApiConnectionError $e) { $paymentError = new PaymentError('We could not communicate with stripe please try again.'); } catch (Stripe_Error $e) { //Todo: send mail to admin $paymentError = new PaymentError('Sorry we can not process your card at this moment.'); } catch (\Exception $e) { //Todo: send mail to admin $paymentError = new PaymentError('Oops something is wrong.'); } if ($paymentError) { return $this->paymentBus->getFailedHandler($payment, $paymentError)->setPayment($payment)->redirect(); } $stripeTransaction->setStatus('Completed')->setStripeId($charge->id); $stripeTransaction->save(); $serializedData = serialize($charge); //Stripe log $stripeLog = new StripeLog(); $stripeLog->setLog($serializedData); $stripeLog->save(); return $this->paymentBus->getCompletedHandler($payment)->process()->redirect(); }
public function addConvertToDonationTransaction(ConnectionInterface $con, Lender $lender, Money $amount) { $this->assertAmount($amount); $transaction = new Transaction(); $transaction->setUserId($lender->getId())->setAmount($amount->multiply(-1))->setDescription('Donation to Zidisha')->setTransactionDate(new \DateTime())->setType(Transaction::DONATION)->setSubType(Transaction::DONATE_BY_ADMIN); $transaction->save($con); $transactionDonation = new Transaction(); $transactionDonation->setUserId(Setting::get('site.adminId'))->setAmount($amount)->setDescription('Donation from lender')->setTransactionDate(new \DateTime())->setType(Transaction::DONATION)->setSubType(Transaction::DONATE_BY_ADMIN); $transactionDonation->save($con); }
public function postFunds() { $form = $this->uploadFundForm; $form->handleRequest(\Request::instance()); if ($form->isValid()) { $country = Utility::getCountryCodeByIP(); $blockedCountries = Setting::get('site.countriesCodesBlockedFromUploadFunds'); $blockedCountries = explode(',', $blockedCountries); if (in_array($country['code'], $blockedCountries)) { \Flash::error("Something went wrong!"); return Redirect::route('lender:funds')->withForm($form); } return $form->makePayment(); } \Flash::error("Entered Amounts are invalid!"); return Redirect::route('lender:funds')->withForm($form); }
public function __construct() { $this->facebook = new \Facebook(array('appId' => Setting::get('facebook.appId'), 'secret' => Setting::get('facebook.appSecret'))); }