@Test public void testGetHtmlFormItemisedWithAddressTwoLines() throws Exception { final Map<String, String> params = getHtmlFormParamsItemised(); final PostFinancePaymentGatewayImpl gatewayImpl = new PostFinancePaymentGatewayImpl() { @Override public String getParameterValue(String valueLabel) { if (params.containsKey(valueLabel)) { return params.get(valueLabel); } return ""; } }; String htmlFormPart = gatewayImpl.getHtmlForm( "holder name", "en", BigDecimal.TEN.setScale(2), "USD", "234-1324-1324-1324sdf-sdf", createTestPayment(true, true) ); assertEquals("<input type='hidden' name='ACCEPTURL' value='http: "<input type='hidden' name='AMOUNT' value='1000'>\n" + "<input type='hidden' name='CANCELURL' value='http: "<input type='hidden' name='CATALOGURL' value='http: "<input type='hidden' name='CN' value='holder name'>\n" + "<input type='hidden' name='COM' value='bob@doe.com, 1234'>\n" + "<input type='hidden' name='CURRENCY' value='USD'>\n" + "<input type='hidden' name='DECLINEURL' value='http: "<input type='hidden' name='EMAIL' value='bob@doe.com'>\n" + "<input type='hidden' name='EXCEPTIONURL' value='http: "<input type='hidden' name='HOMEURL' value='http: "<input type='hidden' name='ITEMID1' value='code2'>\n" + "<input type='hidden' name='ITEMID2' value='ship2'>\n" + "<input type='hidden' name='ITEMNAME1' value='name2'>\n" + "<input type='hidden' name='ITEMNAME2' value='ship2'>\n" + "<input type='hidden' name='ITEMPRICE1' value='5.0000'>\n" + "<input type='hidden' name='ITEMPRICE2' value='0.0000'>\n" + "<input type='hidden' name='ITEMQUANT1' value='2'>\n" + "<input type='hidden' name='ITEMQUANT2' value='1'>\n" + "<input type='hidden' name='ITEMVATCODE1' value='25.0'>\n" + "<input type='hidden' name='ITEMVATCODE2' value='0.0'>\n" + "<input type='hidden' name='LANGUAGE' value='en'>\n" + "<input type='hidden' name='OPERATION' value='SAL'>\n" + "<input type='hidden' name='ORDERID' value='234-1324-1324-1324sdf-sdf'>\n" + "<input type='hidden' name='OWNERADDRESS' value='In the middle of 123'>\n" + "<input type='hidden' name='OWNERCTY' value='NA'>\n" + "<input type='hidden' name='OWNERTELNO' value='123412341234'>\n" + "<input type='hidden' name='OWNERTOWN' value='Nowhere'>\n" + "<input type='hidden' name='OWNERZIP' value='NA1 NA1'>\n" + "<input type='hidden' name='PSPID' value='ID0001'>\n" + "<input type='hidden' name='SHASIGN' value='31E48B4A837DD6F09A2B41615CB37F2CA1AD957F'>\n" + "<input type='hidden' name='TAXINCLUDED1' value='1'>\n" + "<input type='hidden' name='TAXINCLUDED2' value='1'>\n" + "<input type='hidden' name='USERID' value='bob@doe.com'>\n", htmlFormPart); }
@Override public String getHtmlForm(final String cardHolderName, final String locale, final BigDecimal amount, final String currencyCode, final String orderReference, final Payment payment) { final Map<String, String> params = new TreeMap<>(); params.put("PSPID", getParameterValue(PF_PSPID)); params.put("ORDERID", orderReference); params.put("AMOUNT", amount.multiply(MoneyUtils.HUNDRED).setScale(0, RoundingMode.HALF_UP).toPlainString()); params.put("CURRENCY", currencyCode); params.put("LANGUAGE", paymentLocaleTranslator.translateLocale(this, locale)); setValueIfNotNull(params, "CN", cardHolderName); setValueIfNotNull(params, "EMAIL", payment.getBillingEmail()); final boolean invoiceDetailsEnabled = Boolean.valueOf(getParameterValue(PF_DELIVERY_AND_INVOICE_ON)); if (invoiceDetailsEnabled) { final boolean useAddress2AsNumber = Boolean.valueOf(getParameterValue(PF_DELIVERY_AND_INVOICE_ADDR2_IS_NUMBER)); final String address1NumberRegEx = getParameterValue(PF_DELIVERY_AND_INVOICE_ADDR1_NUMBER_REGEX); final PaymentAddress billing = payment.getBillingAddress() != null ? payment.getBillingAddress() : payment.getShippingAddress(); if (billing != null) { setValueIfNotNull(params, "ECOM_BILLTO_COMPANY", billing.getCompanyName1()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_PREFIX", billing.getSalutation()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_FIRST", billing.getFirstname()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_LAST", billing.getLastname()); final Pair<String, String> numberAndStreet = determineAddressNumberAndStreet(billing, useAddress2AsNumber, address1NumberRegEx); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_STREET_NUMBER", numberAndStreet.getFirst()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_STREET_LINE1", numberAndStreet.getSecond()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_POSTALCODE", billing.getPostcode()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_CITY", billing.getCity()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_COUNTRYCODE", billing.getCountryCode()); setValueIfNotNull(params, "ECOM_BILLTO_TELECOM_MOBILE_NUMBER", billing.getMobile1()); setValueIfNotNull(params, "ECOM_BILLTO_TELECOM_PHONE_NUMBER", billing.getPhone1()); } final PaymentAddress shipping = payment.getShippingAddress() != null ? payment.getShippingAddress() : payment.getBillingAddress(); if (shipping != null) { setValueIfNotNull(params, "ECOM_SHIPTO_COMPANY", shipping.getCompanyName1()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_PREFIX", shipping.getSalutation()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_FIRST", shipping.getFirstname()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_LAST", shipping.getLastname()); final Pair<String, String> numberAndStreet = determineAddressNumberAndStreet(shipping, useAddress2AsNumber, address1NumberRegEx); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_STREET_NUMBER", numberAndStreet.getFirst()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_STREET_LINE1", numberAndStreet.getSecond()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_POSTALCODE", shipping.getPostcode()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_CITY", shipping.getCity()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_COUNTRYCODE", shipping.getCountryCode()); setValueIfNotNull(params, "ECOM_SHIPTO_TELECOM_MOBILE_NUMBER", shipping.getMobile1()); setValueIfNotNull(params, "ECOM_SHIPTO_TELECOM_PHONE_NUMBER", shipping.getPhone1()); } } else { final PaymentAddress address = payment.getBillingAddress(); if (address != null) { setValueIfNotNull(params, "OWNERADDRESS", getAddressLines(address)); setValueIfNotNull(params, "OWNERZIP", address.getPostcode()); setValueIfNotNull(params, "OWNERTOWN", address.getCity()); setValueIfNotNull(params, "OWNERCTY", address.getCountryCode()); setValueIfNotNull(params, "OWNERTELNO", address.getPhone1()); } } final boolean itemised = Boolean.valueOf(getParameterValue(PF_ITEMISED)); params.put("COM", getDescription(payment, itemised)); if (itemised) { populateItems(payment, params); } setParameterIfNotNull(params, "TITLE", PF_STYLE_TITLE); setParameterIfNotNull(params, "BGCOLOR", PF_STYLE_BGCOLOR); setParameterIfNotNull(params, "TXTCOLOR", PF_STYLE_TXTCOLOR); setParameterIfNotNull(params, "TBLBGCOLOR", PF_STYLE_TBLBGCOLOR); setParameterIfNotNull(params, "TBLTXTCOLOR", PF_STYLE_TBLTXTCOLOR); setParameterIfNotNull(params, "BUTTONBGCOLOR", PF_STYLE_BUTTONBGCOLOR); setParameterIfNotNull(params, "BUTTONTXTCOLOR", PF_STYLE_BUTTONTXTCOLOR); setParameterIfNotNull(params, "FONTTYPE", PF_STYLE_FONTTYPE); setParameterIfNotNull(params, "LOGO", PF_STYLE_LOGO); setParameterIfNotNull(params, "TP", PF_STYLE_TP); setParameterIfNotNull(params, "PM", PF_PM); setParameterIfNotNull(params, "BRAND", PF_BRAND); setParameterIfNotNull(params, "WIN3DS", PF_WIN3DS); setParameterIfNotNull(params, "PMLIST", PF_PMLIST); setParameterIfNotNull(params, "EXCLPMLIST", PF_EXCLPMLIST); setParameterIfNotNull(params, "PMLISTTYPE", PF_PMLISTTYPE); setParameterIfNotNull(params, "HOMEURL", PF_RESULT_URL_HOME); setParameterIfNotNull(params, "CATALOGURL", PF_RESULT_URL_CATALOG); setParameterIfNotNull(params, "ACCEPTURL", PF_RESULT_URL_ACCEPT); setParameterIfNotNull(params, "DECLINEURL", PF_RESULT_URL_DECLINE); setParameterIfNotNull(params, "EXCEPTIONURL", PF_RESULT_URL_EXCEPTION); setParameterIfNotNull(params, "CANCELURL", PF_RESULT_URL_CANCEL); params.put("OPERATION", getExternalFormOperation()); setValueIfNotNull(params, "USERID", payment.getBillingEmail()); params.put("SHASIGN", sha1sign(params, getParameterValue(PF_SHA_IN))); final StringBuilder form = new StringBuilder(); for (final Map.Entry<String, String> param : params.entrySet()) { form.append(getHiddenField(param.getKey(), param.getValue())); } LOG.debug("PostFinance form request: {}", form); return form.toString(); }
PostFinancePaymentGatewayImpl extends AbstractPostFinancePaymentGatewayImpl implements PaymentGatewayExternalForm, CallbackAware { @Override public String getHtmlForm(final String cardHolderName, final String locale, final BigDecimal amount, final String currencyCode, final String orderReference, final Payment payment) { final Map<String, String> params = new TreeMap<>(); params.put("PSPID", getParameterValue(PF_PSPID)); params.put("ORDERID", orderReference); params.put("AMOUNT", amount.multiply(MoneyUtils.HUNDRED).setScale(0, RoundingMode.HALF_UP).toPlainString()); params.put("CURRENCY", currencyCode); params.put("LANGUAGE", paymentLocaleTranslator.translateLocale(this, locale)); setValueIfNotNull(params, "CN", cardHolderName); setValueIfNotNull(params, "EMAIL", payment.getBillingEmail()); final boolean invoiceDetailsEnabled = Boolean.valueOf(getParameterValue(PF_DELIVERY_AND_INVOICE_ON)); if (invoiceDetailsEnabled) { final boolean useAddress2AsNumber = Boolean.valueOf(getParameterValue(PF_DELIVERY_AND_INVOICE_ADDR2_IS_NUMBER)); final String address1NumberRegEx = getParameterValue(PF_DELIVERY_AND_INVOICE_ADDR1_NUMBER_REGEX); final PaymentAddress billing = payment.getBillingAddress() != null ? payment.getBillingAddress() : payment.getShippingAddress(); if (billing != null) { setValueIfNotNull(params, "ECOM_BILLTO_COMPANY", billing.getCompanyName1()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_PREFIX", billing.getSalutation()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_FIRST", billing.getFirstname()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_LAST", billing.getLastname()); final Pair<String, String> numberAndStreet = determineAddressNumberAndStreet(billing, useAddress2AsNumber, address1NumberRegEx); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_STREET_NUMBER", numberAndStreet.getFirst()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_STREET_LINE1", numberAndStreet.getSecond()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_POSTALCODE", billing.getPostcode()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_CITY", billing.getCity()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_COUNTRYCODE", billing.getCountryCode()); setValueIfNotNull(params, "ECOM_BILLTO_TELECOM_MOBILE_NUMBER", billing.getMobile1()); setValueIfNotNull(params, "ECOM_BILLTO_TELECOM_PHONE_NUMBER", billing.getPhone1()); } final PaymentAddress shipping = payment.getShippingAddress() != null ? payment.getShippingAddress() : payment.getBillingAddress(); if (shipping != null) { setValueIfNotNull(params, "ECOM_SHIPTO_COMPANY", shipping.getCompanyName1()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_PREFIX", shipping.getSalutation()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_FIRST", shipping.getFirstname()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_LAST", shipping.getLastname()); final Pair<String, String> numberAndStreet = determineAddressNumberAndStreet(shipping, useAddress2AsNumber, address1NumberRegEx); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_STREET_NUMBER", numberAndStreet.getFirst()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_STREET_LINE1", numberAndStreet.getSecond()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_POSTALCODE", shipping.getPostcode()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_CITY", shipping.getCity()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_COUNTRYCODE", shipping.getCountryCode()); setValueIfNotNull(params, "ECOM_SHIPTO_TELECOM_MOBILE_NUMBER", shipping.getMobile1()); setValueIfNotNull(params, "ECOM_SHIPTO_TELECOM_PHONE_NUMBER", shipping.getPhone1()); } } else { final PaymentAddress address = payment.getBillingAddress(); if (address != null) { setValueIfNotNull(params, "OWNERADDRESS", getAddressLines(address)); setValueIfNotNull(params, "OWNERZIP", address.getPostcode()); setValueIfNotNull(params, "OWNERTOWN", address.getCity()); setValueIfNotNull(params, "OWNERCTY", address.getCountryCode()); setValueIfNotNull(params, "OWNERTELNO", address.getPhone1()); } } final boolean itemised = Boolean.valueOf(getParameterValue(PF_ITEMISED)); params.put("COM", getDescription(payment, itemised)); if (itemised) { populateItems(payment, params); } setParameterIfNotNull(params, "TITLE", PF_STYLE_TITLE); setParameterIfNotNull(params, "BGCOLOR", PF_STYLE_BGCOLOR); setParameterIfNotNull(params, "TXTCOLOR", PF_STYLE_TXTCOLOR); setParameterIfNotNull(params, "TBLBGCOLOR", PF_STYLE_TBLBGCOLOR); setParameterIfNotNull(params, "TBLTXTCOLOR", PF_STYLE_TBLTXTCOLOR); setParameterIfNotNull(params, "BUTTONBGCOLOR", PF_STYLE_BUTTONBGCOLOR); setParameterIfNotNull(params, "BUTTONTXTCOLOR", PF_STYLE_BUTTONTXTCOLOR); setParameterIfNotNull(params, "FONTTYPE", PF_STYLE_FONTTYPE); setParameterIfNotNull(params, "LOGO", PF_STYLE_LOGO); setParameterIfNotNull(params, "TP", PF_STYLE_TP); setParameterIfNotNull(params, "PM", PF_PM); setParameterIfNotNull(params, "BRAND", PF_BRAND); setParameterIfNotNull(params, "WIN3DS", PF_WIN3DS); setParameterIfNotNull(params, "PMLIST", PF_PMLIST); setParameterIfNotNull(params, "EXCLPMLIST", PF_EXCLPMLIST); setParameterIfNotNull(params, "PMLISTTYPE", PF_PMLISTTYPE); setParameterIfNotNull(params, "HOMEURL", PF_RESULT_URL_HOME); setParameterIfNotNull(params, "CATALOGURL", PF_RESULT_URL_CATALOG); setParameterIfNotNull(params, "ACCEPTURL", PF_RESULT_URL_ACCEPT); setParameterIfNotNull(params, "DECLINEURL", PF_RESULT_URL_DECLINE); setParameterIfNotNull(params, "EXCEPTIONURL", PF_RESULT_URL_EXCEPTION); setParameterIfNotNull(params, "CANCELURL", PF_RESULT_URL_CANCEL); params.put("OPERATION", getExternalFormOperation()); setValueIfNotNull(params, "USERID", payment.getBillingEmail()); params.put("SHASIGN", sha1sign(params, getParameterValue(PF_SHA_IN))); final StringBuilder form = new StringBuilder(); for (final Map.Entry<String, String> param : params.entrySet()) { form.append(getHiddenField(param.getKey(), param.getValue())); } LOG.debug("PostFinance form request: {}", form); return form.toString(); } }
PostFinancePaymentGatewayImpl extends AbstractPostFinancePaymentGatewayImpl implements PaymentGatewayExternalForm, CallbackAware { @Override public String getHtmlForm(final String cardHolderName, final String locale, final BigDecimal amount, final String currencyCode, final String orderReference, final Payment payment) { final Map<String, String> params = new TreeMap<>(); params.put("PSPID", getParameterValue(PF_PSPID)); params.put("ORDERID", orderReference); params.put("AMOUNT", amount.multiply(MoneyUtils.HUNDRED).setScale(0, RoundingMode.HALF_UP).toPlainString()); params.put("CURRENCY", currencyCode); params.put("LANGUAGE", paymentLocaleTranslator.translateLocale(this, locale)); setValueIfNotNull(params, "CN", cardHolderName); setValueIfNotNull(params, "EMAIL", payment.getBillingEmail()); final boolean invoiceDetailsEnabled = Boolean.valueOf(getParameterValue(PF_DELIVERY_AND_INVOICE_ON)); if (invoiceDetailsEnabled) { final boolean useAddress2AsNumber = Boolean.valueOf(getParameterValue(PF_DELIVERY_AND_INVOICE_ADDR2_IS_NUMBER)); final String address1NumberRegEx = getParameterValue(PF_DELIVERY_AND_INVOICE_ADDR1_NUMBER_REGEX); final PaymentAddress billing = payment.getBillingAddress() != null ? payment.getBillingAddress() : payment.getShippingAddress(); if (billing != null) { setValueIfNotNull(params, "ECOM_BILLTO_COMPANY", billing.getCompanyName1()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_PREFIX", billing.getSalutation()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_FIRST", billing.getFirstname()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_LAST", billing.getLastname()); final Pair<String, String> numberAndStreet = determineAddressNumberAndStreet(billing, useAddress2AsNumber, address1NumberRegEx); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_STREET_NUMBER", numberAndStreet.getFirst()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_STREET_LINE1", numberAndStreet.getSecond()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_POSTALCODE", billing.getPostcode()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_CITY", billing.getCity()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_COUNTRYCODE", billing.getCountryCode()); setValueIfNotNull(params, "ECOM_BILLTO_TELECOM_MOBILE_NUMBER", billing.getMobile1()); setValueIfNotNull(params, "ECOM_BILLTO_TELECOM_PHONE_NUMBER", billing.getPhone1()); } final PaymentAddress shipping = payment.getShippingAddress() != null ? payment.getShippingAddress() : payment.getBillingAddress(); if (shipping != null) { setValueIfNotNull(params, "ECOM_SHIPTO_COMPANY", shipping.getCompanyName1()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_PREFIX", shipping.getSalutation()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_FIRST", shipping.getFirstname()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_LAST", shipping.getLastname()); final Pair<String, String> numberAndStreet = determineAddressNumberAndStreet(shipping, useAddress2AsNumber, address1NumberRegEx); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_STREET_NUMBER", numberAndStreet.getFirst()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_STREET_LINE1", numberAndStreet.getSecond()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_POSTALCODE", shipping.getPostcode()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_CITY", shipping.getCity()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_COUNTRYCODE", shipping.getCountryCode()); setValueIfNotNull(params, "ECOM_SHIPTO_TELECOM_MOBILE_NUMBER", shipping.getMobile1()); setValueIfNotNull(params, "ECOM_SHIPTO_TELECOM_PHONE_NUMBER", shipping.getPhone1()); } } else { final PaymentAddress address = payment.getBillingAddress(); if (address != null) { setValueIfNotNull(params, "OWNERADDRESS", getAddressLines(address)); setValueIfNotNull(params, "OWNERZIP", address.getPostcode()); setValueIfNotNull(params, "OWNERTOWN", address.getCity()); setValueIfNotNull(params, "OWNERCTY", address.getCountryCode()); setValueIfNotNull(params, "OWNERTELNO", address.getPhone1()); } } final boolean itemised = Boolean.valueOf(getParameterValue(PF_ITEMISED)); params.put("COM", getDescription(payment, itemised)); if (itemised) { populateItems(payment, params); } setParameterIfNotNull(params, "TITLE", PF_STYLE_TITLE); setParameterIfNotNull(params, "BGCOLOR", PF_STYLE_BGCOLOR); setParameterIfNotNull(params, "TXTCOLOR", PF_STYLE_TXTCOLOR); setParameterIfNotNull(params, "TBLBGCOLOR", PF_STYLE_TBLBGCOLOR); setParameterIfNotNull(params, "TBLTXTCOLOR", PF_STYLE_TBLTXTCOLOR); setParameterIfNotNull(params, "BUTTONBGCOLOR", PF_STYLE_BUTTONBGCOLOR); setParameterIfNotNull(params, "BUTTONTXTCOLOR", PF_STYLE_BUTTONTXTCOLOR); setParameterIfNotNull(params, "FONTTYPE", PF_STYLE_FONTTYPE); setParameterIfNotNull(params, "LOGO", PF_STYLE_LOGO); setParameterIfNotNull(params, "TP", PF_STYLE_TP); setParameterIfNotNull(params, "PM", PF_PM); setParameterIfNotNull(params, "BRAND", PF_BRAND); setParameterIfNotNull(params, "WIN3DS", PF_WIN3DS); setParameterIfNotNull(params, "PMLIST", PF_PMLIST); setParameterIfNotNull(params, "EXCLPMLIST", PF_EXCLPMLIST); setParameterIfNotNull(params, "PMLISTTYPE", PF_PMLISTTYPE); setParameterIfNotNull(params, "HOMEURL", PF_RESULT_URL_HOME); setParameterIfNotNull(params, "CATALOGURL", PF_RESULT_URL_CATALOG); setParameterIfNotNull(params, "ACCEPTURL", PF_RESULT_URL_ACCEPT); setParameterIfNotNull(params, "DECLINEURL", PF_RESULT_URL_DECLINE); setParameterIfNotNull(params, "EXCEPTIONURL", PF_RESULT_URL_EXCEPTION); setParameterIfNotNull(params, "CANCELURL", PF_RESULT_URL_CANCEL); params.put("OPERATION", getExternalFormOperation()); setValueIfNotNull(params, "USERID", payment.getBillingEmail()); params.put("SHASIGN", sha1sign(params, getParameterValue(PF_SHA_IN))); final StringBuilder form = new StringBuilder(); for (final Map.Entry<String, String> param : params.entrySet()) { form.append(getHiddenField(param.getKey(), param.getValue())); } LOG.debug("PostFinance form request: {}", form); return form.toString(); }  }
PostFinancePaymentGatewayImpl extends AbstractPostFinancePaymentGatewayImpl implements PaymentGatewayExternalForm, CallbackAware { @Override public String getHtmlForm(final String cardHolderName, final String locale, final BigDecimal amount, final String currencyCode, final String orderReference, final Payment payment) { final Map<String, String> params = new TreeMap<>(); params.put("PSPID", getParameterValue(PF_PSPID)); params.put("ORDERID", orderReference); params.put("AMOUNT", amount.multiply(MoneyUtils.HUNDRED).setScale(0, RoundingMode.HALF_UP).toPlainString()); params.put("CURRENCY", currencyCode); params.put("LANGUAGE", paymentLocaleTranslator.translateLocale(this, locale)); setValueIfNotNull(params, "CN", cardHolderName); setValueIfNotNull(params, "EMAIL", payment.getBillingEmail()); final boolean invoiceDetailsEnabled = Boolean.valueOf(getParameterValue(PF_DELIVERY_AND_INVOICE_ON)); if (invoiceDetailsEnabled) { final boolean useAddress2AsNumber = Boolean.valueOf(getParameterValue(PF_DELIVERY_AND_INVOICE_ADDR2_IS_NUMBER)); final String address1NumberRegEx = getParameterValue(PF_DELIVERY_AND_INVOICE_ADDR1_NUMBER_REGEX); final PaymentAddress billing = payment.getBillingAddress() != null ? payment.getBillingAddress() : payment.getShippingAddress(); if (billing != null) { setValueIfNotNull(params, "ECOM_BILLTO_COMPANY", billing.getCompanyName1()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_PREFIX", billing.getSalutation()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_FIRST", billing.getFirstname()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_LAST", billing.getLastname()); final Pair<String, String> numberAndStreet = determineAddressNumberAndStreet(billing, useAddress2AsNumber, address1NumberRegEx); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_STREET_NUMBER", numberAndStreet.getFirst()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_STREET_LINE1", numberAndStreet.getSecond()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_POSTALCODE", billing.getPostcode()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_CITY", billing.getCity()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_COUNTRYCODE", billing.getCountryCode()); setValueIfNotNull(params, "ECOM_BILLTO_TELECOM_MOBILE_NUMBER", billing.getMobile1()); setValueIfNotNull(params, "ECOM_BILLTO_TELECOM_PHONE_NUMBER", billing.getPhone1()); } final PaymentAddress shipping = payment.getShippingAddress() != null ? payment.getShippingAddress() : payment.getBillingAddress(); if (shipping != null) { setValueIfNotNull(params, "ECOM_SHIPTO_COMPANY", shipping.getCompanyName1()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_PREFIX", shipping.getSalutation()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_FIRST", shipping.getFirstname()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_LAST", shipping.getLastname()); final Pair<String, String> numberAndStreet = determineAddressNumberAndStreet(shipping, useAddress2AsNumber, address1NumberRegEx); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_STREET_NUMBER", numberAndStreet.getFirst()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_STREET_LINE1", numberAndStreet.getSecond()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_POSTALCODE", shipping.getPostcode()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_CITY", shipping.getCity()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_COUNTRYCODE", shipping.getCountryCode()); setValueIfNotNull(params, "ECOM_SHIPTO_TELECOM_MOBILE_NUMBER", shipping.getMobile1()); setValueIfNotNull(params, "ECOM_SHIPTO_TELECOM_PHONE_NUMBER", shipping.getPhone1()); } } else { final PaymentAddress address = payment.getBillingAddress(); if (address != null) { setValueIfNotNull(params, "OWNERADDRESS", getAddressLines(address)); setValueIfNotNull(params, "OWNERZIP", address.getPostcode()); setValueIfNotNull(params, "OWNERTOWN", address.getCity()); setValueIfNotNull(params, "OWNERCTY", address.getCountryCode()); setValueIfNotNull(params, "OWNERTELNO", address.getPhone1()); } } final boolean itemised = Boolean.valueOf(getParameterValue(PF_ITEMISED)); params.put("COM", getDescription(payment, itemised)); if (itemised) { populateItems(payment, params); } setParameterIfNotNull(params, "TITLE", PF_STYLE_TITLE); setParameterIfNotNull(params, "BGCOLOR", PF_STYLE_BGCOLOR); setParameterIfNotNull(params, "TXTCOLOR", PF_STYLE_TXTCOLOR); setParameterIfNotNull(params, "TBLBGCOLOR", PF_STYLE_TBLBGCOLOR); setParameterIfNotNull(params, "TBLTXTCOLOR", PF_STYLE_TBLTXTCOLOR); setParameterIfNotNull(params, "BUTTONBGCOLOR", PF_STYLE_BUTTONBGCOLOR); setParameterIfNotNull(params, "BUTTONTXTCOLOR", PF_STYLE_BUTTONTXTCOLOR); setParameterIfNotNull(params, "FONTTYPE", PF_STYLE_FONTTYPE); setParameterIfNotNull(params, "LOGO", PF_STYLE_LOGO); setParameterIfNotNull(params, "TP", PF_STYLE_TP); setParameterIfNotNull(params, "PM", PF_PM); setParameterIfNotNull(params, "BRAND", PF_BRAND); setParameterIfNotNull(params, "WIN3DS", PF_WIN3DS); setParameterIfNotNull(params, "PMLIST", PF_PMLIST); setParameterIfNotNull(params, "EXCLPMLIST", PF_EXCLPMLIST); setParameterIfNotNull(params, "PMLISTTYPE", PF_PMLISTTYPE); setParameterIfNotNull(params, "HOMEURL", PF_RESULT_URL_HOME); setParameterIfNotNull(params, "CATALOGURL", PF_RESULT_URL_CATALOG); setParameterIfNotNull(params, "ACCEPTURL", PF_RESULT_URL_ACCEPT); setParameterIfNotNull(params, "DECLINEURL", PF_RESULT_URL_DECLINE); setParameterIfNotNull(params, "EXCEPTIONURL", PF_RESULT_URL_EXCEPTION); setParameterIfNotNull(params, "CANCELURL", PF_RESULT_URL_CANCEL); params.put("OPERATION", getExternalFormOperation()); setValueIfNotNull(params, "USERID", payment.getBillingEmail()); params.put("SHASIGN", sha1sign(params, getParameterValue(PF_SHA_IN))); final StringBuilder form = new StringBuilder(); for (final Map.Entry<String, String> param : params.entrySet()) { form.append(getHiddenField(param.getKey(), param.getValue())); } LOG.debug("PostFinance form request: {}", form); return form.toString(); }  @Override String getPostActionUrl(); @Override String getSubmitButton(final String locale); @Override Callback convertToCallback(final Map privateCallBackParameters,
                                      final boolean forceProcessing); @Override void preProcess(final Payment payment, final Callback callback, final String processorOperation); @Override void postProcess(final Payment payment, final Callback callback, final String processorOperation); @Override CallbackAware.CallbackResult getExternalCallbackResult(final Map<String, String> callbackResult,
                                                                  final boolean forceProcessing); @Override String getHtmlForm(final String cardHolderName, final String locale, final BigDecimal amount,
                              final String currencyCode, final String orderReference, final Payment payment); @Override Payment authorizeCapture(final Payment payment, final boolean forceProcessing); @Override Payment authorize(final Payment paymentIn, final boolean forceProcessing); @Override Payment reverseAuthorization(final Payment paymentIn, final boolean forceProcessing); @Override Payment capture(final Payment paymentIn, final boolean forceProcessing); @Override Payment voidCapture(final Payment paymentIn, final boolean forceProcessing); @Override Payment refund(final Payment paymentIn, final boolean forceProcessing); @Override Payment createPaymentPrototype(final String operation,
                                          final Map map,
                                          final boolean forceProcessing); @Override PaymentGatewayFeature getPaymentGatewayFeatures(); }
PostFinancePaymentGatewayImpl extends AbstractPostFinancePaymentGatewayImpl implements PaymentGatewayExternalForm, CallbackAware { @Override public String getHtmlForm(final String cardHolderName, final String locale, final BigDecimal amount, final String currencyCode, final String orderReference, final Payment payment) { final Map<String, String> params = new TreeMap<>(); params.put("PSPID", getParameterValue(PF_PSPID)); params.put("ORDERID", orderReference); params.put("AMOUNT", amount.multiply(MoneyUtils.HUNDRED).setScale(0, RoundingMode.HALF_UP).toPlainString()); params.put("CURRENCY", currencyCode); params.put("LANGUAGE", paymentLocaleTranslator.translateLocale(this, locale)); setValueIfNotNull(params, "CN", cardHolderName); setValueIfNotNull(params, "EMAIL", payment.getBillingEmail()); final boolean invoiceDetailsEnabled = Boolean.valueOf(getParameterValue(PF_DELIVERY_AND_INVOICE_ON)); if (invoiceDetailsEnabled) { final boolean useAddress2AsNumber = Boolean.valueOf(getParameterValue(PF_DELIVERY_AND_INVOICE_ADDR2_IS_NUMBER)); final String address1NumberRegEx = getParameterValue(PF_DELIVERY_AND_INVOICE_ADDR1_NUMBER_REGEX); final PaymentAddress billing = payment.getBillingAddress() != null ? payment.getBillingAddress() : payment.getShippingAddress(); if (billing != null) { setValueIfNotNull(params, "ECOM_BILLTO_COMPANY", billing.getCompanyName1()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_PREFIX", billing.getSalutation()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_FIRST", billing.getFirstname()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_NAME_LAST", billing.getLastname()); final Pair<String, String> numberAndStreet = determineAddressNumberAndStreet(billing, useAddress2AsNumber, address1NumberRegEx); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_STREET_NUMBER", numberAndStreet.getFirst()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_STREET_LINE1", numberAndStreet.getSecond()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_POSTALCODE", billing.getPostcode()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_CITY", billing.getCity()); setValueIfNotNull(params, "ECOM_BILLTO_POSTAL_COUNTRYCODE", billing.getCountryCode()); setValueIfNotNull(params, "ECOM_BILLTO_TELECOM_MOBILE_NUMBER", billing.getMobile1()); setValueIfNotNull(params, "ECOM_BILLTO_TELECOM_PHONE_NUMBER", billing.getPhone1()); } final PaymentAddress shipping = payment.getShippingAddress() != null ? payment.getShippingAddress() : payment.getBillingAddress(); if (shipping != null) { setValueIfNotNull(params, "ECOM_SHIPTO_COMPANY", shipping.getCompanyName1()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_PREFIX", shipping.getSalutation()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_FIRST", shipping.getFirstname()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_NAME_LAST", shipping.getLastname()); final Pair<String, String> numberAndStreet = determineAddressNumberAndStreet(shipping, useAddress2AsNumber, address1NumberRegEx); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_STREET_NUMBER", numberAndStreet.getFirst()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_STREET_LINE1", numberAndStreet.getSecond()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_POSTALCODE", shipping.getPostcode()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_CITY", shipping.getCity()); setValueIfNotNull(params, "ECOM_SHIPTO_POSTAL_COUNTRYCODE", shipping.getCountryCode()); setValueIfNotNull(params, "ECOM_SHIPTO_TELECOM_MOBILE_NUMBER", shipping.getMobile1()); setValueIfNotNull(params, "ECOM_SHIPTO_TELECOM_PHONE_NUMBER", shipping.getPhone1()); } } else { final PaymentAddress address = payment.getBillingAddress(); if (address != null) { setValueIfNotNull(params, "OWNERADDRESS", getAddressLines(address)); setValueIfNotNull(params, "OWNERZIP", address.getPostcode()); setValueIfNotNull(params, "OWNERTOWN", address.getCity()); setValueIfNotNull(params, "OWNERCTY", address.getCountryCode()); setValueIfNotNull(params, "OWNERTELNO", address.getPhone1()); } } final boolean itemised = Boolean.valueOf(getParameterValue(PF_ITEMISED)); params.put("COM", getDescription(payment, itemised)); if (itemised) { populateItems(payment, params); } setParameterIfNotNull(params, "TITLE", PF_STYLE_TITLE); setParameterIfNotNull(params, "BGCOLOR", PF_STYLE_BGCOLOR); setParameterIfNotNull(params, "TXTCOLOR", PF_STYLE_TXTCOLOR); setParameterIfNotNull(params, "TBLBGCOLOR", PF_STYLE_TBLBGCOLOR); setParameterIfNotNull(params, "TBLTXTCOLOR", PF_STYLE_TBLTXTCOLOR); setParameterIfNotNull(params, "BUTTONBGCOLOR", PF_STYLE_BUTTONBGCOLOR); setParameterIfNotNull(params, "BUTTONTXTCOLOR", PF_STYLE_BUTTONTXTCOLOR); setParameterIfNotNull(params, "FONTTYPE", PF_STYLE_FONTTYPE); setParameterIfNotNull(params, "LOGO", PF_STYLE_LOGO); setParameterIfNotNull(params, "TP", PF_STYLE_TP); setParameterIfNotNull(params, "PM", PF_PM); setParameterIfNotNull(params, "BRAND", PF_BRAND); setParameterIfNotNull(params, "WIN3DS", PF_WIN3DS); setParameterIfNotNull(params, "PMLIST", PF_PMLIST); setParameterIfNotNull(params, "EXCLPMLIST", PF_EXCLPMLIST); setParameterIfNotNull(params, "PMLISTTYPE", PF_PMLISTTYPE); setParameterIfNotNull(params, "HOMEURL", PF_RESULT_URL_HOME); setParameterIfNotNull(params, "CATALOGURL", PF_RESULT_URL_CATALOG); setParameterIfNotNull(params, "ACCEPTURL", PF_RESULT_URL_ACCEPT); setParameterIfNotNull(params, "DECLINEURL", PF_RESULT_URL_DECLINE); setParameterIfNotNull(params, "EXCEPTIONURL", PF_RESULT_URL_EXCEPTION); setParameterIfNotNull(params, "CANCELURL", PF_RESULT_URL_CANCEL); params.put("OPERATION", getExternalFormOperation()); setValueIfNotNull(params, "USERID", payment.getBillingEmail()); params.put("SHASIGN", sha1sign(params, getParameterValue(PF_SHA_IN))); final StringBuilder form = new StringBuilder(); for (final Map.Entry<String, String> param : params.entrySet()) { form.append(getHiddenField(param.getKey(), param.getValue())); } LOG.debug("PostFinance form request: {}", form); return form.toString(); }  @Override String getPostActionUrl(); @Override String getSubmitButton(final String locale); @Override Callback convertToCallback(final Map privateCallBackParameters,
                                      final boolean forceProcessing); @Override void preProcess(final Payment payment, final Callback callback, final String processorOperation); @Override void postProcess(final Payment payment, final Callback callback, final String processorOperation); @Override CallbackAware.CallbackResult getExternalCallbackResult(final Map<String, String> callbackResult,
                                                                  final boolean forceProcessing); @Override String getHtmlForm(final String cardHolderName, final String locale, final BigDecimal amount,
                              final String currencyCode, final String orderReference, final Payment payment); @Override Payment authorizeCapture(final Payment payment, final boolean forceProcessing); @Override Payment authorize(final Payment paymentIn, final boolean forceProcessing); @Override Payment reverseAuthorization(final Payment paymentIn, final boolean forceProcessing); @Override Payment capture(final Payment paymentIn, final boolean forceProcessing); @Override Payment voidCapture(final Payment paymentIn, final boolean forceProcessing); @Override Payment refund(final Payment paymentIn, final boolean forceProcessing); @Override Payment createPaymentPrototype(final String operation,
                                          final Map map,
                                          final boolean forceProcessing); @Override PaymentGatewayFeature getPaymentGatewayFeatures();  }