BrightSide Workbench Full Report + Source Code
org.turro.financials.cart.RedsysPOS Class Reference

Public Member Functions

void addParameters (ElephantMarker marker, double amount, String order)
 
boolean isOnlineNotification (IConstructor constructor)
 
Cart isAccepted (IConstructor constructor)
 
void logProperties ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 42 of file RedsysPOS.java.

Member Function Documentation

◆ addParameters()

void org.turro.financials.cart.RedsysPOS.addParameters ( ElephantMarker  marker,
double  amount,
String  order 
)

Definition at line 46 of file RedsysPOS.java.

46  {
47  ApiMacSha256 apiMacSha256 = new ApiMacSha256();
48 
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());
60  //apiMacSha256.setParameter("DS_MERCHANT_MERCHANTDATA", request.getParameter("data"));
61  apiMacSha256.setParameter("DS_MERCHANT_CONSUMERLANGUAGE", ShopContext.getInstance().getMerchantLanguage());
62 
63  try {
64  if(ShopContext.getInstance().isMerchantTestScope()) {
65  marker.put("pos_url", "https://sis-t.redsys.es:25443/sis/realizarPago");
66  } else {
67  marker.put("pos_url", "https://sis.redsys.es/sis/realizarPago");
68  }
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);
75  }
76 
77  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAccepted()

Cart org.turro.financials.cart.RedsysPOS.isAccepted ( IConstructor  constructor)

Definition at line 113 of file RedsysPOS.java.

113  {
114  ApiMacSha256 apiMacSha256 = new ApiMacSha256();
115 
116  String version = constructor.getParameter("Ds_SignatureVersion", true),
117  params = constructor.getParameter("Ds_MerchantParameters", true),
118  signature = constructor.getParameter("Ds_Signature", true);
119 
120  try {
121 
122  apiMacSha256.decodeMerchantParameters(params);
123 
124  String response = apiMacSha256.getParameter("Ds_Response"),
125  order = apiMacSha256.getParameter("Ds_Order");
126 
127  properties.put("Ds_Order", order);
128 
129  if(!Strings.isBlank(response) && Long.valueOf(response) < 100) {
130  return Cart.deserializeForOrder(order);
131  }
132 
133  } catch (UnsupportedEncodingException ex) {
134  Logger.getLogger(RedsysPOS.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
135  }
136 
137  return null;
138  }
Here is the call graph for this function:

◆ isOnlineNotification()

boolean org.turro.financials.cart.RedsysPOS.isOnlineNotification ( IConstructor  constructor)

Definition at line 82 of file RedsysPOS.java.

82  {
83  String version = constructor.getParameter("Ds_SignatureVersion", true),
84  params = constructor.getParameter("Ds_MerchantParameters", true),
85  signature = constructor.getParameter("Ds_Signature", true);
86 
87  if(Strings.isBlank(signature)) {
88  return false;
89  }
90 
91  properties.put("Ds_SignatureVersion", version);
92  properties.put("Ds_MerchantParameters", params);
93  properties.put("Ds_Signature", signature);
94 
95  ApiMacSha256 apiMacSha256 = new ApiMacSha256();
96 
97  try {
98 
99  apiMacSha256.decodeMerchantParameters(params);
100 
101  String calculated = apiMacSha256.createMerchantSignatureNotif(ShopContext.getInstance().getMerchantKey(), params);
102 
103  return calculated.equals(signature);
104 
105  } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException | IllegalStateException |
106  NoSuchPaddingException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
107  Logger.getLogger(RedsysPOS.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
108  }
109 
110  return false;
111  }
Here is the call graph for this function:

◆ logProperties()

void org.turro.financials.cart.RedsysPOS.logProperties ( )

Definition at line 140 of file RedsysPOS.java.

140  {
141  for(String k : properties.keySet()) {
142  Logger.getLogger(RedsysPOS.class.getName()).log(Level.INFO, k + ":" + properties.get(k));
143  }
144  }

The documentation for this class was generated from the following file: