Search in sources :

Example 1 with ClientInfo

use of paypal.payflow.ClientInfo in project adempiere by adempiere.

the class PP_PayFlowPro4 method process.

//  processCC
/**
	 *  Process Transaction
	 *  @param parameter Command String
	 *  @return true if processed successfully
	 */
public boolean process(String parameter) {
    long start = System.currentTimeMillis();
    StringBuffer param = new StringBuffer(parameter);
    //  Usr/Pwd
    param.append("&PARTNER=").append(p_mpp.getPartnerID()).append("&VENDOR=").append(p_mpp.getVendorID()).append("&USER=").append(p_mpp.getUserID()).append("&PWD=").append(p_mpp.getPassword());
    // PCI DSS don't log private data
    // log.fine("-> " + param.toString());
    SDKProperties.setHostAddress(p_mpp.getHostAddress());
    SDKProperties.setHostPort(p_mpp.getHostPort());
    SDKProperties.setTimeOut(getTimeout());
    SDKProperties.setProxyAddress(p_mpp.getProxyAddress());
    SDKProperties.setProxyPort(p_mpp.getProxyPort());
    SDKProperties.setProxyLogin(p_mpp.getProxyLogon());
    SDKProperties.setProxyPassword(p_mpp.getProxyPassword());
    //Logging is by default off. To turn logging on uncomment the following lines:
    //SDKProperties.setLogFileName("payflow_java.log");
    //SDKProperties.setLoggingLevel(PayflowConstants.SEVERITY_DEBUG);
    //SDKProperties.setMaxLogFileSize(1000000);
    //SDKProperties.setStackTraceOn(true);
    //		 Create an instance of PayflowAPI.
    m_pp = new PayflowAPI();
    // RequestId is a unique string that is required for each & every transaction.
    // The merchant can use her/his own algorithm to generate this unique request id or
    // use the SDK provided API to generate this as shown below (PayflowAPI.generateRequestId).
    String requestId = m_pp.generateRequestId();
    String response = m_pp.submitTransaction(param.toString(), requestId);
    // Create a new Client Information data object.
    ClientInfo clInfo = new ClientInfo();
    // Set the ClientInfo object of the PayflowAPI.
    m_pp.setClientInfo(clInfo);
    // Following lines of code are optional.
    // Begin optional code for displaying SDK errors ...
    // It is used to read any errors that might have occured in the SDK.
    // Get the transaction errors.
    String transErrors = m_pp.getTransactionContext().toString();
    if (transErrors != null && transErrors.length() > 0) {
        log.log(Level.SEVERE, "Transaction Errors from SDK = \n" + transErrors);
    }
    p_mp.setR_Result("");
    //	complete info
    p_mp.setR_Info(response);
    //  RESULT=1&PNREF=PN0001480030&RESPMSG=Invalid User Authentication
    //  RESULT=0&PNREF=P60501480167&RESPMSG=Approved&AUTHCODE=010101&AVSADDR=X&AVSZIP=X
    //	RESULT=-31&RESPMSG=The certificate chain did not validate, no local certificate found, javax.net.ssl.SSLException: Cert Path = C:\Adempiere\lib, Working Directory = C:\Adempiere\adempiere-all2\client\temp
    StringTokenizer st = new StringTokenizer(response, "&", false);
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        int pos = token.indexOf('=');
        String name = token.substring(0, pos);
        String value = token.substring(pos + 1);
        //
        if (name.equals("RESULT")) {
            p_mp.setR_Result(value);
            m_ok = RESULT_OK.equals(value);
        } else if (name.equals("PNREF"))
            p_mp.setR_PnRef(value);
        else if (name.equals("RESPMSG"))
            p_mp.setR_RespMsg(value);
        else if (name.equals("AUTHCODE"))
            p_mp.setR_AuthCode(value);
        else if (name.equals("AVSADDR"))
            p_mp.setR_AvsAddr(value);
        else if (name.equals("AVSZIP"))
            p_mp.setR_AvsZip(value);
        else if (//	N=YSA, Y=International
        name.equals("IAVS"))
            ;
        else if (//	Y/N X=not supported
        name.equals("CVV2MATCH"))
            ;
        else
            log.log(Level.SEVERE, "Response unknown = " + token);
    }
    //  Problems with rc (e.g. 0 with Result=24)
    return m_ok;
}
Also used : ClientInfo(paypal.payflow.ClientInfo) PayflowAPI(paypal.payflow.PayflowAPI)

Aggregations

ClientInfo (paypal.payflow.ClientInfo)1 PayflowAPI (paypal.payflow.PayflowAPI)1