47 ApiMacSha256 apiMacSha256 =
new ApiMacSha256();
49 apiMacSha256.setParameter(
"DS_MERCHANT_TITULAR", Strings.truncateAndWarn(ElephantContext.getSiteName(), 60));
50 apiMacSha256.setParameter(
"DS_MERCHANT_AMOUNT", DecimalFormats.format(amount * 100,
"0"));
51 apiMacSha256.setParameter(
"DS_MERCHANT_ORDER", order);
52 apiMacSha256.setParameter(
"DS_MERCHANT_MERCHANTNAME", ElephantContext.getSiteName());
53 apiMacSha256.setParameter(
"DS_MERCHANT_MERCHANTCODE", ShopContext.getInstance().getMerchantCode());
54 apiMacSha256.setParameter(
"DS_MERCHANT_CURRENCY", ShopContext.getInstance().getMerchantCurrency());
55 apiMacSha256.setParameter(
"DS_MERCHANT_TRANSACTIONTYPE",
"0");
56 apiMacSha256.setParameter(
"DS_MERCHANT_TERMINAL", ShopContext.getInstance().getMerchantTerminal());
57 apiMacSha256.setParameter(
"DS_MERCHANT_MERCHANTURL", ElephantContext.getServerUrl(
"http") + ShopContext.getInstance().getNotificationPath());
58 apiMacSha256.setParameter(
"DS_MERCHANT_URLOK", ElephantContext.getServerUrl(
"http") + ShopContext.getInstance().getOKPath());
59 apiMacSha256.setParameter(
"DS_MERCHANT_URLKO", ElephantContext.getServerUrl(
"http") + ShopContext.getInstance().getKOPath());
61 apiMacSha256.setParameter(
"DS_MERCHANT_CONSUMERLANGUAGE", ShopContext.getInstance().getMerchantLanguage());
64 if(ShopContext.getInstance().isMerchantTestScope()) {
65 marker.put(
"pos_url",
"https://sis-t.redsys.es:25443/sis/realizarPago");
67 marker.put(
"pos_url",
"https://sis.redsys.es/sis/realizarPago");
69 marker.put(
"pos_version", ShopContext.getInstance().getMerchantKeyType());
70 marker.put(
"pos_params", apiMacSha256.createMerchantParameters());
71 marker.put(
"pos_signature", apiMacSha256.createMerchantSignature(ShopContext.getInstance().getMerchantKey()));
72 }
catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException | IllegalStateException |
73 NoSuchPaddingException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
74 Logger.getLogger(RedsysPOS.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);