Hello, I have a php shopping cart and am using a Cyber Source merchant account. The only API they have is a java API. How would you go about putting the variables from the php cart into the Java API or is this possible? Any help would be appreciated.

Damon Doran

    Just checking before I sound too stupid...you mean JSP, correct?

      It a a web Services API written in Java.

      Below is an example of the API. I need to get the results from the PHP shopping cart into this. Any help would be appreciated.

      package com.cybersource.sample;

      import java.util.*;

      import com.cybersource.ws.client.*;

      public class SimpleAuthSample

      {

      public static void main( String[] args )

      {

      Properties props = Utility.readProperties( args );
      
      
      
      HashMap request = new HashMap();
      
      
      
      // we want to do Credit Card Authorization in this sample
      
      request.put( "ccAuthService_run", "true" );
      
      
      
      // add required fields
      
      request.put( "merchantReferenceCode", "MRC-14344" );
      
      
      
      request.put( "billTo_firstName", "Jane" );
      
      request.put( "billTo_lastName", "Smith" );
      
      request.put( "billTo_street1", "1295 Charleston Road" );
      
      request.put( "billTo_city", "Mountain View" );
      
      request.put( "billTo_state", "CA" );
      
      request.put( "billTo_postalCode", "94043" );
      
      request.put( "billTo_country", "US" );
      
      request.put( "billTo_email", "jsmith@example.com" );
      
      
      
      request.put( "card_accountNumber", "4111111111111111" );
      
      request.put( "card_expirationMonth", "12" );
      
      request.put( "card_expirationYear", "2010" );
      
      request.put( "purchaseTotals_currency", "USD" );
      
      
      
      // there are two items in this sample
      
      request.put( "item_0_unitPrice", "12.34" );
      
      request.put( "item_1_unitPrice", "56.78" );
      
      
      
      // add optional fields here according to your business needs
      
      
      
      // See Using the Decision and Reason Code
      
      // for details about processing the reply 
      
      try 
      
      {
      
          HashMap reply = Client.runTransaction( request, props );
      
      } 
      
      catch (ClientException e) {
      
          if (e.isCritical())
      
          {
      
              handleCriticalException( e, request );
      
          }
      
      } 
      
      catch (FaultException e) {
      
          if (e.isCritical())
      
          {
      
              handleCriticalException( e, request );
      
          }    
      
      }

      }

      }

        That does help a bit. What you SHOULD be able to do is to run a system() call, adding the variables you need to the line..

        $sys_call = "merc ".$_POST['var1']." ".$query_row['var2'];
        
        system ( $sys_call, $retvar );
        

        You should get the idea. Hope this helps a bit!

          Write a Reply...