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:
| Key | Type | Description |
|---|---|---|
rrn | String | Internal myPOS reference number |
cardholder_name | String | Name embossed on the card |
date_time | String | Format: YYMMDDHHmmss |
status | int | Status constant from TransactionProcessingResult |
status_text | String | Textual status (e.g., "Approved", "Declined") |
card_brand | String | MASTERCARD, MAESTRO, VISA, etc. |
card_entry_mode | String | ENTRY_MODE_MAGSTR, ENTRY_MODE_EMV, ENTRY_MODE_CONTACTLESS, etc. |
response_code | String | Issuer response code ("00" = Approved) |
authorization_code | String | Issuer's authorization code |
signature_required | boolean | Whether a signature is required on the receipt |
TSI | String | Transaction Status Indicator |
TVR | String | Terminal Verification Result |
AID | String | Application Identifier (from card) |
STAN | String | System Trace Audit Number |
CVM | String | Cardholder Verification Method (P, S, N) |
application_name | String | Card application label |
transaction_approved | boolean | true if approved, false otherwise |
TID | String | Terminal ID |
update_pending | boolean | true if app update is available |
resp_code | String | Response code for the payment request |
expire_date | String | Expiry of the payment request |
merchant_data | Bundle | Includes merchant details for receipts: billing descriptor, MID, address, custom footer rows |
installment_data | Bundle | If paid in installments, includes number, interest rate, fee, APR, and breakdown of installment amounts |
Note:
- All extras (unless noted) are returned as
Stringvalues.- Presence of certain fields depends on card type and transaction specifics.