Quick Start: Your First Transaction

This guide helps you create your first successful payment transaction using the Get Smart App2App integration. You'll create an Intent, submit a payment request, and handle the transaction result—all in a few minutes.

What You'll Build

In this tutorial, you'll create a simple Android method that creates a payment intent, adds the required transaction parameters, launches the Get Smart application, and handles the transaction result.

Requirements

Before you begin, ensure you have:

  • The Get Smart application installed on your test device
  • An Android project set up with a working Activity
  • Basic familiarity with Android development and Intents
information icon
Tip: Make sure the Get Smart application is updated to the latest version to ensure compatibility.

Step 1: Define the Request Code

First, add a constant to your Activity to identify this payment request:

java
public class MainActivity extends AppCompatActivity { // Request code to identify the payment transaction private static final int REQUEST_CODE_PAYMENT = 1001; // ... rest of your Activity code }

Step 2: Create the Payment Method

Add a method to initiate the payment transaction:

java
private void startPayment(double amount, String invoice) { // 1. Create the Intent with the specific action name Intent intent = new Intent("es.android.redsys.mPOS.movil.tpvAndroid_PAYMENT_REQUEST"); // 2. Add the required parameters intent.putExtra("amount", amount); intent.putExtra("invoice", invoice); intent.putExtra("type", 1); // 1 = Sale transaction // 3. Launch the Get Smart app with error handling try { startActivityForResult(intent, REQUEST_CODE_PAYMENT); } catch (ActivityNotFoundException e) { // The Get Smart app is not installed showErrorDialog(); } } private void showErrorDialog() { new AlertDialog.Builder(this) .setTitle("Payment App Not Found") .setMessage("Please ensure the Get Smart application is installed and updated.") .setPositiveButton("OK", null) .show(); }
information icon
Note: The request code REQUEST_CODE_PAYMENT is an integer constant defined by you. You will use this same code in the onActivityResult method to identify which request is returning.

Step 3: Handle the Transaction Result

Override the onActivityResult method to receive the transaction outcome:
java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_PAYMENT) { if (resultCode == RESULT_OK && data != null) { // Transaction completed - check if it was authorized String result = data.getStringExtra("RESULT"); if ("AUTORIZADA".equals(result)) { // Payment successful! String authNumber = data.getStringExtra("AUTORIZATION_NUMBER"); String orderNumber = data.getStringExtra("ORDER"); showSuccessMessage("Payment approved! Auth: " + authNumber); } else { // Payment denied String errorMsg = data.getStringExtra("ERROR_MSG"); showErrorMessage("Payment denied: " + errorMsg); } } else if (resultCode == RESULT_CANCELED) { // User cancelled the transaction showInfoMessage("Transaction cancelled by user"); } } } private void showSuccessMessage(String message) { Toast.makeText(this, message, Toast.LENGTH_LONG).show(); } private void showErrorMessage(String message) { Toast.makeText(this, message, Toast.LENGTH_LONG).show(); } private void showInfoMessage(String message) { Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); }
information icon
Important: RESULT_OK does not mean the payment was authorized. It only means the Get Smart app completed its process. You must check the RESULT extra to determine if the payment was actually approved.

Step 4: Trigger the Payment

Add a button click handler (or trigger method) to start the payment:

java
// Example: Button click handler public void onPayButtonClick(View view) { // Process a payment of 10.50 euros startPayment(10.50, "ORDER-001"); }
information icon
Tip: Replace the hardcoded amount with your actual transaction amount based on the customer's order.

Here's the complete code in one place:

java
public class MainActivity extends AppCompatActivity { private static final int REQUEST_CODE_PAYMENT = 1001; private void startPayment(double amount, String invoice) { Intent intent = new Intent("es.android.redsys.mPOS.movil.tpvAndroid_PAYMENT_REQUEST"); intent.putExtra("amount", amount); intent.putExtra("invoice", invoice); intent.putExtra("type", 1); // Sale try { startActivityForResult(intent, REQUEST_CODE_PAYMENT); } catch (ActivityNotFoundException e) { new AlertDialog.Builder(this) .setTitle("Payment App Not Found") .setMessage("Please install the Get Smart application.") .setPositiveButton("OK", null) .show(); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_PAYMENT) { if (resultCode == RESULT_OK && data != null) { String result = data.getStringExtra("RESULT"); if ("AUTORIZADA".equals(result)) { String authNumber = data.getStringExtra("AUTORIZATION_NUMBER"); Toast.makeText(this, "Payment approved! Auth: " + authNumber, Toast.LENGTH_LONG).show(); } else { String errorMsg = data.getStringExtra("ERROR_MSG"); Toast.makeText(this, "Payment denied: " + errorMsg, Toast.LENGTH_LONG).show(); } } else if (resultCode == RESULT_CANCELED) { Toast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show(); } } } }

Congratulations! You've successfully created your first payment transaction using the Get Smart App2App integration. This complete example demonstrates the essential components needed to process payments: creating the Intent, handling responses, and managing error scenarios. You can now build upon this foundation to add more sophisticated payment features to your application.

Troubleshooting

If you encounter issues during integration or at runtime, refer to the table below:

Issue / ExceptionDescription & Potential CausesRecommended Action
ActivityNotFoundExceptionThe Get Smart application is not installed on the device.Install the app via your device management system or contact a Get Smart representative.
RESULT_CANCELEDThe user manually exited the interface or pressed the back button.Handle this as a standard user cancellation; ensure your UI returns to a neutral state.
No data in onActivityResultThe Intent data is null. This occurs if the app crashed, the device ran out of memory, or the system killed the process.Log the error details and prompt the user to attempt the transaction again.
Payment "DENEGADA"The payment gateway declined the transaction (e.g., insufficient funds, expired card, or blocked account).Parse the ERROR_MSG field and display it to the user so they know why the card was rejected.

What You've Learned

In this tutorial, you've learned how to:

  • Create and configure a payment Intent
  • Launch the Get Smart application
  • Handle transaction results
  • Implement proper error handling

Next Steps

Now that you have a working integration: