Subversion Repositories SmartDukaan

Rev

Rev 2758 | Rev 3010 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2758 Rev 2818
Line 11... Line 11...
11
import in.shop2020.payments.Payment;
11
import in.shop2020.payments.Payment;
12
import in.shop2020.payments.PaymentStatus;
12
import in.shop2020.payments.PaymentStatus;
13
import in.shop2020.payments.PaymentService.Client;
13
import in.shop2020.payments.PaymentService.Client;
14
import in.shop2020.thrift.clients.PaymentServiceClient;
14
import in.shop2020.thrift.clients.PaymentServiceClient;
15
 
15
 
16
 
-
 
17
public class HdfcPaymentService implements IPaymentService {
16
public class HdfcPaymentService implements IPaymentService {
18
	private static final long serialVersionUID = 1L;
17
	private static final long serialVersionUID = 1L;
19
	private static Logger log = Logger.getLogger(Class.class);
18
	private static Logger log = Logger.getLogger(Class.class);
20
	
19
	
21
//	private static String resourceFilePath;
-
 
22
//	private static String aliasName;
-
 
23
//	private static String responseURL;
-
 
24
//	private static String errorURL;
-
 
25
//	private static final String regex = "[^a-zA-Z0-9\\s\\-\\@\\/\\.]";
-
 
26
//	private static final String replacement = " ";
-
 
27
//	private static final int MAX_UDF_LENGTH = 30;
-
 
28
//	private static final String currencyCode = "356";
-
 
29
	private String redirectURL;
20
	private String redirectURL;
30
//	private e24PaymentPipe pipe = null;
-
 
31
	
-
 
32
//	private double amount;
-
 
33
	private static int gatewayId=1;
21
	private static int gatewayId=1;
34
	
22
	
35
//	private long paymentId;
-
 
36
	
-
 
37
//	private enum ActionType{
-
 
38
//		PURCHASE("1"),
-
 
39
//		AUTH ("4"),
-
 
40
//		CAPTURE("5");
-
 
41
//		private String value;
-
 
42
//		ActionType(String value) {
-
 
43
//			this.value = value;
-
 
44
//		}
-
 
45
//		public String value(){
-
 
46
//			return this.value;
-
 
47
//		}
-
 
48
//	}
-
 
49
	
-
 
50
	public HdfcPaymentService() {
23
	public HdfcPaymentService() {
51
	
24
	
52
	}
25
	}
53
	
26
	
54
//	static{
-
 
55
//		try {
-
 
56
//			resourceFilePath = ConfigClient.getClient().get("payment_resource_file_path");
-
 
57
//			aliasName  = ConfigClient.getClient().get("payment_alias_name");
-
 
58
//			responseURL = ConfigClient.getClient().get("payment_response_url");
-
 
59
//			errorURL = ConfigClient.getClient().get("payment_error_url");
-
 
60
//		} catch (ConfigException e) {
-
 
61
//			log.error("Unable to get data from config server.");
-
 
62
//		}
-
 
63
//	}
-
 
64
	
-
 
65
	
-
 
66
	public long createPayment(long currentCartId, long userId, long txnId, String paymentOption){
27
	public long createPayment(long currentCartId, long userId, long txnId, String paymentOption){
67
		log.info("Creating payment for the txn#: " + txnId + " for the user: " + userId + " for processing through HDFC");
28
		log.info("Creating payment for the txn#: " + txnId + " for the user: " + userId + " for processing through HDFC");
68
		CommonPaymentService cps = new CommonPaymentService();
29
		CommonPaymentService cps = new CommonPaymentService();
69
		if(!cps.createPayment(currentCartId, userId, txnId, gatewayId)){
30
		if(!cps.createPayment(currentCartId, userId, txnId, gatewayId)){
70
			log.error("Error while creating the basic payment");
31
			log.error("Error while creating the basic payment");
Line 115... Line 76...
115
		}
76
		}
116
		
77
		
117
		return resultMap;
78
		return resultMap;
118
	}
79
	}
119
	
80
	
120
//	private List<Attribute> getAttributesAndSetUdfs(long txnId) throws TransactionServiceException, TException{
-
 
121
//		StringBuilder orderDetails = new StringBuilder();
-
 
122
//		StringBuilder billingAddress = new StringBuilder();
-
 
123
//		String email = "";
-
 
124
//		String contactNumber = "";
-
 
125
//		
-
 
126
//		//get udfs
-
 
127
//		Transaction transaction;
-
 
128
//		TransactionServiceClient transactionServiceClient = null;
-
 
129
//		try {
-
 
130
//			transactionServiceClient = new TransactionServiceClient();
-
 
131
//		} catch (Exception e) {
-
 
132
//			// TODO Auto-generated catch block
-
 
133
//			e.printStackTrace();
-
 
134
//		}
-
 
135
//		
-
 
136
//		in.shop2020.model.v1.order.TransactionService.Client txnClient = transactionServiceClient.getClient();
-
 
137
//		transaction = txnClient.getTransaction(txnId);
-
 
138
//		orderDetails.append(transaction.getOrdersSize() + " ");
-
 
139
//		for (Order order : transaction.getOrders()) {
-
 
140
//			contactNumber= order.getCustomer_mobilenumber();
-
 
141
//			email = order.getCustomer_email();
-
 
142
//			billingAddress.append(" ");
-
 
143
//			if(order.getCustomer_pincode()!=null){
-
 
144
//				billingAddress.append(order.getCustomer_pincode());
-
 
145
//			}
-
 
146
//			if(order.getCustomer_city()!=null){
-
 
147
//				billingAddress.append(" " + order.getCustomer_city());
-
 
148
//			}
-
 
149
//			if(order.getCustomer_address1()!=null){
-
 
150
//				billingAddress.append(" " + order.getCustomer_address1());
-
 
151
//			}
-
 
152
//			if(order.getCustomer_address2()!=null){
-
 
153
//				billingAddress.append(" " + order.getCustomer_address2());
-
 
154
//			}
-
 
155
//			if(order.getCustomer_state()!=null){
-
 
156
//				billingAddress.append(" " + order.getCustomer_state());
-
 
157
//			}
-
 
158
//			
-
 
159
//
-
 
160
//			for(LineItem line: order.getLineitems()){
-
 
161
//				if(line.getBrand() != null){
-
 
162
//					orderDetails.append(line.getBrand());
-
 
163
//				}
-
 
164
//				if(line.getModel_name() != null){
-
 
165
//					orderDetails.append(line.getModel_name()); 
-
 
166
//				}
-
 
167
//				if(line.getModel_number() != null){
-
 
168
//					orderDetails.append(line.getModel_number());
-
 
169
//				}
-
 
170
//				if(line.getColor() != null){
-
 
171
//					orderDetails.append(line.getColor());
-
 
172
//				}
-
 
173
//				orderDetails.append(" ");
-
 
174
//			}
-
 
175
//			
-
 
176
//		}
-
 
177
//		
-
 
178
//		Random random = new Random();
-
 
179
//		String merchantInfo = ""+random.nextLong(); 
-
 
180
//		
-
 
181
//	    String udf1 = formatUdf(orderDetails.toString()); 
-
 
182
//	    String udf2 = formatUdf(email);
-
 
183
//	    String udf3 = formatUdf(contactNumber);
-
 
184
//	    String udf4 = formatUdf(billingAddress.toString());
-
 
185
//	    String udf5 = merchantInfo;
-
 
186
//
-
 
187
//	    log.info("udf1:"  + udf1);
-
 
188
//	    log.info("udf2:"  + udf2);
-
 
189
//	    log.info("udf3:"  + udf3);
-
 
190
//	    log.info("udf4:"  + udf4);
-
 
191
//	    log.info("udf5:"  + udf5);
-
 
192
//	    
-
 
193
//
-
 
194
//	    pipe.setUdf1(udf1);       //	UDF 1 - Order details
-
 
195
//		pipe.setUdf2(udf2);        	  				//	UDF 2 - Email ID
-
 
196
//		pipe.setUdf3(udf3);      			//	UDF 3 - Contact Number. 
-
 
197
//		pipe.setUdf4(udf4);     //	UDF 4 - Billing Address
-
 
198
//		pipe.setUdf5(udf5);		  						//	UDF 5 - Merchant specific
-
 
199
//	    
-
 
200
//		List<Attribute> attributes = new ArrayList<Attribute>();
-
 
201
//		Attribute attribute1 = new Attribute("udf1",udf1);
-
 
202
//		Attribute attribute2 = new Attribute("udf2",udf2);
-
 
203
//		Attribute attribute3 = new Attribute("udf3",udf3);
-
 
204
//		Attribute attribute4 = new Attribute("udf4",udf4);
-
 
205
//		Attribute attribute5 = new Attribute("udf5",udf5);
-
 
206
//		
-
 
207
//		attributes.add(attribute1);
-
 
208
//		attributes.add(attribute2);
-
 
209
//		attributes.add(attribute3);
-
 
210
//		attributes.add(attribute4);
-
 
211
//		attributes.add(attribute5);
-
 
212
//		
-
 
213
//		return attributes;
-
 
214
//	}
-
 
215
	
-
 
216
//	private void initializePayment(long merchantPaymentId, double amounta) throws ShoppingCartException, TException{
-
 
217
//		String amount;
-
 
218
//		
-
 
219
//		amount = (new Double(amounta)).toString();
-
 
220
//		
-
 
221
//		//Following is the code which initilize e24PaymentPipe with proper value		
-
 
222
//		pipe=new e24PaymentPipe();
-
 
223
//		pipe.setResourcePath(resourceFilePath);	//mandatory 
-
 
224
//		String as = pipe.getResourcePath();
-
 
225
//		log.info("Resource= " +as);
-
 
226
//		
-
 
227
//		pipe.setAlias(aliasName);			//mandatory 
-
 
228
//		String ab=pipe.getAlias();
-
 
229
//		log.info("Alias= " +ab);
-
 
230
//	
-
 
231
//		pipe.setAction(ActionType.AUTH.value());			//mandatory 
-
 
232
//		String ac=pipe.getAction();
-
 
233
//		log.info("Action= " +ac);
-
 
234
//	
-
 
235
//		pipe.setResponseURL( responseURL );	//mandatory
-
 
236
//		String at=pipe.getResponseURL();
-
 
237
//		log.info("ResponseURL= "+at);
-
 
238
//	
-
 
239
//		// Removed payment url parameter, as adding parameters stops payment from initialisation with hdfc jar.
-
 
240
//		// It gives following error. 
-
 
241
//		// Payment Initialization returned an invalid response: !ERROR!-PY20011-Invalid Merchant Error URL.
-
 
242
//		pipe.setErrorURL( errorURL );		//mandatory
-
 
243
//	    String ak=pipe.getErrorURL();
-
 
244
//	    log.info("ErrorURL= " + ak);
-
 
245
//	
-
 
246
//	
-
 
247
//		pipe.setAmt(amount);		
-
 
248
//		String ap=pipe.getAmt();
-
 
249
//		log.info("Amt= " + ap);
-
 
250
//	
-
 
251
//		pipe.setCurrency(currencyCode);
-
 
252
//		String a=pipe.getCurrency();
-
 
253
//		log.info("Currency= " + a);
-
 
254
//	
-
 
255
//		pipe.setLanguage("USA");
-
 
256
//		String p=pipe.getLanguage();
-
 
257
//		log.info("Language= "+ p);
-
 
258
//	    
-
 
259
//		pipe.setTrackId((new Long(merchantPaymentId)).toString());
-
 
260
//	
-
 
261
//	}
-
 
262
	
-
 
263
//	String formatUdf(String udfString){
-
 
264
//		udfString = udfString.replaceAll(regex, replacement);
-
 
265
//		if(udfString.length() > MAX_UDF_LENGTH){
-
 
266
//			udfString = udfString.substring(0, MAX_UDF_LENGTH);
-
 
267
//		}
-
 
268
//		return udfString;
-
 
269
//	}
-
 
270
	
-
 
271
	public String getRedirectUrl(){
81
	public String getRedirectUrl(){
272
		return this.redirectURL;
82
		return this.redirectURL;
273
	}
83
	}
274
	
84
	
275
	public static void main(String args[]){
85
	public static void main(String args[]){