× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks Scott....

The client import portion comes from cybersource who is our CC validator. I
would want to keep that intact if in the future there might be some changes
in their class, I would want to just copy the .jar file to the iseries and
be done with it.

I will work on doing what I have in ILE and post the results.

Might I say Scott, U DA MAN!!! *lol*

Tim

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Scott Klement
Sent: Wednesday, May 02, 2007 1:36 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: Can a java pgm be converted to rpgle

Hi Tim,

The "import" statement lets you save a bit of typing. When you import a
Java class, you can use the class name without having to specify the
package name every time.


For example, consider the following Java code:

java.util.Properties props = new java.util.Properties();
props.setProperty("merchantID","v2348705");

java.util.HashMap request = new java.util.HashMap();
request.put( "ccAuthService_run", "true" );


If you had a lot of these "java.util.Properties", "java.util.HashMap"
classes in your program, it might become cumbersome to keep typing
"java.util.Properties" over and over again. Lots of typing. So you'd
use an import statement to make it easier. If I import
java.util.Properties, then I don't have to type "java.util" every time I
use it:

import java.util.Properties;
import java.util.HashMap;

Properties props = new Properties();
props.setProperty("merchantID","v2348705");

HashMap request = new HashMap();
request.put( "ccAuthService_run", "true" );


You can use an asterisk ("star") character as a wildcard if you want to
import all classes in a given package. That's what your sample does.. So
instead of individually listing every class I want to use, I could do this:

import java.util.*;

Properties props = new Properties();
props.setProperty("merchantID","v2348705");

HashMap request = new HashMap();
request.put( "ccAuthService_run", "true" );

This lets me import both java.util.Properties and java.util.HashMap in
one go. I can also use any other java.util.xxxxx class the same way, no
need to manually import them all.

So that's what import does. You could certainly re-write your code in
RPG. You'd have to continue to call the Properties, HashMap and Client
classes in Java, however. Unless there's a way to replace that Client
altogether with something written in ILE?


tim wrote:
Hello,



I have a java credit card valiation program that I wish to convert to rpg.
I've seen several posts on calling java methods and such, but can it be
done
with the following code. If so, can someone provide some examples. I guess
the most confusing part is the "import" section.



Thanks.



import java.util.*;

import com.cybersource.ws.client.*;



public class CCAuthorization {



public static void main( String[] args ) {

Properties props = new Properties();

props.setProperty("merchantID","v2348705");


props.setProperty("keysDirectory","/QIBM/UserData/Java400/ext/keys");

props.setProperty("targetAPIVersion","1.2");

props.setProperty("sendToProduction","TRUE");

props.setProperty("enableLog","TRUE");


props.setProperty("logDirectory","/QIBM/UserData/Java400/ext/logs");

props.setProperty("logMaximumSize","100");



String requestID = runAuth( props, args );

}



public static String runAuth( Properties props, String[] args ) {



String requestID = null;

try {



HashMap request = new HashMap();



request.put( "ccAuthService_run", "true" );

request.put( "merchantReferenceCode", args[13] );

request.put( "billTo_firstName", args[0]);

request.put( "billTo_lastName", args[1]);

request.put( "billTo_street1", args[2]);

request.put( "billTo_city", args[3]);

request.put( "billTo_state", args[4]);

request.put( "billTo_postalCode", args[5]);

request.put( "billTo_country", args[6] );

request.put( "billTo_email", args[8] );

request.put( "billTo_phoneNumber", args[9] );

request.put( "card_accountNumber", args[10] );

request.put( "card_expirationMonth", args[11] );

request.put( "card_expirationYear", args[12] );

request.put( "purchaseTotals_currency","USD");

request.put( "item_0_unitPrice", args[14]);

request.put( "comments", args[15]);





HashMap reply = Client.runTransaction( request, props );



args[24] = (String) reply.get( "decision" );

args[25] = (String) reply.get( "reasonCode" );

args[26] = (String) reply.get( "requestID" );



if ("ACCEPT".equalsIgnoreCase(
args[24]
))

{



args[28] = (String)
reply.get( "ccAuthReply_amount" );

args[29] = (String) reply.get(
"ccAuthReply_authorizationCode");



requestID = (String)
reply.get( "requestID" );



request = new HashMap();



request.put(
"ccCaptureService_run", "true" );

request.put(
"merchantReferenceCode", args[13] );

request.put(
"ccCaptureService_authRequestID", requestID);

request.put(
"purchaseTotals_currency", "USD" );

request.put(
"item_0_unitPrice", args[14]);



reply =
Client.runTransaction( request, props );





} else {



args[28] = (String)
reply.get("ccAuthReply_avsCode" );

args[29] = (String)
reply.get("ccAuthReply_authFactorCode");



}



} catch (ClientException e) {

System.out.println( e.getMessage() );

} catch (FaultException e) {

System.out.println( e.getMessage() );

}





return( requestID );

}

}



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.