Class BaseTransaction

java.lang.Object
paypal.payflow.BaseTransaction
Direct Known Subclasses:
AuthorizationTransaction, BuyerAuthTransaction, CreditTransaction, RecurringTransaction, ReferenceTransaction, SaleTransaction, VoiceAuthTransaction

public class BaseTransaction extends Object
This class is the base class for all transaction objects. It has methods for generating the transaction request, sending it to the server and obtaining the response.

This class can be extended to create a new transaction type.

This example shows how to create and perform an Sale transaction using a Basetransaction Object. *

.......... .......... //Populate required data objects. .......... .......... *

//Create a new Base Transaction. BaseTransaction trans = new BaseTransaction("S",User, Connection, Inv, Card, PayflowUtility.RequestId); *

//Submit the transaction. trans.submitTransaction(); // Get the Response Response resp = trans.getResponse(); *

// Display the transaction response parameters. if (resp != null) { // Get the Transaction Response parameters. TransactionResponse trxnResponse = resp.getTransactionResponse(); *

if (TrxnResponse != null) { System.out.println("RESULT = " + trxnResponse.getResult()); System.out.println("PNREF = " + trxnResponse.getPnref()); System.out.println("RESPMSG = " + trxnResponse.getRespMsg()); System.out.println("AUTHCODE = " + trxnResponse.getAuthCode()); System.out.println("AVSADDR = " + trxnResponse.getAVSAddr()); System.out.println("AVSZIP = " + trxnResponse.getAVSZip()); System.out.println("IAVS = " + trxnResponse.getIAVS()); } // Get the Fraud Response parameters. FraudResponse fraudResp = resp.getFraudResponse(); if (fraudResp != null) { System.out.println("PREFPSMSG = " + fraudResp.getPreFpsMsg()); System.out.println("POSTFPSMSG = " + fraudResp.getPostFpsMsg()); } *

// Display the response. System.out.println(PayflowUtility.getStatus(Resp)); *

// Get the Transaction Context and check for any contained SDK specific errors (optional code). Context transCtx = resp.getTransactionContext(); if (transCtx != null && transCtx.getErrorCount() %3E 0) { System.out.println(+ "Transaction Errors = " + transCtx.toString()); } }

  • Field Details

    • requestId

      public String requestId
      Unique request id for the transaction.

      Maps to Payflow Parameter in header - PAYFLOW-REQUEST-ID

  • Constructor Details

    • BaseTransaction

      protected BaseTransaction()
      protected Constructor. This prevents creation of an empty Transaction object.
    • BaseTransaction

      public BaseTransaction(String strTrxType, UserInfo objUserInfo, PayflowConnectionData objpayflowConnectionData, String requestId)
      Parameters:
      strTrxType - String transaction type
      objUserInfo - UserInfo : UserInfo object populated with user credentials
      objpayflowConnectionData - PayflowConnectionData
      requestId - String
    • BaseTransaction

      public BaseTransaction(String strTrxType, UserInfo objUserInfo, String requestId)
      Parameters:
      strTrxType - String
      objUserInfo - UserInfo : UserInfo object populated with user credentials
      requestId - String
    • BaseTransaction

      public BaseTransaction(String strTrxType, UserInfo objUserInfo, PayflowConnectionData objpayflowConnectionData, Invoice objInvoice, String requestId)
      Parameters:
      strTrxType - String
      objUserInfo - UserInfo : UserInfo object populated with user credentials
      objpayflowConnectionData - PayflowConnectionData : Connection credentials object
      objInvoice - Invoice : Invoice object
      requestId - String
    • BaseTransaction

      public BaseTransaction(String strTrxType, UserInfo objUserInfo, Invoice objInvoice, String requestId)
      Parameters:
      strTrxType - String : transaction type
      objUserInfo - UserInfo : UserInfo object populated with user credentials
      objInvoice - Invoice : Invoice Object
      requestId - String
    • BaseTransaction

      public BaseTransaction(String strTrxType, UserInfo objUserInfo, PayflowConnectionData objpayflowConnectionData, Invoice objInvoice, BaseTender objTender, String requestId)
      Parameters:
      strTrxType - String : Transaction type
      objUserInfo - UserInfo : UserInfo object populated with user credentials
      objpayflowConnectionData - PayflowConnectionData : Connection credentials object
      objInvoice - Invoice : Invoice object
      objTender - BaseTender : Tender object such as CardTender
      requestId - String
    • BaseTransaction

      public BaseTransaction(String strTrxType, UserInfo objUserInfo, Invoice objInvoice, BaseTender objTender, String requestId)
      Parameters:
      strTrxType - String : Transaction type
      objUserInfo - UserInfo : UserInfo object populated with user credentials
      objInvoice - : Invoice object
      objTender - BaseTender : Tender object such as CardTender
      requestId - String
  • Method Details

    • getBuyerAuthStatus

      public BuyerAuthStatus getBuyerAuthStatus()
      Returns:
      Buyer auth status object
    • setBuyerAuthStatus

      public void setBuyerAuthStatus(BuyerAuthStatus buyerAuthStatus)
      Sets buyer
      Parameters:
      buyerAuthStatus - buyer auth status object
    • getClientInfo

      public ClientInfo getClientInfo()
    • setClientInfo

      public void setClientInfo(ClientInfo clientInfo)
    • getExtData

      public ArrayList getExtData()
      Gets the extend data list.
      Returns:
      extData ArrayList ............ //Trans is the transaction object. ............ ArrayList extDataList = trans.getExtendData();
    • setExtData

      public void setExtData(ExtendData extData)
      sets extData ArrayList
      Parameters:
      extData - ArrayList
    • getRequest

      public String getRequest()
      Transaction request in Name-Value Pair format.
      Returns:
      request String TRXTYPE[1]=S&ACCT[16]=5105105105105100&EXPDATE[4]=0109&TENDER[1]=C&INVNUM[8]=INV12345&AMT[5]=25.12 USER=user&VENDOR=vendor&PARTNER=partner&PWD=password
    • getRequestId

      public String getRequestId()
    • setRequestId

      public void setRequestId(String requestId)
      Parameters:
      requestId - String ............ //Trans is the transaction object. //A unique RequestId can be generated //using the PayflowUtility.getRequestId() property. ............ trans.setRequestId(PayflowUtility.getRequestId(); System.out.println("Transaction RequestId = " + trans.getRequestId());
    • getResponse

      public Response getResponse()
      Gets the transaction response object.
      Returns:
      response Response ............ //Trans is the transaction object. ............ *

      //Submit the transaction. trans.submitTransaction(); *

      // Get the Response. Response resp = trans.getResponse(); if (resp != null) { // Get the Transaction Response parameters. TransactionResponse trxnResponse = resp.getTransactionResponse(); if (trxnResponse != null) { System.out.println("RESULT = " + trxnResponse.getResult()); System.out.println("PNREF = " + trxnResponse.getPnref()); System.out.println("RESPMSG = " + trxnResponse.getRespMsg()); System.out.println("AUTHCODE = " + trxnResponse.getAuthCode()); System.out.println("AVSADDR = " + trxnResponse.getAVSAddr()); System.out.println("AVSZIP = " + trxnResponse.getAVSZip()); System.out.println("IAVS = " + trxnResponse.getIAVS()); } // Get the Fraud Response parameters. FraudResponse fraudResp = resp.getFraudResponse(); if (fraudResp != null) { System.out.println("PREFPSMSG = " + fraudResp.getPreFpsMsg()); System.out.println("POSTFPSMSG = " + fraudResp.getPostFpsMsg()); } } // Get the Context and check for any contained SDK specific errors. Context ctx = resp.getTransactionContext(); if (ctx != null ++ Ctx.getErrorCount() %3E 0) { System.out.println(Environment.NewLine + "Errors = " + Ctx.ToString()); }

    • getTender

      public BaseTender getTender()
      gets the tender object
      Returns:
      tender BaseTender
    • setTender

      public void setTender(BaseTender tender)
      Tender object for ACH, Credit Card, PINless Debit & eCheck.
      Parameters:
      tender - BaseTender Allowed Tender Types are: Tender Type : Tender Name A - ACH (Automatic Clearing House) C - Credit Card D - PINLess Debit K - e-Check (TeleCheck)

      Each Tender type Maps to Payflow Parameter - TENDER

      See Also:
    • getTrxType

      public String getTrxType()
      Type of transaction to perform, indicated by a single character. Credit payments require an ORIGID referring to an earlier Debit/Sale payment, and the AMT must be empty or the exact amount of the original Debit/Sale payment.
      Returns:
      trxType String

      Maps to Payflow Parameter - TRXTYPE

      Allowed TrxType values are: Transaction Type - Transaction Name S - Sale/Debit A - Voice Authorization/Force C - Credit V - Void D - Delayed Capture F - Force/Voice Authorization I - Inquiry R - Recurring billing
    • getVerbosity

      public String getVerbosity()
      Value (LOW, MEDIUM or HIGH) that controls the detail level and format of transaction results. LOW (default) returns normalized values. MEDIUM or HIGH return the processor's raw response values.

      Maps to Payflow Parameter - VERBOSITY

      Returns:
      verbosity String ............ //Trans is the transaction object. ............ trans.setVerbosity( "HIGH"); System.out.println("Transaction Type = " + Trans.getTrxType())
    • setVerbosity

      public void setVerbosity(String verbosity)
      Value (LOW, MEDIUM or HIGH) that controls the detail level and format of transaction results. LOW (default) returns normalized values. MEDIUM or HIGH return the processor's raw response values.

      Maps to Payflow Parameter - VERBOSITY

      Parameters:
      verbosity - String ............ //Trans is the transaction object. ............ trans.setVerbosity( "HIGH"); System.out.println("Transaction Type = " + Trans.getTrxType())
    • getContext

      protected Context getContext()
      Gets the context object of the current transaction.
      Returns:
      context Context
    • setContext

      protected void setContext(Context context)
    • getRequestBuffer

      protected StringBuffer getRequestBuffer()
      Gets the StringBuffer object for RequestBuffer.
      Returns:
      requestBuffer StringBuffer
    • submitTransaction

      public Response submitTransaction()
      This method submits the transaction to the PayPal Payment Gateway. The response is obtained from the gateway and response object is populated with the response values along with the sdk specific errors in context, if any.
      Returns:
      response String ............ //Trans is the transaction object. ............ *

      //Submit the transaction. trans.submitTransaction(); *

      // Get the Response. Response resp = trans.getResponse(); if (Resp != null) { // Get the Transaction Response parameters. TransactionResponse trxnResponse = resp.transactionResponse(); if (trxnResponse != null) { System.out.println("RESULT = " + trxnResponse.getResult()); System.out.println("PNREF = " + trxnResponse.getPnref()); System.out.println("RESPMSG = " + trxnResponse.getRespMsg()); System.out.println("AUTHCODE = " + trxnResponse.getAuthCode()); System.out.println("AVSADDR = " + trxnResponse.getAVSAddr()); System.out.println("AVSZIP = " + trxnResponse.getAVSZip()); System.out.println("IAVS = " + trxnResponse.getIAVS()); } // Get the Fraud Response parameters. FraudResponse fraudResp = resp.getFraudResponse(); if (FraudResp != null) { System.out.println("PREFPSMSG = " + fraudResp.getPreFpsMsg()); System.out.println("POSTFPSMSG = " + fraudResp.getPostFpsMsg()); } } // Get the Context and check for any contained SDK specific errors. Context ctx = resp.getTransactionContext(); if (ctx != null && ctx.getErrorCount() %3E 0) { System.out.println("Errors = " + ctx.ToString()); }

    • generateRequest

      protected void generateRequest()
      Generates the transaction request.
    • clearExtendData

      public void clearExtendData()
      Clears the Extend Data list held by transaction object.
    • addHeader

      public void addHeader(String headerName, String headerValue)
      Parameters:
      headerName - String
      headerValue - String
    • RemoveTransHeader

      public void RemoveTransHeader(String headerName)
      Parameters:
      headerName - String