コード例 #1
0
 public function finishSmsPayment(Account $account, SmsPayment $payment)
 {
     if ($payment->isFinished()) {
         return;
     }
     $transaction = new Transaction($account);
     $transaction->setAmount($payment->getAmount());
     $transaction->setCurrency(CurrencyCode::VIRTUAL);
     $transaction->setInformation('Doładowanie poprzez sms');
     $this->bank->deposit($transaction);
     $payment->setStatus(DotpayPaymentStatus::FINISHED);
     $this->updateSmsPayment($payment);
 }
コード例 #2
0
 /**
  * @todo move to better place
  *
  * @param type $service
  * @param type $account 
  */
 public function addServiceToAccount($service, $account)
 {
     if ($service instanceof VirtualPackage) {
         $transaction = new Transaction($account);
         $transaction->enableInvoice();
         $transaction->enableLogging();
         $transaction->setAmount($service->getCost());
         $transaction->setVirtualAmount($service->getAmount());
         $transaction->setInformation($service->getDescription());
         $transaction->disableExchange();
         $this->bank->deposit($transaction);
     } elseif ($service instanceof SubscriptionService) {
         $this->sa->add($service, $account);
     } else {
         throw new BankException("Unsupported service object class");
     }
 }
コード例 #3
0
 public function testDeposit()
 {
     $account = $this->getAccount(135);
     $exchanger = $this->getMock('\\Hatimeria\\BankBundle\\Bank\\CurrencyExchanger');
     $exchanger->expects($this->atLeastOnce())->method('exchange')->with(45, CurrencyExchanger::PLN)->will($this->returnValue(450));
     $em = $this->getMockBuilder('\\Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $em->expects($this->atLeastOnce())->method('persist');
     $bl = $this->getMock('\\Hatimeria\\BankBundle\\Model\\BankLog');
     $blm = $this->getMockBuilder('\\Hatimeria\\BankBundle\\Model\\BankLogManager', array('createLog'))->disableOriginalConstructor()->getMock();
     $blm->expects($this->atLeastOnce())->method('createLog')->will($this->returnValue($bl));
     $blm->expects($this->atLeastOnce())->method('updateLog');
     $t = new Transaction($account);
     $t->setAmount(45);
     $t->setCurrency(CurrencyExchanger::PLN);
     $t->setInformation('Test deposit');
     $bank = new Bank($exchanger, $em, $blm);
     $bank->deposit($t);
     $this->assertBalance(585, $account);
 }