• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: authorize.net integration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: authorize.net integration


  • Subject: Re: authorize.net integration
  • From: Dov Rosenberg <email@hidden>
  • Date: Thu, 23 Sep 2004 22:42:14 -0400

Authorize.net has some sample code in their online documentation. Overall
the integration is pretty simple. You basically build up a string with the
required transaction parameters and pass it to a URL. You need to refer to
the documentation to know the return codes and all of the possible
parameters to pass.

Here is some code that I have used:

....
// standard variables for basic Java AIM test
            // use your own values where appropriate

            StringBuffer sb = new StringBuffer();

            // mandatory name/value pairs for all AIM CC transactions
            // as well as some "good to have" values
            sb.append("x_login=yyyyyyyyy&"); // replace with your own
            sb.append("x_tran_key=xxxxxxxx&"); // replace with your own
            sb.append("x_version=3.1&");
            sb.append("x_test_request=TRUE&"); // for testing
            sb.append("x_method=CC&");
            sb.append("x_type=AUTH_CAPTURE&");
            sb.append("x_amount=" + cost + "&");
            sb.append("x_delim_data=TRUE&");
            sb.append("x_delim_char=|&");
            sb.append("x_relay_response=FALSE&");
            sb.append("x_first_name=" + eo.firstName() + "&");
            sb.append("x_last_name=" + eo.lastName() + "&");
            sb.append("x_company=" + eo.groupName() + "&");
            Address billingAddress = eo.getBillingAddress();
            if (billingAddress != null) {
                sb.append("x_address=" + billingAddress.address1() + "&");
// billing adddress
                sb.append("x_city=" + billingAddress.city() + "&");
                sb.append("x_state=" + billingAddress.state() + "&");
                sb.append("x_zip=" + billingAddress.postalCode() + "&");
                sb.append("x_country=US&");
            }
            sb.append("x_phone=" + eo.phone() + "&");
            sb.append("x_email=" + eo.emailAddress() + "&");
            sb.append("x_customer_ip=" + request._remoteAddress() + "&");

                sb.append("x_customer_organization_type=I&");


            // CC information
            sb.append("x_card_num=" + eo.cardNumber() + "&");
            sb.append("x_exp_date=" + eo.expirationMonth().toString() + "/"
+ eo.expirationYear().toString() + "&");

            // not required...but my test account is set up to require it
            sb.append("x_description=some descriptive text&");

            // open secure connection
            URL url = null;
            if (true) { // test mode
                url = new
URL("https://certification.authorize.net/gateway/transact.dll";);
            } else { // real mode
                // real transactions
                url = new
URL("https://secure.authorize.net/gateway/transact.dll";);
            }

            /* NOTE: If you want to use SSL-specific features,change to:
                  HttpsURLConnection connection = (HttpsURLConnection)
url.openConnection();
            */

            URLConnection connection = url.openConnection();
            connection.setDoOutput(true);
            connection.setUseCaches(false);

            // not necessarily required but fixes a bug with some servers
            connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");

            // POST the data in the string buffer
            DataOutputStream out = new
DataOutputStream(connection.getOutputStream());
            out.write(sb.toString().getBytes());
            out.flush();
            out.close();

            // process and read the gateway response
            BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
            String line;
            line = in.readLine();

            StringTokenizer st = new StringTokenizer(line, "|");
            Vector tokens = new Vector();

            while (st.hasMoreTokens()){
                String token = st.nextToken();
                tokens.add(token);
            }

            System.out.println("Approval Code: " +
(String)tokens.elementAt(4)); //approval code is 5 position

            System.out.println("transaction code: " +
(String)tokens.elementAt(6)); // transaction code is 7th position
            in.close(); // no more data

...




On 9/23/04 3:08 PM, "Kieran Kelleher" <email@hidden> wrote:

> Any pointers on where I could get resources to integrate credit card
> processing (for example using authorize.net). By resources, I mean
> sample code, classes, how-to's, etc.
>
> Any help appreciated,
>
> Kieran
>
>
> ________________________________________________________________
> Dev Config = OS X 10.3.4 / Java 1.4.2_05 /  WO 5.2.3 / XCode v1.5 /
> MySQL 4.0.20 / Connector-J 3.0.11
> Deploy Config = OS X 10.3.4 Server / Java 1.4.2_05 / WO 5.2.3 / MySQL
> 4.0.20 / Connector-J 3.0.11
> My Blog: http://webobjects.webhop.org/
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> n.com
>
> This email sent to email@hidden

--
Dov Rosenberg
Conviveon Corporation
370 Centerpointe Circle, suite 1178
Altamonte Springs, FL 32701
http://www.conviveon.com
email@hidden
AOL IM: dovrosenberg
(407) 339-1177 x102
(407) 339-6704 (fax)
(800) 475-9890
(407) 310-8316 (cell)

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >authorize.net integration (From: Kieran Kelleher <email@hidden>)

  • Prev by Date: Re: Deploying WebObjects in the Windows World
  • Next by Date: Custom frameworks with references to Application and Session
  • Previous by thread: Re: authorize.net integration
  • Next by thread: Java 1.4.2 Update 2 is now available
  • Index(es):
    • Date
    • Thread