Quick Start: Your First Transaction
This guide helps you process your first payment transaction using Get Mini App2App. You’ll create an Intent, launch the Get Mini app, and handle the response—all in a few minutes.
Requirements
Before you begin, ensure you have:
- Get Mini application installed on your Android device
- Compatible PIN pad device paired and ready
- Android development environment with your application project
- Completed the Prerequisites and Setup guide
Make sure the PIN pad is connected and the Get Mini app is properly configured before testing.
Step 1: Register the Activity Result Launcher
First, register an ActivityResultLauncher in your Activity or Fragment. This will handle the callback when the Get Mini app completes the transaction.
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import android.content.Intent;
import android.app.Activity;
public class MainActivity extends AppCompatActivity {
private ActivityResultLauncher<Intent> paymentLauncher;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Register the Activity Result Launcher
paymentLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> {
if (result.getResultCode() == Activity.RESULT_OK) {
// Payment successful
Intent data = result.getData();
if (data != null) {
String authNumber = data.getStringExtra("AUTHORIZATION_NUMBER");
String order = data.getStringExtra("ORDER");
// Display success message to user
Toast.makeText(this,
"Payment Successful! Auth: " + authNumber,
Toast.LENGTH_LONG).show();
}
} else if (result.getResultCode() == Activity.RESULT_CANCELED) {
// Payment failed or cancelled
Intent data = result.getData();
if (data != null) {
String errorMsg = data.getStringExtra("ERROR_MSG");
String state = data.getStringExtra("STATE");
// Display error message to user
Toast.makeText(this,
"Payment Failed: " + errorMsg,
Toast.LENGTH_LONG).show();
}
}
}
);
}
}Step 2: Create and Launch the Payment Intent
Next, create a method to build the payment Intent and launch it with the registered launcher.
private void processPayment(double amount, String invoiceNumber) {
// Create the payment Intent
Intent paymentIntent = new Intent("es.redsys.paysys.mPOSRedsys_PAYMENT_REQUEST");
// Add required parameters
paymentIntent.putExtra("amount", amount);
paymentIntent.putExtra("invoice", invoiceNumber);
try {
// Launch the Get Mini application
paymentLauncher.launch(paymentIntent);
} catch (ActivityNotFoundException e) {
// Handle case where Get Mini app is not installed
showInstallDialog();
}
}
private void showInstallDialog() {
String playStoreUrl = "https://play.google.com/store/apps/details?id=es.android.redsys.Get Mini.movil";
new AlertDialog.Builder(this)
.setTitle("Get Mini Not Found")
.setMessage("The Get Mini app must be installed to process payments.")
.setPositiveButton("Install", (dialog, which) -> {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(playStoreUrl));
startActivity(intent);
})
.setNegativeButton("Cancel", null)
.show();
}Step 3: Trigger the Payment
Finally, call your processPayment method when the user initiates a payment (e.g., when they tap a “Pay Now” button).
// Example: Process a payment of €10.50 with invoice number "ORD-12345"
Button payButton = findViewById(R.id.pay_button);
payButton.setOnClickListener(v -> {
processPayment(10.50, "ORD-12345");
});Step 4: Test Your Integration
Run your application on a device with the Get Mini app installed:
- Launch your application
- Tap the payment button
- The Get Mini app should launch and prompt you to insert or tap a card
- Complete the transaction on the PIN pad
- Your app receives the callback with the transaction result
Troubleshooting
Get Mini app not found: If you see an ActivityNotFoundException, the Get Mini app is not installed. Follow the Handle App Availability guide to direct users to install it.
Transaction cancelled: The Get Mini app returns RESULT_CANCELED when a transaction fails or is cancelled by the user. Check the ERROR_MSG extra for details.
PIN pad not connected: Ensure the PIN pad device is properly paired via Bluetooth and the Get Mini app is configured to use it.
Next Steps
Congratulations! You’ve processed your first payment transaction. To learn more:
- Refund a Payment - Learn how to refund a previous payment
- Handle Transaction Results - Detailed guide on processing response data
- Certified Ticket Management - Learn how to display and share transaction tickets
- Request Parameters - Complete reference of all Intent actions and parameters