| 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 19... |
Line 20... |
| 19 |
public static final String DATE_TIME = "dateTime";
|
20 |
public static final String DATE_TIME = "dateTime";
|
| 20 |
public static final String MODE = "mode";
|
21 |
public static final String MODE = "mode";
|
| 21 |
public static final String REF_NO = "referenceNo";
|
22 |
public static final String REF_NO = "referenceNo";
|
| 22 |
public static final String TXN_TYPE = "transactionType";
|
23 |
public static final String TXN_TYPE = "transactionType";
|
| 23 |
|
24 |
|
| - |
|
25 |
private static int gatewayId=19;
|
| - |
|
26 |
|
| 24 |
private long paymentId;
|
27 |
private long paymentId;
|
| 25 |
|
28 |
|
| 26 |
@Override
|
29 |
@Override
|
| 27 |
public long createPayment(long userId, long txnId, String paymentOption, int gatewayId){
|
30 |
public long createPayment(long userId, long txnId, String paymentOption, int gatewayId){
|
| 28 |
log.info("Creating payment for the txn#: " + txnId + " for the user: " + userId + " for processing through EBS");
|
31 |
log.info("Creating payment for the txn#: " + txnId + " for the user: " + userId + " for processing through EBS");
|
| Line 50... |
Line 53... |
| 50 |
}
|
53 |
}
|
| 51 |
}
|
54 |
}
|
| 52 |
|
55 |
|
| 53 |
return paymentId;
|
56 |
return paymentId;
|
| 54 |
}
|
57 |
}
|
| - |
|
58 |
|
| - |
|
59 |
public long createPayment(RechargeOrder rechargeOrder, String paymentOption) {
|
| - |
|
60 |
log.info("Creating payment for the txn#: " + rechargeOrder.getId() + " for the user: " + rechargeOrder.getUserId() + " for processing through Payu");
|
| - |
|
61 |
CommonPaymentService cps = new CommonPaymentService();
|
| - |
|
62 |
if(!cps.createPayment(rechargeOrder, gatewayId)){
|
| - |
|
63 |
log.error("Error while creating the basic payment");
|
| - |
|
64 |
return PAYMENT_NOT_CREATED;
|
| - |
|
65 |
}
|
| - |
|
66 |
paymentId = cps.getPaymentId();
|
| - |
|
67 |
|
| - |
|
68 |
if(paymentOption != null){
|
| - |
|
69 |
List<Attribute> attributes = new ArrayList<Attribute>();
|
| - |
|
70 |
attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
|
| - |
|
71 |
|
| - |
|
72 |
try {
|
| - |
|
73 |
PaymentClient paymentServiceClient = new PaymentClient();
|
| - |
|
74 |
paymentServiceClient.getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null, PaymentStatus.INIT, null, attributes);
|
| - |
|
75 |
} catch (Exception e) {
|
| - |
|
76 |
log.error("Error while saving payment option attribute", e);
|
| - |
|
77 |
// TODO: We've already created the payment. We could allow the
|
| - |
|
78 |
// payment to go through. The customer will be a little
|
| - |
|
79 |
// annoyed to have to select from a host of options again but
|
| - |
|
80 |
// will be better than completely disallowing him.
|
| - |
|
81 |
return PAYMENT_NOT_CREATED;
|
| - |
|
82 |
}
|
| - |
|
83 |
}
|
| 55 |
|
84 |
|
| 56 |
public static void main(String[] args){
|
- |
|
| 57 |
//capturePayment(30450.00, "2412653");
|
85 |
return paymentId;
|
| 58 |
|
86 |
}
|
| 59 |
// <output transactionId="4793507" paymentId="2411078" amount="25005" dateTime="2011-05-16 09:03:15" mode="TEST" referenceNo="4" transactionType="Captured" status="Processing" />";
|
- |
|
| 60 |
|
87 |
|
| 61 |
// <output errorCode="2" error="Invalid Account ID/Secret Key" />
|
- |
|
| 62 |
// <output errorCode="12" error="This payment is failed" />
|
88 |
public static void main(String[] args){
|
| 63 |
// <output errorCode="13" error="This payment is captured already" />
|
- |
|
| 64 |
}
|
89 |
}
|
| 65 |
}
|
90 |
}
|