runTransaction

Runs a transaction using the Transaction API.

Description

This method duplicates the functionality of the gateway API. It can be used to run a wide variety of transaction types including sales, credits, authonly, void, and checks.

The parameters argument is a TransactionRequestObject containing any of the variable names supported by the Transaction API (See the docs for a list of valid field names). Make sure to remove the UM from the front of the field names. (ie: UMamount should be passed as Amount.)

See also runSale, runCredit, runAuthOnly, runQuickSale, postAuth, captureTransaction, voidTransaction, getTransactionStatus, getTransaction, getTransactionCustom, searchTransactions, searchTransactionsCustom, getTransactionReport

Syntax

TransactionResponse runTransaction ( ueSecurityToken Token, TransactionRequestObject Parameters

Arguments

Type Name Description
ueSecurityToken Token Merchant security token: used to identify merchant and validate transaction.
TransactionRequestObject Parameters Request transaction details from all fields of the transaction form, including reference number, transaction amount, customer ID, currency, authorization code, and any other information entered at the time of the transaction.

Return Value

Name Description
TransactionResponse Returns a TransactionResponse object containing the results of the transaction and all relevant data.

Examples

PHP

For directions on how to set up the WSDL link, create "$token" and "$client", go to PHP Soap How-to.

    <?php

    try {

      $Request=array(
        'AccountHolder' => 'Tester Jones',
        'Details' => array(
          'Description' => 'Example Transaction',
          'Amount' => '4.00',
          'Invoice' => '44539'
        ),
        'CreditCardData' => array(
          'CardNumber' => '4444555566667779',
          'CardExpiration' => '0919',
          'AvsStreet' => '1234 Main Street',
          'AvsZip' => '99281',
          'CardCode' => '999'
        )
      );

      $res=$client->runTransaction($token, $Request);

      print_r($res);

    }
    catch (SoapFault $e){
      echo $client->__getLastRequest();
      echo $client->__getLastResponse();
      die("runTransaction failed :" .$e->getMessage());
    }            

Java

This example uses the Newtek Gateway Java library. For directions on how to install the library and create the token/client objects, go to the Java JAX-WS Howto.

    try {
      TransactionRequestObject params = new TransactionRequestObject();

      // set card holder name
        params.setAccountHolder("Test Joe");
        params.setCommand("Sale");

      // populate transaction details
      TransactionDetail details = new TransactionDetail();
          details.setAmount(22.34);
          details.setDescription("My Test Sale");
          details.setInvoice("119891");
        params.setDetails(details);

      // populate credit card data
      CreditCardData ccdata = new CreditCardData();
          ccdata.setCardNumber("4444555566667779");
          ccdata.setCardExpiration("0919");
          ccdata.setCardCode("999");
        params.setCreditCardData(ccdata);


      // Create request object
      RunTransaction request = new RunTransaction();
        request.setToken(token);

      // Create response object
      TransactionResponse response;

      // run transaction
      response = client.runTransaction(token, params);

      System.out.println("Result: " + response.getResult());
    } catch (Exception e) {
        System.out.println("Soap Exception: " + e.getMessage());
    }

Visual Basic (.Net)

For directions on how to set up the WSDL link, create "token" and "client", go to Visual Basic .Net Soap How-to.

    Dim client As newtek.newtekService = New newtek.newtekService
            Dim token As newtek.ueSecurityToken

            token = Me.CreateToken("714SSUxv1uohng2XkMJ7kLpETsu58G66", "1234")



            Dim tran As newtek.TransactionRequestObject = New newtek.TransactionRequestObject

            tran.CreditCardData = New newtek.CreditCardData
            tran.CreditCardData.CardNumber = "4444555566667779"
            tran.CreditCardData.CardExpiration = "0919"
            tran.CreditCardData.CardCode = "999"

            tran.Details = New newtek.TransactionDetail
            tran.Details.Amount = 9.02
            tran.Details.AmountSpecified = True
            tran.Details.Invoice = "434534"
            tran.Details.Description = "Example transaction"

            tran.Command = "sale"


            Dim response As newtek.TransactionResponse

            response = client.runTransaction(token, tran)

            If response.ResultCode = "A" Then
                MsgBox("Transaction Approved, Refernce Number: " & response.RefNum)
            ElseIf response.ResultCode = "D" Then
                MsgBox("Transaction Declined, Reason: " & response.Error)
            Else
                MsgBox("Transaction Error, Reason: " & response.Error)
            End If

C Sharp (.Net)

For directions on how to set up the WSDL link, create "token" and "client", go to C Sharp .Net Soap How-to.

    newtek.TransactionRequestObject tran = new newtek.TransactionRequestObject();

    tran.Command = "cc:sale";
    tran.Details =  new newtek.TransactionDetail();
    tran.Details.Amount = 1.00;
    tran.Details.AmountSpecified = true;
    tran.Details.Invoice = "1234";
    tran.Details.Description = "Example Transaction";

    tran.CreditCardData = new newtek.CreditCardData();
    tran.CreditCardData.CardNumber = "4444555566667779";
    tran.CreditCardData.CardExpiration = "0919";

    newtek.TransactionResponse response = new newtek.TransactionResponse();

    try
    {
        response = client.runTransaction(token, tran);

        if (response.ResultCode == "A")
        {
            MessageBox.Show(string.Concat("Transaction Approved, RefNum: ",
                    response.RefNum));
        }
        else
        {
            MessageBox.Show(string.Concat("Transaction Failed: ",
                    response.Error));
        }
    }
    catch (Exception err)
    {
        MessageBox.Show(err.Message);
    }

XML

Request:

<?xml version="1.0" encoding="UTF-8"?>
   <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:newtek"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
         <ns1:runTransaction>
            <Token xsi:type="ns1:ueSecurityToken">
               <ClientIP xsi:type="xsd:string"> 123.123.123.123 </ClientIP>
               <PinHash xsi:type="ns1:ueHash">
                  <HashValue xsi:type="xsd:string"> 58bdbfeb7c15078fa62291bd6a4473990dd50dd8 </HashValue>
                   <Seed xsi:type="xsd:string"> 11139209200-test </Seed>
                   <Type xsi:type="xsd:string"> sha1 </Type>
                </PinHash>
                <SourceKey xsi:type="xsd:string"> _B4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT </SourceKey>
             </Token>
             <Parameters xsi:type="ns1:TransactionRequestObject">
                <AccountHolder xsi:type="xsd:string"> Tester Jones </AccountHolder>
                <BillingAddress xsi:type="ns1:Address">
                   <City xsi:type="xsd:string"> Albany </City>
                   <Company xsi:type="xsd:string"> testing </Company>
                   <Country xsi:type="xsd:string"> Un </Country>
                   <FirstName xsi:type="xsd:string"> Timmy </FirstName>
                   <LastName xsi:type="xsd:string"> Rodriguez </LastName>
                   <Phone xsi:type="xsd:string"> -5555 </Phone>
                   <State xsi:type="xsd:string"> APO AE 09021 </State>
                   <Street xsi:type="xsd:string"> 180 State st </Street>
                   <Street2 xsi:type="xsd:string"> 133 Lancaster st </Street2>
                   <Zip xsi:type="xsd:string"> 12210 </Zip>
                </BillingAddress>

                <ClientIP xsi:type="xsd:string"> 123.123.123.123 </ClientIP>
                <Command xsi:type="xsd:string"> sale </Command>
                <CreditCardData xsi:type="ns1:CreditCardData">
                   <AvsStreet xsi:type="xsd:string"> 1234 Main Street </AvsStreet>
                   <AvsZip xsi:type="xsd:string"> 99281 </AvsZip>
                   <CardCode xsi:type="xsd:string"> 999 </CardCode>
                   <CardExpiration xsi:type="xsd:string"> 1018 </CardExpiration>
                   <CardNumber xsi:type="xsd:string"> 4444555566667779 </CardNumber>
                </CreditCardData>
                <CustomerID xsi:type="xsd:string"> 123456 </CustomerID>
                <CustomFields SOAP-ENC:arrayType="ns1:FieldValue[2]" xsi:type="ns1:FieldValueArray">
                   <item xsi:type="ns1:FieldValue">
                      <Field xsi:type="xsd:string"> custom1 </Field>
                      <Value xsi:type="xsd:string"> Cya </Value>
                   </item>
                   <item xsi:type="ns1:FieldValue">
                      <Field xsi:type="xsd:string"> custom2 </Field>
                      <Value xsi:type="xsd:string"> Booyah </Value>
                   </item>
                </CustomFields>
                <CustReceipt xsi:type="xsd:boolean"> true </CustReceipt>
                <Details xsi:type="ns1:TransactionDetail">
                   <Amount xsi:type="xsd:double"> 5.99 </Amount>
                   <Clerk xsi:type="xsd:string"> John Doe </Clerk>
                   <Currency xsi:type="xsd:string"> 0 </Currency>
                   <Description xsi:type="xsd:string"> Example Transaction </Description>
                   <Invoice xsi:type="xsd:string"> 44539 </Invoice>
                   <OrderID xsi:type="xsd:string"> 12345 </OrderID>
                   <PONum xsi:type="xsd:string"> 54321 </PONum>
                   <Shipping xsi:type="xsd:double"> 2 </Shipping>
                   <Table xsi:type="xsd:string"> 1 </Table>
                   <Terminal xsi:type="xsd:string"> 15 </Terminal>
                </Details>
                <LineItems SOAP-ENC:arrayType="ns1:LineItem[2]" xsi:type="ns1:LineItemArray">
                   <item xsi:type="ns1:LineItem">
                      <SKU xsi:type="xsd:string"> 1234 </SKU>
                      <ProductName xsi:type="xsd:string"> Boogers </ProductName>
                      <Description xsi:type="xsd:string"> Rock On </Description>
                      <UnitPrice xsi:type="xsd:string"> 19.99 </UnitPrice>
                      <Qty xsi:type="xsd:string"> 9 </Qty>
                      <Taxable xsi:type="xsd:boolean"> true </Taxable>
                   </item>
                   <item xsi:type="ns1:LineItem">
                      <SKU xsi:type="xsd:string"> 333 </SKU>
                      <ProductName xsi:type="xsd:string"> Stuff </ProductName>
                      <Description xsi:type="xsd:string"> Yahoo </Description>
                      <UnitPrice xsi:type="xsd:string"> 19.21 </UnitPrice>
                      <Qty xsi:type="xsd:string"> 5 </Qty>
                      <Taxable xsi:type="xsd:boolean"> true </Taxable>
                   </item>
                </LineItems>
                <ShippingAddress xsi:type="ns1:Address">
                   <City xsi:type="xsd:string"> Los Angeles </City>
                   <Company xsi:type="xsd:string"> SomeOtherCompany </Company>
                   <Country xsi:type="xsd:string"> Un </Country>
                   <FirstName xsi:type="xsd:string"> Ship </FirstName>
                   <LastName xsi:type="xsd:string"> Tome </LastName>
                   <Phone xsi:type="xsd:string"> 3133129163 </Phone>
                   <State xsi:type="xsd:string"> CA </State>
                   <Street xsi:type="xsd:string"> 9999 s sycamore </Street>
                   <Street2 xsi:type="xsd:string"> 9999 Lancaster st </Street2>
                   <Zip xsi:type="xsd:string"> 90036 </Zip>
                </ShippingAddress>
             </Parameters>
          </ns1:runTransaction>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

Response:

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:newtek"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <ns1:runTransactionResponse>
      <runTransactionReturn xsi:type="ns1:TransactionResponse">
        <AcsUrl xsi:type="xsd:string">  </AcsUrl>
        <AuthAmount xsi:type="xsd:double"> 5.99 </AuthAmount>
        <AuthCode xsi:type="xsd:string"> 025821 </AuthCode>
        <AvsResult xsi:type="xsd:string"> Address: Match &amp; 5 Digit Zip: Match </AvsResult>
        <AvsResultCode xsi:type="xsd:string"> YYY </AvsResultCode>
        <BatchNum xsi:type="xsd:string"> 1 </BatchNum>
        <BatchRefNum xsi:type="xsd:string"> 9597 </BatchRefNum>
        <CardCodeResult xsi:type="xsd:string"> Match </CardCodeResult>
        <CardCodeResultCode xsi:type="xsd:string"> M </CardCodeResultCode>
        <CardLevelResult xsi:type="xsd:string"> Visa Traditional </CardLevelResult>
        <CardLevelResultCode xsi:type="xsd:string"> A </CardLevelResultCode>
        <ConversionRate xsi:type="xsd:double"> 0 </ConversionRate>
        <ConvertedAmount xsi:type="xsd:double"> 0 </ConvertedAmount>
        <ConvertedAmountCurrency xsi:type="xsd:string"> 840 </ConvertedAmountCurrency>
        <CustNum xsi:type="xsd:string"> 0 </CustNum>
        <Error xsi:type="xsd:string"> Approved </Error>
        <ErrorCode xsi:type="xsd:integer"> 0 </ErrorCode>
        <isDuplicate xsi:type="xsd:boolean"> false </isDuplicate>
        <Payload xsi:type="xsd:string">  </Payload>
        <RefNum xsi:type="xsd:string"> 100071480 </RefNum>
        <Result xsi:type="xsd:string"> Approved </Result>
        <ResultCode xsi:type="xsd:string"> A </ResultCode>
        <Status xsi:type="xsd:string"> Pending </Status>
        <StatusCode xsi:type="xsd:string"> P </StatusCode>
        <VpasResultCode xsi:type="xsd:string">  </VpasResultCode>
      </runTransactionReturn>
    </ns1:runTransactionResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>