Email and Print Receipts
After the transaction has been completed, you must enable the merchant to send a receipt to
the shopper. Through the SDK, you can easily send
a ready-made electronic receipt via email or print
one.
If you support refunds, you also have to be able to send and print receipts for successful
refunds.
Call
sendCustomerReceiptForTransactionIdentifier
with the
transactionIdentifier
of the
transaction for which you want to send a
receipt:
[transactionProvider sendCustomerReceiptForTransactionIdentifier:@"transactionIdentifer"
emailAddress:@"
[email protected]"
completed:^(NSString *transactionIdentifier,
NSString *emailAddress,
NSError *error) {
if(!error) {
// Receipt successfully sent!
}
}];
emailAddress:@"
[email protected]"
completed:^(NSString *transactionIdentifier,
NSString *emailAddress,
NSError *error) {
if(!error) {
// Receipt successfully sent!
}
}];
Print Receipt via Printer
Use
printCustomerReceiptForTransactionIdentifier
with the
transactionIdentifier
of the transaction for
which you want to print a receipt.
Similar to
MPTransactionProcess
, you
need to build a user interface for the
MPPrintingProcess
to show status
information to the merchant:
MPPrintingProcess *process =
[transactionProvider printCustomerReceiptForTransactionIdentifier:@"transactionIdentifer"
usingAccessory:MPAccessoryFamilySewoo
statusChanged:^(MPPrintingProcess *printingProcess,
MPTransaction *transaction,
MPPrintingProcessDetails *details)
{
NSLog(@"%@\n%@", details.information[0], details.information[1]);
}
completed:^(MPPrintingProcess *printingProcess,
MPTransaction *transaction,
MPPrintingProcessDetails *details)
{
if (details.state == MPPrintingProcessDetailsStateSentToPrinter) {
// Show to the merchant, that printing was successful
// and close the printing UI
} else {
// Allow your merchant to retry printing
}
}];