Payment Request via myPOS Smart SDK
The Payment Request feature allows a merchant to initiate a payment request directly from a myPOS Smart device and send it to the customer via SMS.
Step 1: Perform Payment Request
Build and initiate a payment request transaction using the MyPOSPaymentRequest builder.
// 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")
.build();
// Start the payment request transaction
MyPOSAPI.createPaymentRequest(MainActivity.this, paymentRequest, PAYMENT_REQUEST_REQUEST_CODE);
}
Step 2: Handle the Result
As with other transaction types, handle the result in the onActivityResult() method of your 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();
}
}
}
Tip: Use meaningful recipient names and reasons in the request to help customers identify and trust the message they receive via SMS.