Is this JAVA code can be converted in to Extension (.aix) file?

package com.dvrj.upi;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

        version = 1,
        description = "",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,
        iconName = "")

@SimpleObject(external = true)
@UsesLibraries(libraries = "")
@UsesPermissions(permissionNames = "")

public class UPI extends AndroidNonvisibleComponent {

    //Activity and Context
    private Context context;
    private Activity activity;

    public UPI(ComponentContainer container){
        this.activity = container.$context();
        this.context = container.$context();
    public class MainActivity extends AppCompatActivity implements PaymentStatusListener {
    // initializing variables for our edit text and button.
    private EditText amountEdt, upiEdt, nameEdt, descEdt;
    private TextView transactionDetailsTV;
    protected void onCreate(Bundle savedInstanceState) {
        // initializing all our variables.
        amountEdt = findViewById(;
        upiEdt = findViewById(;
        nameEdt = findViewById(;
        descEdt = findViewById(;
        Button makePaymentBtn = findViewById(;
        transactionDetailsTV = findViewById(;
        // on below line we are getting date and then we are setting this date as transaction id.
        Date c = Calendar.getInstance().getTime();
        SimpleDateFormat df = new SimpleDateFormat("ddMMyyyyHHmmss", Locale.getDefault());
        String transcId = df.format(c);
        // on below line we are adding click listener for our payment button.
        makePaymentBtn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // on below line we are getting data from our edit text.
                String amount = amountEdt.getText().toString();
                String upi = upiEdt.getText().toString();
                String name = nameEdt.getText().toString();
                String desc = descEdt.getText().toString();
                // on below line we are validating our text field.
                if (TextUtils.isEmpty(amount) && TextUtils.isEmpty(upi) && TextUtils.isEmpty(name) && TextUtils.isEmpty(desc)) {
                    Toast.makeText(MainActivity.this, "Please enter all the details..", Toast.LENGTH_SHORT).show();
                } else {
                    // if the edit text is not empty then
                    // we are calling method to make payment.
                    makePayment(amount, upi, name, desc, transcId);
    private void makePayment(String amount, String upi, String name, String desc, String transactionId) {
        // on below line we are calling an easy payment method and passing 
        // all parameters to it such as upi id,name, description and others.
        final EasyUpiPayment easyUpiPayment = new EasyUpiPayment.Builder()
                // on below line we are adding upi id.
                // on below line we are setting name to which we are making payment.
                // on below line we are passing transaction id.
                // on below line we are passing transaction ref id.
                // on below line we are adding description to payment.
                // on below line we are passing amount which is being paid.
                // on below line we are calling a build method to build this ui.
        // on below line we are calling a start 
        // payment method to start a payment.
        // on below line we are calling a set payment
        // status listener method to call other payment methods.
    public void onTransactionCompleted(TransactionDetails transactionDetails) {
        // on below line we are getting details about transaction when completed.
        String transcDetails = transactionDetails.getStatus().toString() + "\n" + "Transaction ID : " + transactionDetails.getTransactionId();
        // on below line we are setting details to our text view.
    public void onTransactionSuccess() {
        // this method is called when transaction is successful and we are displaying a toast message.
        Toast.makeText(this, "Transaction successfully completed..", Toast.LENGTH_SHORT).show();
    public void onTransactionSubmitted() {
        // this method is called when transaction is done 
        // but it may be successful or failure.
        Log.e("TAG", "TRANSACTION SUBMIT");
    public void onTransactionFailed() {
        // this method is called when transaction is failure.
        Toast.makeText(this, "Failed to complete transaction", Toast.LENGTH_SHORT).show();
    public void onTransactionCancelled() {
        // this method is called when transaction is cancelled.
        Toast.makeText(this, "Transaction cancelled..", Toast.LENGTH_SHORT).show();
    public void onAppNotFound() {
        // this method is called when the users device is not having any app installed for making payment.
        Toast.makeText(this, "No app found for making transaction..", Toast.LENGTH_SHORT).show();

You need to define the blocks that correspond to the methods and functionality you want to expose. This involves specifying the block’s name, type, and parameters.

I don’t have know knowledge about extension building, I want to create upi extension that works because other upi extensions are not working for me and I just want know if this code can build that or just i found a wrong code.

1 Like