Payment Request


This functionality allows a merchant to create a payment request and send it as an SMS directly from a myPOS Smart device.

 
1. Perform Payment Request

// 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);
   }

 
2. Handle the result

The same as with the payment, in your calling Activity, override the onActivityResult method to handle the result of the Payment request:

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