Get Last Transaction Data (myPOS Smart SDK)

You can retrieve the last recorded transaction directly from the system content provider without needing to track it manually within your app.

Access the Last Transaction

To get transaction info, query the LastTransactionProvider:

    final Uri CONTENT_URI = Uri.parse("content://com.mypos.providers.LastTransactionProvider/last_transaction");

Cursor cursor = getContentResolver().query(
    CONTENT_URI,
    new String[] { // projection parameters you want to receive in response. Choose only the needed ones
        "amount",
        "currency",
        "reference_number",
        "reference_number_type",
        "operator_code",
        "response_code",
        "stan",
        "date_time",
        "authorization_code",
        "card_brand",
        "transaction_approved",
        "cvm",
        "transaction_type",
        "rrn"
    },
    null,
    null,
    null
);

if (cursor == null)
    return; // there is no last transaction recorded
    
cursor.moveToFirst();

double amount               = cursor.getDouble(cursor.getColumnIndex("amount"));
String currency             = cursor.getString(cursor.getColumnIndex("currency"));
String referenceNumber      = cursor.getString(cursor.getColumnIndex("reference_number"));
int referenceNumberType     = cursor.getInt(cursor.getColumnIndex("reference_number_type"));
String operatorCode         = cursor.getString(cursor.getColumnIndex("operator_code"));
String responseCode         = cursor.getString(cursor.getColumnIndex("response_code"));
String stan                 = cursor.getString(cursor.getColumnIndex("stan"));
String dateTime             = cursor.getString(cursor.getColumnIndex("date_time"));
String authorizationCode    = cursor.getString(cursor.getColumnIndex("authorization_code"));
String cardBrand            = cursor.getString(cursor.getColumnIndex("card_brand"));
boolean transactionApproved = cursor.getInt(cursor.getColumnIndex("transaction_approved")) == 1;
String cvm                  = cursor.getString(cursor.getColumnIndex("cvm"));
String transactionType      = cursor.getString(cursor.getColumnIndex("transaction_type"));
String rrn                  = cursor.getString(cursor.getColumnIndex("rrn"));

if(!cursor.isClosed())
    cursor.close();

Response Data Fields

Here’s a breakdown of what’s returned by the last transaction or in the result intent after any operation:

🧩 General Transaction Info

KeyDescription
reference_numberInternal myPOS reference ID
rrnRetrieval Reference Number
date_timeDate & time of the transaction (format: YYMMDDHHmmss)
amountTransaction amount
currencyCurrency code (e.g. EUR, USD)
authorization_codeCode returned by the card issuer
statusTransaction status (see status codes table)
status_textTextual version of the status
transaction_approvedtrue if approved, false if declined
response_codeIssuer's response code ("00" = approved; others indicate decline)

Card Details

KeyDescription
cardholder_nameCardholder’s name (if available)
panObfuscated card number (e.g., XXXX-XXXX-XXXX-8008)
pan_hashSecure hash of the PAN (Primary Account Number)
card_brandCard scheme (e.g., VISA, MASTERCARD)
card_entry_modeHow the card was used:
- ENTRY_MODE_MAGSTR
- ENTRY_MODE_EMV
- ENTRY_MODE_CONTACTLESS
- ENTRY_MODE_CONTACTLESS_MCHIP
- ENTRY_MODE_MANUAL
CVMCardholder Verification Method:
- P: PIN
- S: Signature
- N: No CVM
AIDApplication Identifier from the card chip
application_nameApplication label from the card chip

Receipt & Terminal

KeyDescription
signature_requiredIndicates if a signature line is required on the receipt
TSITransaction Status Indicator
TVRTerminal Verification Result
STANSystem Trace Audit Number
TIDTerminal ID
update_pendingtrue if a terminal update is available, otherwise false
operator_codeOptional code identifying the terminal operator

Dynamic Currency Conversion (DCC)

KeyDescription
dcc_availableIndicates if Dynamic Currency Conversion (DCC) was offered
amount_dccAmount converted into the selected foreign currency
currency_dccCurrency used for DCC (e.g., USD, GBP)
exchange_rateExchange rate applied for the conversion

Merchant Data (merchant_data Bundle)

KeyDescription
billing_descriptorDescriptor shown on the cardholder’s bank statement
address_line1Address line 1
address_line2Address line 2
MIDMerchant ID
custom_receipt_row1Footer row 1 for receipts
custom_receipt_row2Footer row 2 for receipts

Installment Info (installment_data Bundle)

KeyDescription
number (int)Number of installments
interest_rate (double)Interest applied
fee (double)Additional fee
annual_percentage_rateAnnual Percentage Rate (APR)
total_amount (double)Total amount due
first_installment_amountValue of the first installment
subsequent_installment_amountValue of each remaining installment

Most fields are returned as strings. Some keys may be missing depending on transaction type or card capabilities.

Transaction Result Codes (Reference)

public class TransactionProcessingResult {
    public static final int TRANSACTION_SUCCESS      = 0;
    public static final int TRANSACTION_CANCELED     = 1;
    public static final int TRANSACTION_DECLINED     = 2;
    public static final int TRANSACTION_FAILED       = 3;
    public static final int DEVICE_NOT_ACTIVATED     = 4;
    public static final int NO_DATA_FOUND            = 5;
    public static final int INVALID_CURRENCY         = 6;
    public static final int INVALID_AMOUNT           = 7;
}

Tip: Use the transaction_approved boolean or status code for quick validation. If needed, log reference_number, authorization_code, and rrn for reconciliation or support purposes.