Subversion Repositories SmartDukaan

Rev

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

Rev 2159 Rev 2199
Line 74... Line 74...
74
	private static int gatewayId=2;
74
	private static int gatewayId=2;
75
	private long paymentId;
75
	private long paymentId;
76
	
76
	
77
	@Override
77
	@Override
78
	public long createPayment(long currentCartId, long userId, long txnId, String paymentOption){
78
	public long createPayment(long currentCartId, long userId, long txnId, String paymentOption){
79
		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 + " for processing through EBS");
80
		CommonPaymentService cps = new CommonPaymentService();
80
		CommonPaymentService cps = new CommonPaymentService();
81
		if(!cps.createPayment(currentCartId, userId, txnId, gatewayId)){
81
		if(!cps.createPayment(currentCartId, userId, txnId, gatewayId)){
82
			log.error("Error while creating the basic payment");
82
			log.error("Error while creating the basic payment");
83
			return PAYMENT_NOT_CREATED;
83
			return PAYMENT_NOT_CREATED;
84
		}
84
		}
85
		paymentId = cps.getPaymentId();
85
		paymentId = cps.getPaymentId();
86
		
86
		
-
 
87
		if(paymentOption != null){
87
		List<Attribute> attributes = new ArrayList<Attribute>();
88
			List<Attribute> attributes = new ArrayList<Attribute>();
88
		attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
89
			attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
89
		
90
			
90
		PaymentServiceClient paymentServiceClient = null;
-
 
91
		try {
91
			try {
92
			paymentServiceClient = new PaymentServiceClient();
92
				PaymentServiceClient paymentServiceClient = new PaymentServiceClient();
-
 
93
				paymentServiceClient.getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null, PaymentStatus.INIT, null, attributes);
93
		} catch (Exception e) {
94
			} catch (Exception e) {
94
			log.error("Error while getting payment client", e);
95
				log.error("Error while saving payment option attribute", e);
95
			return PAYMENT_NOT_CREATED;
96
				// TODO: We've already created the payment. We could allow the
96
		}
-
 
97
		
-
 
98
		try {
-
 
99
			paymentServiceClient.getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null, PaymentStatus.INIT, null, attributes);
97
				// payment to go through. The customer will be a little
100
		} catch (Exception e) {
98
				// annoyed to have to select from a host of options again but
101
			log.error("Error while saving payment option attribute", e);
99
				// will be better than completely disallowing him.
102
			return PAYMENT_NOT_CREATED;
100
				return PAYMENT_NOT_CREATED;
-
 
101
			}
103
		}
102
		}
104
 
103
 
105
		return paymentId;
104
		return paymentId;
106
	}
105
	}
107
 
106