Subversion Repositories SmartDukaan

Rev

Rev 18937 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18937 Rev 20278
Line 8... Line 8...
8
import in.shop2020.payments.Payment;
8
import in.shop2020.payments.Payment;
9
import in.shop2020.payments.PaymentException;
9
import in.shop2020.payments.PaymentException;
10
import in.shop2020.serving.services.EbsPaymentService;
10
import in.shop2020.serving.services.EbsPaymentService;
11
import in.shop2020.serving.services.HdfcPaymentService;
11
import in.shop2020.serving.services.HdfcPaymentService;
12
import in.shop2020.serving.services.IPaymentService;
12
import in.shop2020.serving.services.IPaymentService;
-
 
13
import in.shop2020.serving.utils.PaymentUtils;
13
import in.shop2020.serving.utils.Utils;
14
import in.shop2020.serving.utils.Utils;
14
import in.shop2020.thrift.clients.PaymentClient;
15
import in.shop2020.thrift.clients.PaymentClient;
15
import in.shop2020.thrift.clients.TransactionClient;
16
import in.shop2020.thrift.clients.TransactionClient;
16
import in.shop2020.thrift.clients.UserClient;
17
import in.shop2020.thrift.clients.UserClient;
17
 
18
 
Line 128... Line 129...
128
            log.error("Problem saving the address", e);
129
            log.error("Problem saving the address", e);
129
            return "recharge-pay-options-redirect";
130
            return "recharge-pay-options-redirect";
130
        }
131
        }
131
 
132
 
132
        String paymentOption = request.getParameter("payment_option");
133
        String paymentOption = request.getParameter("payment_option");
-
 
134
        String paymentType="";
133
        log.info("Payment Option Selected: " + paymentOption);
135
        log.info("Payment Option Selected: " + paymentOption);
134
        if(paymentOption == null || paymentOption.equals("")){
136
        if(paymentOption == null || paymentOption.equals("")){
135
            addActionError("Please select a payment method to continue.");
137
            addActionError("Please select a payment method to continue.");
136
            return "recharge-pay-options-redirect";
138
            return "recharge-pay-options-redirect";
137
        }
139
        }
-
 
140
        if(paymentOption.contains("~")){
-
 
141
    		paymentType = paymentOption.split("~")[0];
-
 
142
    		paymentOption = paymentOption.split("~")[1];
-
 
143
    	}
138
        
144
        
139
        if (name.isEmpty() && !phone.isEmpty()) {
145
        if (name.isEmpty() && !phone.isEmpty()) {
140
            //This means we only got the phone from UI.
146
            //This means we only got the phone from UI.
141
            //Lets keep it.
147
            //Lets keep it.
142
        } else {
148
        } else {
143
            //For all other cases make it empty.
149
            //For all other cases make it empty.
144
            phone = "";
150
            phone = "";
145
        }
151
        }
146
        
152
        
-
 
153
        long gatewayId =  PaymentUtils.getGatewayId(paymentType+paymentOption);
-
 
154
        
147
        if(paymentOption.equals(IPaymentService.HDFC_MASTERCARD_CREDIT) || paymentOption.equals(IPaymentService.HDFC_MASTERCARD_DEBIT) || 
155
       /* if(paymentOption.equals(IPaymentService.HDFC_MASTERCARD_CREDIT) || paymentOption.equals(IPaymentService.HDFC_MASTERCARD_DEBIT) || 
148
                paymentOption.equals(IPaymentService.HDFC_VISA) || paymentOption.equals(IPaymentService.HDFC_VISA_ELECTRON)) {
156
                paymentOption.equals(IPaymentService.HDFC_VISA) || paymentOption.equals(IPaymentService.HDFC_VISA_ELECTRON)) {
149
            // User has selected Visa or MasterCard
157
            // User has selected Visa or MasterCard
150
            HdfcPaymentService hdfcPaymentService = new HdfcPaymentService();
158
            HdfcPaymentService hdfcPaymentService = new HdfcPaymentService();
151
            paymentId = hdfcPaymentService.createPayment(rechargeOrder, paymentOption, phone);
159
            paymentId = hdfcPaymentService.createPayment(rechargeOrder, paymentOption, phone);
152
            if (paymentId == IPaymentService.PAYMENT_NOT_CREATED) {
160
            if (paymentId == IPaymentService.PAYMENT_NOT_CREATED) {
Line 155... Line 163...
155
                this.redirectURL = hdfcPaymentService.getRedirectUrl();
163
                this.redirectURL = hdfcPaymentService.getRedirectUrl();
156
                log.info(this.redirectURL);
164
                log.info(this.redirectURL);
157
                return "success";
165
                return "success";
158
            }
166
            }
159
        }
167
        }
-
 
168
        
-
 
169
    
160
 
170
 
161
        if(paymentOption.equals(IPaymentService.HDFC_VISA))
171
        if(paymentOption.equals(IPaymentService.HDFC_VISA))
162
            paymentOption = IPaymentService.EBS_VISA;
172
            paymentOption = IPaymentService.EBS_VISA;
163
        else if(paymentOption.equals(IPaymentService.HDFC_MASTERCARD_DEBIT) || paymentOption.equals(IPaymentService.HDFC_MASTERCARD_CREDIT))
173
        else if(paymentOption.equals(IPaymentService.HDFC_MASTERCARD_DEBIT) || paymentOption.equals(IPaymentService.HDFC_MASTERCARD_CREDIT))
164
            paymentOption = IPaymentService.EBS_MASTERCARD;
174
            paymentOption = IPaymentService.EBS_MASTERCARD;
165
        else if(paymentOption.equals(IPaymentService.HDFC_VISA_ELECTRON))
175
        else if(paymentOption.equals(IPaymentService.HDFC_VISA_ELECTRON))
166
            paymentOption = null;           //Since we don't know the bank's name in this case, we'll let the user select the bank on the EBS page.
176
            paymentOption = null;           //Since we don't know the bank's name in this case, we'll let the user select the bank on the EBS page.
167
        
177
  */      
168
        if(paymentOption.equals(IPaymentService.PAYU_CC) || Utils.NET_BANKING_CODES_MAP.containsKey(paymentOption)){
178
       // if(paymentOption.equals(IPaymentService.PAYU_CC) || PaymentUtils.PAYU_NET_BANKING_CODES_MAP.containsKey(paymentOption)){
-
 
179
        if(gatewayId==5){	
169
        	PayuPaymentService payuPaymentService = new PayuPaymentService();
180
        	PayuPaymentService payuPaymentService = new PayuPaymentService();
170
        	paymentId = payuPaymentService.createPayment(rechargeOrder, paymentOption);
181
        	paymentId = payuPaymentService.createPayment(rechargeOrder, paymentOption,paymentType);
-
 
182
        	if(paymentId == IPaymentService.PAYMENT_NOT_CREATED){
-
 
183
                addActionError("We are experiencing some problems. Please try later.");
-
 
184
                log.error("Unable to process payment through PAYU.");
-
 
185
                setErrorMessage("There was some problem. Please try again.");
-
 
186
                return "recharge-redirect";
-
 
187
            } else {
-
 
188
                log.info("Successfully created payment for Payu to process. Redirecting to /payu-pay/" + paymentId);
-
 
189
               
171
        	this.redirectURL = "payu-pay/" + paymentId + "/edit?phone=" + phone;
190
                this.redirectURL = "payu-pay/" + paymentId + "/edit?phone=" + phone;
172
        	return "success";
191
            	return "success";
-
 
192
            } 
-
 
193
        	
-
 
194
        }else{
-
 
195
        	addActionError("We are experiencing some problems. Please try later.");
-
 
196
            log.error("Unable to process payment through PAYU.");
-
 
197
            setErrorMessage("There was some problem. Please try again.");
-
 
198
            return "recharge-redirect";
173
        }
199
        }
174
 
200
 
175
        EbsPaymentService ebsPaymentService = new EbsPaymentService();
201
/*        EbsPaymentService ebsPaymentService = new EbsPaymentService();
176
        paymentId = ebsPaymentService.createPayment(rechargeOrder, paymentOption);
202
        paymentId = ebsPaymentService.createPayment(rechargeOrder, paymentOption);
177
        if(paymentId == IPaymentService.PAYMENT_NOT_CREATED){
203
        if(paymentId == IPaymentService.PAYMENT_NOT_CREATED){
178
            addActionError("We are experiencing some problems. Please try later.");
204
            addActionError("We are experiencing some problems. Please try later.");
179
            log.error("Unable to process payment through EBS.");
205
            log.error("Unable to process payment through EBS.");
180
            setErrorMessage("There was some problem. Please try again.");
206
            setErrorMessage("There was some problem. Please try again.");
181
            return "recharge-redirect";
207
            return "recharge-redirect";
182
        } else {
208
        } else {
183
            log.info("Successfully created payment for EBS to process. Redirecting to /ebs-pay/" + paymentId);
209
            log.info("Successfully created payment for EBS to process. Redirecting to /ebs-pay/" + paymentId);
184
            return "ebs-pay-redirect";
210
            return "ebs-pay-redirect";
185
        }           
211
        }  */         
186
    }
212
    }
187
            
213
            
188
    public String getMyaccountHeaderSnippet(){
214
    public String getMyaccountHeaderSnippet(){
189
        return htmlSnippets.get("MYACCOUNT_HEADER");
215
        return htmlSnippets.get("MYACCOUNT_HEADER");
190
    }
216
    }