Issue Digital Receipts
This guide explains how to issue digital receipts using the TicketDigitalRepository. This functionality offers an eco-friendly alternative to printing by allowing you to send tickets via email or display them via a QR code.
To use these features, you generally need the operationId of a completed transaction, which is available in the Transaction object returned by payments or history searches.
Sending Receipts via Email
To send a digital receipt directly to a customer’s email address, use the sendTicketDigital function.
Repository: TicketDigitalRepository
Parameters:
operId: The unique identifier of the operation.email: The customer’s email address.
Example Implementation
suspend fun emailReceipt(operationId: String, customerEmail: String) {
val result = ticketDigitalRepository.sendTicketDigital(
operId = operationId,
email = customerEmail
)
when (result) {
is RepositoryResult.Success -> {
// The request was successfully sent to the host
println("✅ Email sent successfully.")
}
is RepositoryResult.ConnectionError -> {
println("❌ Connection failed. Please check internet.")
}
is RepositoryResult.ProtocolError -> {
println("❌ Protocol Error: ${result.type}")
}
else -> {}
}
}The success result contains a TicketDigitalResult.
Retrieving a QR Code URL
If you prefer to display a QR code on the TPV screen for the customer to scan, you can retrieve the URL associated with the digital receipt using getTicketDigitalURL.
Repository: TicketDigitalRepository
Parameters:
operId: The unique identifier of the operation.
Example Implementation
suspend fun getQrUrl(operationId: String) {
val result = ticketDigitalRepository.getTicketDigitalURL(
operId = operationId
)
when (result) {
is RepositoryResult.Success -> {
// Extract the URL from the result
val urlResult = result.data
// Note: Depending on the specific result object structure, accessing the URL property
// (Check Javadoc for exact property name in TicketDigitalUrlResult)
println("✅ Receipt URL retrieved. Ready to generate QR.")
}
is RepositoryResult.ConnectionError -> println("❌ Connection Error")
else -> {}
}
}The success result contains a TicketDigitalUrlResult.
Next Steps
- Control the Device Printer: Learn how to control the physical printer if digital delivery is not preferred.
- Configure Bizum Payments: Integration guides for Bizum.
- Configure Alipay and WeChat QR: Integration guides for Alipay and WeChat Pay using QR-based flows.