Skip to main content

Print Receipts

This guide shows you how to print custom receipts using the Paynt app's built-in printer functionality.


Set Up the Print Launcher

private val printReceiptLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
if (result.resultCode == Activity.RESULT_OK) {
// Print completed successfully
}
}

fun printReceipt(receipt: MutableList<List<String>>) {
try {
val intent = Intent(PayntIntentConstants.ACTION_PRINT_RECEIPT).apply {
data = Uri.parse("printer://paynt")
addCategory(Intent.CATEGORY_DEFAULT)
putExtra(PayntIntentConstants.EXTRA_PRINT_RECEIPT_CONTENT, Gson().toJson(receipt))
}
printReceiptLauncher.launch(intent)
} catch (e: Exception) {
Log.e("App", "Error starting print receipt command", e)
}
}

Receipt Processing

Receipt data is returned as formatted lines that can be directly printed or displayed by the integrating application (integrator's app resides on the terminal as well thus it can use the printer):

  • Text content with formatting instructions
  • Size indicators for different font sizes
  • Alignment specifications (Left/Center/Right)
  • Style indicators (Normal/Bold)