Payment Requests
The myPOS Glass SDK supports Payment Requests, allowing merchants to generate a QR code or send a payment request via SMS or Email directly from the terminal. These requests enable remote payments without requiring the cardholder to be physically present.
1. Create a QR Payment Request
Use MyPOSQRPaymentRequest to initiate a payment request that generates a QR code for the customer to scan.
// Build the payment request transaction
private static final int PAYMENT_REQUEST_REQUEST_CODE = 4;
private void startQRPaymentRequest() {
// Build the payment request
MyPOSQRPaymentRequest paymentRequest = MyPOSQRPaymentRequest.builder()
.productAmount(3.55)
.currency(Currency.EUR)
.language(Language.EN)
.build();
// Start the payment request transaction
MyPOSAPI.createQRPaymentRequest(MainActivity.this, paymentRequest, PAYMENT_REQUEST_REQUEST_CODE);
}
Note: The QR code will appear on the screen of the myPOS Glass device, ready to be scanned by the customer.
2. Create a Payment Request via SMS or Email
Use MyPOSPaymentRequest to send a payment request directly to a recipient through SMS or Email:
// Build the payment request transaction
private static final int PAYMENT_REQUEST_REQUEST_CODE = 4;
private void startPaymentRequest() {
// Build the payment request
MyPOSPaymentRequest paymentRequest = MyPOSPaymentRequest.builder()
.productAmount(3.55)
.currency(Currency.EUR)
.expiryDays(60)
.recipientName("John Doe")
.GSM("0899070087")
.eMail("")
.reason("System test")
.language(Language.EN)
.build();
// Start the payment request transaction
MyPOSAPI.createPaymentRequest(MainActivity.this, paymentRequest, PAYMENT_REQUEST_REQUEST_CODE);
}
You may choose to leave either
GSMor
3. Handle the Payment Request Result
To process the result of either type of payment request, override onActivityResult() in your calling activity:
@Override
void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PAYMENT_REQUEST_REQUEST_CODE) {
// The transaction was processed, handle the response
if (resultCode == RESULT_OK) {
// Something went wrong in the Payment core app and the result couldn't be returned properly
if (data == null) {
Toast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show();
return;
}
int transactionResult = data.getIntExtra("status", TransactionProcessingResult.TRANSACTION_FAILED);
Toast.makeText(this, "Payment request transaction has completed. Result: " + transactionResult, Toast.LENGTH_SHORT).show();
// TODO: handle each transaction response accordingly
if (transactionResult == TransactionProcessingResult.TRANSACTION_SUCCESS) {
// Transaction is successful
}
} else {
// The user cancelled the transaction
Toast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show();
}
}
}