diff --git a/merchantsample/pom.xml b/merchantsample/pom.xml
index 10fe2ad..72f10df 100644
--- a/merchantsample/pom.xml
+++ b/merchantsample/pom.xml
@@ -23,6 +23,27 @@
permissionssdk
2.2.101
+
+ junit
+ junit
+ 4.11
+ test
+
+
+ org.seleniumhq.selenium
+ selenium-java
+ 2.33.0
+
+
+ org.seleniumhq.selenium
+ selenium-server
+ 2.33.0
+
+
+ com.github.detro.ghostdriver
+ phantomjsdriver
+ 1.0.3
+
diff --git a/merchantsample/src/main/java/com/sample/ipn/IPNListenerServlet.java b/merchantsample/src/main/java/com/sample/ipn/IPNListenerServlet.java
index a48938f..040d2a1 100644
--- a/merchantsample/src/main/java/com/sample/ipn/IPNListenerServlet.java
+++ b/merchantsample/src/main/java/com/sample/ipn/IPNListenerServlet.java
@@ -10,7 +10,7 @@
import com.paypal.core.LoggingManager;
import com.paypal.ipn.IPNMessage;
-import com.sample.merchant.Configuration;
+import com.sample.util.Configuration;
public class IPNListenerServlet extends HttpServlet {
diff --git a/merchantsample/src/main/java/com/sample/merchant/CheckoutServlet.java b/merchantsample/src/main/java/com/sample/merchant/CheckoutServlet.java
index 8207ea5..abdcf7b 100644
--- a/merchantsample/src/main/java/com/sample/merchant/CheckoutServlet.java
+++ b/merchantsample/src/main/java/com/sample/merchant/CheckoutServlet.java
@@ -73,6 +73,7 @@
import com.paypal.exception.MissingCredentialException;
import com.paypal.exception.SSLConfigurationException;
import com.paypal.sdk.exceptions.OAuthException;
+import com.sample.util.Configuration;
/**
* Servlet implementation class CheckoutServlet
diff --git a/merchantsample/src/main/java/com/sample/merchant/DoDirectPaymentServlet.java b/merchantsample/src/main/java/com/sample/merchant/DoDirectPaymentServlet.java
index 0989301..ba11ee6 100644
--- a/merchantsample/src/main/java/com/sample/merchant/DoDirectPaymentServlet.java
+++ b/merchantsample/src/main/java/com/sample/merchant/DoDirectPaymentServlet.java
@@ -38,6 +38,7 @@
import com.paypal.exception.MissingCredentialException;
import com.paypal.exception.SSLConfigurationException;
import com.paypal.sdk.exceptions.OAuthException;
+import com.sample.util.Configuration;
public class DoDirectPaymentServlet extends HttpServlet {
diff --git a/merchantsample/src/main/java/com/sample/merchant/GenerateAccessTokenServlet.java b/merchantsample/src/main/java/com/sample/merchant/GenerateAccessTokenServlet.java
index 296ae4c..89ad61c 100644
--- a/merchantsample/src/main/java/com/sample/merchant/GenerateAccessTokenServlet.java
+++ b/merchantsample/src/main/java/com/sample/merchant/GenerateAccessTokenServlet.java
@@ -21,6 +21,7 @@
import com.paypal.svcs.types.common.RequestEnvelope;
import com.paypal.svcs.types.perm.GetAccessTokenRequest;
import com.paypal.svcs.types.perm.GetAccessTokenResponse;
+import com.sample.util.Configuration;
public class GenerateAccessTokenServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
diff --git a/merchantsample/src/main/java/com/sample/merchant/MassPayServlet.java b/merchantsample/src/main/java/com/sample/merchant/MassPayServlet.java
index b2d431c..cf18b1d 100644
--- a/merchantsample/src/main/java/com/sample/merchant/MassPayServlet.java
+++ b/merchantsample/src/main/java/com/sample/merchant/MassPayServlet.java
@@ -31,6 +31,7 @@
import com.paypal.exception.MissingCredentialException;
import com.paypal.exception.SSLConfigurationException;
import com.paypal.sdk.exceptions.OAuthException;
+import com.sample.util.Configuration;
/**
* Servlet implementation class MassPayServlet
diff --git a/merchantsample/src/main/java/com/sample/merchant/OnboardingServlet.java b/merchantsample/src/main/java/com/sample/merchant/OnboardingServlet.java
index fbaf33b..454730b 100644
--- a/merchantsample/src/main/java/com/sample/merchant/OnboardingServlet.java
+++ b/merchantsample/src/main/java/com/sample/merchant/OnboardingServlet.java
@@ -15,14 +15,6 @@
import org.xml.sax.SAXException;
-import com.paypal.exception.ClientActionRequiredException;
-import com.paypal.exception.HttpErrorException;
-import com.paypal.exception.InvalidCredentialException;
-import com.paypal.exception.InvalidResponseDataException;
-import com.paypal.exception.MissingCredentialException;
-import com.paypal.exception.SSLConfigurationException;
-import com.paypal.sdk.exceptions.OAuthException;
-
import urn.ebay.api.PayPalAPI.EnterBoardingReq;
import urn.ebay.api.PayPalAPI.EnterBoardingRequestType;
import urn.ebay.api.PayPalAPI.EnterBoardingResponseType;
@@ -46,6 +38,15 @@
import urn.ebay.apis.eBLBaseComponents.PercentageRevenueFromOnlineSalesType;
import urn.ebay.apis.eBLBaseComponents.PersonNameType;
+import com.paypal.exception.ClientActionRequiredException;
+import com.paypal.exception.HttpErrorException;
+import com.paypal.exception.InvalidCredentialException;
+import com.paypal.exception.InvalidResponseDataException;
+import com.paypal.exception.MissingCredentialException;
+import com.paypal.exception.SSLConfigurationException;
+import com.paypal.sdk.exceptions.OAuthException;
+import com.sample.util.Configuration;
+
/**
* Servlet implementation class OnboardingServlet
*/
diff --git a/merchantsample/src/main/java/com/sample/merchant/PermissionServlet.java b/merchantsample/src/main/java/com/sample/merchant/PermissionServlet.java
index cb45bce..b91a55b 100644
--- a/merchantsample/src/main/java/com/sample/merchant/PermissionServlet.java
+++ b/merchantsample/src/main/java/com/sample/merchant/PermissionServlet.java
@@ -23,6 +23,7 @@
import com.paypal.svcs.types.common.RequestEnvelope;
import com.paypal.svcs.types.perm.RequestPermissionsRequest;
import com.paypal.svcs.types.perm.RequestPermissionsResponse;
+import com.sample.util.Configuration;
public class PermissionServlet extends HttpServlet {
/**
diff --git a/merchantsample/src/main/java/com/sample/merchant/PermissionsMassPayServlet.java b/merchantsample/src/main/java/com/sample/merchant/PermissionsMassPayServlet.java
index 7fd8103..c7e0711 100644
--- a/merchantsample/src/main/java/com/sample/merchant/PermissionsMassPayServlet.java
+++ b/merchantsample/src/main/java/com/sample/merchant/PermissionsMassPayServlet.java
@@ -34,6 +34,7 @@
import com.paypal.exception.MissingCredentialException;
import com.paypal.exception.SSLConfigurationException;
import com.paypal.sdk.exceptions.OAuthException;
+import com.sample.util.Configuration;
/**
* Servlet implementation class MassPayServlet
diff --git a/merchantsample/src/main/java/com/sample/merchant/RecurringPaymentsServlet.java b/merchantsample/src/main/java/com/sample/merchant/RecurringPaymentsServlet.java
index 6447ffb..7deaf68 100644
--- a/merchantsample/src/main/java/com/sample/merchant/RecurringPaymentsServlet.java
+++ b/merchantsample/src/main/java/com/sample/merchant/RecurringPaymentsServlet.java
@@ -80,6 +80,7 @@
import com.paypal.exception.MissingCredentialException;
import com.paypal.exception.SSLConfigurationException;
import com.paypal.sdk.exceptions.OAuthException;
+import com.sample.util.Configuration;
/**
* Servlet implementation class RecurringPaymentsServlet
diff --git a/merchantsample/src/main/java/com/sample/merchant/ReportingServlet.java b/merchantsample/src/main/java/com/sample/merchant/ReportingServlet.java
index ba9da77..73797da 100644
--- a/merchantsample/src/main/java/com/sample/merchant/ReportingServlet.java
+++ b/merchantsample/src/main/java/com/sample/merchant/ReportingServlet.java
@@ -41,6 +41,7 @@
import com.paypal.exception.MissingCredentialException;
import com.paypal.exception.SSLConfigurationException;
import com.paypal.sdk.exceptions.OAuthException;
+import com.sample.util.Configuration;
public class ReportingServlet extends HttpServlet {
private static final long serialVersionUID = 2212442342452L;
diff --git a/merchantsample/src/main/java/com/sample/merchant/SettlementServlet.java b/merchantsample/src/main/java/com/sample/merchant/SettlementServlet.java
index a6b8b86..a2e0c02 100644
--- a/merchantsample/src/main/java/com/sample/merchant/SettlementServlet.java
+++ b/merchantsample/src/main/java/com/sample/merchant/SettlementServlet.java
@@ -64,6 +64,7 @@
import com.paypal.exception.MissingCredentialException;
import com.paypal.exception.SSLConfigurationException;
import com.paypal.sdk.exceptions.OAuthException;
+import com.sample.util.Configuration;
/**
* Servlet implementation class CheckoutServlet
diff --git a/merchantsample/src/main/java/com/sample/usecase/ParallelPaymentServlet.java b/merchantsample/src/main/java/com/sample/usecase/ParallelPaymentServlet.java
new file mode 100644
index 0000000..2e0c6bc
--- /dev/null
+++ b/merchantsample/src/main/java/com/sample/usecase/ParallelPaymentServlet.java
@@ -0,0 +1,303 @@
+package com.sample.usecase;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import urn.ebay.api.PayPalAPI.DoExpressCheckoutPaymentReq;
+import urn.ebay.api.PayPalAPI.DoExpressCheckoutPaymentRequestType;
+import urn.ebay.api.PayPalAPI.DoExpressCheckoutPaymentResponseType;
+import urn.ebay.api.PayPalAPI.PayPalAPIInterfaceServiceService;
+import urn.ebay.api.PayPalAPI.SetExpressCheckoutReq;
+import urn.ebay.api.PayPalAPI.SetExpressCheckoutRequestType;
+import urn.ebay.api.PayPalAPI.SetExpressCheckoutResponseType;
+import urn.ebay.apis.CoreComponentTypes.BasicAmountType;
+import urn.ebay.apis.eBLBaseComponents.CurrencyCodeType;
+import urn.ebay.apis.eBLBaseComponents.DoExpressCheckoutPaymentRequestDetailsType;
+import urn.ebay.apis.eBLBaseComponents.PaymentActionCodeType;
+import urn.ebay.apis.eBLBaseComponents.PaymentDetailsType;
+import urn.ebay.apis.eBLBaseComponents.PaymentInfoType;
+import urn.ebay.apis.eBLBaseComponents.SellerDetailsType;
+import urn.ebay.apis.eBLBaseComponents.SetExpressCheckoutRequestDetailsType;
+
+import com.sample.util.Configuration;
+
+public class ParallelPaymentServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1239098098123L;
+
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+
+
+ if(request.getRequestURI().contains("SetExpressCheckoutForParallelPayment")){
+ getServletConfig().getServletContext().getRequestDispatcher("/usecase_jsp/SetExpressCheckoutForParallelPayment.jsp")
+ .forward(request, response);
+ }else if(request.getRequestURI().contains("DoExpressCheckoutForParallelPayment")){
+ getServletConfig().getServletContext().getRequestDispatcher("/usecase_jsp/DoExpressCheckoutForParallelPayment.jsp")
+ .forward(request, response);
+ }
+ }
+
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+
+ HttpSession session = request.getSession();
+ session.setAttribute("url", request.getRequestURI());
+ response.setContentType("text/html");
+
+ // Configuration map containing signature credentials and other required
+ // configuration.
+ // For a full list of configuration parameters refer at
+ // [https://github.com/paypal/merchant-sdk-java/wiki/SDK-Configuration-Parameters]
+ Map configurationMap = Configuration
+ .getSignatureConfig();
+
+ // Creating service wrapper object to make an API call by loading
+ // configuration map.
+ PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(
+ configurationMap);
+
+ // # SetExpressCheckout API
+ // The SetExpressCheckout API operation initiates an Express Checkout
+ // transaction.
+ // This sample code uses Merchant Java SDK to make API call. You can
+ // download the SDKs
+ // [here](https://github.com/paypal/sdk-packages/tree/gh-pages/merchant-sdk/java)
+ if (request.getRequestURI().contains("SetExpressCheckoutForParallelPayment")) { // *************** SetExpressCheckout for parallel payment ************************
+ SetExpressCheckoutRequestType setExpressCheckoutReq = new SetExpressCheckoutRequestType();
+ SetExpressCheckoutRequestDetailsType details = new SetExpressCheckoutRequestDetailsType();
+
+ StringBuffer url = new StringBuffer();
+ url.append("http://");
+ url.append(request.getServerName());
+ url.append(":");
+ url.append(request.getServerPort());
+ url.append(request.getContextPath());
+
+ String returnURL = url.toString() + "/DoExpressCheckoutForParallelPayment";
+ String cancelURL = url.toString() + "/SetExpressCheckoutForParallelPayment";
+
+ /*
+ * (Required) URL to which the buyer's browser is returned after
+ * choosing to pay with PayPal. For digital goods, you must add
+ * JavaScript to this page to close the in-context experience. Note:
+ * PayPal recommends that the value be the final review page on
+ * which the buyer confirms the order and payment or billing
+ * agreement. Character length and limitations: 2048 single-byte
+ * characters
+ */
+ details.setReturnURL(returnURL + "?currencyCodeType="
+ + request.getParameter("currencyCode"));
+
+ details.setCancelURL(cancelURL);
+ /*
+ * (Optional) Email address of the buyer as entered during checkout.
+ * PayPal uses this value to pre-fill the PayPal membership sign-up
+ * portion on the PayPal pages. Character length and limitations:
+ * 127 single-byte alphanumeric characters
+ */
+ details.setBuyerEmail(request.getParameter("buyerEmail"));
+
+ SellerDetailsType seller_1 = new SellerDetailsType();
+ seller_1.setPayPalAccountID(request.getParameter("receiverEmail_0"));
+ PaymentDetailsType paymentDetails_1 = new PaymentDetailsType();
+ paymentDetails_1.setSellerDetails(seller_1);
+ paymentDetails_1.setPaymentRequestID(request
+ .getParameter("requestId_0"));
+ BasicAmountType orderTotal_1 = new BasicAmountType();
+ orderTotal_1.setCurrencyID(CurrencyCodeType.fromValue(request
+ .getParameter("currencyCode")));
+ orderTotal_1.setValue(request.getParameter("orderTotal"));
+ paymentDetails_1.setOrderTotal(orderTotal_1);
+ paymentDetails_1.setPaymentAction(PaymentActionCodeType
+ .fromValue(request.getParameter("paymentAction")));
+
+ SellerDetailsType seller_2 = new SellerDetailsType();
+ seller_2.setPayPalAccountID(request.getParameter("receiverEmail_1"));
+ PaymentDetailsType paymentDetails_2 = new PaymentDetailsType();
+ paymentDetails_2.setSellerDetails(seller_2);
+ paymentDetails_2.setPaymentRequestID(request
+ .getParameter("requestId_1"));
+ BasicAmountType orderTotal_2 = new BasicAmountType();
+ orderTotal_2.setCurrencyID(CurrencyCodeType.fromValue(request
+ .getParameter("currencyCode")));
+ orderTotal_2.setValue(request.getParameter("orderTotal"));
+ paymentDetails_2.setOrderTotal(orderTotal_2);
+ paymentDetails_2.setPaymentAction(PaymentActionCodeType
+ .fromValue(request.getParameter("paymentAction")));
+
+ List payDetails = new ArrayList();
+ payDetails.add(paymentDetails_1);
+ payDetails.add(paymentDetails_2);
+
+ details.setPaymentDetails(payDetails);
+
+ setExpressCheckoutReq.setSetExpressCheckoutRequestDetails(details);
+
+ SetExpressCheckoutReq expressCheckoutReq = new SetExpressCheckoutReq();
+ expressCheckoutReq
+ .setSetExpressCheckoutRequest(setExpressCheckoutReq);
+ SetExpressCheckoutResponseType setExpressCheckoutResponse = null;
+
+ try {
+ setExpressCheckoutResponse = service
+ .setExpressCheckout(expressCheckoutReq);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ if (setExpressCheckoutResponse != null) {
+ session.setAttribute("lastReq", service.getLastRequest());
+ session.setAttribute("lastResp", service.getLastResponse());
+
+ if (setExpressCheckoutResponse.getAck().toString()
+ .equalsIgnoreCase("SUCCESS")) {
+ session.setAttribute("ecToken",
+ setExpressCheckoutResponse.getToken());
+ response.sendRedirect("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="
+ + setExpressCheckoutResponse.getToken());
+ } else {
+
+ session.setAttribute("Error",
+ setExpressCheckoutResponse.getErrors());
+ response.sendRedirect(this.getServletContext()
+ .getContextPath() + "/Error.jsp");
+ }
+
+ }
+ }else if (request.getRequestURI().contains("DoExpressCheckoutForParallelPayment")) { // *************** DoExpressCheckout for parallel payment ************************
+
+
+ DoExpressCheckoutPaymentRequestType doCheckoutPaymentRequestType = new DoExpressCheckoutPaymentRequestType();
+ DoExpressCheckoutPaymentRequestDetailsType doEcdetails = new DoExpressCheckoutPaymentRequestDetailsType();
+ /*
+ * A timestamped token by which you identify to PayPal that you
+ * are processing this payment with Express Checkout. The token
+ * expires after three hours. If you set the token in the
+ * SetExpressCheckout request, the value of the token in the
+ * response is identical to the value in the request. Character
+ * length and limitations: 20 single-byte characters
+ */
+ doEcdetails.setToken(request.getParameter("token"));
+ /*
+ * Unique PayPal Customer Account identification number.
+ * Character length and limitations: 13 single-byte alphanumeric
+ * characters
+ */
+ doEcdetails.setPayerID(request.getParameter("payerID"));
+ /*
+ * (Optional) How you want to obtain payment. If the transaction
+ * does not include a one-time purchase, this field is ignored.
+ * It is one of the following values: Sale This is a final
+ * sale for which you are requesting payment (default).
+ * Authorization This payment is a basic authorization subject
+ * to settlement with PayPal Authorization and Capture. Order
+ * This payment is an order authorization subject to settlement
+ * with PayPal Authorization and Capture. Note: You cannot set
+ * this field to Sale in SetExpressCheckout request and then
+ * change this value to Authorization or Order in the
+ * DoExpressCheckoutPayment request. If you set the field to
+ * Authorization or Order in SetExpressCheckout, you may set the
+ * field to Sale. Character length and limitations: Up to 13
+ * single-byte alphabetic characters This field is deprecated.
+ * Use PaymentAction in PaymentDetailsType instead.
+ */
+ doEcdetails.setPaymentAction(PaymentActionCodeType.fromValue(request.getParameter("paymentAction")));
+
+ SellerDetailsType seller_1 = new SellerDetailsType();
+ seller_1.setPayPalAccountID(request.getParameter("receiverEmail_0"));
+ PaymentDetailsType paymentDetails_1 = new PaymentDetailsType();
+ paymentDetails_1.setSellerDetails(seller_1);
+ paymentDetails_1.setPaymentRequestID(request.getParameter("requestId_0"));
+ BasicAmountType orderTotal_1 = new BasicAmountType();
+ orderTotal_1.setCurrencyID(CurrencyCodeType.fromValue(request.getParameter("currencyCode")));
+ orderTotal_1.setValue(request.getParameter("orderTotal"));
+ paymentDetails_1.setOrderTotal(orderTotal_1);
+ paymentDetails_1.setPaymentAction(PaymentActionCodeType.fromValue(request.getParameter("paymentAction")));
+
+ SellerDetailsType seller_2 = new SellerDetailsType();
+ seller_2.setPayPalAccountID(request.getParameter("receiverEmail_1"));
+ PaymentDetailsType paymentDetails_2 = new PaymentDetailsType();
+ paymentDetails_2.setSellerDetails(seller_2);
+ paymentDetails_2.setPaymentRequestID(request.getParameter("requestId_1"));
+ BasicAmountType orderTotal_2 = new BasicAmountType();
+ orderTotal_2.setCurrencyID(CurrencyCodeType.fromValue(request.getParameter("currencyCode")));
+ orderTotal_2.setValue(request.getParameter("orderTotal"));
+ paymentDetails_2.setOrderTotal(orderTotal_2);
+ paymentDetails_2.setPaymentAction(PaymentActionCodeType.fromValue(request.getParameter("paymentAction")));
+
+ List payDetails = new ArrayList();
+ payDetails.add(paymentDetails_1);
+ payDetails.add(paymentDetails_2);
+
+ doEcdetails.setPaymentDetails(payDetails);
+ doCheckoutPaymentRequestType.setDoExpressCheckoutPaymentRequestDetails(doEcdetails);
+ DoExpressCheckoutPaymentReq doExpressCheckoutPaymentReq = new DoExpressCheckoutPaymentReq();
+ doExpressCheckoutPaymentReq.setDoExpressCheckoutPaymentRequest(doCheckoutPaymentRequestType);
+ DoExpressCheckoutPaymentResponseType doCheckoutPaymentResponseType = null;
+
+ try {
+ doCheckoutPaymentResponseType = service
+ .doExpressCheckoutPayment(doExpressCheckoutPaymentReq);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ response.setContentType("text/html");
+
+ if (doCheckoutPaymentResponseType != null) {
+ //session.setAttribute("nextDescription"," \n Parallel Payment completed");
+ session.setAttribute("lastReq", service.getLastRequest());
+ session.setAttribute("lastResp", service.getLastResponse());
+ if (doCheckoutPaymentResponseType.getAck().toString()
+ .equalsIgnoreCase("SUCCESS")) {
+ Map