Added payment processor extension.
This commit is contained in:
parent
a29a673fc0
commit
9cb417eeaf
|
@ -12,6 +12,7 @@
|
||||||
<extension-point id="org.adempiere.base.IModelFactory" name="Model Factory" schema="schema/org.adempiere.base.IModelFactory.exsd"/>
|
<extension-point id="org.adempiere.base.IModelFactory" name="Model Factory" schema="schema/org.adempiere.base.IModelFactory.exsd"/>
|
||||||
<extension-point id="org.adempiere.base.IDocFactory" name="Financial Document Factory" schema="schema/org.adempiere.base.IDocFactory.exsd"/>
|
<extension-point id="org.adempiere.base.IDocFactory" name="Financial Document Factory" schema="schema/org.adempiere.base.IDocFactory.exsd"/>
|
||||||
<extension-point id="org.adempiere.base.IGridTabExporter" name="Grid data export extension" schema="schema/org.adempiere.base.IGridTabExporter.exsd"/>
|
<extension-point id="org.adempiere.base.IGridTabExporter" name="Grid data export extension" schema="schema/org.adempiere.base.IGridTabExporter.exsd"/>
|
||||||
|
<extension-point id="org.compiere.model.PaymentProcessor" name="Payment Processor" schema="schema/org.compiere.model.PaymentProcessor.exsd"/>
|
||||||
<extension
|
<extension
|
||||||
id="org.adempiere.base.DefaultModelFactory"
|
id="org.adempiere.base.DefaultModelFactory"
|
||||||
name="Default model factory"
|
name="Default model factory"
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!-- Schema file written by PDE -->
|
||||||
|
<schema targetNamespace="org.adempiere.base" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<annotation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.schema plugin="org.adempiere.base" id="org.compiere.model.PaymentProcessor" name="Payment Processor"/>
|
||||||
|
</appinfo>
|
||||||
|
<documentation>
|
||||||
|
Extension to provide payment gateway integration through payment gateway specific payment processor implementation
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<element name="extension">
|
||||||
|
<annotation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.element />
|
||||||
|
</appinfo>
|
||||||
|
</annotation>
|
||||||
|
<complexType>
|
||||||
|
<choice>
|
||||||
|
<element ref="processor"/>
|
||||||
|
</choice>
|
||||||
|
<attribute name="point" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="id" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="name" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.attribute translatable="true"/>
|
||||||
|
</appinfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="processor">
|
||||||
|
<complexType>
|
||||||
|
<attribute name="priority" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
numeric priority value, higher value is of higher priority
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="class" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Class name for payment gateway processor that extend the org.compiere.model.PaymentProcessor abstract class.
|
||||||
|
</documentation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.attribute kind="java" basedOn="org.compiere.model.PaymentProcessor:"/>
|
||||||
|
</appinfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.section type="since"/>
|
||||||
|
</appinfo>
|
||||||
|
<documentation>
|
||||||
|
1.0.0
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.section type="examples"/>
|
||||||
|
</appinfo>
|
||||||
|
<documentation>
|
||||||
|
[Enter extension point usage example here.]
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.section type="apiinfo"/>
|
||||||
|
</appinfo>
|
||||||
|
<documentation>
|
||||||
|
The class attribute must extend the org.compiere.model.PaymentProcessor abstract class.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.section type="implementation"/>
|
||||||
|
</appinfo>
|
||||||
|
<documentation>
|
||||||
|
Default implementation in the org.adempiere.payment.processor bundle.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.section type="copyright"/>
|
||||||
|
</appinfo>
|
||||||
|
<documentation>
|
||||||
|
This file is part of Adempiere ERP Bazaar http://www.adempiere.org.
|
||||||
|
|
||||||
|
Copyright (C) Jorg Viola.
|
||||||
|
Copyright (C) Contributors.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms version 2 of the GNU General Public License as published
|
||||||
|
by the Free Software Foundation. This program is distributed in the hope
|
||||||
|
that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
</schema>
|
|
@ -22,9 +22,14 @@ package org.adempiere.base;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.compiere.model.MPayment;
|
||||||
|
import org.compiere.model.MPaymentProcessor;
|
||||||
import org.compiere.model.ModelValidator;
|
import org.compiere.model.ModelValidator;
|
||||||
|
import org.compiere.model.PaymentProcessor;
|
||||||
import org.compiere.process.ProcessCall;
|
import org.compiere.process.ProcessCall;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a facade class for the Service Locator.
|
* This is a facade class for the Service Locator.
|
||||||
|
@ -35,6 +40,8 @@ import org.compiere.process.ProcessCall;
|
||||||
*/
|
*/
|
||||||
public class Core {
|
public class Core {
|
||||||
|
|
||||||
|
private final static CLogger s_log = CLogger.getCLogger(Core.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list of active resource finder
|
* @return list of active resource finder
|
||||||
*/
|
*/
|
||||||
|
@ -89,4 +96,43 @@ public class Core {
|
||||||
return Service.locate(ModelValidator.class, "org.adempiere.base.ModelValidator", query);
|
return Service.locate(ModelValidator.class, "org.adempiere.base.ModelValidator", query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory
|
||||||
|
* @param mpp payment processor model
|
||||||
|
* @param mp payment model
|
||||||
|
* @return initialized PaymentProcessor or null
|
||||||
|
*/
|
||||||
|
public static PaymentProcessor getPaymentProcessor(MPaymentProcessor mpp, MPayment mp) {
|
||||||
|
s_log.info("create for " + mpp);
|
||||||
|
String className = mpp.getPayProcessorClass();
|
||||||
|
if (className == null || className.length() == 0) {
|
||||||
|
s_log.log(Level.SEVERE, "No PaymentProcessor class name in " + mpp);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
PaymentProcessor myProcessor = null;
|
||||||
|
myProcessor = Service.locate(PaymentProcessor.class);
|
||||||
|
if (myProcessor == null) {
|
||||||
|
try {
|
||||||
|
Class<?> ppClass = Class.forName(className);
|
||||||
|
if (ppClass != null)
|
||||||
|
myProcessor = (PaymentProcessor)ppClass.newInstance();
|
||||||
|
} catch (Error e1) { // NoClassDefFound
|
||||||
|
s_log.log(Level.SEVERE, className + " - Error=" + e1.getMessage());
|
||||||
|
return null;
|
||||||
|
} catch (Exception e2) {
|
||||||
|
s_log.log(Level.SEVERE, className, e2);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (myProcessor == null) {
|
||||||
|
s_log.log(Level.SEVERE, "Not found in extension registry and classpath");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
myProcessor.initialize(mpp, mp);
|
||||||
|
//
|
||||||
|
return myProcessor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
import org.adempiere.base.Core;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
@ -58,9 +59,20 @@ public abstract class PaymentProcessor
|
||||||
/** Encode Parameters */
|
/** Encode Parameters */
|
||||||
private boolean m_encoded = false;
|
private boolean m_encoded = false;
|
||||||
/** Ampersand */
|
/** Ampersand */
|
||||||
public static final char AMP = '&';
|
public static final char AMP = '&';
|
||||||
/** Equals */
|
/** Equals */
|
||||||
public static final char EQ = '=';
|
public static final char EQ = '=';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param mpp
|
||||||
|
* @param mp
|
||||||
|
*/
|
||||||
|
public void initialize(MPaymentProcessor mpp, MPayment mp)
|
||||||
|
{
|
||||||
|
p_mp = mp;
|
||||||
|
p_mpp = mpp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory
|
* Factory
|
||||||
|
@ -70,42 +82,7 @@ public abstract class PaymentProcessor
|
||||||
*/
|
*/
|
||||||
public static PaymentProcessor create (MPaymentProcessor mpp, MPayment mp)
|
public static PaymentProcessor create (MPaymentProcessor mpp, MPayment mp)
|
||||||
{
|
{
|
||||||
s_log.info("create for " + mpp);
|
return Core.getPaymentProcessor(mpp, mp);
|
||||||
String className = mpp.getPayProcessorClass();
|
|
||||||
if (className == null || className.length() == 0)
|
|
||||||
{
|
|
||||||
s_log.log(Level.SEVERE, "No PaymentProcessor class name in " + mpp);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
PaymentProcessor myProcessor = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Class<?> ppClass = Class.forName(className);
|
|
||||||
if (ppClass != null)
|
|
||||||
myProcessor = (PaymentProcessor)ppClass.newInstance();
|
|
||||||
}
|
|
||||||
catch (Error e1) // NoClassDefFound
|
|
||||||
{
|
|
||||||
s_log.log(Level.SEVERE, className + " - Error=" + e1.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
catch (Exception e2)
|
|
||||||
{
|
|
||||||
s_log.log(Level.SEVERE, className, e2);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (myProcessor == null)
|
|
||||||
{
|
|
||||||
s_log.log(Level.SEVERE, "no class");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize
|
|
||||||
myProcessor.p_mpp = mpp;
|
|
||||||
myProcessor.p_mp = mp;
|
|
||||||
//
|
|
||||||
return myProcessor;
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
@ -134,7 +111,7 @@ public abstract class PaymentProcessor
|
||||||
// Validation methods. Override if you have specific needs.
|
// Validation methods. Override if you have specific needs.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate payment before process.
|
* Validate payment before process.
|
||||||
* @return "" or Error AD_Message.
|
* @return "" or Error AD_Message.
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
*/
|
*/
|
||||||
|
@ -149,7 +126,7 @@ public abstract class PaymentProcessor
|
||||||
}
|
}
|
||||||
return(msg);
|
return(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard account validation.
|
* Standard account validation.
|
||||||
* @return
|
* @return
|
||||||
|
@ -157,11 +134,11 @@ public abstract class PaymentProcessor
|
||||||
public String validateAccountNo() {
|
public String validateAccountNo() {
|
||||||
return MPaymentValidate.validateAccountNo(p_mp.getAccountNo());
|
return MPaymentValidate.validateAccountNo(p_mp.getAccountNo());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String validateCheckNo() {
|
public String validateCheckNo() {
|
||||||
return MPaymentValidate.validateCheckNo(p_mp.getCheckNo());
|
return MPaymentValidate.validateCheckNo(p_mp.getCheckNo());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String validateCreditCard() throws IllegalArgumentException {
|
public String validateCreditCard() throws IllegalArgumentException {
|
||||||
String msg = MPaymentValidate.validateCreditCardNumber(p_mp.getCreditCardNumber(), p_mp.getCreditCardType());
|
String msg = MPaymentValidate.validateCreditCardNumber(p_mp.getCreditCardNumber(), p_mp.getCreditCardType());
|
||||||
if (msg != null && msg.length() > 0)
|
if (msg != null && msg.length() > 0)
|
||||||
|
@ -177,7 +154,7 @@ public abstract class PaymentProcessor
|
||||||
}
|
}
|
||||||
return(msg);
|
return(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Set Timeout
|
* Set Timeout
|
||||||
* @param newTimeout timeout
|
* @param newTimeout timeout
|
||||||
|
@ -195,7 +172,7 @@ public abstract class PaymentProcessor
|
||||||
return m_timeout;
|
return m_timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Check for delimiter fields &= and add length of not encoded
|
* Check for delimiter fields &= and add length of not encoded
|
||||||
* @param name name
|
* @param name name
|
||||||
|
@ -235,7 +212,7 @@ public abstract class PaymentProcessor
|
||||||
* @param name name
|
* @param name name
|
||||||
* @param value value
|
* @param value value
|
||||||
* @param maxLength maximum length
|
* @param maxLength maximum length
|
||||||
* @return name[5]=value or name=value
|
* @return name[5]=value or name=value
|
||||||
*/
|
*/
|
||||||
protected String createPair(String name, String value, int maxLength)
|
protected String createPair(String name, String value, int maxLength)
|
||||||
{
|
{
|
||||||
|
@ -243,10 +220,10 @@ public abstract class PaymentProcessor
|
||||||
if (name == null || name.length() == 0
|
if (name == null || name.length() == 0
|
||||||
|| value == null || value.length() == 0)
|
|| value == null || value.length() == 0)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
if (value.length() > maxLength)
|
if (value.length() > maxLength)
|
||||||
value = value.substring(0, maxLength);
|
value = value.substring(0, maxLength);
|
||||||
|
|
||||||
StringBuffer retValue = new StringBuffer(name);
|
StringBuffer retValue = new StringBuffer(name);
|
||||||
if (m_encoded)
|
if (m_encoded)
|
||||||
try
|
try
|
||||||
|
@ -264,7 +241,7 @@ public abstract class PaymentProcessor
|
||||||
retValue.append(value);
|
retValue.append(value);
|
||||||
return retValue.toString();
|
return retValue.toString();
|
||||||
} // createPair
|
} // createPair
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Encoded
|
* Set Encoded
|
||||||
* @param doEncode true if encode
|
* @param doEncode true if encode
|
||||||
|
@ -281,7 +258,7 @@ public abstract class PaymentProcessor
|
||||||
{
|
{
|
||||||
return m_encoded;
|
return m_encoded;
|
||||||
} // setEncode
|
} // setEncode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Connect Post Properties
|
* Get Connect Post Properties
|
||||||
* @param urlString POST url string
|
* @param urlString POST url string
|
||||||
|
@ -321,7 +298,7 @@ public abstract class PaymentProcessor
|
||||||
log.fine(ms + "ms - " + prop.toString());
|
log.fine(ms + "ms - " + prop.toString());
|
||||||
return prop;
|
return prop;
|
||||||
} // connectPost
|
} // connectPost
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect via Post
|
* Connect via Post
|
||||||
* @param urlString url destination (assuming https)
|
* @param urlString url destination (assuming https)
|
||||||
|
@ -360,5 +337,5 @@ public abstract class PaymentProcessor
|
||||||
//
|
//
|
||||||
return response;
|
return response;
|
||||||
} // connectPost
|
} // connectPost
|
||||||
|
|
||||||
} // PaymentProcessor
|
} // PaymentProcessor
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#Sat Sep 25 06:49:38 MYT 2010
|
#Mon Dec 20 14:26:28 MYT 2010
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
pluginProject.extensions=false
|
pluginProject.extensions=true
|
||||||
resolve.requirebundle=false
|
resolve.requirebundle=false
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: Processor
|
Bundle-Name: Processor
|
||||||
Bundle-SymbolicName: org.adempiere.payment.processor
|
Bundle-SymbolicName: org.adempiere.payment.processor;singleton:=true
|
||||||
Bundle-Version: 1.0.0.qualifier
|
Bundle-Version: 1.0.0.qualifier
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
Require-Bundle: org.adempiere.base;bundle-version="1.0.0"
|
Require-Bundle: org.adempiere.base;bundle-version="1.0.0"
|
||||||
|
@ -9,4 +9,4 @@ Bundle-ClassPath: jpayment.jar,
|
||||||
payflow.jar,
|
payflow.jar,
|
||||||
Verisign.jar,
|
Verisign.jar,
|
||||||
.
|
.
|
||||||
Eclipse-RegisterBuddy: org.adempiere.base
|
|
||||||
|
|
|
@ -4,4 +4,5 @@ bin.includes = META-INF/,\
|
||||||
.,\
|
.,\
|
||||||
jpayment.jar,\
|
jpayment.jar,\
|
||||||
payflow.jar,\
|
payflow.jar,\
|
||||||
Verisign.jar
|
Verisign.jar,\
|
||||||
|
plugin.xml
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?eclipse version="3.4"?>
|
||||||
|
<plugin>
|
||||||
|
<extension
|
||||||
|
id="org.compiere.model.PP_Authorize"
|
||||||
|
name="Authorize.net"
|
||||||
|
point="org.compiere.model.PaymentProcessor">
|
||||||
|
<processor
|
||||||
|
class="org.compiere.model.PP_Authorize"
|
||||||
|
priority="0">
|
||||||
|
</processor>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
id="org.compiere.model.PP_Optimal"
|
||||||
|
name="Optimal"
|
||||||
|
point="org.compiere.model.PaymentProcessor">
|
||||||
|
<processor
|
||||||
|
class="org.compiere.model.PP_Optimal"
|
||||||
|
priority="0">
|
||||||
|
</processor>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
id="org.compiere.model.PP_PayPal"
|
||||||
|
name="PayPal"
|
||||||
|
point="org.compiere.model.PaymentProcessor">
|
||||||
|
<processor
|
||||||
|
class="org.compiere.model.PP_PayPal"
|
||||||
|
priority="0">
|
||||||
|
</processor>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
id="org.compiere.model.PP_PayFlowPro"
|
||||||
|
name="Pay Flow Pro"
|
||||||
|
point="org.compiere.model.PaymentProcessor">
|
||||||
|
<processor
|
||||||
|
class="org.compiere.model.PP_PayFlowPro"
|
||||||
|
priority="0">
|
||||||
|
</processor>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
id="org.compiere.model.PP_PayFlowPro4"
|
||||||
|
name="Pay Flow Pro V4"
|
||||||
|
point="org.compiere.model.PaymentProcessor">
|
||||||
|
<processor
|
||||||
|
class="org.compiere.model.PP_PayFlowPro4"
|
||||||
|
priority="0">
|
||||||
|
</processor>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
</plugin>
|
Loading…
Reference in New Issue