| Line 54... |
Line 54... |
| 54 |
private static String errorURLforRecharge;
|
54 |
private static String errorURLforRecharge;
|
| 55 |
private static final String resourceFileName = "resource.cgn";
|
55 |
private static final String resourceFileName = "resource.cgn";
|
| 56 |
|
56 |
|
| 57 |
private enum ActionType{
|
57 |
private enum ActionType{
|
| 58 |
PURCHASE("1"),
|
58 |
PURCHASE("1"),
|
| - |
|
59 |
REFUND("2"),
|
| 59 |
AUTH ("4"),
|
60 |
AUTH ("4"),
|
| 60 |
CAPTURE("5");
|
61 |
CAPTURE("5");
|
| 61 |
private String value;
|
62 |
private String value;
|
| 62 |
ActionType(String value) {
|
63 |
ActionType(String value) {
|
| 63 |
this.value = value;
|
64 |
this.value = value;
|
| Line 166... |
Line 167... |
| 166 |
}
|
167 |
}
|
| 167 |
|
168 |
|
| 168 |
return resultMap;
|
169 |
return resultMap;
|
| 169 |
}
|
170 |
}
|
| 170 |
|
171 |
|
| - |
|
172 |
public static Map<String, String> refundPayment(Payment payment, double amount){
|
| - |
|
173 |
String ramount = "" + payment.getAmount();
|
| - |
|
174 |
String gatewayPaymentId = payment.getGatewayPaymentId();
|
| - |
|
175 |
log.info("Refunding amount: Rs " + amount + " for payment Id: " + gatewayPaymentId);
|
| - |
|
176 |
|
| - |
|
177 |
//Prepare resultMap to elicit failure behaviour in case anything goes wrong.
|
| - |
|
178 |
Map<String, String> resultMap = new HashMap<String, String>();
|
| - |
|
179 |
resultMap.put(STATUS, Errors.CAPTURE_FAILURE.code);
|
| - |
|
180 |
resultMap.put(ERR_CODE, Errors.CAPTURE_FAILURE.code);
|
| - |
|
181 |
resultMap.put(ERROR, Errors.CAPTURE_FAILURE.message);
|
| - |
|
182 |
|
| - |
|
183 |
e24TranPipe pipe = new e24TranPipe();
|
| - |
|
184 |
pipe.setResourcePath(resourceDirPath);
|
| - |
|
185 |
pipe.setAlias(aliasName);
|
| - |
|
186 |
pipe.setAction(ActionType.REFUND.value());
|
| - |
|
187 |
pipe.setAmt(ramount);
|
| - |
|
188 |
pipe.setTrackId("" + payment.getId());
|
| - |
|
189 |
pipe.setMember("SAHOLIC");
|
| - |
|
190 |
pipe.setCurrencyCode(currencyCode);
|
| - |
|
191 |
pipe.setTransId(payment.getGatewayTxnId());
|
| - |
|
192 |
|
| - |
|
193 |
//Check if the values have been set properly
|
| - |
|
194 |
log.info("Pipe Amount: " + pipe.getAmt());
|
| - |
|
195 |
log.info("Pipe Action Code: " + pipe.getAction());
|
| - |
|
196 |
log.info("Pipe Currency Code: " + pipe.getCurrencyCode());
|
| - |
|
197 |
log.info("Pipe Track Id: " + pipe.getTrackId());
|
| - |
|
198 |
log.info("Pipe Trans Id:" + pipe.getTransId());
|
| - |
|
199 |
|
| - |
|
200 |
int refundStatus = e24TranPipe.FAILURE;
|
| - |
|
201 |
try {
|
| - |
|
202 |
refundStatus = pipe.performTransaction();
|
| - |
|
203 |
|
| - |
|
204 |
log.info("Refund Status: " + refundStatus);
|
| - |
|
205 |
log.info("Gateway Txn Status: " + pipe.getResult());
|
| - |
|
206 |
log.info("Debug Msg: " + pipe.getDebugMsg());
|
| - |
|
207 |
log.info("Auth: " + pipe.getAuth());
|
| - |
|
208 |
log.info("Ref: " + pipe.getRef());
|
| - |
|
209 |
log.info("TransId:" + pipe.getTransId());
|
| - |
|
210 |
log.info("Amount: " + pipe.getAmt());
|
| - |
|
211 |
|
| - |
|
212 |
resultMap.put(STATUS, "" + refundStatus);
|
| - |
|
213 |
String result = pipe.getResult();
|
| - |
|
214 |
log.info("Result: " + pipe.getResult());
|
| - |
|
215 |
resultMap.put(GATEWAY_STATUS, result.substring(0, Math.min(result.length(), 20)).trim()); //This will return the result of the transaction. (Successful or Failed)
|
| - |
|
216 |
if(refundStatus != e24TranPipe.SUCCESS){
|
| - |
|
217 |
resultMap.put(ERROR, pipe.getErrorMsg()); // In case of any error, we only need to get the error message
|
| - |
|
218 |
|
| - |
|
219 |
if (refundStatus == CAPTURE_STATUS_FOR_CONNECTION_ISSUE) {
|
| - |
|
220 |
resultMap.put(ERR_CODE, Errors.CONN_FAILURE.code);
|
| - |
|
221 |
}
|
| - |
|
222 |
}
|
| - |
|
223 |
else {
|
| - |
|
224 |
resultMap.put(CAPTURE_AUTH_ID, pipe.getAuth()); // Unique ID generated by Authorizer of the transaction
|
| - |
|
225 |
resultMap.put(CAPTURE_REF_ID, pipe.getRef()); // Unique reference number generated during the transaction
|
| - |
|
226 |
resultMap.put(CAPTURE_TXN_ID, pipe.getTransId()); // Unique Transaction ID generated after every successful transaction
|
| - |
|
227 |
resultMap.put(CAPTURE_AMNT, pipe.getAmt()); // Original Amount of the transaction
|
| - |
|
228 |
}
|
| - |
|
229 |
} catch (NotEnoughDataException e) {
|
| - |
|
230 |
log.error(Errors.CAPTURE_FAILURE.message, e);
|
| - |
|
231 |
resultMap.put(ERR_CODE, Errors.CAPTURE_FAILURE.code);
|
| - |
|
232 |
resultMap.put(ERROR, e.getMessage());
|
| - |
|
233 |
}
|
| - |
|
234 |
|
| - |
|
235 |
return resultMap;
|
| - |
|
236 |
}
|
| - |
|
237 |
|
| 171 |
public static String initializeHdfcPayment(Payment payment, PaymentServiceHandler handler) throws Exception{
|
238 |
public static String initializeHdfcPayment(Payment payment, PaymentServiceHandler handler) throws Exception{
|
| 172 |
long merchantPaymentId = payment.getId();
|
239 |
long merchantPaymentId = payment.getId();
|
| 173 |
double amount = payment.getAmount();
|
240 |
double amount = payment.getAmount();
|
| 174 |
e24PaymentPipe pipe = new e24PaymentPipe();
|
241 |
e24PaymentPipe pipe = new e24PaymentPipe();
|
| 175 |
|
242 |
|