public function testClient()
 {
     $client = new BlockchainClient("1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq", "seCrEtKey");
     $this->assertEquals($client->getReceivingAddress(), "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq");
     $this->assertEquals($client->generateCallbackUrl("http://yoururl.com"), "http://yoururl.com/?secret=seCrEtKey");
     $this->assertEquals($client->getSecretParameter(), "seCrEtKey");
     $response = $client->generatePayment("http://yoururl.com");
     $this->assertEquals($response->getDestination(), "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq");
     $this->assertNotNull($response->getInputAddress());
     $this->assertEquals($response->getFeePercent(), 0);
     $this->assertEquals($response->getCallbackUrl(), "http://yoururl.com/?secret=seCrEtKey");
     try {
         // nieprawidłowa odpowiedź
         $client = new BlockchainClient("invalid address", "seCrEtKey");
         $client->generatePayment("http://yoururl.com");
         $this->assertTrue(false);
     } catch (\Exception $e) {
         if ($e->getCode() == 1) {
             $this->assertTrue(true);
         } else {
             $this->assertTrue(false);
         }
     }
 }
 /**
  * @param FinancialTransactionInterface $transaction
  * @return ActionRequiredException
  * @throws FinancialException
  */
 public function createPaymentRedirect(FinancialTransactionInterface $transaction)
 {
     $actionRequest = new ActionRequiredException('Redirecting to payment.');
     $actionRequest->setFinancialTransaction($transaction);
     $instruction = $transaction->getPayment()->getPaymentInstruction();
     if ($instruction->getCurrency() != "BTC") {
         $e = new FinancialException("Transaction currency is not BTC");
         $e->setFinancialTransaction($transaction);
         throw $e;
     }
     $data = $transaction->getExtendedData();
     $response = $this->client->generatePayment($this->router->generate('vsymfo_payment_blockchain_callback', array("id" => $instruction->getId()), true));
     $data->set("generated_input_address", $response->getInputAddress());
     $actionRequest->setAction(new VisitUrl($this->router->generate('vsymfo_payment_blockchain_redirect', array("id" => $instruction->getId()))));
     return $actionRequest;
 }