Send Digital Receipts
The Get Mini framework allows you to handle receipts in two ways: by providing customer contact details so Get Mini sends the receipt automatically, or by accessing transaction “Literals” to generate your own digital or physical receipt.
Requirements
Before sending receipts, ensure:
- Transaction Result: You must have a
RespuestaTransaccionDTOreturned from theonPaymentFinishedcallback. - Permissions: Ensure your merchant profile allows receipt generation (checked via
PerfilComercioManager).
Option 1: Automatic Digital Receipts (Email/SMS)
The easiest way to send receipts is to provide the customer’s contact information during the initial payment request. Get Mini will handle the delivery automatically.
Implementation
When initializing your PagoDTO, include the emailCliente or tlfCliente. If these fields are populated, the Get Mini gateway sends the ticket without further code on your part.
let pago = PagoDTO(
valor: 1500,
mMoneda: 978,
nFactura: "INV-101",
email: "[email protected]", // Get Mini sends email automatically
tlfCliente: "600000000", // Get Mini sends SMS automatically
datosPropietarios: ""
)Option 2: Custom Digital Receipts
If you want to display a receipt in your app or use the iOS Share Sheet, you must manually compile the data from the transaction result.
Step 1: Access Transaction Literals
The RespuestaTransaccionDTO contains a Literales property (an array of strings) and a DatosDCC object. These contain the legal text required for the receipt.
func onPaymentFinished(_ result: RespuestaTransaccionDTO!, orError error: Error!) {
guard let response = result, error == nil else { return }
// The 'Literales' field aggregates all required receipt text
if let receiptLines = response.literales as? [String] {
let fullReceiptText = receiptLines.joined(separator: "\n")
self.showShareSheet(text: fullReceiptText)
}
}Step 2: Handle Signature Requirements
Check the reciboSoloCliente property. If it is true, you only need to provide the customer copy (usually because the signature was captured digitally on the device).
if response.reciboSoloCliente {
print("Only customer copy required.")
} else {
print("Signature or Merchant copy may be required.")
}Step 3: Access Full Financial Record (Boleta)
If you need to generate a receipt for a past transaction, use the peticionConsultaBoleta method to get the full financial data.
let consulta = ConsultaBoletaDTO(
terminal: termTPVPC,
withIdRTS: originalRTS,
andUserInfo: userInfo
)
RedsysTransactionManager.peticionConsultaBoleta(consulta) { result, error in
if let boleta = result {
// Access fields like boleta.tarjetaClienteRecibo, boleta.importe, etc.
let receiptBody = """
Terminal: \(boleta.terminal ?? "")
Amount: \(boleta.importe ?? "") \(boleta.moneda ?? "")
Auth: \(boleta.codigoRespuesta ?? "")
"""
self.printOrShare(receiptBody)
}
}Receipt Best Practices
- DCC Transactions: For foreign cards, always include the
DatosDCC(exchange rate, markup, and currency) in the receipt text to comply with regulations. - Privacy: When displaying or sharing receipts, ensure the card number is masked (the SDK provides it as
************1234). - Signature: If
AutenticadoPorPinis false, the receipt should include a signature line unlessenvioFirmaDigitalizadawas used.
Troubleshooting
Receipt Data Missing Verify that the Estado is “F”. Literals are only generated once the transaction reaches a finalized state on the server.
Emails Not Received
Ensure the email field in PagoDTO is a valid format. If the field is empty, no automatic receipt is triggered.
Next Steps
- Create a Single-Step Payment - Standard sale transactions
- Refund a Payment - Learn how to return funds
- Manage Bluetooth Reader - Connect your hardware