Subversion Repositories SmartDukaan

Rev

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

Rev 2118 Rev 2159
Line 1... Line 1...
1
package in.shop2020.serving.services;
1
package in.shop2020.serving.services;
2
 
2
 
3
import in.shop2020.config.ConfigException;
3
import in.shop2020.config.ConfigException;
-
 
4
import in.shop2020.payments.Attribute;
-
 
5
import in.shop2020.payments.PaymentStatus;
-
 
6
import in.shop2020.thrift.clients.PaymentServiceClient;
4
import in.shop2020.thrift.clients.config.ConfigClient;
7
import in.shop2020.thrift.clients.config.ConfigClient;
5
 
8
 
6
import java.io.BufferedReader;
9
import java.io.BufferedReader;
7
import java.io.DataOutputStream;
10
import java.io.DataOutputStream;
8
import java.io.IOException;
11
import java.io.IOException;
Line 10... Line 13...
10
import java.io.StringReader;
13
import java.io.StringReader;
11
import java.net.MalformedURLException;
14
import java.net.MalformedURLException;
12
import java.net.URL;
15
import java.net.URL;
13
import java.net.URLConnection;
16
import java.net.URLConnection;
14
import java.net.URLEncoder;
17
import java.net.URLEncoder;
-
 
18
import java.util.ArrayList;
15
import java.util.HashMap;
19
import java.util.HashMap;
-
 
20
import java.util.List;
16
import java.util.Map;
21
import java.util.Map;
17
import java.util.Map.Entry;
22
import java.util.Map.Entry;
18
 
23
 
19
import javax.xml.xpath.XPath;
24
import javax.xml.xpath.XPath;
20
import javax.xml.xpath.XPathConstants;
25
import javax.xml.xpath.XPathConstants;
Line 68... Line 73...
68
	
73
	
69
	private static int gatewayId=2;
74
	private static int gatewayId=2;
70
	private long paymentId;
75
	private long paymentId;
71
	
76
	
72
	@Override
77
	@Override
73
	public long createPayment(long currentCartId, long userId, long txnId){
78
	public long createPayment(long currentCartId, long userId, long txnId, String paymentOption){
74
		log.info("Creating payment for the txn#: " + txnId + " for the user: " + userId);
79
		log.info("Creating payment for the txn#: " + txnId + " for the user: " + userId);
75
		CommonPaymentService cps = new CommonPaymentService();
80
		CommonPaymentService cps = new CommonPaymentService();
76
		if(!cps.createPayment(currentCartId, userId, txnId, gatewayId)){
81
		if(!cps.createPayment(currentCartId, userId, txnId, gatewayId)){
77
			log.error("Error while creating the basic payment");
82
			log.error("Error while creating the basic payment");
78
			return PAYMENT_NOT_CREATED;
83
			return PAYMENT_NOT_CREATED;
79
		}
84
		}
80
		
-
 
81
		paymentId = cps.getPaymentId();
85
		paymentId = cps.getPaymentId();
-
 
86
		
-
 
87
		List<Attribute> attributes = new ArrayList<Attribute>();
-
 
88
		attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
-
 
89
		
-
 
90
		PaymentServiceClient paymentServiceClient = null;
-
 
91
		try {
-
 
92
			paymentServiceClient = new PaymentServiceClient();
-
 
93
		} catch (Exception e) {
-
 
94
			log.error("Error while getting payment client", e);
-
 
95
			return PAYMENT_NOT_CREATED;
-
 
96
		}
-
 
97
		
-
 
98
		try {
-
 
99
			paymentServiceClient.getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null, PaymentStatus.INIT, null, attributes);
-
 
100
		} catch (Exception e) {
-
 
101
			log.error("Error while saving payment option attribute", e);
-
 
102
			return PAYMENT_NOT_CREATED;
-
 
103
		}
-
 
104
 
82
		return paymentId;
105
		return paymentId;
83
	}
106
	}
84
 
107
 
85
	/**
108
	/**
86
	 * Capture the amount which was authorized for this payment Id. Makes
109
	 * Capture the amount which was authorized for this payment Id. Makes