Rev 2118 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.serving.controllers;import org.apache.log4j.Logger;import in.shop2020.config.ConfigException;import in.shop2020.model.v1.order.Order;import in.shop2020.model.v1.order.Transaction;import in.shop2020.payments.Payment;import in.shop2020.thrift.clients.PaymentServiceClient;import in.shop2020.thrift.clients.TransactionServiceClient;import in.shop2020.thrift.clients.config.ConfigClient;public class EbsPayController {private static Logger log = Logger.getLogger(Class.class);private static String accountId;private static String returnUrl;private static String mode;static{try {accountId = ConfigClient.getClient().get("ebs_account_id");returnUrl = ConfigClient.getClient().get("ebs_return_url");mode = ConfigClient.getClient().get("ebs_pay_mode");} catch (ConfigException e) {log.error("Unable to get EBS payment configuration.");}}private String id;private double amount;private ContactDetails billingDetails;public String show(){PaymentServiceClient paymentServiceClient = null;Payment payment = null;try {long paymentId = Long.parseLong(this.id);paymentServiceClient = new PaymentServiceClient();payment = paymentServiceClient.getClient().getPayment(paymentId);} catch (Exception e) {log.error("Error while getting payment client");e.printStackTrace();return "fail";}Order order = null;try {long txnId = payment.getMerchantTxnId();TransactionServiceClient transactionServiceClient = new TransactionServiceClient();in.shop2020.model.v1.order.TransactionService.Client txnClient = transactionServiceClient.getClient();Transaction transaction = txnClient.getTransaction(txnId);order = transaction.getOrders().get(0);} catch (Exception e) {e.printStackTrace();return "fail";}this.amount = payment.getAmount();this.billingDetails = new ContactDetails(order.getCustomer_name(),order.getCustomer_email(), order.getCustomer_address1(),order.getCustomer_city(), order.getCustomer_state(),order.getCustomer_pincode(), "IND",order.getCustomer_mobilenumber());log.info(billingDetails);return "show";}public void setId(String id) {this.id = id;}public String getId() {return id;}public String getAccountId() {return accountId;}public static String getReturnUrl() {return returnUrl;}public static String getMode() {return mode;}public double getAmount() {return amount;}public ContactDetails getBillingDetails() {return billingDetails;}public static class ContactDetails{private String name;private String email;private String address;private String city;private String state;private String postalCode;private String country;private String phone;public ContactDetails(String name, String email, String address,String city, String state, String postalCode, String country,String phone) {this.name = name;this.email = email;this.address = address;this.city = city;this.state = state;this.postalCode = postalCode;this.country = country;this.phone = phone;}@Overridepublic String toString() {return "ContactDetails [name=" + name + ", email=" + email+ ", address=" + address + ", city=" + city + ", state="+ state + ", postalCode=" + postalCode + ", country="+ country + ", phone=" + phone + "]";}public String getName() {return name;}public String getEmail() {return email;}public String getAddress() {return address;}public String getCity() {return city;}public String getState() {return state;}public String getPostalCode() {return postalCode;}public String getCountry() {return country;}public String getPhone() {return phone;}}}