| Line 11... |
Line 11... |
| 11 |
import org.springframework.stereotype.Component;
|
11 |
import org.springframework.stereotype.Component;
|
| 12 |
|
12 |
|
| 13 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
13 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
| 14 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
14 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
| 15 |
import com.spice.profitmandi.thrift.clients.config.ConfigClient;
|
15 |
import com.spice.profitmandi.thrift.clients.config.ConfigClient;
|
| 16 |
import com.spice.profitmandi.web.payment.IPaymentService;
|
- |
|
| 17 |
import com.spice.profitmandi.web.payment.PaymentUtils;
|
- |
|
| 18 |
import com.spice.profitmandi.web.res.order.PayuPayPojo;
|
16 |
import com.spice.profitmandi.web.res.order.PayuPayPojo;
|
| 19 |
|
17 |
|
| 20 |
import in.shop2020.config.ConfigException;
|
18 |
import in.shop2020.config.ConfigException;
|
| 21 |
import in.shop2020.model.v1.order.LineItem;
|
19 |
import in.shop2020.model.v1.order.LineItem;
|
| 22 |
import in.shop2020.model.v1.order.Order;
|
20 |
import in.shop2020.model.v1.order.Order;
|
| Line 43... |
Line 41... |
| 43 |
private static String postActionUrl;
|
41 |
private static String postActionUrl;
|
| 44 |
|
42 |
|
| 45 |
|
43 |
|
| 46 |
|
44 |
|
| 47 |
public PayuPayPojo getPayuParams(long paymentId) throws Exception{
|
45 |
public PayuPayPojo getPayuParams(long paymentId) throws Exception{
|
| - |
|
46 |
PayuPayPojo ppp = new PayuPayPojo();
|
| 48 |
PaymentClient paymentServiceClient = new PaymentClient();
|
47 |
/*PaymentClient paymentServiceClient = new PaymentClient();
|
| 49 |
Payment payment = paymentServiceClient.getClient().getPayment(paymentId);
|
48 |
Payment payment = paymentServiceClient.getClient().getPayment(paymentId);
|
| 50 |
|
49 |
|
| 51 |
long txnId = payment.getMerchantTxnId();
|
50 |
long txnId = payment.getMerchantTxnId();
|
| 52 |
TransactionClient transactionServiceClient = new TransactionClient();
|
51 |
TransactionClient transactionServiceClient = new TransactionClient();
|
| 53 |
in.shop2020.model.v1.order.TransactionService.Client txnClient = transactionServiceClient.getClient();
|
52 |
in.shop2020.model.v1.order.TransactionService.Client txnClient = transactionServiceClient.getClient();
|
| 54 |
Transaction transaction = txnClient.getTransaction(txnId);
|
53 |
Transaction transaction = txnClient.getTransaction(txnId);
|
| 55 |
Order order = transaction.getOrders().get(0);
|
54 |
Order order = transaction.getOrders().get(0);
|
| 56 |
|
55 |
|
| 57 |
String paymentOption = getPaymentOption(payment);
|
56 |
String paymentOption = getPaymentOption(payment);
|
| 58 |
PayuPayPojo ppp = new PayuPayPojo();
|
- |
|
| 59 |
ppp.setKey(accountId);
|
57 |
ppp.setKey(accountId);
|
| 60 |
ppp.setAmount(payment.getAmount() + "");
|
58 |
ppp.setAmount(payment.getAmount() + "");
|
| 61 |
ppp.setEmail(order.getCustomer_email());
|
59 |
ppp.setEmail(order.getCustomer_email());
|
| 62 |
ppp.setPhone(order.getCustomer_mobilenumber());
|
60 |
ppp.setPhone(order.getCustomer_mobilenumber());
|
| 63 |
ppp.setAddress1(order.getCustomer_address1());
|
61 |
ppp.setAddress1(order.getCustomer_address1());
|
| Line 81... |
Line 79... |
| 81 |
}
|
79 |
}
|
| 82 |
ppp.setTxnid(paymentId + "");
|
80 |
ppp.setTxnid(paymentId + "");
|
| 83 |
ppp.setCountry("India");
|
81 |
ppp.setCountry("India");
|
| 84 |
|
82 |
|
| 85 |
ppp.setPostActionUrl(postActionUrl);
|
83 |
ppp.setPostActionUrl(postActionUrl);
|
| 86 |
ppp.setHash(getSecureHash(paymentId, ppp));
|
84 |
ppp.setHash(getSecureHash(paymentId, ppp));*/
|
| 87 |
|
85 |
|
| 88 |
return ppp;
|
86 |
return ppp;
|
| 89 |
}
|
87 |
}
|
| 90 |
|
88 |
|
| 91 |
/**
|
89 |
/**
|
| Line 116... |
Line 114... |
| 116 |
return descriptionBuilder.substring(0, 255).trim();
|
114 |
return descriptionBuilder.substring(0, 255).trim();
|
| 117 |
else
|
115 |
else
|
| 118 |
return descriptionBuilder.toString().trim();
|
116 |
return descriptionBuilder.toString().trim();
|
| 119 |
}
|
117 |
}
|
| 120 |
|
118 |
|
| 121 |
private String getPaymentOption(Payment payment) {
|
119 |
/*private String getPaymentOption(Payment payment) {
|
| 122 |
String paymentType = null;
|
120 |
String paymentType = null;
|
| 123 |
String paymentOpt = null;
|
121 |
String paymentOpt = null;
|
| 124 |
List<Attribute> attributes = payment.getAttributes();
|
122 |
List<Attribute> attributes = payment.getAttributes();
|
| 125 |
if(attributes == null)
|
123 |
if(attributes == null)
|
| 126 |
return "";
|
124 |
return "";
|
| Line 129... |
Line 127... |
| 129 |
paymentOpt = attr.getValue();
|
127 |
paymentOpt = attr.getValue();
|
| 130 |
if(attr.getName().equals(IPaymentService.PAYMENT_TYPE))
|
128 |
if(attr.getName().equals(IPaymentService.PAYMENT_TYPE))
|
| 131 |
paymentType = attr.getValue();
|
129 |
paymentType = attr.getValue();
|
| 132 |
}
|
130 |
}
|
| 133 |
return paymentType+paymentOpt;
|
131 |
return paymentType+paymentOpt;
|
| 134 |
}
|
132 |
}*/
|
| 135 |
|
133 |
|
| 136 |
private String getSecureHash(long paymentId, PayuPayPojo ppp) throws NoSuchAlgorithmException{
|
134 |
private String getSecureHash(long paymentId, PayuPayPojo ppp) throws NoSuchAlgorithmException{
|
| 137 |
String pass = accountId + "|" + paymentId + "|" + ppp.getAmount() + "|" + ppp.getProductinfo() + "|" + ppp.getFirstname() + "|" + ppp.getEmail() + "|||||||||||" + salt;
|
135 |
String pass = accountId + "|" + paymentId + "|" + ppp.getAmount() + "|" + ppp.getProductinfo() + "|" + ppp.getFirstname() + "|" + ppp.getEmail() + "|||||||||||" + salt;
|
| 138 |
log.info("Secure hash-->accountId|paymentId|ppp.getAmount()|ppp.getProductinfo()|ppp.getFirstname()|ppp.getEmail()|||||||||||salt");
|
136 |
log.info("Secure hash-->accountId|paymentId|ppp.getAmount()|ppp.getProductinfo()|ppp.getFirstname()|ppp.getEmail()|||||||||||salt");
|
| 139 |
log.info("Pass-->" + pass);
|
137 |
log.info("Pass-->" + pass);
|