public function testConstructor() { $data = new ExtendedData(); $instruction = new PaymentInstruction(123.45, 'USD', 'foo', $data); $this->assertEquals(123.45, $instruction->getAmount()); $this->assertEquals('USD', $instruction->getCurrency()); $this->assertEquals('foo', $instruction->getPaymentSystemName()); $this->assertSame($data, $instruction->getExtendedData()); $this->assertSame(FinancialTransaction::STATE_NEW, $instruction->getState()); $this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $instruction->getCredits()); $this->assertEquals(0, count($instruction->getCredits())); $this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $instruction->getPayments()); $this->assertEquals(0, count($instruction->getPayments())); $this->assertEquals(0.0, $instruction->getApprovingAmount()); $this->assertEquals(0.0, $instruction->getApprovedAmount()); $this->assertEquals(0.0, $instruction->getDepositingAmount()); $this->assertEquals(0.0, $instruction->getDepositedAmount()); $this->assertEquals(0.0, $instruction->getCreditingAmount()); $this->assertEquals(0.0, $instruction->getCreditedAmount()); $this->assertEquals(0.0, $instruction->getReversingApprovedAmount()); $this->assertEquals(0.0, $instruction->getReversingCreditedAmount()); $this->assertEquals(0.0, $instruction->getReversingDepositedAmount()); $this->assertNull($instruction->getId()); $this->assertTrue(time() - $instruction->getCreatedAt()->getTimestamp() < 10); $this->assertNull($instruction->getUpdatedAt()); }
/** * Przekierowanie do systemu płatności * @param PaymentInstruction $instruction * @return Response */ public function redirectAction(PaymentInstruction $instruction) { $sci = $this->get('payment.perfectmoney.client'); if (null === ($transaction = $instruction->getPendingTransaction())) { throw new \RuntimeException('No pending transaction found for the payment instruction'); } $extendedData = $transaction->getExtendedData(); if (!$extendedData->has('payment_url')) { throw new \RuntimeException('You must configure a payment_url.'); } if (!$extendedData->has('nopayment_url')) { throw new \RuntimeException('You must configure a nopayment_url.'); } $html = $this->container->get('twig')->render('vSymfoPaymentPerfectMoneyBundle:Default:redirect.html.twig', array("PAYEE_ACCOUNT" => $sci->getPayeeAccount(), "PAYMENT_AMOUNT" => $transaction->getRequestedAmount(), "PAYMENT_UNITS" => $instruction->getCurrency(), "PAYMENT_URL" => $extendedData->get('payment_url'), "NOPAYMENT_URL" => $extendedData->get('nopayment_url'), "PAYEE_NAME" => $this->container->getParameter('vsymfo_payment_perfectmoney.payee_name'), "STATUS_URL" => $this->generateUrl('vsymfo_payment_perfectmoney_callback', array("id" => $instruction->getId()), true))); return new Response(ViewUtility::redirectView($html)); }