public void testAll() throws CvqException {

    SecurityContext.setCurrentSite(localAuthorityName, SecurityContext.FRONT_OFFICE_CONTEXT);
    SecurityContext.setCurrentEcitizen(fake.responsibleId);

    InternalInvoiceItem invoice1 =
        new InternalInvoiceItem(
            "PaylineV4 Invoice 1",
            Double.valueOf("300"),
            "key",
            "keyOwner",
            "PaylineV4",
            Integer.valueOf(1),
            Double.valueOf(2));
    Payment payment = paymentService.createPaymentContainer(invoice1, PaymentMode.INTERNET);
    InternalInvoiceItem invoice2 =
        new InternalInvoiceItem(
            "PaylineV4 Invoice 2",
            Double.valueOf("600"),
            "key",
            "keyOwner",
            "PaylineV4",
            Integer.valueOf(1),
            Double.valueOf(2));
    paymentService.addPurchaseItemToPayment(payment, invoice2);

    payment.addPaymentSpecificData("domainName", "localhost");

    URL url = paymentService.initPayment(payment);
    assertNotNull(url);

    continueWithNewTransaction();

    Set<Critere> criterias = new HashSet<Critere>();
    criterias.add(new Critere(Payment.SEARCH_BY_HOME_FOLDER_ID, fake.id, Critere.EQUALS));
    List<Payment> payments = paymentService.get(criterias, null, null, 0, 0);
    assertEquals(1, payments.size());
    Payment finalPayment = payments.get(0);
    assertNotNull(finalPayment.getBankReference());
    assertNotNull(finalPayment.getCvqReference());

    //        Map<String, String> parameters = new HashMap<String, String>();
    //        parameters.put("token", payment.getBankReference());
    //        PaymentResultStatus returnStatus = iPaymentService.commitPayment(parameters);
    //        Assert.assertEquals(PaymentResultStatus.OK, returnStatus);
  }
  public URL doInitPayment(Payment payment, PaymentServiceBean paymentServiceBean)
      throws CvqException {

    try {
      String cvqReference = "FPS_" + payment.getHomeFolderId() + "_" + System.currentTimeMillis();
      payment.setCvqReference(cvqReference);

      String domainName = payment.getPaymentSpecificData().get("domainName");
      String scheme = payment.getPaymentSpecificData().get("scheme");
      String port = payment.getPaymentSpecificData().get("port");

      if (payment.getPaymentSpecificData().get("callbackUrl") != null)
        callbackUrl = payment.getPaymentSpecificData().get("callbackUrl");

      if (port == null) port = "80";
      if (scheme == null) scheme = "https";

      String baseSiteUrl = scheme + "://" + domainName + ":" + port;

      StringBuffer urlBuffer =
          new StringBuffer()
              .append(baseSiteUrl)
              .append(paymentUrl)
              .append("?cvqReference=")
              .append(cvqReference)
              .append("&amount=")
              .append(payment.getEuroAmount())
              .append("&callbackUrl=")
              .append(baseSiteUrl)
              .append(callbackUrl)
              .append("&capDematFake=true");

      String email = payment.getPaymentSpecificDataByKey(Payment.SPECIFIC_DATA_EMAIL);
      if (email != null && !email.equals("")) urlBuffer.append("&email=").append(email);

      return new URL(urlBuffer.toString());

    } catch (MalformedURLException mue) {
      throw new CvqException(mue.getMessage());
    }
  }