Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titlePAYEEZYCRMUIPayeezyPaymentGatewaySettingBean.java
linenumberstrue
collapsetrue
package payeezy.process.paymentgateway.payeezy;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import com.crm.businessobject.paymentgateway.CRMBOPaymentGatewayCurrencyBean;
import com.crm.businessobject.paymentgateway.CRMBOPaymentGatewayParameterBean;
import com.crm.businessobject.paymentgateway.CRMBOPaymentGatewayParameterValueBean;
import com.crm.dataobject.CRMDO;
import com.crm.dataobject.financialtransactions.PaymentCancellationType;
import com.crm.dataobject.financialtransactions.PaymentMethod;
import com.crm.dataobject.paymentgateway.CRMDOPaymentGatewayCurrency;
import com.crm.dataobject.paymentgateway.CRMDOPaymentGatewayParameter;
import com.crm.dataobject.paymentgateway.CRMDOPaymentGatewayParameterValue;
import com.crm.dataobject.paymentgateway.CRMDOPaymentGatewaySetting;
import com.crm.dataobject.paymentgateway.PaymentGatewayLifeCycleState;
import com.crm.dataobject.paymentgateway.PaymentGatewayParameter;
import com.crm.dataobject.platform.CurrenciesScope;
import com.crm.framework.main.LookupBuilder;
import com.crm.process.paymentgateway.CRMUIPaymentGatewaySettingBean;
import payeezy.businessobject.paymentgateway.payeezy.PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean;
import payeezy.dataobject.paymentgateway.payeezy.PayeezyMode;
import payeezy.dataobject.paymentgateway.payeezy.PayeezyParameter;
/**
 * Session Bean implementation class PAYEEZYCRMUIPayeezyPaymentGatewaySettingBean
 */
@Stateless
@LocalBean
public class PAYEEZYCRMUIPayeezyPaymentGatewaySettingBean extends CRMUIPaymentGatewaySettingBean {
       
   
	private static final long serialVersionUID = 1L;
	
	@EJB private PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean payeezyPaymentGatewaySettingBean;
	@EJB private CRMBOPaymentGatewayCurrencyBean paymentGatewayCurrencyBean;
	@EJB private CRMBOPaymentGatewayParameterBean paymentGatewayParameterBean;
	@EJB private CRMBOPaymentGatewayParameterValueBean paymentGatewayParameterValueBean;
	/**
     * @see CRMUIPaymentGatewaySettingBean#CRMUIPaymentGatewaySettingBean()
     */
    public PAYEEZYCRMUIPayeezyPaymentGatewaySettingBean() {
        super();
    }
    
    /**
     * Loads a payment gateway setting form.
     * 
     * @param id - the payment gateway setting id to load
     * @return the loaded form
     * @throws Exception
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public CRMDOPaymentGatewaySetting loadForm(String id) throws Exception {
    	
    	CRMDOPaymentGatewaySetting setting = (CRMDOPaymentGatewaySetting)payeezyPaymentGatewaySettingBean.load(id);
    	
    	setting	= payeezyPaymentGatewaySettingBean.setObjectsFromXML(setting);
    	setting	= payeezyPaymentGatewaySettingBean.initializeParameters(setting);
    	setting = setFinancialInformation(setting);
    	setting.setCurrenciesScope(CurrenciesScope.ALLOW_ALL_CURRENCIES);
    	
    	setting.setPaymentGatewayCurrencies(new HashSet(loadCurrenciesTab(setting)));
    	
    	if((setting.getCurrencies()!=null && setting.getCurrencies().size()>0) ||
    			(setting.getPaymentGatewayCurrencies()!=null && setting.getPaymentGatewayCurrencies().size()>0))
    	{
    		setting.setCurrenciesScope(CurrenciesScope.ALLOW_SPECIFIC_CURRENCIES);
    	}
    	
    	setting = setPaymentGatewayParameters(setting);
    	
    	return setting;
    }
    
    
    /**
     * Loads a payment gateway setting form.
     * 
     * @return the loaded form
     * @throws Exception
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public CRMDOPaymentGatewaySetting loadForm() throws Exception {
		
		CRMDOPaymentGatewaySetting setting= payeezyPaymentGatewaySettingBean.load();
		
    	if (setting==null)
    	{
        	setting = createButton();
    	}
    	else
    	{
    		setting = payeezyPaymentGatewaySettingBean.setObjectsFromXML(setting);
        	setting	= payeezyPaymentGatewaySettingBean.initializeParameters(setting);
        	setting = setFinancialInformation(setting);
    	}
    	
    	setting.setCurrenciesScope(CurrenciesScope.ALLOW_ALL_CURRENCIES);
    	
    	setting.setPaymentGatewayCurrencies(new HashSet(loadCurrenciesTab(setting)));
    	
    	if((setting.getCurrencies()!=null && setting.getCurrencies().size()>0) ||
    			(setting.getPaymentGatewayCurrencies()!=null && setting.getPaymentGatewayCurrencies().size()>0))
    	{
    		setting.setCurrenciesScope(CurrenciesScope.ALLOW_SPECIFIC_CURRENCIES);
    	}
    	
    	setting = setPaymentGatewayParameters(setting);
		
		return setting;
		
    }
    
    
    @SuppressWarnings({ "unchecked", "rawtypes" })
	private CRMDOPaymentGatewaySetting setPaymentGatewayParameters(CRMDOPaymentGatewaySetting setting) throws Exception{
    	Set<PaymentGatewayParameter> paymentGatewayParameters = new HashSet<PaymentGatewayParameter>();
    	
    	setting.setPaymentGatewayParameters(new HashSet(paymentGatewayParameterBean.load(setting)));
    	
    	PayeezyParameter[] braintreeParameters = PayeezyParameter.values();
    	for(PayeezyParameter braintreeParameter:braintreeParameters)
    	{
    		PaymentGatewayParameter paymentGatewayParameter = get(setting.getPaymentGatewayParameters(), braintreeParameter, setting);
    		paymentGatewayParameters.add(paymentGatewayParameter);
    	}
    	
    	setting.setGatewayParameters(paymentGatewayParameters);
    	
    	setting = setParametersVisibility(setting);
    	
    	return setting;
    }
    
    
    private PaymentGatewayParameter get(Set<CRMDOPaymentGatewayParameter> parameters, PayeezyParameter braintreeParameter, CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception{
    	PaymentGatewayParameter paymentGatewayParameter = null;
    	CRMDOPaymentGatewayParameter parameter = null;
    	CRMDOPaymentGatewayParameterValue paymentGatewayParameterValue=null;
    	if(parameters!=null)
    	{
    		Iterator<CRMDOPaymentGatewayParameter> iter = parameters.iterator();
    		while(iter.hasNext())
    		{
    			CRMDOPaymentGatewayParameter existingParameter = iter.next();
    			if(existingParameter!=null && existingParameter.getName()!=null && existingParameter.getName().equals(braintreeParameter.toString()))
    			{
    				parameter = existingParameter;
    				ArrayList<CRMDO> paymentGatewayParameterValues= paymentGatewayParameterValueBean.load(parameter);
    				if(paymentGatewayParameterValues!=null && !paymentGatewayParameterValues.isEmpty())
    				{
    					paymentGatewayParameterValue = (CRMDOPaymentGatewayParameterValue) paymentGatewayParameterValues.get(0);
    				}
    				break;
    			}
    		}
    	}

    	if(parameter==null)
    	{
    		parameter =(CRMDOPaymentGatewayParameter) paymentGatewayParameterBean.construct(paymentGatewaySetting);
    		parameter.setType(PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean.GENERAL_PARAMETERS);
    		parameter.setName(braintreeParameter.toString());
    	}
    	
    	if(paymentGatewayParameterValue==null)
    	{
    		paymentGatewayParameterValue=(CRMDOPaymentGatewayParameterValue) paymentGatewayParameterValueBean.construct(parameter);
    	}
    	if(braintreeParameter.equals(PayeezyParameter.MODE) && paymentGatewayParameterValue.getStringValue()==null)
    	{
    		paymentGatewayParameterValue.setStringValue(PayeezyMode.TEST.toString());
    	}
    	parameter.setAlias("name", braintreeParameter.getLabel());
    	
    	paymentGatewayParameter=new PaymentGatewayParameter();
    	paymentGatewayParameter.setParameter(parameter);
    	paymentGatewayParameter.setValue(paymentGatewayParameterValue);
    	paymentGatewayParameter.setType(braintreeParameter.getType());
    	paymentGatewayParameter.setOrder(braintreeParameter.getOrder());
    	return paymentGatewayParameter;
    }
    
    
    
    /**
     * Creates a payment gateway setting.
     * 
     * @return a payment gateway setting.
     * @throws Exception
     */
    public CRMDOPaymentGatewaySetting createButton() throws Exception {
    	return createButton(PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean.PROTOCOL);
    }
    
    /**
     * Creates a payment gateway setting.
     * 
     * @param paymentGateway - the payment gateway to create the payment gateway setting
     * @return a payment gateway setting.
     * @throws Exception
     */
    public CRMDOPaymentGatewaySetting createButton(String paymentGateway) throws Exception {
    	
    	CRMDOPaymentGatewaySetting setting = null;
    	
    	if (paymentGateway!=null)
    	{    	
	    	if (paymentGateway.equals(PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean.PROTOCOL))
	    	{
	    		setting = (CRMDOPaymentGatewaySetting)payeezyPaymentGatewaySettingBean.construct(null);
	    	}
	    	
	    	setting = setPaymentGatewayParameters(setting);
    	}
    	
    	return setting;
    }
    
    
    /**
     * Saves a payment gateway setting.
     * 
     * @param paymentGatewaySetting - the payment gateway setting to save
     * @return the saved payment gateway setting
     * @throws Exception
     */
    public CRMDOPaymentGatewaySetting saveButton(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
    	
    	String paymentGateway = paymentGatewaySetting.getPaymentGatewayProtocol();
    	
    	if (paymentGateway.equals(PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean.PROTOCOL))
    	{
    		paymentGatewaySetting 	= setPaymentGatewayParametersToSave(paymentGatewaySetting);
    		paymentGatewaySetting	= (CRMDOPaymentGatewaySetting)payeezyPaymentGatewaySettingBean.validateOnSave(paymentGatewaySetting);
    		paymentGatewaySetting	= (CRMDOPaymentGatewaySetting)payeezyPaymentGatewaySettingBean.save(paymentGatewaySetting);
    	}
    	return paymentGatewaySetting;
    }
    
    /**
     * Loads a payment gateway setting form.
     * 
     * @param paymentGatewaySetting - the payment gateway setting to load
     * @return the loaded form
     * @throws Exception
     */
	public CRMDOPaymentGatewaySetting editButton(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
		return (paymentGatewaySetting!=null && !paymentGatewaySetting.isNew()) ? loadForm(paymentGatewaySetting.getId()) : loadForm();
	}
	
	
	/**
     * Deletes a payment gateway setting.
     * 
     * @param paymentGatewaySetting - the payment gateway setting to delete
     * @return the deleted payment gateway setting 
     * @throws Exception
     */
	public CRMDOPaymentGatewaySetting deleteButton(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
		
		String paymentGateway = paymentGatewaySetting.getPaymentGatewayProtocol();
    	
    	if (paymentGateway.equals(PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean.PROTOCOL))
    	{
    		return (CRMDOPaymentGatewaySetting)payeezyPaymentGatewaySettingBean.validateAndDelete(paymentGatewaySetting);
    	}
    	
		return paymentGatewaySetting;
	}
	
	/**
	 * Adds a payment cancellation type to payment gateway setting.
	 * 
	 * @return the loaded payment cancellation type
	 * @throws Exception
	 */
	@Override
	public PaymentCancellationType addPaymentCancellationTypeButton() throws Exception {
		return new PaymentCancellationType();
	}
	/**
	 * Removes a list of payment cancellation types from a payment gateway setting.
	 * 
	 * @param dtoList - a list of payment cancellation types to delete
	 * @return the updated list
	 * @throws Exception
	 */
	@Override
	public ArrayList<CRMDO> removePaymentCancellationTypeButton(ArrayList<CRMDO> dtoList) throws Exception {
		return setDeleted(dtoList);
	}
	
	/**
	 * Adds a payment method to payment gateway setting.
	 * 
	 * @return the loaded payment method
	 * @throws Exception
	 */
	@Override
	public PaymentMethod addPaymentMethodButton() throws Exception {
		return new PaymentMethod();
	}
	/**
	 * Removes a list of payment methods from a payment gateway setting.
	 * 
	 * @param dtoList - a list of payment methods to delete
	 * @return the updated list
	 * @throws Exception
	 */
	@Override
	public ArrayList<CRMDO> removePaymentMethodButton(ArrayList<CRMDO> dtoList) throws Exception {
		return setDeleted(dtoList);
	}
	
	/**
	 * Sets the payment gateway setting's life cycle state to Not Effective
	 * @param paymentGatewaySetting - he payment gateway setting to change its life cycle state
	 * @return the payment gateway setting
	 * @throws Exception
	 */
	public CRMDOPaymentGatewaySetting setNotEffective(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
		paymentGatewaySetting.setLifeCycleState(PaymentGatewayLifeCycleState.NOT_EFFECTIVE);
		paymentGatewaySetting = (CRMDOPaymentGatewaySetting) payeezyPaymentGatewaySettingBean.validateOnSave(paymentGatewaySetting);
		paymentGatewaySetting = (CRMDOPaymentGatewaySetting) payeezyPaymentGatewaySettingBean.save(paymentGatewaySetting);
		
		return paymentGatewaySetting;
		
	}
   	
	/**
	 * Loads the payment gateway mode options.
	 *  
	 * @return the payment gateway mode options
	 * @throws Exception
	 */
	public LookupBuilder getModeOptions() throws Exception {
		return getModeOptions(null);
	}
	
	/**
	 * Loads the payment gateway mode options.
	 *  
	 * @param emptyValue - an empty value for mode 
	 * @return the payment gateway mode options
	 * @throws Exception
	 */
	public LookupBuilder getModeOptions(String emptyValue) throws Exception {
		
		LookupBuilder builder = new LookupBuilder();
		
		if (emptyValue!=null)
		{
			builder.build("", emptyValue);
		}
		PayeezyMode[] modes = PayeezyMode.values();
		
		for (int i=0; i<modes.length; i++)
		{
			PayeezyMode mode = modes[i];
			builder.build(mode.toString(), mode.getLabel());
		}
		
		return builder;
	}
	
	/**
	 * Adds a currency to payment gateway setting.
	 * 
	 * @return the newly created payment gateway currency
	 * @throws Exception
	 */
	public CRMDOPaymentGatewayCurrency addCurrencyButton(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
		return (CRMDOPaymentGatewayCurrency) paymentGatewayCurrencyBean.construct(paymentGatewaySetting);
	}
	
	/**
	 * Loads the currencies of a payment gateway setting
	 * 
	 * @param paymentGatewaySetting - the payment gateway setting to load the currencies for
	 * @return a list of payment gateway currencies
	 * @throws Exception
	 */
	public ArrayList<CRMDO> loadCurrenciesTab(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
		ArrayList<CRMDO> dtos = paymentGatewayCurrencyBean.load(paymentGatewaySetting);
		return dtos;
	}
	
	/**
	 * Resets the supported currencies of the given payment gateway
	 * @param paymentGateway - the payment gateway to reset the currencies for
	 * @return the updated payment gateway
	 * @throws Exception 
	 */	
	@Override
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public CRMDOPaymentGatewaySetting resetCurrencies(CRMDOPaymentGatewaySetting paymentGateway) throws Exception
	{
		if(paymentGateway.getPaymentGatewayCurrencies()!=null)
		{		
			setDeleted(new ArrayList(paymentGateway.getPaymentGatewayCurrencies()));
		}
		
		return paymentGateway;
	}
	
	public CRMDOPaymentGatewaySetting setParametersVisibility(CRMDOPaymentGatewaySetting paymentGateway) throws Exception
	{
		if(paymentGateway.getGatewayParameters()!=null)
		{		
			PayeezyMode mode = getMode(paymentGateway.getGatewayParameters());
			Iterator<PaymentGatewayParameter> iter = paymentGateway.getGatewayParameters().iterator();
			while(iter.hasNext())
			{
				PaymentGatewayParameter parameter = iter.next();
				if(parameter!=null && 
						parameter.getParameter()!=null &&
						parameter.getParameter().getName()!=null)
				{
					if	(parameter.getParameter().getName().equals(PayeezyParameter.TEST_URL.toString()) ||
							parameter.getParameter().getName().equals(PayeezyParameter.TEST_API_KEY.toString()) ||
							parameter.getParameter().getName().equals(PayeezyParameter.TEST_API_SECRET.toString()) ||
							parameter.getParameter().getName().equals(PayeezyParameter.TEST_JS_SECURITY_KEY.toString()) ||
							parameter.getParameter().getName().equals(PayeezyParameter.TEST_MERCHANT_TOKEN.toString()) ||
							parameter.getParameter().getName().equals(PayeezyParameter.TEST_TA_TOKEN.toString()))
					{
						if(mode!=null && mode.equals(PayeezyMode.TEST))
						{
							parameter.setIsVisible(new Integer(1));
						}
						else if(mode!=null && mode.equals(PayeezyMode.LIVE))
						{
							parameter.setIsVisible(new Integer(0));
						}
					}
					if	(parameter.getParameter().getName().equals(PayeezyParameter.LIVE_URL.toString()) ||
							parameter.getParameter().getName().equals(PayeezyParameter.LIVE_API_KEY.toString()) ||
							parameter.getParameter().getName().equals(PayeezyParameter.LIVE_API_SECRET.toString()) ||
							parameter.getParameter().getName().equals(PayeezyParameter.LIVE_JS_SECURITY_KEY.toString()) ||
							parameter.getParameter().getName().equals(PayeezyParameter.LIVE_MERCHANT_TOKEN.toString()) ||
							parameter.getParameter().getName().equals(PayeezyParameter.LIVE_TA_TOKEN.toString()))
					{
						if(mode!=null && mode.equals(PayeezyMode.TEST))
						{
							parameter.setIsVisible(new Integer(0));
						}
						else if(mode!=null && mode.equals(PayeezyMode.LIVE))
						{
							parameter.setIsVisible(new Integer(1));
						}
					}
					else
					{
						parameter.setIsVisible(new Integer(1));
					}
				}
			}
		}
		return paymentGateway;
	}
	
	private PayeezyMode getMode(Set<PaymentGatewayParameter> paymentGatewayParameters){
		PayeezyMode mode = null;
		if(paymentGatewayParameters!=null)
		{
			Iterator<PaymentGatewayParameter> iter = paymentGatewayParameters.iterator();
			while(iter.hasNext())
			{
				PaymentGatewayParameter parameter = iter.next();
				if(parameter!=null &&
						parameter.getParameter()!=null &&
						parameter.getParameter().getName()!=null &&
						parameter.getParameter().getName().equals(PayeezyParameter.MODE.toString()) &&
						parameter.getValue()!=null &&
						parameter.getValue().getStringValue()!=null)
				{
					mode = PayeezyMode.valueOf(PayeezyMode.class,parameter.getValue().getStringValue());
					break;
				}
			}
		}
		
		
		return mode;
	}
}

5. Provisioning Provider Process Class

a. Create Class and Implement a Method for Each Action

Use @Stateless(mappedName = "ejb/MYCOMPANYCRMProcessTucanoProvider") to define the mapped name of the provisioning provider EJB. The mapped name should match the one defined in provisioningproviders.xml metadata file.

The new process class must extend The payment gateway process class should extend com.crm.process.provisioningpaymentgateway.CRMProcessProviderBeanCRMProcessPaymentGatewayBean and implement the following methods (which are defined as abstract in CRMProcessProviderBean parent class):

Note that the value of PORVIDER_PROTOCOL must be the same as <provproviderprotocol> tag's value as defined in provisioningproviders.xml 

public String getProtocol()

its abstract methods for creating/updating/deleting a payment gateway account and card, creating a payment and payment cancellation, and checking whether a currency is supported by the payment gateway. Implement only the methods required by your business model.

Code Block
languagejava
title

...

public void processSwapServiceSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> removedProviderServices, ArrayList<ProviderService> addedProviderServices)

This method is called whenever a 'Swap Service' subscription action is executed.

...

languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue

...

com.crm.process.paymentgateway.CRMProcessPaymentGatewayBean.java
linenumberstrue
collapsetrue

...

@Stateless(mappedName = "ejb/MYCOMPANYCRMProcessTucanoProvider")
@LocalBean
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	
	public static String PROVIDER_PROTOCOL = "TUCANO";
	
    /**
     * Default constructor. 
     */
	public MYCOMPANYCRMProcessTucanoProviderBean() {
        super();
    }
	public String getProtocol() throws Exception {
		return PROVIDER_PROTOCOL;
	}
	...
}

...

public CRMDOProvProvider setObjectsFromXML(CRMDOProvProvider provProvider)

This method is called whenever loadProvider(), loadEffectiveProvider(String protocol) and loadEffectiveProvider(String protocol , Boolean applicationServerFiltering) methods of CRMProcessProviderBean are called.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {

	@EJB private MYCOMPANYCRMBOTucanoProviderBean tucanoProviderBean;
	...
	public CRMDOProvProvider setObjectsFromXML(CRMDOProvProvider provProvider) throws Exception {
		
		provProvider = tucanoProviderBean.setObjectsFromXML(provProvider);
		
		return provProvider;
	}
	...
}

...

public void processAddServiceSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices, ArrayList<ProviderInstalledItem> providerInstalledItems)

This method is called whenever an 'Add Service' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processAddServiceSubscriptionAction(CRMDOSubscriptionAction subscriptionAction,ArrayList<ProviderService> providerServices, ArrayList<ProviderInstalledItem> providerInstalledItems)throws Exception {
		
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		activateTucanoServices(subscriptionAction, provProvider, subscription, providerServices);
	}
	...
}

...

public void processAmendBundleServiceSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> removedProviderServices, ArrayList<ProviderService> addedProviderServices)

This method is called whenever an 'Amend Bundled' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processAmendBundleServiceSubscriptionAction(CRMDOSubscriptionAction subscriptionAction,ArrayList<ProviderService> removedProviderServices, ArrayList<ProviderService> addedProviderServices)
			throws Exception {
		...
	}
	...
}

...

public void processRemoveServiceSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> removedProviderServices, ArrayList<ProviderService> addedProviderServices)

This method is called whenever a 'Remove Service' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processRemoveServiceSubscriptionAction(CRMDOSubscriptionAction subscriptionAction,ArrayList<ProviderService> removedProviderServices, ArrayList<ProviderService> addedProviderServices)throws Exception {
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		
		//addedProviderServices in case of regret the swap  
		//The "Activating an AlphaNetworks Tucano Services Process" is performed for the services that will be restored (i.e. the services that the subscriber had before the service swap)
		activateTucanoServices(subscriptionAction, provProvider, subscription, addedProviderServices);
		
		ArrayList<ProviderService> authorisedServices = getAuthorisedServices(removedProviderServices);
		deactivateTucanoServices(subscriptionAction, provProvider, subscription, authorisedServices);
	}
	...
}
package payeezy.process.paymentgateway.payeezy;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import org.json.JSONException;
import org.apache.commons.codec.binary.Base64;
import com.crm.businessobject.accounts.CRMBOAccountReceivableBean;
import com.crm.businessobject.billing.CRMBOBillBean;
import com.crm.businessobject.financialtransactions.CRMBOPaymentBean;
import com.crm.businessobject.financialtransactions.CRMBOPaymentCancellationBean;
import com.crm.businessobject.financialtransactions.CRMBOPaymentIntentionBean;
import com.crm.businessobject.paymentgateway.CRMBOPaymentGatewayCardBean;
import com.crm.dataobject.financialtransactions.CRMDOPayment;
import com.crm.dataobject.paymentgateway.CRMDOPaymentGatewayCard;
import com.crm.dataobject.paymentgateway.CRMDOPaymentGatewaySetting;
import com.crm.dataobject.paymentgateway.PaymentGatewayRequestLifeCycleState;
import com.crm.dataobject.platform.CRMDOCurrency;
import com.crm.exception.MandatoryFieldException;
import com.crm.framework.json.JSONArray;
import com.crm.framework.json.JSONObject;
import com.crm.framework.json.JSONUtil;
import com.crm.framework.util.CallList;
import com.crm.framework.util.DateUtil;
import com.crm.framework.util.ExceptionUtil;
import com.crm.process.paymentgateway.CRMProcessPaymentGatewayBean;
import com.crm.process.paymentgateway.CreateAccountParameters;
import com.crm.process.paymentgateway.CreateCardParameters;
import com.crm.process.paymentgateway.CreatePaymentCancellationParameters;
import com.crm.process.paymentgateway.CreatePaymentGatewayAccountResult;
import com.crm.process.paymentgateway.CreatePaymentGatewayCardResult;
import com.crm.process.paymentgateway.CreatePaymentGatewayPaymentCancellationResult;
import com.crm.process.paymentgateway.CreatePaymentGatewayPaymentResult;
import com.crm.process.paymentgateway.CreatePaymentParameters;
import com.crm.process.paymentgateway.DeleteAccountParameters;
import com.crm.process.paymentgateway.DeleteCardParameters;
import com.crm.process.paymentgateway.DeletePaymentGatewayAccountResult;
import com.crm.process.paymentgateway.DeletePaymentGatewayCardResult;
import com.crm.process.paymentgateway.PaymentGatewayCardResult;
import com.crm.process.paymentgateway.PaymentGatewayParameters;
import com.crm.process.paymentgateway.PaymentGatewayResult;
import com.crm.process.paymentgateway.UpdateAccountParameters;
import com.crm.process.paymentgateway.UpdateCardParameters;
import com.crm.process.paymentgateway.UpdatePaymentGatewayAccountResult;
import com.crm.process.paymentgateway.UpdatePaymentGatewayCardResult;
import payeezy.businessobject.paymentgateway.payeezy.PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean;
import payeezy.dataobject.paymentgateway.payeezy.PayeezyMode;
import payeezy.dataobject.paymentgateway.payeezy.PayeezyParameter;
import payeezy.exception.paymentgateway.PaymentGatewayPayeezyException;

@Stateless(mappedName = "ejb/PAYEEZYCRMProcessPayeezyGateway")
@LocalBean
public class PAYEEZYCRMProcessPayeezyGatewayBean extends CRMProcessPaymentGatewayBean {
	private static final long serialVersionUID = 1L;
	private static final String PAYEEZY_PAYMENT_GATEWAY_SUC_LOG_PATH		= "Providers/Payment Gateways/Payeezy_Gateway";
	private static final String PAYEEZY_PAYMENT_GATEWAY_ERROR_LOG_PATH		= "Providers/Payment Gateways/Errors/Payeezy_Gateway";
	private static final String HMAC_SHA256_ALGORITHM 						= "HmacSHA256";
	@EJB private CRMBOPaymentBean paymentBean;
	@EJB private CRMBOPaymentCancellationBean paymentCancellationBean;
	@EJB private CRMBOAccountReceivableBean accountReceivableBean;
	@EJB private CRMBOPaymentIntentionBean paymentIntentionBean;
	@EJB private CRMBOBillBean billBean;
	@EJB private CRMBOPaymentGatewayCardBean paymentGatewayCardBean;
	@EJB private PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean payeezyPaymentGatewaySettingBean;	
	
	protected static Integer timeout = 300 * 1000;

	/**
	 * Default constructor.
	 */
	public PAYEEZYCRMProcessPayeezyGatewayBean() {
		super();
	}
	@Override
	public CreatePaymentGatewayAccountResult processCreateAccount(CreateAccountParameters parameters) throws Exception {
		

...

CreatePaymentGatewayAccountResult 

...

result = 

...

new CreatePaymentGatewayAccountResult();
		

...

result.setLifeCycleState(PaymentGatewayRequestLifeCycleState.POSTED);
		

...

result.setResponseID(parameters.getAccountNumber());
		

...

return result;
	}
	@Override
	

...

public 

...

UpdatePaymentGatewayAccountResult 

...

processUpdateAccount(UpdateAccountParameters parameters) throws Exception {
		

...

return null;
	}
	

...

public void processStartServiceSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever a 'Start Service' subscription action is executed.

...

languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue

...

@Override
	public DeletePaymentGatewayAccountResult processDeleteAccount(DeleteAccountParameters parameters) throws Exception {
		return null;
	}
	
	@Override
	public 

...

CreatePaymentGatewayCardResult 

...

processCreateCard(

...

CreateCardParameters parameters) throws PaymentGatewayPayeezyException, Exception

...

{
		

...

CreatePaymentGatewayCardResult 

...

result = new 

...

CreatePaymentGatewayCardResult();

		

...

result.setLifeCycleState(PaymentGatewayRequestLifeCycleState.POSTED);
		

...

result.setReferenceNumber(parameters.getToken());
		
		return result;
	}

	

...

public void processStopServiceSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever a 'Stop Service' subscription action is executed.

...

languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue

...

@Override
	public UpdatePaymentGatewayCardResult processUpdateCard(UpdateCardParameters parameters) throws Exception {
		return null;
	}
	@Override
	public DeletePaymentGatewayCardResult processDeleteCard(DeleteCardParameters parameters) throws Exception {
		return null;
	}
	
	@Override
	public 

...

CreatePaymentGatewayPaymentResult 

...

processCreatePayment(

...

CreatePaymentParameters parameters) throws Exception {
		

...

CreatePaymentGatewayPaymentResult 

...

result = 

...

new CreatePaymentGatewayPaymentResult();
	
		
	

...

	String 

...

requestStr = 

...

null;
		

...

try
		{
			String cardReferenceNumber = parameters.getCardReferenceNumber();
	

...

public void processAddInstalledItemSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderInstalledItem> providerInstalledItems)

This method is called whenever an 'Add Installed Item' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processAddInstalledItemSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderInstalledItem> providerInstalledItems) throws Exception {
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		addTucanoSTBs(subscriptionAction, provProvider, subscription, providerInstalledItems);
		
	}
	...
}

...

public void processRemoveInstalledItemSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderInstalledItem> providerInstalledItems)

This method is called whenever a 'Remove Installed Item' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processRemoveInstalledItemSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderInstalledItem> providerInstalledItems) throws Exception {
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		removeTucanoSTBs(subscriptionAction, provProvider, subscription, providerInstalledItems);
		if(subscription.getLifeCycleState()==null)
		{
			subscription.setLifeCycleState(subscriptionBean.getLifeCycleState(subscription, getCurrentDate()));
		}
		if(subscription.getLifeCycleState()!=null 
				&& (subscription.getLifeCycleState().equals(SubscriptionLifeCycleState.CANCELLED) 
						|| subscription.getLifeCycleState().equals(SubscriptionLifeCycleState.REGRETTED) )
				&& !installedItemExists(subscription, provProvider))
		{
			updateSubscriptionProvisioningParameter(PROVIDER_PROTOCOL, subscription, USERNAME, null, subscription.getNumber(), SubProvProviderLifeCycleState.CANCELLED);
		}	
	}
	...
}

...

public void processSwapInstalledItemSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderInstalledItem> removedProviderInstalledItems, ArrayList<ProviderInstalledItem> addedProviderInstalledItems)

This method is called whenever a 'Swap Installed Item' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processSwapInstalledItemSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderInstalledItem> removedProviderInstalledItems,ArrayList<ProviderInstalledItem> addedProviderInstalledItems) throws Exception {
		
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		addTucanoSTBs(subscriptionAction, provProvider, subscription, addedProviderInstalledItems);
		
		removeTucanoSTBs(subscriptionAction, provProvider, subscription, removedProviderInstalledItems);
	}
	...
}

...

public void processChangeSubscriptionDistributionSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> removedProviderServices, ArrayList<ProviderInstalledItem> removedProviderInstalledItems, ArrayList<ProviderService> addedProviderServices, ArrayList<ProviderInstalledItem> addedProviderInstalledItems)

This method is called whenever a 'Change Subscription Distribution' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processChangeSubscriptionDistributionSubscriptionAction(CRMDOSubscriptionAction subscriptionAction,
																		ArrayList<ProviderService> removedProviderServices,
																		ArrayList<ProviderInstalledItem> removedProviderInstalledItems,
																		ArrayList<ProviderService> addedProviderServices,
																		ArrayList<ProviderInstalledItem> addedProviderInstalledItems) throws Exception {
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		
		activateTucanoServices(subscriptionAction, provProvider, subscription, addedProviderServices);
		
		deactivateTucanoServices(subscriptionAction, provProvider, subscription, removedProviderServices);
		addTucanoSTBs(subscriptionAction, provProvider, subscription, addedProviderInstalledItems);
		
		removeTucanoSTBs(subscriptionAction, provProvider, subscription, removedProviderInstalledItems);
	}
	...
}

...

public void processBecomeSubscriberSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices, ArrayList<ProviderInstalledItem> providerInstalledItems)

This method is called whenever a 'Become Subscriber' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processBecomeSubscriberSubscriptionAction(CRMDOSubscriptionAction subscriptionAction,
														  ArrayList<ProviderService> providerServices, 
														  ArrayList<ProviderInstalledItem> providerInstalledItems) throws Exception {
		
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		
		createNewTucanoAccount(subscriptionAction, provProvider, subscription, providerServices, providerInstalledItems);
	}
	...
}

...

public void processActivateSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever an 'Activate Subscription' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processActivateSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices) throws Exception {
		
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		
		activateTucanoServices(subscriptionAction, provProvider, subscription, providerServices);
	}
	...
}

...

public void processDeactivateSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever a 'Deactivate Subscription' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processDeactivateSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices) throws Exception {
		
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		deactivateTucanoServices(subscriptionAction, provProvider, subscription, providerServices);
	}
	...
}

...

public void processTerminateSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever a 'Terminate Subscription' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	public static String PROVIDER_PROTOCOL = "TUCANO";
	public static String USERNAME = "USERNAME";
	...
	@Override
	public void processTerminateSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices) throws Exception {
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		deactivateTucanoServices(subscriptionAction, provProvider, subscription, providerServices);
		
		if(!installedItemExists(subscription, provProvider))
		{
			updateSubscriptionProvisioningParameter(PROVIDER_PROTOCOL, subscription, USERNAME, null, subscription.getNumber(), SubProvProviderLifeCycleState.CANCELLED);
		}
	}
	...
}

...

public void processRestSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever a 'Rest Subscription' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processRestSubscriptionAction(CRMDOSubscriptionAction subscriptionAction,ArrayList<ProviderService> providerServices) throws Exception {
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		deactivateTucanoServices(subscriptionAction, provProvider, subscription, providerServices);
		
	}
	...
}

...

public void processEndSubscriptionRestingSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever an 'End Subscription Resting' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processEndSubscriptionRestingSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices) throws Exception {
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		activateTucanoServices(subscriptionAction, provProvider, subscription, providerServices);
		
	}
	...
}

...

public void processShortTermActivationSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever a 'Short Term Activation' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processShortTermActivationSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices) throws Exception {
		
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		activateTucanoServices(subscriptionAction, provProvider, subscription, providerServices);	
	}
	...
}

...

public void processEndShortTermActivationSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever an 'End Short Term Activation' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processEndShortTermActivationSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices) throws Exception {
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		deactivateTucanoServices(subscriptionAction, provProvider, subscription, providerServices);
		
	}
	...
}

...

public void processShortTermDeactivationSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever a 'Short Term Deactivation' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processShortTermDeactivationSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices) throws Exception {
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		deactivateTucanoServices(subscriptionAction, provProvider, subscription, providerServices);	
	}
	...
}

...

public void processEndShortTermDeactivationSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices)

This method is called whenever an 'End Short Term Deactivation' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processEndShortTermDeactivationSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderService> providerServices) throws Exception {
		CRMDOProvProvider provProvider = loadProvider();
		CRMDOSubscription subscription = subscriptionAction.getSubscription();
		activateTucanoServices(subscriptionAction, provProvider, subscription, providerServices);
	}
	...
}

...

 public void processAddServiceUsageSubscriptionAction(CRMDOSubscriptionAction subscriptionAction, ArrayList<ProviderUsageDataRecord> protocolProviderUdrs)

This method is called whenever an 'Add Service Usage' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processAddServiceUsageSubscriptionAction(CRMDOSubscriptionAction subscriptionAction,ArrayList<ProviderUsageDataRecord> protocolProviderUdrs) throws Exception {
		...
	}
	...
}

...

public void processCancelledUDRs(ArrayList<ProviderUsageDataRecord> providerUsageDataRecords)

This method is called whenever a 'Cancel UDR' action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processCancelledUDRs(ArrayList<ProviderUsageDataRecord> providerUsageDataRecords) throws Exception {
		...
	}
	...
}

...

public void processResetSubscription(CRMDOProvProvider provProvider, CRMDOSubscription subscription)

This method is callled whenever a 'Reset Subscription' subscription action is executed.

Code Block
languagejava
titleMYCOMPANYCRMProcessTucanoProvider.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	@Override
	public void processResetSubscription(CRMDOProvProvider provProvider, CRMDOSubscription subscription) throws Exception {
		String processName = ProvisioningRequestProcessName.RESET.toString();
		
		if(!isSubscriptionProvisioned(subscription.getId()) && ifSubscriptionServiceProvisionedExists(subscription.getId(), provProvider.getId()))
		{
			createNewTucanoAccount(provProvider, subscription, null, null, processName, null);
		}
		ArrayList<ProviderService> providerServicesForDeactivation = getProviderServicesForDeactivation(subscription, provProvider);
		
		if(providerServicesForDeactivation != null && providerServicesForDeactivation.size() > 0)
		{
			deactivateTucanoServices(provProvider, subscription, providerServicesForDeactivation, processName, null);
		}	
		
		ArrayList<ProviderService> providerServicesForActivation = getProviderServicesForActivation(subscription, provProvider);
		
		if(providerServicesForActivation != null && providerServicesForActivation.size() > 0)
		{
			activateTucanoServices(provProvider, subscription, providerServicesForActivation, processName, null);
		}
		
		ArrayList<ProviderInstalledItem> providerInstalledItemsForActivation = getProviderInstalledItemsForActivation(subscription, provProvider);
		
		if(providerInstalledItemsForActivation != null && providerInstalledItemsForActivation.size() > 0)
		{
			addTucanoSTBs(provProvider, subscription, providerInstalledItemsForActivation, processName, null);
		}
		
		ArrayList<ProviderInstalledItem> providerInstalledItemsForDeactivation = getProviderInstalledItemsForDeactivation(subscription, provProvider);
		
		if(providerInstalledItemsForDeactivation != null && providerInstalledItemsForDeactivation.size() > 0)
		{
			removeTucanoSTBs(provProvider, subscription, providerInstalledItemsForDeactivation, processName, null);
		}
	}
	...
}

b. Create and Process Provisioning Requests

In the following example, you can see how a provisioning request for adding services, can be created and processed.

Code Block
languagejava
titleMYCOMPANYCRMBOTucanoProviderBean.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMProcessTucanoProviderBean extends CRMProcessProviderBean {
	...
	private CRMDOProvisioningRequest processActivateOptionsProvisioningRequest(		CRMDOProvProvider provProvider, 
																					CRMDOSubscription subscription,
																					CRMDOSubProvProviderParameter subProvProviderParameter,
																					ArrayList<ProviderService> providerServices,
																					String processName, 
																					String processID,
																					TucanoAuthenticationToken tucanoAuthenticationToken) throws Exception {
		
		//The provisioning request parameters to be created 
		HashMap<String,Object> parameterValues = new HashMap<String,Object>();
 
		//The subscription provisioning parameter
		parameterValues.put(ProvisioningRequestParameterType.SUB_PROVISIONING_PARAMETER_ID.toString(), subProvProviderParameter);
		
		//A list of service CA IDs
		ArrayList<Integer> optionIds = new ArrayList<Integer>();
	    ArrayList<CRMDOSubProvisioningDistribution> subProvDistributions = new ArrayList<CRMDOSubProvisioningDistribution>();
		for(int i=0; i<providerServices.size(); i++)
		{
			optionIds.add(new Integer(tucanoProviderBean.getServiceCAID(provProvider,providerServices.get(i).getProduct())));
			subProvDistributions.add(providerServices.get(i).getSubProvisioningDistribution());
		}
 
		//The subscription provisioning distributor linked with the service
		parameterValues.put(ProvisioningRequestParameterType.SERVICE_CA_ID.toString(),optionIds);
		//The subscription service CA ID
		parameterValues.put(ProvisioningRequestParameterType.SERVICE_SUB_PROVISIONING_DISTRIBUTION_ID.toString(),subProvDistributions);
		
		//Create and save the porvisioning request and provisioning request parameters
		CRMDOProvisioningRequest provisioningRequest = createProvisioningRequest(	provProvider,
																					ProvisioningRequestTypeCode.ACTIVATE_OPTIONS.toString(), 
																					getCurrentDate(), 
																					parameterValues, 
																					"addOptions", 
																					null, 
																					processName, 
																					processID, 
																					subscription);
		
		Boolean success = false;
		String request = null;
		String result = null;
		
		//Send request to TUCANO and set values of request, success and result
		{...}
		//
		
		if(success)
		{
			provisioningRequest.setRequest(request+" / "result);
			completeProvisioningRequest(request+" / "result, getCurrentDate(),subProvDistributions,null,null,null,null);
		}
		else
		{
			rejectProvisioningRequest(provisioningRequest, result, subProvDistributions,null,null,null,null);
		}
		
		return provisioningRequest;
	}
	...		if(cardReferenceNumber==null)
			{
				throw new MandatoryFieldException(getCRMSession(), "key_card_reference_number");
			}
			CRMDOPaymentGatewayCard paymentGatewayCard = paymentGatewayCardBean.loadByReferenceNumber(cardReferenceNumber, new ArrayList<String>());
			
			String cardHolderName = null;
			String brand = null;
			Integer expirationMonth = null;
			Integer expirationYear = null;
			
			if(paymentGatewayCard!=null)
			{
				cardHolderName = paymentGatewayCard.getHolderName();
				brand = paymentGatewayCard.getBrand();
				expirationMonth = paymentGatewayCard.getExpMonth();
				expirationYear = paymentGatewayCard.getExpYear();
			}
			
			PayeezyConnectionParameters connectionParameters = getConnectionParameters(parameters);
			
			JSONObject request = new JSONObject();
			
			Integer amountInt = parameters.getAmount().multiply(new BigDecimal(100)).intValue();
			String amountStr = amountInt.toString();
			
			ArrayList<String> billNumbers = parameters.getBillNumbers();
			ArrayList<String> invoiceNumbers = parameters.getInvoiceNumbers();
			
			String orderData = "Bills: "+getMetadataList(billNumbers)+" Invoices: "+getMetadataList(invoiceNumbers);
			request.put("method", "token");
			request.put("transaction_type", "purchase");
			request.put("amount", amountStr);
			request.put("order_data ", orderData);
			request.put("currency_code", "USD");			
			request.put("token", getTokenJSON(cardHolderName, cardReferenceNumber, brand, expirationMonth, expirationYear));
			String authorization = getAuthorization(connectionParameters, request.toString());
			String urlStr = connectionParameters.getUrl();
			URL url = new URL(urlStr);
			HttpURLConnection conn = (HttpURLConnection) url.openConnection();
			conn.setDoOutput(true);
			conn.setRequestMethod("POST");
			conn.setRequestProperty("Content-Type", connectionParameters.getContentType());
			conn.setRequestProperty("apiKey", connectionParameters.getApiKey());
			conn.setRequestProperty("token", connectionParameters.getMerchantToken());
			conn.setRequestProperty("Authorization", authorization);
			conn.setRequestProperty("nonce", connectionParameters.getNonce());
			conn.setRequestProperty("timestamp", connectionParameters.getTimestamp());
			
			conn.setDoOutput(true);
			requestStr = getRequest(urlStr,request);
			JSONObject responseJSON = getResponse(conn, request, "Create Payment Request: " +requestStr);
			result = (CreatePaymentGatewayPaymentResult) setTransactionInformation(result, responseJSON);
		}
		catch (Exception e)
		{
			CallList.LogTextFile(getCRMSession(), "Create Payment Request: " +requestStr+") Error: "+ExceptionUtil.getStackTrace(e), PAYEEZY_PAYMENT_GATEWAY_ERROR_LOG_PATH,"");
			result.setErrorDescription(e.getMessage());
			result.setLifeCycleState(PaymentGatewayRequestLifeCycleState.REJECTED);
		}
		
		return result;
	}
	@Override
	public CreatePaymentGatewayPaymentCancellationResult processCreatePaymentCancellation(CreatePaymentCancellationParameters parameters) throws Exception {
		CreatePaymentGatewayPaymentCancellationResult result = new CreatePaymentGatewayPaymentCancellationResult();
		
		String requestStr = null;
		try
		{
			
			ArrayList<String> associations =  new ArrayList<String>();
			associations.add("accountReceivable");
			associations.add("paymentGatewayCard");
			associations.add("accountReceivable.currency");
			
			CRMDOPayment payment 							= paymentBean.loadByReferenceNumber(parameters.getPaymentNumber(), associations);
			String paymentPayeezyRefNumber					= payment.getPaymentGatewayRefNumber();
			CRMDOPaymentGatewayCard paymentGatewayCard 		= payment.getPaymentGatewayCard();
			String transactionTag 							= parameters.getPaymentReferenceNumber();
			Integer amountInt 								= payment.getTotalAmount().multiply(new BigDecimal(100)).intValue();
			String amountStr 								= amountInt.toString();
			String currency 								= payment.getAccountReceivable().getCurrency().getCode();
			String cardReferenceNumber 						= paymentGatewayCard.getReferenceNumber();
			String cardHolderName 							= null;
			String brand 									= null;
			Integer expirationMonth							= null;
			Integer expirationYear 							= null;
			
			if(paymentGatewayCard!=null)
			{
				cardHolderName = paymentGatewayCard.getHolderName();
				brand = paymentGatewayCard.getBrand();
				expirationMonth = paymentGatewayCard.getExpMonth();
				expirationYear = paymentGatewayCard.getExpYear();
			}
			
			PayeezyConnectionParameters connectionParameters = getConnectionParameters(parameters);
			
			JSONObject request = new JSONObject();
			request.put("method", "token");
			request.put("transaction_type", "refund");
			request.put("amount", amountStr);
			request.put("transaction_tag ", transactionTag);
			request.put("currency_code", "USD");			
			request.put("token", getTokenJSON(cardHolderName, cardReferenceNumber, brand, expirationMonth, expirationYear));
			String urlStr = connectionParameters.getUrl()+"/"+paymentPayeezyRefNumber;
			URL url = new URL(urlStr);
			HttpURLConnection conn = (HttpURLConnection) url.openConnection();
			conn.setDoOutput(true);
			conn.setRequestMethod("POST");
			conn.setRequestProperty("Content-Type", connectionParameters.getContentType());
			conn.setRequestProperty("apiKey", connectionParameters.getApiKey());
			conn.setRequestProperty("token", connectionParameters.getMerchantToken());
			conn.setRequestProperty("Authorization", getAuthorization(connectionParameters,request.toString()));
			conn.setRequestProperty("nonce", connectionParameters.getNonce());
			conn.setRequestProperty("timestamp", connectionParameters.getTimestamp());
			conn.setDoOutput(true);

			requestStr = getRequest(urlStr,request);
			JSONObject responseJSON = getResponse(conn, request, "Create Payment Cancellation Request: " +requestStr);
			result = (CreatePaymentGatewayPaymentCancellationResult) setTransactionInformation(result, responseJSON);
		}
		catch (Exception e)
		{
			CallList.LogTextFile(getCRMSession(), "Create Payment Cancellation Request: " +requestStr+") Error: "+ExceptionUtil.getStackTrace(e), PAYEEZY_PAYMENT_GATEWAY_ERROR_LOG_PATH,"");
			result.setErrorDescription(e.getMessage());
			result.setLifeCycleState(PaymentGatewayRequestLifeCycleState.REJECTED);
		}
		
		return result;
	}	
	
	private PaymentGatewayCardResult setCardInformation(PaymentGatewayCardResult card, JSONObject responseJSON) throws Exception{
		
		if(responseJSON!=null)
		{
			JSONObject tokenJSON 	= JSONUtil.getJSONObjectParameter(responseJSON, "token", getCRMSession());
			String status 			= JSONUtil.getStringParameter(responseJSON, "status", getCRMSession());
			
			if(status!=null && status.equalsIgnoreCase("success"))
			{
				card.setLifeCycleState(PaymentGatewayRequestLifeCycleState.POSTED);
			}
			else
			{
				card = (PaymentGatewayCardResult) setErrorInformation(card, responseJSON);
				card.setLifeCycleState(PaymentGatewayRequestLifeCycleState.REJECTED);
			}
			
			if(tokenJSON!=null)
			{
				String cardholderName 	= JSONUtil.getStringParameter(tokenJSON, "cardholder_name", getCRMSession());
				String expDate			= JSONUtil.getStringParameter(tokenJSON, "exp_date", getCRMSession());
				String type 			= JSONUtil.getStringParameter(tokenJSON, "type", getCRMSession());
				String token 			= JSONUtil.getStringParameter(tokenJSON, "value", getCRMSession());
				
				card.setHolderName(cardholderName);
				card.setResponseID(token);
				card.setBrand(payeezyPaymentGatewaySettingBean.getCardBrand(type));
				
				if(expDate!=null)
				{
					Integer expMonth = new Integer(expDate.substring(0,2));
					Integer expYear = new Integer(expDate.substring(2,4))+2000;
					
					card.setExpMonth(expMonth);
					card.setExpYear(expYear);
				}
				
			}
		}
		
		return card;
	}
	private PaymentGatewayResult setTransactionInformation(PaymentGatewayResult result, JSONObject responseJSON) throws Exception{
		if(responseJSON!=null)
		{
			
			String transactionStatus 			= JSONUtil.getStringParameter(responseJSON, "transaction_status", getCRMSession());
			String valisationStatus 			= JSONUtil.getStringParameter(responseJSON, "validation_status", getCRMSession());
			if(valisationStatus!=null && 
					valisationStatus.equalsIgnoreCase("success") && 
					transactionStatus!=null && 
					transactionStatus.equalsIgnoreCase("approved"))
			{
				String transactionTag = JSONUtil.getStringParameter(responseJSON, "transaction_tag", getCRMSession());
				result.setResponseID(transactionTag);
				result.setLifeCycleState(PaymentGatewayRequestLifeCycleState.POSTED);
			}
			else
			{
				result = (CreatePaymentGatewayPaymentResult) setErrorInformation(result, responseJSON);
				result.setLifeCycleState(PaymentGatewayRequestLifeCycleState.REJECTED);
			}
		}
		return result;
	}
	private PaymentGatewayResult setErrorInformation(PaymentGatewayResult result, JSONObject responseJSON) throws Exception{
		String errorCode = "";
		String errorDescription = "";
		
		if(responseJSON!=null)
		{
			JSONObject errorJSON 	= JSONUtil.getJSONObjectParameter(responseJSON, "error", getCRMSession());
			
			if(errorJSON!=null)
			{
				JSONArray messagesJSON = JSONUtil.getJSONArrayParameter(errorJSON, "messages", getCRMSession());
				
				if(messagesJSON!=null)
				{
					for(int i=0;i<messagesJSON.size();i++)
					{
						JSONObject messageJSON = (JSONObject) messagesJSON.get(i);
						if(messageJSON!=null)
						{
							errorCode += JSONUtil.getStringParameter(messageJSON, "code", getCRMSession())+", ";
							errorDescription += JSONUtil.getStringParameter(messageJSON, "description", getCRMSession())+", ";
						}
					}
				}
			}
		}
		
		if(errorCode!=null && !errorCode.isEmpty())
		{
			errorCode = errorCode.substring(0, errorCode.length()-2);
			if(errorCode.length()>32)
			{
				errorCode = errorCode.substring(0, 31);
			}
			
			result.setErrorCode(errorCode);
		}
		
		if(errorDescription!=null && !errorDescription.isEmpty())
		{
			errorDescription = errorDescription.substring(0, errorDescription.length()-2);
			
			result.setErrorDescription(errorDescription);
		}
		return result;
	}
	
	private String getRequest(String url, JSONObject originalRequestJSON) throws Exception{
		
		JSONObject requestJSON = new JSONObject(originalRequestJSON, JSONObject.getNames(originalRequestJSON));
		String request="";
		
		if(url!=null)
		{
			request = "URL:" +url;
		}
		
		if(requestJSON!=null)
		{
			JSONObject creditCardJSON = JSONUtil.getJSONObjectParameter(requestJSON, "credit_card", getCRMSession());
			
			if(creditCardJSON!=null)
			{
				creditCardJSON.remove("cvv");
				String cardNumber 		= JSONUtil.getStringParameter(requestJSON, "card_number", getCRMSession());
				
				if(cardNumber!=null)
				{
					cardNumber = "************"+cardNumber.substring(cardNumber.length()-4,cardNumber.length());
					creditCardJSON.remove("card_number");
				}
				
				creditCardJSON.put("card_number", cardNumber);
			}
			
			request+= ", Request: "+requestJSON.toString();
		}
		
		
		
		return request;
	}
	
	private String getMetadataList(ArrayList<String> list){
		String s = "";
		if(list!=null)
		{
			for(String o:list)
			{
				s += ""+o+",";
			}
			if(s.length()>0)
			{
				s = s.substring(0, s.length()-1);
			}
		}
		return s;
	}
	@Override
	public Boolean isCurrencySupported(CRMDOCurrency currency, CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
		return payeezyPaymentGatewaySettingBean.isCurrencySupported(currency,paymentGatewaySetting);
	}
	
	private PayeezyConnectionParameters getConnectionParameters(PaymentGatewayParameters parameters) throws NoSuchAlgorithmException{
		PayeezyConnectionParameters connectionParameters = new PayeezyConnectionParameters();
		
		String mode 			= (String) parameters.getGeneralparameter(PayeezyParameter.MODE.toString());
		String apiKey 			= null;
		String merchantToken 	= null;
		String apiSecret 		= null;
		String jsSecurityKey 	= null;
		String transarmorToken 	= null;
		String url				= null;
		String nonce = Long.toString(Math.abs(SecureRandom.getInstance("SHA1PRNG").nextLong()));
		String timestamp =  Long.toString(Instant.now().toEpochMilli());
		
		if(mode!=null && mode.equals(PayeezyMode.TEST.toString()))
		{
			apiKey 			= (String) parameters.getGeneralparameter(PayeezyParameter.TEST_API_KEY.toString());
			merchantToken 	= (String) parameters.getGeneralparameter(PayeezyParameter.TEST_MERCHANT_TOKEN.toString());
			apiSecret 		= (String) parameters.getGeneralparameter(PayeezyParameter.TEST_API_SECRET.toString());
			jsSecurityKey 	= (String) parameters.getGeneralparameter(PayeezyParameter.TEST_JS_SECURITY_KEY.toString());
			transarmorToken = (String) parameters.getGeneralparameter(PayeezyParameter.TEST_TA_TOKEN.toString());
			url				= (String) parameters.getGeneralparameter(PayeezyParameter.TEST_URL.toString());
		}
		else if(mode!=null && mode.equals(PayeezyMode.LIVE.toString()))
		{
			apiKey 			= (String) parameters.getGeneralparameter(PayeezyParameter.LIVE_API_KEY.toString());
			merchantToken 	= (String) parameters.getGeneralparameter(PayeezyParameter.LIVE_MERCHANT_TOKEN.toString());
			apiSecret 		= (String) parameters.getGeneralparameter(PayeezyParameter.LIVE_API_SECRET.toString());
			jsSecurityKey 	= (String) parameters.getGeneralparameter(PayeezyParameter.LIVE_JS_SECURITY_KEY.toString());
			transarmorToken = (String) parameters.getGeneralparameter(PayeezyParameter.LIVE_TA_TOKEN.toString());
			url				= (String) parameters.getGeneralparameter(PayeezyParameter.LIVE_URL.toString());
		}
		
		if(url!=null)
		{
			if(parameters instanceof CreateCardParameters)
			{
				url += "transactions/tokens";
			}
			else if(parameters instanceof CreatePaymentParameters)
			{
				url += "transactions";
			}
			else if(parameters instanceof CreatePaymentCancellationParameters)
			{
				url += "transactions";
			}
		}
		
		connectionParameters.setApiKey(apiKey);
		connectionParameters.setMerchantToken(merchantToken);
		connectionParameters.setUrl(url);
		connectionParameters.setApiSecret(apiSecret);
		connectionParameters.setJsSecurityKey(jsSecurityKey);
		connectionParameters.setContentType("application/json");
		connectionParameters.setTransarmorToken(transarmorToken);
		connectionParameters.setNonce(nonce);
		connectionParameters.setTimestamp(timestamp);
		
		return connectionParameters;
		
	}
	
	public JSONObject getCreditCardJSON(String cardHolderName, String cardNumber, String cardBrand, Integer expMonth, Integer expYear, String cvv) throws Exception {
		JSONObject creditCardJSON=new JSONObject();
		Integer expDate = null;
		
		if(expMonth!=null && expYear!=null)
		{
			expDate = expMonth*100+expYear % 1000;
		}
		
		creditCardJSON.put("type", payeezyPaymentGatewaySettingBean.getCardType(cardBrand));
		creditCardJSON.put("cardholder_name", cardHolderName);
		creditCardJSON.put("card_number", cardNumber);
		creditCardJSON.put("exp_date", expDate);
		creditCardJSON.put("cvv", cvv);
		
		return creditCardJSON;
	}
	public JSONObject getTokenJSON(String cardHolderName, String cardReferenceNumber, String cardBrand, Integer expMonth, Integer expYear) throws Exception {
		JSONObject tokenJSON=new JSONObject();
		tokenJSON.put("token_type", "FDToken");
		JSONObject tokenDataJSON=new JSONObject();
		Integer expDate = null;
		if(expMonth!=null && expYear!=null)
		{
			expDate = expMonth*100+expYear % 1000;
		}
		tokenDataJSON.put("type", payeezyPaymentGatewaySettingBean.getCardType(cardBrand));
		tokenDataJSON.put("cardholder_name", cardHolderName);
		tokenDataJSON.put("value", cardReferenceNumber);
		tokenDataJSON.put("exp_date", expDate);
		tokenJSON.put("token_data", tokenDataJSON);
		return tokenJSON;
	}
	private String getAuthorization(PayeezyConnectionParameters connectionParameters, String request) throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException, Exception{		
		
		Mac mac=Mac.getInstance(HMAC_SHA256_ALGORITHM);
		String apiSecret=connectionParameters.getApiSecret();
		SecretKeySpec secret_key = new SecretKeySpec(apiSecret.getBytes(), HMAC_SHA256_ALGORITHM);
		mac.init(secret_key);
		String apikey = connectionParameters.getApiKey();
		String nonce = connectionParameters.getNonce();
		String timeStamp = connectionParameters.getTimestamp();
		String token = connectionParameters.getMerchantToken();
		String payload = request;
		StringBuilder buff=new StringBuilder();
		buff.append(apikey)
		.append(nonce)
		.append(timeStamp);
		if(token!=null){
			buff.append(token);
		}
		if(payload != null){
			buff.append(payload);
		}
		String bufferData = buff.toString();
		//MessageLogger.logMessage(String.format(bufferData));
		byte[] macHash=mac.doFinal(bufferData.getBytes("UTF-8"));
		//MessageLogger.logMessage(Integer.toString(macHash.length));
		//MessageLogger.logMessage(String.format("MacHAsh:{}" , macHash));
		String authorizeString = new String(Base64.encodeBase64(toHex(macHash)));
		//   MessageLogger.logMessage(String.format("Authorize:{}" , authorizeString));

		return authorizeString;
	}
	
	   /**
     * Converts the bytes to Hex bytes
     * @param arr
     * @return
     */
    private byte[] toHex(byte[] arr) {
        String hex= byteArrayToHex(arr);
        return hex.getBytes();
    }
    private String byteArrayToHex(byte[] a) {
        StringBuilder sb = new StringBuilder(a.length * 2);
        for(byte b: a)
            sb.append(String.format("%02x", b & 0xff));
        return sb.toString();
    }
	
	
	@SuppressWarnings("deprecation")
	private JSONObject getResponse(HttpURLConnection conn, JSONObject request, String requestInfo) throws Exception{
		JSONObject responseJSON = null;
		
		CallList.LogTextFile(getCRMSession(), requestInfo, PAYEEZY_PAYMENT_GATEWAY_SUC_LOG_PATH,"");
		
		OutputStream os = conn.getOutputStream();
		os.write(request.toString().getBytes());
		os.flush();
		if (conn.getResponseCode() != HttpURLConnection.HTTP_OK && 
				conn.getResponseCode() != HttpURLConnection.HTTP_CREATED && 
				conn.getResponseCode() != HttpURLConnection.HTTP_ACCEPTED) 
		{
			String errorDescription = "";
			if(conn.getErrorStream()!=null)
			{
				BufferedReader br = new BufferedReader(new InputStreamReader((conn.getErrorStream())));
				if(br!=null)
				{
					errorDescription = br.readLine();
				}
			}
			CallList.LogTextFile(getCRMSession(),requestInfo+"\nError: HTTP error code : "+ conn.getResponseCode()+"\nError Description: "+errorDescription,PAYEEZY_PAYMENT_GATEWAY_ERROR_LOG_PATH,"");
			throw new RuntimeException("Failed : HTTP error code : "+ conn.getResponseCode()+" error description: "+errorDescription);
		}

		BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
		String output;
		Date date = DateUtil.getCurrentDate();
		long startTime = date.getTime();
		long duration = 0;
		while( true )
		{
			duration =DateUtil.getCurrentDate().getTime() - startTime;
			if(duration>timeout)
			{
				throw new Exception("Time out");
			}
			if ((output = br.readLine()) != null) 
			{
				try
				{
					CallList.LogTextFile(getCRMSession(),requestInfo+"\nResponse: "+output,PAYEEZY_PAYMENT_GATEWAY_SUC_LOG_PATH,"");
					break;
				}
				catch (JSONException ex)
				{
				}
			}
			else{
				try {
					Thread.sleep(50);
				} catch (Exception e) {
				}
			}
		}
		conn.disconnect();
		responseJSON = new JSONObject(output);
		
		
		return responseJSON;
	}
}

6. Summary Pages

You will need to create one main summary page for provisioning requests, and two that will be used by the main as drill-downs: one for provisioning request parameters and one for provisioning request process information.

...