/* * License Notice * * The contents of this file are copyright (c) 2004 JAMM Consulting, Inc. * All Rights Reserved. * * For more information, please visit http://www.JAMMConsulting.com * * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ import java.io.*; import java.net.*; /** * Example that illustrates a simple integration with ProPay's XML interface. */ public class ProPayExample { /** The url to the ProPay test server */ public static final String PROPAY_URL = "http://devtst.propay.com/xml/xml.exe/process"; /** The merchant user name */ private static final String MERCHANT_USER_NAME = "xmlTesting@propay.com"; /** The merchant's test certification string */ private static final String MERCHANT_TEST_CERT_STRING = "111XMLCertStr111"; /** Creates a new instance of ProPayExample */ public ProPayExample() throws Exception { // Create the request for the propay server String request = "\n"; request += "\n"; request += "\n"; request += " "+MERCHANT_USER_NAME+"\n"; request += " "+MERCHANT_TEST_CERT_STRING+"\n"; request += " partner\n"; request += " \n"; request += " 05\n"; request += " 9997\n"; request += " "+MERCHANT_USER_NAME+"\n"; request += " 4222222222222\n"; request += " 1207\n"; request += " 312\n"; request += " G67613E\n"; request += " \n"; request += "\n"; // Connect to the ProPay url URL url = new URL(PROPAY_URL); URLConnection connection = url.openConnection(); if( connection instanceof HttpURLConnection ) ((HttpURLConnection)connection).setRequestMethod("POST"); connection.setDoOutput(true); connection.connect(); // Create a writer to the url and send the request to the ProPay server System.out.println( "Sending:\n"+request ); PrintWriter writer = new PrintWriter(new OutputStreamWriter(connection.getOutputStream())); writer.println(request); writer.flush(); // Get a reader from the url and read back the response System.out.println( "Response:" ); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line = reader.readLine(); while( line != null ) { System.out.println( line ); line = reader.readLine(); } } /** * @param args the command line arguments */ public static void main(String[] args) throws Exception { new ProPayExample(); } }