Get Last Transaction Data

The myPOS Glass SDK allows you to retrieve information about the most recent transaction completed on the terminal. This is done by querying the content provider exposed by the myPOS Glass app.

1. Retrieve Last Transaction Details via Content Provider

To access last transaction data, use the LastTransactionProvider via the following CONTENT_URI:

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();

2. Transaction Result Data (Intent Response)

When a transaction completes, the result is returned via an Intent to the calling Activity, containing the following extras:

KeyTypeDescription
rrnStringInternal myPOS reference number
cardholder_nameStringName embossed on the card
date_timeStringFormat: YYMMDDHHmmss
statusintStatus constant from TransactionProcessingResult
status_textStringTextual status (e.g., "Approved", "Declined")
card_brandStringMASTERCARD, MAESTRO, VISA, etc.
card_entry_modeStringENTRY_MODE_MAGSTR, ENTRY_MODE_EMV, ENTRY_MODE_CONTACTLESS, etc.
response_codeStringIssuer response code ("00" = Approved)
authorization_codeStringIssuer's authorization code
signature_requiredbooleanWhether a signature is required on the receipt
TSIStringTransaction Status Indicator
TVRStringTerminal Verification Result
AIDStringApplication Identifier (from card)
STANStringSystem Trace Audit Number
CVMStringCardholder Verification Method (P, S, N)
application_nameStringCard application label
transaction_approvedbooleantrue if approved, false otherwise
TIDStringTerminal ID
update_pendingbooleantrue if app update is available
resp_codeStringResponse code for the payment request
expire_dateStringExpiry of the payment request
merchant_dataBundleIncludes merchant details for receipts: billing descriptor, MID, address, custom footer rows
installment_dataBundleIf paid in installments, includes number, interest rate, fee, APR, and breakdown of installment amounts

Note:

  • All extras (unless noted) are returned as String values.
  • Presence of certain fields depends on card type and transaction specifics.