cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use sdk-node setTrackData for Card Present transactions?

I am using the sdk-node library.

I am attempting to use the authorize-credit-card.js sample and add track data to the process.

The class PaymentType in apicontracts.js shows setTrackData as an available method.

I've tried applying it to the payment class using:

var creditCard = new ApiContracts.CreditCardType();
creditCard.setCardNumber(transactionData.cardNumber);
creditCard.setExpirationDate(transactionData.expirationDate);
creditCard.setCardCode(transactionData.code);

var trackData = new ApiContracts.CreditCardTrackType();
trackData.setTrack1(transactionData.track1));
trackData.setTrack2(transactionData.track2);
console.log('trackData', trackData);
// CreditCardTrackType {
//   track1: 'Bxxxxxxxxxxxxxx ^xx0510100000009601000000259000000',
//   track2: 'xxxxxxxxxxxxxx=0905101096010259'
//  }

var paymentType = new ApiContracts.PaymentType();
paymentType.setCreditCard(creditCard); // THIS console.log shows trackData: null
console.log('paymentType', paymentType);
paymentType.setTrackData(trackData);
console.log('paymentType after setTrackData', paymentType); // THIS console.log shows the CreditCardTrackType, from above
 
Submitting the data produces the following error:
 
MessagesType {
   resultCode: 'Error',
   message: [
     {
    code: 'E00003',
    text: "The element 'payment' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'trackData' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'dataSource' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."
    }
  ]
}
jamesastound
Member
6 REPLIES 6

 use this code 

const paymentSDK = require('sdk-node'); // Replace 'sdk-node' with the actual SDK module

// Initialize the SDK with your credentials or configuration
paymentSDK.initialize({
apiKey: 'your_api_key',
// other configuration parameters
});

// Create a transaction object with the required details
const cardPresentTransaction = {
amount: 1000, // Replace with your desired amount
trackData: 'your_encrypted_track_data', // Replace with the actual encrypted track data
// other transaction details
};

// Set the track data for the Card Present transaction
paymentSDK.setTrackData(cardPresentTransaction.trackData);

// Process the transaction
paymentSDK.processTransaction(cardPresentTransaction)
.then(result => {
// Handle the result of the transaction
console.log('Transaction result:', result);
})
.catch(error => {
// Handle errors
console.error('Transaction error:', error);
});

bilalmirza
Member

paymentSDK.initialize is not a function

I've searched all of the node-sdk files and cannot find any reference to the method "initialize" or "processTransaction."  Are you just making up pseudocode? 

Where is the documentation for your code, showing all the parameters, their formatting and required fields? 

You're encountering an issue with the SDK while attempting to add track data to a credit card transaction. The error message suggests that the 'track data' element is not being recognized as a valid child element within the 'payment' element.

To troubleshoot, make sure you are using the correct structure and method for adding track data. Here's a revised version of your code with adjustments:

javascriptCopy code
var creditCard = new ApiContracts.CreditCardType(); creditCard.setCardNumber(transactionData.cardNumber); creditCard.setExpirationDate(transactionData.expirationDate); creditCard.setCardCode(transactionData.code); var trackData = new ApiContracts.CreditCardTrackType(); trackData.setTrack1(transactionData.track1); trackData.setTrack2(transactionData.track2); var paymentType = new ApiContracts.PaymentType(); paymentType.setCreditCard(creditCard); // Use setPaymentType method to specify the payment type paymentType.setPaymentType(ApiContracts.PaymentTypeEnum.CREDITCARD); // Set the track data using setTrackData method paymentType.setTrackData(trackData); console.log('paymentType', paymentType); // Continue with the rest of your transaction processing...

In this revised code, I added the setPaymentType method to set the payment type to 'CREDITCARD explicitly' and used setTrackData directly on the paymentType object. Ensure that the SDK documentation aligns with these modifications, and adjust accordingly based on your SDK version.

If the issue persists, consider checking the SDK documentation or contacting the SDK's support for specific guidance on handling track data in card-present transactions.

jhoney12
Member

Thanks for the replies. Unfortunately, again, I'm getting advice for methods that do not exist in the sdk-node library.  paymentType.setPaymentType is not a method that exists on the ApiContracts.PaymentType() class. Also ApiContracts does not have a property PaymentTypeEnum.

I've already searched the documentation, which is why I am posting here. There are no mentions of how to apply track data using the sdk-node library.

 

 

Use dataSource Property: If the documentation suggests using dataSource, modify your code as follows:

 

var paymentType = new ApiContracts.PaymentType();
paymentType.setCreditCard(creditCard);
paymentType.setDataSource(ApiContracts.PaymentType.DATA_SOURCE.TRACK_DATA);

 

Consult SDK Documentation: Refer to the sdk-node library's documentation for specific instructions on how to provide track data within the context of the chosen data source. There might be additional methods or properties involved. adobe flash player

 

 

ativadore
Member

What specific documentation exists for applying trackData? I've looked. I don't see any documentation, only the classes that exist in the apicontracts.js file, of which PaymentType.DATA_SOURCE.TRACK_DATA is not part of.

There is nothing within the sdk-node repository, the sdk-node issues, or the Authorize.net API Documentation, that shows how to apply track data using the sdk-node library.