Added payment processor extension.

This commit is contained in:
Heng Sin Low 2010-12-20 14:31:56 +08:00
parent a29a673fc0
commit 9cb417eeaf
8 changed files with 261 additions and 56 deletions

View File

@ -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.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.compiere.model.PaymentProcessor" name="Payment Processor" schema="schema/org.compiere.model.PaymentProcessor.exsd"/>
<extension
id="org.adempiere.base.DefaultModelFactory"
name="Default model factory"

View File

@ -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>

View File

@ -22,9 +22,14 @@ package org.adempiere.base;
import java.net.URL;
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.PaymentProcessor;
import org.compiere.process.ProcessCall;
import org.compiere.util.CLogger;
/**
* This is a facade class for the Service Locator.
@ -35,6 +40,8 @@ import org.compiere.process.ProcessCall;
*/
public class Core {
private final static CLogger s_log = CLogger.getCLogger(Core.class);
/**
* @return list of active resource finder
*/
@ -89,4 +96,43 @@ public class Core {
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;
}
}

View File

@ -30,6 +30,7 @@ import java.util.logging.Level;
import javax.net.ssl.HttpsURLConnection;
import org.adempiere.base.Core;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
@ -62,6 +63,17 @@ public abstract class PaymentProcessor
/** Equals */
public static final char EQ = '=';
/**
*
* @param mpp
* @param mp
*/
public void initialize(MPaymentProcessor mpp, MPayment mp)
{
p_mp = mp;
p_mpp = mpp;
}
/**
* Factory
* @param mpp payment processor model
@ -70,42 +82,7 @@ public abstract class PaymentProcessor
*/
public static PaymentProcessor create (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;
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;
return Core.getPaymentProcessor(mpp, mp);
} // create
/*************************************************************************/

View File

@ -1,4 +1,4 @@
#Sat Sep 25 06:49:38 MYT 2010
#Mon Dec 20 14:26:28 MYT 2010
eclipse.preferences.version=1
pluginProject.extensions=false
pluginProject.extensions=true
resolve.requirebundle=false

View File

@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Processor
Bundle-SymbolicName: org.adempiere.payment.processor
Bundle-SymbolicName: org.adempiere.payment.processor;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.adempiere.base;bundle-version="1.0.0"
@ -9,4 +9,4 @@ Bundle-ClassPath: jpayment.jar,
payflow.jar,
Verisign.jar,
.
Eclipse-RegisterBuddy: org.adempiere.base

View File

@ -4,4 +4,5 @@ bin.includes = META-INF/,\
.,\
jpayment.jar,\
payflow.jar,\
Verisign.jar
Verisign.jar,\
plugin.xml

View File

@ -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>