@Test public void getSeamlessFormTest() { CurrencyModel currency = new CurrencyModel(); currency.setIsocode(ISOCODE); Locale locale = Locale.ENGLISH; when(abstractOrderModel.getGuid()).thenReturn(GUID); when(abstractOrderModel.getTotalPrice()).thenReturn(2d); when(abstractOrderModel.getCurrency()).thenReturn(currency); when(i18NService.getCurrentLocale()).thenReturn(locale); when(wirecardSignatureStrategy.getMaid(paymentModeModel)).thenReturn(MAID); when(wirecardSignatureStrategy.generateSignatureV1(wirecardRequestData, paymentModeModel)).thenReturn(SIGNATURE); WirecardRequestData wirecardRequestData = wirecardPaymentModeFacade.getSeamlessFormData(abstractOrderModel, TransactionType.AUTHORIZATION, PaymentMethodName.CREDITCARD, paymentModeModel); assertEquals("transactionType does not match", TransactionType.AUTHORIZATION.value(), wirecardRequestData.getTransactionType()); assertEquals("requestedAmount does not match", String.valueOf(abstractOrderModel.getTotalPrice()), wirecardRequestData.getRequestedAmount()); assertEquals("requestedAmountCurrency does not match", abstractOrderModel.getCurrency().getIsocode(), wirecardRequestData.getRequestedAmountCurrency()); assertEquals("paymentMethod does not match", PaymentMethodName.CREDITCARD.value(), wirecardRequestData.getPaymentMethod()); }
@Override public WirecardRequestData getSeamlessFormData(AbstractOrderModel abstractOrderModel, TransactionType transactionType, PaymentMethodName paymentMethodName, PaymentModeModel paymentModeModel) { WirecardRequestData wirecardRequestData = new WirecardRequestData(); Date newDate = new Date(); SimpleDateFormat format = new SimpleDateFormat(REQUEST_DATA_DATE_FORMAT); format.setTimeZone(TimeZone.getTimeZone(UTC)); String dateToStr = format.format(newDate); wirecardRequestData.setRequestTimeStamp(dateToStr); wirecardRequestData.setRequestId(abstractOrderModel.getGuid() .concat(paymentMethodName.value()) .concat(String.valueOf(newDate.getTime()))); wirecardRequestData.setMerchantAccountId(wirecardSignatureStrategy.getMaid(paymentModeModel)); wirecardRequestData.setTransactionType(transactionType.value()); wirecardRequestData.setRequestedAmount(String.valueOf(abstractOrderModel.getTotalPrice())); wirecardRequestData.setRequestedAmountCurrency(abstractOrderModel.getCurrency().getIsocode()); wirecardRequestData.setLocale(getI18NService().getCurrentLocale().getLanguage()); wirecardRequestData.setPaymentMethod(paymentMethodName.value()); wirecardRequestData.setRequestSignature(wirecardSignatureStrategy.generateSignatureV1(wirecardRequestData, paymentModeModel)); return wirecardRequestData; }
DefaultWirecardPaymentModeFacade implements WirecardPaymentModeFacade { @Override public WirecardRequestData getSeamlessFormData(AbstractOrderModel abstractOrderModel, TransactionType transactionType, PaymentMethodName paymentMethodName, PaymentModeModel paymentModeModel) { WirecardRequestData wirecardRequestData = new WirecardRequestData(); Date newDate = new Date(); SimpleDateFormat format = new SimpleDateFormat(REQUEST_DATA_DATE_FORMAT); format.setTimeZone(TimeZone.getTimeZone(UTC)); String dateToStr = format.format(newDate); wirecardRequestData.setRequestTimeStamp(dateToStr); wirecardRequestData.setRequestId(abstractOrderModel.getGuid() .concat(paymentMethodName.value()) .concat(String.valueOf(newDate.getTime()))); wirecardRequestData.setMerchantAccountId(wirecardSignatureStrategy.getMaid(paymentModeModel)); wirecardRequestData.setTransactionType(transactionType.value()); wirecardRequestData.setRequestedAmount(String.valueOf(abstractOrderModel.getTotalPrice())); wirecardRequestData.setRequestedAmountCurrency(abstractOrderModel.getCurrency().getIsocode()); wirecardRequestData.setLocale(getI18NService().getCurrentLocale().getLanguage()); wirecardRequestData.setPaymentMethod(paymentMethodName.value()); wirecardRequestData.setRequestSignature(wirecardSignatureStrategy.generateSignatureV1(wirecardRequestData, paymentModeModel)); return wirecardRequestData; } }
DefaultWirecardPaymentModeFacade implements WirecardPaymentModeFacade { @Override public WirecardRequestData getSeamlessFormData(AbstractOrderModel abstractOrderModel, TransactionType transactionType, PaymentMethodName paymentMethodName, PaymentModeModel paymentModeModel) { WirecardRequestData wirecardRequestData = new WirecardRequestData(); Date newDate = new Date(); SimpleDateFormat format = new SimpleDateFormat(REQUEST_DATA_DATE_FORMAT); format.setTimeZone(TimeZone.getTimeZone(UTC)); String dateToStr = format.format(newDate); wirecardRequestData.setRequestTimeStamp(dateToStr); wirecardRequestData.setRequestId(abstractOrderModel.getGuid() .concat(paymentMethodName.value()) .concat(String.valueOf(newDate.getTime()))); wirecardRequestData.setMerchantAccountId(wirecardSignatureStrategy.getMaid(paymentModeModel)); wirecardRequestData.setTransactionType(transactionType.value()); wirecardRequestData.setRequestedAmount(String.valueOf(abstractOrderModel.getTotalPrice())); wirecardRequestData.setRequestedAmountCurrency(abstractOrderModel.getCurrency().getIsocode()); wirecardRequestData.setLocale(getI18NService().getCurrentLocale().getLanguage()); wirecardRequestData.setPaymentMethod(paymentMethodName.value()); wirecardRequestData.setRequestSignature(wirecardSignatureStrategy.generateSignatureV1(wirecardRequestData, paymentModeModel)); return wirecardRequestData; }  }
DefaultWirecardPaymentModeFacade implements WirecardPaymentModeFacade { @Override public WirecardRequestData getSeamlessFormData(AbstractOrderModel abstractOrderModel, TransactionType transactionType, PaymentMethodName paymentMethodName, PaymentModeModel paymentModeModel) { WirecardRequestData wirecardRequestData = new WirecardRequestData(); Date newDate = new Date(); SimpleDateFormat format = new SimpleDateFormat(REQUEST_DATA_DATE_FORMAT); format.setTimeZone(TimeZone.getTimeZone(UTC)); String dateToStr = format.format(newDate); wirecardRequestData.setRequestTimeStamp(dateToStr); wirecardRequestData.setRequestId(abstractOrderModel.getGuid() .concat(paymentMethodName.value()) .concat(String.valueOf(newDate.getTime()))); wirecardRequestData.setMerchantAccountId(wirecardSignatureStrategy.getMaid(paymentModeModel)); wirecardRequestData.setTransactionType(transactionType.value()); wirecardRequestData.setRequestedAmount(String.valueOf(abstractOrderModel.getTotalPrice())); wirecardRequestData.setRequestedAmountCurrency(abstractOrderModel.getCurrency().getIsocode()); wirecardRequestData.setLocale(getI18NService().getCurrentLocale().getLanguage()); wirecardRequestData.setPaymentMethod(paymentMethodName.value()); wirecardRequestData.setRequestSignature(wirecardSignatureStrategy.generateSignatureV1(wirecardRequestData, paymentModeModel)); return wirecardRequestData; }  @Override List<PaymentModeData> getActivePaymentModes(); PaymentModeData getActiveCreditCardPaymentMode(List<PaymentModeData> paymentModeData, String alias); @Override boolean isPurchase(String paymentMethodChosen); @Override WirecardRequestData getSeamlessFormData(AbstractOrderModel abstractOrderModel,
                                                   TransactionType transactionType,
                                                   PaymentMethodName paymentMethodName, PaymentModeModel paymentModeModel); @Override SepaMandateData getSepaMandateData(String sepaCode); @Override boolean isPaymentMethodActive(String paymentMethodChosen); @Override boolean isPaymentMethodChooseInactive(String paymentMethodChosen); @Required void setI18NService(I18NService i18NService); @Required void setPaymentModeConverter(Converter<PaymentModeModel, PaymentModeData> paymentModeConverter); @Required void setWirecardPaymentModeService(WirecardPaymentModeService wirecardPaymentModeService); @Required void setWirecardPaymentConfigurationService(WirecardPaymentConfigurationService wirecardPaymentConfigurationService); @Required void setWirecardSignatureStrategy(WirecardSignatureStrategy wirecardSignatureStrategy); }
DefaultWirecardPaymentModeFacade implements WirecardPaymentModeFacade { @Override public WirecardRequestData getSeamlessFormData(AbstractOrderModel abstractOrderModel, TransactionType transactionType, PaymentMethodName paymentMethodName, PaymentModeModel paymentModeModel) { WirecardRequestData wirecardRequestData = new WirecardRequestData(); Date newDate = new Date(); SimpleDateFormat format = new SimpleDateFormat(REQUEST_DATA_DATE_FORMAT); format.setTimeZone(TimeZone.getTimeZone(UTC)); String dateToStr = format.format(newDate); wirecardRequestData.setRequestTimeStamp(dateToStr); wirecardRequestData.setRequestId(abstractOrderModel.getGuid() .concat(paymentMethodName.value()) .concat(String.valueOf(newDate.getTime()))); wirecardRequestData.setMerchantAccountId(wirecardSignatureStrategy.getMaid(paymentModeModel)); wirecardRequestData.setTransactionType(transactionType.value()); wirecardRequestData.setRequestedAmount(String.valueOf(abstractOrderModel.getTotalPrice())); wirecardRequestData.setRequestedAmountCurrency(abstractOrderModel.getCurrency().getIsocode()); wirecardRequestData.setLocale(getI18NService().getCurrentLocale().getLanguage()); wirecardRequestData.setPaymentMethod(paymentMethodName.value()); wirecardRequestData.setRequestSignature(wirecardSignatureStrategy.generateSignatureV1(wirecardRequestData, paymentModeModel)); return wirecardRequestData; }  @Override List<PaymentModeData> getActivePaymentModes(); PaymentModeData getActiveCreditCardPaymentMode(List<PaymentModeData> paymentModeData, String alias); @Override boolean isPurchase(String paymentMethodChosen); @Override WirecardRequestData getSeamlessFormData(AbstractOrderModel abstractOrderModel,
                                                   TransactionType transactionType,
                                                   PaymentMethodName paymentMethodName, PaymentModeModel paymentModeModel); @Override SepaMandateData getSepaMandateData(String sepaCode); @Override boolean isPaymentMethodActive(String paymentMethodChosen); @Override boolean isPaymentMethodChooseInactive(String paymentMethodChosen); @Required void setI18NService(I18NService i18NService); @Required void setPaymentModeConverter(Converter<PaymentModeModel, PaymentModeData> paymentModeConverter); @Required void setWirecardPaymentModeService(WirecardPaymentModeService wirecardPaymentModeService); @Required void setWirecardPaymentConfigurationService(WirecardPaymentConfigurationService wirecardPaymentConfigurationService); @Required void setWirecardSignatureStrategy(WirecardSignatureStrategy wirecardSignatureStrategy);  }