Commit 8e25861a by Nilu

added visa and master icons. Invoice retrive on stripe utils

parent 27f0b494
...@@ -83,13 +83,13 @@ public class Company extends BaseCompany ...@@ -83,13 +83,13 @@ public class Company extends BaseCompany
public PaymentPlan getSelectedPaymentPlan() public PaymentPlan getSelectedPaymentPlan()
{ {
if(getPaymentJobCount()!=null) if(getPaymentJobCount() != null)
{ {
PaymentPlan[] plans = PaymentPlan.SearchByAll() PaymentPlan[] plans = PaymentPlan.SearchByAll()
.andActiveJobCount(new EqualsFilter<>(getPaymentJobCount())) .andActiveJobCount(new EqualsFilter<>(getPaymentJobCount()))
.search(getTransaction()); .search(getTransaction());
if(plans.length>0) if(plans.length > 0)
{ {
return plans[0]; return plans[0];
} }
...@@ -147,10 +147,15 @@ public class Company extends BaseCompany ...@@ -147,10 +147,15 @@ public class Company extends BaseCompany
return getPaymentPlan() != null && getPaymentPlan().getActiveJobCount() > openJobs.length; return getPaymentPlan() != null && getPaymentPlan().getActiveJobCount() > openJobs.length;
} }
public String getCardNumber() throws FieldException
public Card getCard() throws FieldException
{
return StripeUtils.retrieveCard(this);
}
public String getCardNumber(Card card) throws FieldException
{ {
Card card = StripeUtils.retrieveCard(this);
return card != null ? "xxxx-xxxx-xxxx-" + card.getLast4() : ""; return card != null ? "xxxx-xxxx-xxxx-" + card.getLast4() : "";
} }
......
...@@ -8,11 +8,13 @@ import com.stripe.exception.CardException; ...@@ -8,11 +8,13 @@ import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException; import com.stripe.exception.InvalidRequestException;
import com.stripe.model.Card; import com.stripe.model.Card;
import com.stripe.model.Customer; import com.stripe.model.Customer;
import com.stripe.model.Invoice;
import com.stripe.model.Plan; import com.stripe.model.Plan;
import com.stripe.model.Subscription; import com.stripe.model.Subscription;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import oneit.appservices.config.ConfigMgr; import oneit.appservices.config.ConfigMgr;
import oneit.logging.LogLevel; import oneit.logging.LogLevel;
...@@ -114,6 +116,25 @@ public class StripeUtils ...@@ -114,6 +116,25 @@ public class StripeUtils
} }
public static List<Invoice> retrieveInvoices(Company company) throws FieldException
{
try
{
Map<String, Object> invoiceParams = new HashMap<>();
invoiceParams.put("subscription", company.getStripeSubscription());
return Invoice.list(invoiceParams).getData();
}
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while retriving invoices in stripe for subscription: " + company.getStripeSubscription());
}
return null;
}
public static void subscribeCustomer(Company company) throws FieldException public static void subscribeCustomer(Company company) throws FieldException
{ {
try try
......
...@@ -53,11 +53,17 @@ ...@@ -53,11 +53,17 @@
<div class="form-group row"> <div class="form-group row">
<div class="col-md-12 col-sm-12 col-xs-12 text-left"> <div class="col-md-12 col-sm-12 col-xs-12 text-left">
<label>Card Number</label> <label>Card Number</label>
<div style="float: right; margin-top:-15px;">
<img src="images/master-small.png" style="width:30px;"/>
<img src="images/visa.svg" style="width:40px;"/>
</div>
<% <%
if(isEdit) if(isEdit)
{ {
Card card = company.getCard();
%> %>
<input type="text" name="cardNumber" value="<%= company.getCardNumber() %>" class="form-control" readonly> <input type="text" name="cardNumber" value="<%= company.getCardNumber(card) %>" class="form-control" readonly>
<% <%
} }
else else
......
...@@ -10,14 +10,16 @@ ...@@ -10,14 +10,16 @@
boolean isEdit = (boolean) getData(request, "IsEdit"); boolean isEdit = (boolean) getData(request, "IsEdit");
String replaceCardPage = WebUtils.getSamePageInRenderMode(request, "ReplaceCard"); String replaceCardPage = WebUtils.getSamePageInRenderMode(request, "ReplaceCard");
String editCardPage = WebUtils.getSamePageInRenderMode(request, "EditCard"); String editCardPage = WebUtils.getSamePageInRenderMode(request, "EditCard");
Card card = company.getCard();
%> %>
<oneit:dynIncluded> <oneit:dynIncluded>
<div class="form-group row"> <div class="form-group row">
<div class="col-lg-3 col-md-3 col-sm-3"> <div class="col-lg-3 col-md-3 col-sm-3">
<label>Card on file</label> <label>Card on file</label>
</div> </div>
<div class="col-lg-5 col-md-5 col-sm-5"> <div class="col-lg-5 col-md-5 col-sm-5" style="margin-top: -20px;">
<label><%= company.getCardNumber() %></label> <img src="<%= card.getBrand() == "MasterCard" ? "images/master.svg" : "images/visa.svg" %>" style="width:60px;"/>
<label><%= company.getCardNumber(card) %></label>
</div> </div>
<div class="col-lg-2 col-md-2 col-sm-2"> <div class="col-lg-2 col-md-2 col-sm-2">
<oneit:button value=" " name="gotoPage" skin="link" cssClass="<%= "edit-card-link " + (isEdit ? "" : "deselected-link")%>" <oneit:button value=" " name="gotoPage" skin="link" cssClass="<%= "edit-card-link " + (isEdit ? "" : "deselected-link")%>"
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
Debug.assertion(company != null , "Invalid company in admin portal my company"); Debug.assertion(company != null , "Invalid company in admin portal my company");
String nextPage = WebUtils.getSamePageInRenderMode(request, "Page"); String nextPage = WebUtils.getSamePageInRenderMode(request, "Page");
StripeUtils.retrieveInvoices(company);
%> %>
<div class="container-fluid"> <div class="container-fluid">
......
<%@ page import="performa.orm.*, performa.orm.types.*, performa.form.*, performa.utils.*"%> <%@ page import="performa.orm.*, performa.orm.types.*, performa.form.*, performa.utils.*"%>
<%@ page import="performa.intercom.utils.*, performa.intercom.resources.User"%> <%@ page import="performa.intercom.utils.*, performa.intercom.resources.User, com.stripe.model.*"%>
<%@ page import="oneit.objstore.rdbms.filters.*, oneit.security.jsp.SecUserToNameTransform, oneit.servlets.utils.*, oneit.utils.image.*, oneit.objstore.utils.ObjstoreUtils "%> <%@ page import="oneit.objstore.rdbms.filters.*, oneit.security.jsp.SecUserToNameTransform, oneit.servlets.utils.*, oneit.utils.image.*, oneit.objstore.utils.ObjstoreUtils "%>
<?xml version="1.0" ?><svg height="60px" version="1.1" viewBox="0 0 60 60" width="60px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><desc/><defs/><g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1"><g id="Social_icons" transform="translate(-422.000000, -954.000000)"><g id="Mastercard" transform="translate(422.000000, 954.000000)"><circle cx="30" cy="30" fill="#FFFFFF" id="Oval" r="30"/><g id="g3110" transform="translate(12.000000, 19.000000)"><path d="M35.9736305,11.1445924 C35.9736305,17.2982476 30.994537,22.2867716 24.8525128,22.2867716 C18.7104886,22.2867716 13.7313936,17.2982476 13.7313936,11.1445924 C13.7313936,4.99093624 18.7104886,0.00241261301 24.8525128,0.00241261301 C30.994537,0.00241261301 35.9736305,4.99093624 35.9736305,11.1445924 L35.9736305,11.1445924 Z" fill="#F79F1A" id="path2997"/><path d="M22.2540437,11.1445924 C22.2540437,17.2982476 17.2749503,22.2867716 11.132926,22.2867716 C4.99090183,22.2867716 0.0118068562,17.2982476 0.0118068562,11.1445924 C0.0118068562,4.99093624 4.99090183,0.00241261301 11.132926,0.00241261301 C17.2749503,0.00241261301 22.2540437,4.99093624 22.2540437,11.1445924 L22.2540437,11.1445924 Z" fill="#EA001B" id="path2995"/><path d="M17.9927419,2.3733871 C15.3979037,4.41315778 13.7322581,7.58283794 13.7322581,11.1435484 C13.7322581,14.7042588 15.3979037,17.8763582 17.9927419,19.916129 C20.5875801,17.8763582 22.2532258,14.7042588 22.2532258,11.1435484 C22.2532258,7.58283794 20.5875801,4.41315778 17.9927419,2.3733871 L17.9927419,2.3733871 Z" fill="#FF5F01" id="path2999"/></g></g></g></g></svg>
\ No newline at end of file
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg height="512px" style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="形状_1_3_" style="enable-background:new ;"><g id="形状_1"><g><path d="M211.328,184.445l-23.465,144.208h37.542l23.468-144.208 H211.328z M156.276,184.445l-35.794,99.185l-4.234-21.358l0.003,0.007l-0.933-4.787c-4.332-9.336-14.365-27.08-33.31-42.223 c-5.601-4.476-11.247-8.296-16.705-11.559l32.531,124.943h39.116l59.733-144.208H156.276z M302.797,224.48 c0-16.304,36.563-14.209,52.629-5.356l5.357-30.972c0,0-16.534-6.288-33.768-6.288c-18.632,0-62.875,8.148-62.875,47.739 c0,37.26,51.928,37.723,51.928,57.285c0,19.562-46.574,16.066-61.944,3.726l-5.586,32.373c0,0,16.763,8.148,42.382,8.148 c25.616,0,64.272-13.271,64.272-49.37C355.192,244.272,302.797,240.78,302.797,224.48z M455.997,184.445h-30.185 c-13.938,0-17.332,10.747-17.332,10.747l-55.988,133.461h39.131l7.828-21.419h47.728l4.403,21.419h34.472L455.997,184.445z M410.27,277.641l19.728-53.966l11.098,53.966H410.27z" style="fill-rule:evenodd;clip-rule:evenodd;fill:#005BAC;"/></g></g></g><g id="形状_1_2_" style="enable-background:new ;"><g id="形状_1_1_"><g><path d="M104.132,198.022c0,0-1.554-13.015-18.144-13.015H25.715 l-0.706,2.446c0,0,28.972,5.906,56.767,28.033c26.562,21.148,35.227,47.51,35.227,47.51L104.132,198.022z" style="fill-rule:evenodd;clip-rule:evenodd;fill:#F6AC1D;"/></g></g></g></svg>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment