Subversion Repositories SmartDukaan

Rev

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

Rev 3583 Rev 6050
Line 1... Line 1...
1
package in.shop2020.serving.services;
1
package in.shop2020.serving.services;
2
 
2
 
-
 
3
import in.shop2020.model.v1.order.RechargeOrder;
3
import in.shop2020.payments.Attribute;
4
import in.shop2020.payments.Attribute;
4
import in.shop2020.payments.PaymentStatus;
5
import in.shop2020.payments.PaymentStatus;
5
import in.shop2020.thrift.clients.PaymentClient;
6
import in.shop2020.thrift.clients.PaymentClient;
6
 
7
 
7
import java.util.ArrayList;
8
import java.util.ArrayList;
Line 51... Line 52...
51
			}
52
			}
52
		}
53
		}
53
 
54
 
54
		return paymentId;
55
		return paymentId;
55
	}
56
	}
-
 
57
	
-
 
58
	public long createPayment(RechargeOrder rechargeOrder, String paymentOption) {
-
 
59
	    log.info("Creating payment for the txn#: " + rechargeOrder.getId() + " for the user: " + rechargeOrder.getUserId() + " for processing through EBS");
-
 
60
        CommonPaymentService cps = new CommonPaymentService();
-
 
61
        if(!cps.createPayment(rechargeOrder, gatewayId)){
-
 
62
            log.error("Error while creating the basic payment");
-
 
63
            return PAYMENT_NOT_CREATED;
-
 
64
        }
-
 
65
        paymentId = cps.getPaymentId();
-
 
66
        
-
 
67
        if(paymentOption != null){
-
 
68
            List<Attribute> attributes = new ArrayList<Attribute>();
-
 
69
            attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
-
 
70
            
-
 
71
            try {
-
 
72
                PaymentClient paymentServiceClient = new PaymentClient();
-
 
73
                paymentServiceClient.getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null, PaymentStatus.INIT, null, attributes);
-
 
74
            } catch (Exception e) {
-
 
75
                log.error("Error while saving payment option attribute", e);
-
 
76
                // TODO: We've already created the payment. We could allow the
-
 
77
                // payment to go through. The customer will be a little
-
 
78
                // annoyed to have to select from a host of options again but
-
 
79
                // will be better than completely disallowing him.
-
 
80
                return PAYMENT_NOT_CREATED;
-
 
81
            }
-
 
82
        }
-
 
83
 
-
 
84
        return paymentId;
-
 
85
    }
56
 
86
 
57
	public static void main(String[] args){
87
	public static void main(String[] args){
58
		//capturePayment(30450.00, "2412653");
88
		//capturePayment(30450.00, "2412653");
59
		
89
		
60
//		<output  transactionId="4793507"  paymentId="2411078"  amount="25005"  dateTime="2011-05-16 09:03:15"  mode="TEST"  referenceNo="4"  transactionType="Captured"  status="Processing"  />";
90
//		<output  transactionId="4793507"  paymentId="2411078"  amount="25005"  dateTime="2011-05-16 09:03:15"  mode="TEST"  referenceNo="4"  transactionType="Captured"  status="Processing"  />";