Generate a Transaction

Estimated time: ~1 minute

Every time you use a card, the Lithic API generates a transaction object based on data received from the card networks (Mastercard, Visa) that describes how the card was used.

In Sandbox, there are additional API endpoints for simulating card usage and generating a transaction since Sandbox cards cannot be used for real purchases. In Production, transactions will be generated automatically whenever a card is used.

Simulate a transaction

Only available in the Sandbox environment.

/*
const lithic = new Lithic({
  apiKey: "{Sandbox API key}", // or "Production API key"
  environment: "sandbox", // or "production". Defaults to "production"
});
*/

const simulation_params: TransactionSimulateAuthorizationParams = {
    amount: 1750,              	// Transaction amount in smallest denominator (pennies for USD)
    descriptor: "COFFEE SHOP", 	// Transaction descriptor
    pan: "{Card PAN}",         	// Pass in the card.pan from the  "create card" step
    // ^^ PAN aka Primary Account Number aka Card Number.
    // This is the 16 digit number found on the front of cards.
  }
await lithic.transactions.simulateAuthorization(simulation_params)
'''
lithic = Lithic(
  api_key="{Sandbox API key}",  # or "Production API key"
  environment="sandbox",  # or "production". Defaults to "production"
)
'''

lithic.transactions.simulate_authorization({
  "amount": 1750,              # Transaction amount in smallest denominator (pennies for USD)
  "descriptor": "COFFEE SHOP", # Transaction descriptor
  "pan": "{Card PAN}",         # Pass in the card.pan from the "create card" step
  # ^^ PAN aka Primary Account Number aka Card Number.
  # This is the 16 digit number found on the front of cards.
})
curl --request POST \
     --url https://sandbox.lithic.com/v1/simulate/authorize \
     --header "Accept: application/json" \
     --header "Authorization: {Sandbox API key}" \
     --header "Content-Type: application/json" \
     --data '
{
	"amount": 1750,
    "descriptor": "COFFEE SHOP",
    "pan": "{Card PAN}"
}
'

For more information on simulating transactions, check out our in-depth guide: Simulating Transactions