1

I want integrate Google Pay in my app. Everything works perfectly fine until the payment comes. I am getting an error saying "You have exceeded the maximum transaction amount set by your bank" and I can't make payments, even though I have not made any transaction with Google Pay in last few days it still gives me the same error. Here is my code

package com.deccan.galaxy.shoponclick.activities;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

import com.deccan.galaxy.shoponclick.databinding.ActivityMainBinding;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.tasks.OnSuccessListener;

import java.util.Locale;

import com.deccan.galaxy.shoponclick.R;

public class MainActivity extends AppCompatActivity {

    public static final String GOOGLE_PAY_PACKAGE_NAME = "com.google.android.apps.nbu.paisa.user";
    int GOOGLE_PAY_REQUEST_CODE = 123;
    String amount;
    String name = "Test Google Pay";
    String upiId = "test@testupi";
    String transactionNote = "pay test";
    String status;
    Uri uri;
    private ActivityMainBinding binding;

    private static boolean isAppInstalled(Context context, String packageName) {
        try {
            context.getPackageManager().getApplicationInfo(packageName, 0);
            return true;
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        }
    }

 

    private Uri generateUri(String name, String upiId, String transactionNote, String amount){

        return Uri.parse("upi://pay").buildUpon()
                .appendQueryParameter("pa", upiId)  // google pay business id
                .appendQueryParameter("pn", name)
                .appendQueryParameter("mc", "")            
                //.appendQueryParameter("tid", "02125412")
                .appendQueryParameter("tr", "25584584")   
                .appendQueryParameter("tn", transactionNote)
                .appendQueryParameter("am", amount)
                .appendQueryParameter("cu", "INR")
                //.appendQueryParameter("refUrl", "blueapp")
                .build();
    }

    ImageView googlePayButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_location2);
        googlePayButton = findViewById(R.id.googlePayButton);

        googlePayButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                amount = "100";
                if (!amount.isEmpty()) {
                    uri = generateUri(name, upiId, transactionNote, amount);
                    payWithGPay();
                } else {
                    Toast.makeText(MainActivity.this, "Amount is required", Toast.LENGTH_SHORT).show();
                }
            }
        });


    }

    private void payWithGPay() {
        if (isAppInstalled(this, GOOGLE_PAY_PACKAGE_NAME)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(uri);
            intent.setPackage(GOOGLE_PAY_PACKAGE_NAME);
            startActivityForResult(intent, GOOGLE_PAY_REQUEST_CODE);
        } else {
            Toast.makeText(MainActivity.this, "Please Install Google Pay", Toast.LENGTH_SHORT).show();
        }
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data != null) {
            status = data.getStringExtra("Status").toLowerCase();
        }

        if ((RESULT_OK == resultCode) && status.equals("success")) {
            Toast.makeText(MainActivity.this, "Transaction Successful", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(MainActivity.this, "Transaction Failed", Toast.LENGTH_SHORT).show();
        }
    }


}
  • Did you find the answer?? I got the same issue – Himani Dec 18 '20 at 09:27
  • Does the following answer help? https://stackoverflow.com/questions/64481458/getting-error-you-have-exceeded-the-maximum-transaction-amount-set-by-your-bank/64724053#64724053 – Soc Jan 12 '21 at 19:17

0 Answers0