diff --git a/resources/taglib/tc-webtags.tld b/resources/taglib/tc-webtags.tld
index 613357022e7..d743bcf4c11 100755
--- a/resources/taglib/tc-webtags.tld
+++ b/resources/taglib/tc-webtags.tld
@@ -185,6 +185,11 @@
false
true
+
+ disabled
+ false
+ true
+
diff --git a/src/main/com/topcoder/web/common/model/PaymentMethod.java b/src/main/com/topcoder/web/common/model/PaymentMethod.java
index c9b1a4e16f7..d83d61f6ce2 100644
--- a/src/main/com/topcoder/web/common/model/PaymentMethod.java
+++ b/src/main/com/topcoder/web/common/model/PaymentMethod.java
@@ -4,12 +4,21 @@
/**
* A class to hold Payment Method data.
*
- * @author VolodymyrK
+ *
+ * Version 1.1 (Topcoder - Add New Payment Provider) Change notes:
+ *
+ * - Added eligible attribute to determinate whether the payment method is allowed or not.
+ *
+ *
+ *
+ * @author VolodymyrK, TCSCODER
+ * @version 1.1
*/
public class PaymentMethod extends Base {
private Long id;
private String name;
+ private boolean eligible = true;
public PaymentMethod() {
}
@@ -30,4 +39,12 @@ public void setName(String name) {
this.name = name;
}
+ public boolean isEligible() {
+ return eligible;
+ }
+
+ public void setEligible(boolean eligible) {
+ this.eligible = eligible;
+ }
+
}
diff --git a/src/main/com/topcoder/web/common/tag/RadioButtonTag.java b/src/main/com/topcoder/web/common/tag/RadioButtonTag.java
index 927b50744e7..fa31e30a4db 100644
--- a/src/main/com/topcoder/web/common/tag/RadioButtonTag.java
+++ b/src/main/com/topcoder/web/common/tag/RadioButtonTag.java
@@ -4,11 +4,18 @@
* User: dok
* Date: Jan 3, 2005
* Time: 5:53:26 PM
+ *
+ * Version 1.1 (Topcoder - Add New Payment Provider) 08/08/2017
+ * - Add "disabled" attribute
+ *
+ * @author dok, TCSCODER
+ * @version 1.1
*/
public class RadioButtonTag extends BaseTag {
private String value = null;
private String selected = null;
private String onClick = null;
+ private String disabled = null;
public int doStartTag() {
StringBuffer ret = new StringBuffer();
@@ -25,6 +32,9 @@ public int doStartTag() {
}
if (onClick != null)
ret.append("onClick=\"").append(onClick).append("\" ");
+ if (disabled != null) {
+ ret.append("disabled ");
+ }
ret.append("/>");
pageContext.getOut().print(ret.toString());
} catch (java.io.IOException ioe) {
@@ -48,6 +58,10 @@ public void setOnClick(String onClick) {
this.onClick = onClick;
}
+ public void setDisabled(String disabled) {
+ this.disabled = disabled;
+ }
+
protected void init() {
this.value = null;
this.selected = null;
diff --git a/src/main/com/topcoder/web/ejb/pacts/Constants.java b/src/main/com/topcoder/web/ejb/pacts/Constants.java
index c256ada8685..aa5d93d7bb3 100644
--- a/src/main/com/topcoder/web/ejb/pacts/Constants.java
+++ b/src/main/com/topcoder/web/ejb/pacts/Constants.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 - 2012 TopCoder Inc., All Rights Reserved.
+ * Copyright (C) 2004 - 2017 TopCoder Inc., All Rights Reserved.
*/
package com.topcoder.web.ejb.pacts;
@@ -75,7 +75,7 @@
*
* - Added common payment types for all tracks. No more separate payments for architecture, assembly, components etc.
*
- *
+ *
*
*
* Version 1.10 (Member Payments Automation Assembly 1.0) Change notes:
@@ -84,8 +84,15 @@
*
*
*
- * @author pulky, VolodymyrK, isv
- * @version 1.10
+ *
+ * Version 1.11 (Topcoder - Add New Payment Provider) Change notes:
+ *
+ * - Added {@link WIPRO_PAYROLL_PAYMENT_METHOD_ID} constant.
+ *
+ *
+ *
+ * @author pulky, VolodymyrK, isv, TCSCODER
+ * @version 1.11
*/
public interface Constants {
@@ -271,10 +278,11 @@ public interface Constants {
public static final long NOT_SET_PAYMENT_METHOD_ID = 1;
public static final long PAYPAL_PAYMENT_METHOD_ID = 2;
public static final long PAYONEER_PAYMENT_METHOD_ID = 5;
+ public static final long WIPRO_PAYROLL_PAYMENT_METHOD_ID = 7;
/**
* A long
providing the ID of Western Union
payment method.
- *
+ *
* @since 1.10
*/
public static final long WESTERN_UNION_PAYMENT_METHOD_ID = 6;
diff --git a/src/main/com/topcoder/web/ejb/pacts/PactsServicesBean.java b/src/main/com/topcoder/web/ejb/pacts/PactsServicesBean.java
index 37a262ccb1f..ca19df025a1 100755
--- a/src/main/com/topcoder/web/ejb/pacts/PactsServicesBean.java
+++ b/src/main/com/topcoder/web/ejb/pacts/PactsServicesBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 - 2012 TopCoder Inc., All Rights Reserved.
+ * Copyright (C) 2004 - 2017 TopCoder Inc., All Rights Reserved.
*/
package com.topcoder.web.ejb.pacts;
@@ -126,11 +126,17 @@
* method.
*
*
+ *
+ * Version 1.8 (Topcoder - Add New Payment Provider) Change notes:
+ *
+ * - Added {@link #hasWiproSSOAccount(long)} method.
+ *
+ *
*
* VERY IMPORTANT: remember to update serialVersionUID if needed.
*
- * @author Dave Pecora, pulky, isv, Vitta, Blues, FireIce
- * @version 1.7
+ * @author Dave Pecora, pulky, isv, Vitta, Blues, FireIce, TCSCODER
+ * @version 1.8
* @see PactsConstants
*/
public class PactsServicesBean extends BaseEJB implements PactsConstants {
@@ -1539,7 +1545,7 @@ public void saveUserPaymentMethod(long userId, long paymentMethodId) {
if (userId == 0) {
throw new IllegalArgumentException("Invalid user ID");
}
-
+
if (paymentMethodId <= 0) {
throw new IllegalArgumentException("Invalid payment method ID.");
}
@@ -1608,7 +1614,7 @@ public void saveUserPayPalAccount(long userId, String payPalAccount) {
if (payPalAccount == null) {
throw new IllegalArgumentException("Invalid email address of the PayPal account");
}
-
+
PreparedStatement insertPs = null, updatePs = null;
Connection conn = null;
try {
@@ -3203,7 +3209,7 @@ public Map findPayments(Map searchCriteria) throws SQLException {
StringBuffer whereClauses = new StringBuffer(300);
whereClauses.append(" WHERE 1=1 ");
-
+
ArrayList objects = new ArrayList();
Iterator i = searchCriteria.keySet().iterator();
try {
@@ -3759,7 +3765,7 @@ public double computePaymentNetAmount(int paymentTypeId, double grossAmount, lon
log.debug("In computePaymentNetAmount");
Connection c = null;
-
+
try {
c = DBMS.getConnection(trxDataSource);
@@ -3813,7 +3819,7 @@ public double computePaymentNetAmount(int paymentTypeId, double grossAmount, lon
} else {
return grossAmount;
}
-
+
// Round to lower pennie
BigDecimal bd = new BigDecimal(netAmount).setScale(2, RoundingMode.HALF_DOWN);
double roundedNetAmount = bd.doubleValue();
@@ -5334,7 +5340,7 @@ public int generateRoundPayments(long roundId, boolean makeChanges, int paymentT
}
/**
-
+
* Generates all the payments for the people who won money for the given project (winners and
* and review board members).
* It doesn't insert the payments in the DB, just generates and returns them.
@@ -5376,7 +5382,7 @@ public List generateComponentPayments(long projectId, long status, String client
getWinners.append(" ELSE ROUND(ri7.value) ");
getWinners.append(" END::float AS payment ");
- getWinners.append(" FROM tcs_catalog:project p ");
+ getWinners.append(" FROM tcs_catalog:project p ");
getWinners.append(" INNER JOIN tcs_catalog:project_category_lu pcl ON pcl.project_category_id = p.project_category_id ");
getWinners.append(" INNER JOIN tcs_catalog:resource r ON r.project_id = p.project_id AND r.resource_role_id = 1 ");
getWinners.append(" INNER JOIN tcs_catalog:resource_info ri1 ON r.resource_id = ri1.resource_id AND ri1.resource_info_type_id = 1 ");
@@ -5398,10 +5404,10 @@ public List generateComponentPayments(long projectId, long status, String client
long resourceId = rsc.getLongItem(i, "resource_id");
long projectCategoryId = rsc.getLongItem(i, "project_category_id");
String submissionType = rsc.getStringItem(i, "submission_type");
-
+
double penalty = penalties.get(coderId) == null ? 0.0 : penalties.get(coderId);
double amount = rsc.getDoubleItem(i, "payment")*(1.0-penalty);
-
+
log.info("Generating payment. Coder: " + coderId + " placed: " + placed + " amount: " + amount + " penalty: " + penalty + " resourceId: " + resourceId);
if (amount < 0.01) {
log.info("Ignoring the payment because of zero or negative amount.");
@@ -5413,7 +5419,7 @@ public List generateComponentPayments(long projectId, long status, String client
if (projectCategoryId == 37) { // If Marathon Match
if (rsc.getItem(i, "mm_round_id").getResultData() == null) {
log.info("MM round ID is not set. Ignoring the payment.");
- continue;
+ continue;
}
long mmRoundId = rsc.getLongItem(i, "mm_round_id");
@@ -5433,7 +5439,7 @@ public List generateComponentPayments(long projectId, long status, String client
// Calculate the due date for the 2nd installment.
// It should be max(general due date assigned by the system, SECOND_INSTALLMENT_HOLD_PERIOD days from now).
- Calendar cal = Calendar.getInstance();
+ Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, SECOND_INSTALLMENT_HOLD_PERIOD);
payment2 = fillPaymentData(payment2);
@@ -5448,8 +5454,8 @@ public List generateComponentPayments(long projectId, long status, String client
} else if (submissionType.startsWith("Checkpoint Submission")) {
payments.add(new ContestCheckpointPayment(coderId, amount, client, projectId, placed));
}
-
- resourceIds.add(new Long(resourceId));
+
+ resourceIds.add(new Long(resourceId));
} else {
log.info("Payments for the coder " + coderId + " are skipped because he/she still has pending late deliverables.");
}
@@ -5494,7 +5500,7 @@ public List generateComponentPayments(long projectId, long status, String client
log.info("Payments for the coder " + coderId + " are skipped because he/she still has pending late deliverables.");
continue;
}
-
+
String paymentType = rsc.getStringItem(i, "payment_type");
double penalty = penalties.get(coderId) == null ? 0.0 : penalties.get(coderId);
double amount = rsc.getDoubleItem(i, "paid");
@@ -5505,7 +5511,7 @@ public List generateComponentPayments(long projectId, long status, String client
ComponentProjectReferencePayment p = null;
int projectType = getProjectType(projectId);
-
+
if (paymentType.startsWith("Copilot Payment")) {
// The penalties are not applied to the copilot payments
p = new CopilotPayment(coderId, amount, client, projectId);
@@ -5537,8 +5543,8 @@ public List generateComponentPayments(long projectId, long status, String client
return payments;
}
- /**
- * Returns the maximum of two dates. A null date is considered to be less than any non-null date.
+ /**
+ * Returns the maximum of two dates. A null date is considered to be less than any non-null date.
*/
private static Date max(Date d1, Date d2) {
if (d1 == null && d2 == null) {
@@ -5559,7 +5565,7 @@ private static Date max(Date d1, Date d2) {
* is still in the 24 hours window since the moment of creation (which means the late member can still explain it).
*
* @param projectId The ID of the project
- * @return List of user IDs who have pending late deliverables for this project.
+ * @return List of user IDs who have pending late deliverables for this project.
* @throws SQLException If there was some error retrieving the data.
*/
private List getPendingUserIds(long projectId) throws SQLException {
@@ -5569,9 +5575,9 @@ private List getPendingUserIds(long projectId) throws SQLException {
query.append(" ld.resource_id = r.resource_id and r.project_id = " + projectId + " and ");
query.append(" r.resource_id = ri.resource_id and ri.resource_info_type_id = 1 and ");
query.append(" ld.forgive_ind=0 and ");
- query.append(" ((ld.explanation is not null and ld.response is null) "); // if the explained record is waiting for the response
+ query.append(" ((ld.explanation is not null and ld.response is null) "); // if the explained record is waiting for the response
query.append(" or (ld.explanation is null and ld.create_date>current-24 units hour)) "); // or if the late member still has time to explain (24 hours)
-
+
List userIds = new ArrayList();
ResultSetContainer rsc = runSelectQuery(query.toString());
for (int i = 0; i < rsc.size(); i++) {
@@ -5598,19 +5604,19 @@ private Map getPaymentPenalties(long projectId) throws SQLException
query.append(" r.project_id=" + projectId + " and r.resource_id=ld.resource_id and r.resource_id=ri.resource_id and ");
query.append(" ri.resource_info_type_id=1 and ld.forgive_ind=0 ");
query.append(" group by 1 ");
-
+
Map penalties = new HashMap();
ResultSetContainer rsc = runSelectQuery(query.toString());
for (int i = 0; i < rsc.size(); i++) {
long userId = rsc.getLongItem(i, "user_id");
long delay = rsc.getLongItem(i, "total_delay");
long rejectedFinalFixes = rsc.getLongItem(i, "rejected_final_fixes");
-
+
long paymentPenaltyPercentage = (delay>0 ? 5 : 0) + (delay/3600) + rejectedFinalFixes * 5;
if (paymentPenaltyPercentage > 50) {
paymentPenaltyPercentage = 50;
}
-
+
penalties.put(userId, (double)paymentPenaltyPercentage/100.0);
}
return penalties;
@@ -6513,7 +6519,7 @@ private int getProjectType(long projectId) throws SQLException {
}
private boolean isStudioProject(long projectId) throws SQLException {
- ResultSetContainer rsc = runSelectQuery("SELECT pcl.project_type_id FROM tcs_catalog:project_category_lu pcl, " +
+ ResultSetContainer rsc = runSelectQuery("SELECT pcl.project_type_id FROM tcs_catalog:project_category_lu pcl, " +
" tcs_catalog:project p WHERE p.project_category_id=pcl.project_category_id and p.project_id=" + projectId);
if (rsc.size() == 0) {
@@ -6748,12 +6754,12 @@ public List findCoderPayments(long coderId, int paymentTypeId, long referenceId)
searchCriteria.put(PAYMENT_REFERENCE_ID, String.valueOf(referenceId));
return findCoderPayments(searchCriteria);
}
-
+
/**
* Find a Jira payment by its issue key.
* @param jiraIssueKey the issue key.
* @return the Jira payments for the given issue, or empty if not found
- * @throws RemoteException if there is an error
+ * @throws RemoteException if there is an error
* @throws Exception if there is an error
* @throws InvalidStatusException if there is an error
*/
@@ -7075,6 +7081,32 @@ public ResultSetContainer getContestsInfo(long eid) throws SQLException {
}
+ /**
+ * Returns true if the specified user is a Wipro SSO user.
+ *
+ * @param userId The user ID to check.
+ * @return Whether the user is a Wipro SSO user.
+ * @throws SQLException If there is some problem querying the database
+ */
+ public boolean hasWiproSSOAccount(long userId) throws SQLException {
+ StringBuffer query = new StringBuffer(300);
+ query.append("SELECT COUNT(*) FROM user u ");
+ query.append(" JOIN user_sso_login su ON su.user_id = u.user_id ");
+ query.append(" JOIN sso_login_provider sp ON sp.sso_login_provider_id = su.provider_id AND sp.name = 'wipro-adfs' ");
+ query.append("WHERE u.user_id = " + userId);
+
+ Connection c = null;
+ boolean ret = false;
+ try {
+ c = DBMS.getConnection(DBMS.COMMON_OLTP_DATASOURCE_NAME);
+ ResultSetContainer rsc = runSelectQuery(c, query.toString());
+ ret = Integer.parseInt(rsc.getItem(0, 0).toString()) > 0;
+ } finally {
+ close(c);
+ }
+ return ret;
+ }
+
class AlgorithmContestPaymentDataRetriever extends AlgorithmContestPayment {
private final String roundName;
private final Date dueDate;
diff --git a/src/main/com/topcoder/web/ejb/pacts/PactsServicesLocal.java b/src/main/com/topcoder/web/ejb/pacts/PactsServicesLocal.java
index 2bba2ade4d2..91379f1e1f0 100644
--- a/src/main/com/topcoder/web/ejb/pacts/PactsServicesLocal.java
+++ b/src/main/com/topcoder/web/ejb/pacts/PactsServicesLocal.java
@@ -36,9 +36,15 @@
* populating the payment statuses for the given resource ids.
*
*
+ *
+ * Version 1.2 (Topcoder - Add New Payment Provider) Change notes:
+ *
+ * - Added {@link #hasWiproSSOAccount(long)} method.
+ *
+ *
*
- * @author Dave Pecora, FireIce
- * @version 1.1
+ * @author Dave Pecora, FireIce, TCSCODER
+ * @version 1.2
* @see PactsServicesBean
* @see com.topcoder.web.tc.controller.legacy.pacts.bean.DataInterfaceBean
*/
@@ -266,6 +272,8 @@ List generateComponentPayments(long projectId, long status, String client, List
ResultSetContainer getAffidavitHistory(long userId, boolean pendingOnly, int sortColumn, boolean sortAscending) throws SQLException;
+ boolean hasWiproSSOAccount(long userId) throws SQLException;
+
// ================== Methods from the Client Service ==================
BasePayment addPayment(BasePayment payment) throws SQLException;
diff --git a/src/main/com/topcoder/web/tc/controller/legacy/pacts/bean/DataInterfaceBean.java b/src/main/com/topcoder/web/tc/controller/legacy/pacts/bean/DataInterfaceBean.java
index ebb5276ba12..58e19961cf7 100755
--- a/src/main/com/topcoder/web/tc/controller/legacy/pacts/bean/DataInterfaceBean.java
+++ b/src/main/com/topcoder/web/tc/controller/legacy/pacts/bean/DataInterfaceBean.java
@@ -79,9 +79,15 @@
* populating the payment statuses for the given resource ids.
*
*
+ *
+ * Version 1.2 (Topcoder - Add New Payment Provider) Change notes:
+ *
+ * - Added {@link #hasWiproSSOAccount(long)} method.
+ *
+ *
*
- * @author Dave Pecora, FireIce
- * @version 1.1
+ * @author Dave Pecora, FireIce, TCSCODER
+ * @version 1.2
* @see ResultSetContainer
* @see PactsServicesBean
* @see PactsConstants
@@ -1638,7 +1644,7 @@ public BasePayment fillPaymentData(BasePayment payment) throws RemoteException,
public double computePaymentNetAmount(int paymentTypeId, double grossAmount, long coderId) throws RemoteException, SQLException {
PactsServicesLocal ps = getEjbHandle();
return ps.computePaymentNetAmount(paymentTypeId, grossAmount, coderId);
- }
+ }
public BasePayment addPayment(BasePayment payment) throws RemoteException, SQLException {
PactsServicesLocal ps = getEjbHandle();
@@ -1796,6 +1802,11 @@ public String getInvoiceNumber(long paymentId) throws RemoteException, SQLExcept
PactsServicesLocal ps = getEjbHandle();
return ps.getInvoiceNumber(paymentId);
}
+
+ public boolean hasWiproSSOAccount(long userId) throws RemoteException, SQLException {
+ PactsServicesLocal ps = getEjbHandle();
+ return ps.hasWiproSSOAccount(userId);
+ }
}
diff --git a/src/main/com/topcoder/web/tc/controller/request/myhome/EditPaymentPreferences.java b/src/main/com/topcoder/web/tc/controller/request/myhome/EditPaymentPreferences.java
index 8e9875a1f49..fec5611707b 100644
--- a/src/main/com/topcoder/web/tc/controller/request/myhome/EditPaymentPreferences.java
+++ b/src/main/com/topcoder/web/tc/controller/request/myhome/EditPaymentPreferences.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2016 TopCoder Inc., All Rights Reserved.
+ * Copyright (C) 2010-2017 TopCoder Inc., All Rights Reserved.
*/
package com.topcoder.web.tc.controller.request.myhome;
@@ -23,6 +23,7 @@
import static com.topcoder.web.tc.Constants.MINIMUM_PAYMENT_ACCRUAL_AMOUNT;
import static com.topcoder.web.ejb.pacts.Constants.PAYPAL_PAYMENT_METHOD_ID;
import static com.topcoder.web.ejb.pacts.Constants.PAYONEER_PAYMENT_METHOD_ID;
+import static com.topcoder.web.ejb.pacts.Constants.WIPRO_PAYROLL_PAYMENT_METHOD_ID;
import java.text.SimpleDateFormat;
import java.util.regex.Matcher;
@@ -37,7 +38,7 @@
*
* Version 1.2 Change notes:
*
- * - Updated {@link #savePaymentPreferences()} method to send email to user in case payment method or PayPal
+ *
- Updated {@link #savePaymentPreferences()} method to send email to user in case payment method or PayPal
* account has changed.
*
*
@@ -45,13 +46,22 @@
*
* Version 1.3 Change notes:
*
- * - Updated {@link #dbProcessing()} method to take measures for preventing possible
Cross-Site Request
+ * - Updated {@link #dbProcessing()} method to take measures for preventing possible
Cross-Site Request
* Forgery
attacks.
*
*
*
- * @author isv, VolodymyrK
- * @version 1.3
+ *
+ * Version 1.4 (Topcoder - Add New Payment Provider) Change notes:
+ *
+ * - Updated {@link #loadPaymentMethods()} and {@link #savePaymentPreferences()} methods to check
+ * if signed in user is a Wipro SSO user. If the user is not Wipro SSO User, the Wipro Payroll payment method will be filtered out.
+ The only available payment method option a Wipro SSO User will be Wipro Payroll.
+ *
+ *
+ *
+ * @author isv, VolodymyrK, TCSCODER
+ * @version 1.4
*/
public class EditPaymentPreferences extends ShortHibernateProcessor {
@@ -84,7 +94,7 @@ public class EditPaymentPreferences extends ShortHibernateProcessor {
private static final String EMAIL_PATTERN = "([_A-Za-z0-9-\\+]+)(\\.[_A-Za-z0-9-\\+]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})";
private Pattern pattern;
-
+
/**
* Constructs new EditPaymentPreferences
instance.
* Simply initializes the regex pattern object..
@@ -151,6 +161,7 @@ protected void dbProcessing() throws Exception {
*/
private void loadPaymentMethods() throws Exception {
DataInterfaceBean dataBean = new DataInterfaceBean();
+ boolean wiproUser = dataBean.hasWiproSSOAccount(getUser().getId());
ResultSetContainer rsc = (ResultSetContainer) dataBean.getPaymentMethods().get(PactsConstants.PAYMENT_METHOD_LIST);
List paymentMethods = new ArrayList();
@@ -160,13 +171,22 @@ private void loadPaymentMethods() throws Exception {
String methodDesc = TCData.getTCString(rsr, "payment_method_desc", "method", true);
boolean active = TCData.getTCBoolean(rsr, "active", true, true);
+ // skip wipro payroll payment method if user is not a Wipro SSO user
+ if (methodID == WIPRO_PAYROLL_PAYMENT_METHOD_ID && !wiproUser) {
+ continue;
+ }
if (active) {
PaymentMethod paymentMethod = new PaymentMethod();
paymentMethod.setId(methodID);
paymentMethod.setName(methodDesc);
+ // mark other payments as ineligible for Wipro SSO user
+ if (methodID != WIPRO_PAYROLL_PAYMENT_METHOD_ID && wiproUser) {
+ paymentMethod.setEligible(false);
+ }
paymentMethods.add(paymentMethod);
}
}
+ getRequest().setAttribute("wiproUser", wiproUser);
getRequest().setAttribute("paymentMethods", paymentMethods);
}
@@ -208,6 +228,7 @@ private void loadPayoneerStatus() {
private void savePaymentPreferences() throws Exception {
TCRequest request = getRequest();
DataInterfaceBean dataBean = new DataInterfaceBean();
+ boolean wiproUser = dataBean.hasWiproSSOAccount(getUser().getId());
// Parse accrual amount from request and validate that it's numeric and is greater than minimum allowed value
String accrualAmountValue = request.getParameter(ACCRUAL_AMOUNT_PARAM);
@@ -234,7 +255,7 @@ private void savePaymentPreferences() throws Exception {
} catch (NumberFormatException e) {
addError(PAYMENT_METHOD_PARAM, "Payment method ID must be an integer number");
}
-
+
if (paymentMethodId == PAYONEER_PAYMENT_METHOD_ID) {
PayoneerService.PayeeStatus payeeStatus = PayoneerService.getPayeeStatus(getUser().getId());
if (payeeStatus == PayoneerService.PayeeStatus.NOT_REGISTERED) {
@@ -249,6 +270,10 @@ private void savePaymentPreferences() throws Exception {
addError(PAYPAL_ACCOUNT_PARAM, "You must specify your PayPal account email address");
}
+ if (paymentMethodId == WIPRO_PAYROLL_PAYMENT_METHOD_ID && !wiproUser) {
+ addError(PAYMENT_METHOD_PARAM, "You must be signed in with Wipro SSO to use Wipro Payroll");
+ }
+
if (!hasErrors()) {
if (newAccrualAmount < MINIMUM_PAYMENT_ACCRUAL_AMOUNT) {
addError(ACCRUAL_AMOUNT_PARAM,
@@ -320,7 +345,7 @@ private void forwardToEditPaymentPreferencesView(String paymentAccrualAmount, St
}
/**
- * Sends an email to email address for current user in case either payment method or PayPal email address have
+ *
Sends an email to email address for current user in case either payment method or PayPal email address have
* changed when servicing the request for updating user's payment preferences.
*
* @param oldPaymentMethodId a long
providing the ID of old payment method.
@@ -331,7 +356,7 @@ private void forwardToEditPaymentPreferencesView(String paymentAccrualAmount, St
* @since 1.2
*/
private void sendEmailOnPaymentPreferencesUpdated(Long oldPaymentMethodId, long paymentMethodId,
- String oldPayPalAccount, String payPalAccountValue,
+ String oldPayPalAccount, String payPalAccountValue,
String toAddress) {
try {
SimpleDateFormat formatter = new SimpleDateFormat(EMAIL_TIMESTAMP_FORMAT);
@@ -341,7 +366,7 @@ private void sendEmailOnPaymentPreferencesUpdated(Long oldPaymentMethodId, long
", your Payment Preference " +
"information was updated.");
emailBody.append("The following changes have been made:
");
-
+
emailBody.append("");
if (oldPaymentMethodId == null) {
emailBody.append("- Payment Method was set to ")
@@ -351,7 +376,7 @@ private void sendEmailOnPaymentPreferencesUpdated(Long oldPaymentMethodId, long
.append(resolvePaymentMethod(oldPaymentMethodId).getName()).append(" to ")
.append(resolvePaymentMethod(paymentMethodId).getName()).append(".
");
}
-
+
if (isEmpty(oldPayPalAccount)) {
emailBody.append("- Your PayPal account email address was set to ")
.append(isEmpty(payPalAccountValue) ? "" : payPalAccountValue).append(".
");
@@ -367,7 +392,7 @@ private void sendEmailOnPaymentPreferencesUpdated(Long oldPaymentMethodId, long
emailBody.append("If you did not initiate these changes, " +
"please contact TopCoder immediately.
");
-
+
TCSEmailMessage message = new TCSEmailMessage();
message.setFromAddress(Constants.PAYMENT_PREFS_UPDATE_EMAIL_FROM_ADDRESS);
message.setToAddress(toAddress, TCSEmailMessage.TO);
@@ -383,10 +408,10 @@ private void sendEmailOnPaymentPreferencesUpdated(Long oldPaymentMethodId, long
/**
* Gets the details for payment method matching the specified ID.
- *
+ *
* @param paymentMethodId a long
providing the ID of payment method.
- * @return a PaymentMethod
providing the details for payment method matching the specified ID or
- * null
if such a method is not found.
+ * @return a PaymentMethod
providing the details for payment method matching the specified ID or
+ * null
if such a method is not found.
* @since 1.2
*/
@SuppressWarnings("unchecked")
@@ -396,14 +421,14 @@ private PaymentMethod resolvePaymentMethod(long paymentMethodId) {
if (paymentMethod.getId() == paymentMethodId) {
return paymentMethod;
}
-
+
}
return null;
}
/**
* Checks if PayPal account has changed.
- *
+ *
* @param oldPayPalAccount a String
providing old PayPal account.
* @param newPayPalAccount a String
providing new PayPal account.
* @return true
if PayPal account has changed; false
otherwise.
diff --git a/src/main/com/topcoder/web/tc/view/my_home/paymentPreferences.jsp b/src/main/com/topcoder/web/tc/view/my_home/paymentPreferences.jsp
index c0204a49054..d718feedd78 100644
--- a/src/main/com/topcoder/web/tc/view/my_home/paymentPreferences.jsp
+++ b/src/main/com/topcoder/web/tc/view/my_home/paymentPreferences.jsp
@@ -1,11 +1,15 @@
<%--
- - Author: isv
+ - Author: isv, TCSCODER
- Version: 1.1 (Member Payment Improvements Release assembly v1.0)
- - Copyright (C) 2010-2016 TopCoder Inc., All Rights Reserved.
+ - Version: 1.2 (Topcoder - Add New Payment Provider)
+ - Copyright (C) 2010-2017 TopCoder Inc., All Rights Reserved.
-
- Description: This page provides a web form for managing user payment preferences. Such a form includes input
- field for setting the payment accrual amount for now.
- v1.1 changes: implemented Synchronizer Token Pattern for web form.
+ - v1.2 changes:
+ - - if the user is Wipro SSO User, only the Wipro Payroll option will be enabled, other options will be disabled.
+ - - Add a description for Wipro Payroll in Payment Provider section.
--%>
<%@ page contentType="text/html;charset=utf-8" %>
@@ -81,7 +85,7 @@