Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

HELP with Streamline Payment Module


genusmind

Recommended Posts

hi

 

i am setting up a store but i use streamline e-solutions payment and there is no module for that ready in here i saw couple of posts but not usefull

 

 

lets make this module and stop people from having same problem we have

 

the programmer i was hired for this sucked he just got the money and lied to me that he finished it

 

here are a some files from the company you may find it helpfull

 

 

thanks

 

/*
* submitXMLExample.java
*
* Created on April 4, 2001, 5:06 PM
*/

import java.net.*;
import java.io.*;
import java.util.Date;
import java.security.Security;

/**
* @author  Robert Kraal, RBS e-Solutions
* $date$
* $revision$ 010502 - a3 removed admincode
* 010516 rk ordercode
* This class requires jsse.jar, jnet.jar and jcert.jar in your classpath
* More information can be found at http://java.sun.com/products/jsse/
*/
public class SubmitXMLExample{
// Enter the MerchantCode you have retrieved from eSolutions
private final static String merchantCode = "MERCHANTCODE";

// Enter the username you have retrieved from eSolutions
// The username will generally be the merchantCode
private final static String userName = "MERCHANTCODE";

// Enter the password you have retrieved from eSolutions
private final static String passWord = "XMLpassword";

// Enter here the URL
// for the production environment use: https://secure.streamline-esolutions.com:443/jsp/merchant/xml/paymentService.jsp
// for the test environment use: https://secure-test.streamline-esolutions.com:443/jsp/merchant/xml/paymentService.jsp
private final static String location = "https://secure-test.streamline-esolutions.com:443/jsp/merchant/xml/paymentService.jsp";

private static HttpURLConnection huc;

/** Creates new submitXMLExample */
public SubmitXMLExample() {
}

/**
 * @param args the command line arguments
 */
public static void main (String args[]) {
	Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
	System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
	System.out.println(sendXml(createXML()));
}

/*
 * creates an XML message
 * In this case an XML message is composed that sends a single order with a paymentmethod mask
 */
private static String createXML() {
	StringBuffer xmlMessage = new StringBuffer();
	// order code should be unique, the date is unique..
	String orderCode= ""+System.currentTimeMillis();
	xmlMessage.append("<?xml version=\"1.0\"?>");
	xmlMessage.append("<!DOCTYPE paymentService PUBLIC ");
	xmlMessage.append("\"-//streamline-esolutions//DTD Streamline PaymentService v1//EN\" ");
	xmlMessage.append("\"http://dtd.streamline-esolutions.com/paymentService_v1.dtd\">");
	xmlMessage.append("<paymentService version=\"1.4\" merchantCode=\""+merchantCode+"\">");
	xmlMessage.append("<submit>");
	xmlMessage.append("<order orderCode=\""+orderCode+"\">");
	xmlMessage.append("<description>Your Order</description>");
	xmlMessage.append("<amount currencyCode=\"GBP\" value=\"5000\" exponent=\"2\"/>");
	xmlMessage.append("<orderContent>Uw order</orderContent>");
	xmlMessage.append("<paymentMethodMask>");
	xmlMessage.append("<include code=\"ALL\"/>");
	xmlMessage.append("</paymentMethodMask>");
	xmlMessage.append("</order>");
	xmlMessage.append("</submit>");
	xmlMessage.append("</paymentService>");
	return xmlMessage.toString();
}

/*
 * Sends a xml message using a secure connection and username password authentication
 */
public static String sendXml(String theXMLMessage) {
	StringBuffer response = new StringBuffer();
	try{
		URL url = new URL(location);
		huc = (HttpURLConnection)url.openConnection();
		huc.setRequestMethod("POST");
		huc.setRequestProperty("Authorization", "Basic "+encodeBase64((userName+":"+passWord).getBytes()));
		huc.setRequestProperty("Host", url.getHost());
		huc.setDoOutput(true);
		PrintWriter writer = new PrintWriter(huc.getOutputStream());
		writer.println(theXMLMessage);
		writer.flush();
		writer.close();
		BufferedReader br = new BufferedReader(new InputStreamReader(huc.getInputStream()));
		String line;
		while((line = br.readLine()) != null){
			response.append(line);
			response.append("\n");
		}
	}catch(MalformedURLException mfue){	
		response.append("The URL is incorrect : ");
		response.append(location);
	}catch(IOException ioe){ 
		response.append("A connection problem has occured, this could be caused by:\n");
		response.append(" - The userName is not correct : "+ userName+ "; Check with eSolutions support at [email protected]\n");
		response.append(" - The password is not correct; Check with eSolutions support at [email protected]\n");
		response.append(" - The URL is not correct : "+ location +"; Review the documentation\n");
		response.append(" - You are behind a firewall that does not allow secure connections; Contact your network administrator\n");
	}
	return response.toString().trim();
}

/*
 * encodes a string to Base 64
 */
public static String encodeBase64(byte[] d){
	if (d == null) return null;
	byte data[] = new byte[d.length+2];
	System.arraycopy(d, 0, data, 0, d.length);
	byte dest[] = new byte[(data.length/3)*4];

	// 3-byte to 4-byte conversion
	for (int sidx = 0, didx=0; sidx < d.length; sidx += 3, didx += 4){
		dest[didx]   = (byte) ((data[sidx] >>> 2) & 077);
		dest[didx+1] = (byte) ((data[sidx+1] >>> 4) & 017 | (data[sidx] << 4) & 077);
		dest[didx+2] = (byte) ((data[sidx+2] >>> 6) & 003 | (data[sidx+1] << 2) & 077);
		dest[didx+3] = (byte) (data[sidx+2] & 077);
	}

	// 0-63 to ascii printable conversion
	for (int idx = 0; idx <dest.length; idx++)
	{
		if (dest[idx] < 26)	 dest[idx] = (byte)(dest[idx] + 'A');
		else if (dest[idx] < 52)  dest[idx] = (byte)(dest[idx] + 'a' - 26);
		else if (dest[idx] < 62)  dest[idx] = (byte)(dest[idx] + '0' - 52);
		else if (dest[idx] < 63)  dest[idx] = (byte)'+';
		else dest[idx] = (byte)'/';
	}

	// add padding
	for (int idx = dest.length-1; idx > (d.length*4)/3; idx--){
		dest[idx] = (byte)'=';
	}
	return new String(dest);
}
}

/*
$log:$
*/

 

 

this code i dont know what it is

 

 

and the sample files you may need to make this module

 

please try it once

 

http://www.afgsapce.com/friends/streamline.zip

Link to comment
Share on other sites

  • 3 weeks later...
Did you get anywhere with this. Im no programmer so can't help but would love a contrib for this

 

 

 

 

No Daz,

 

honestly i tried one week and still trying but i get no where as i am noway programmer

 

 

can you give it a try please???

Link to comment
Share on other sites

  • 3 weeks later...

Hi

Do you have any success with the module, if not I am just making such module and i am waiting the test card number, and if everything is ok I can give you the code .

 

I am not putting it as contribution becouse there a lot of things tobe done to become a contribution, most of the things are hardcoded in the moment

Link to comment
Share on other sites

yes that would be fine

but as emil_nenov

 

said lots of things need to be done besides its hardcoded

 

lets test it and then contribute it

:) :D

 

I will take a care to make it like contribution, if the tests are ok, we will go it and contribute it.

The cntributions won't take long after that.

 

:)

Open Source is the best

Edited by emil_nenov
Link to comment
Share on other sites

  • 4 weeks later...
  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...