Search code examples
androidgradlepayment-gatewayrazorpay

How to set RazorPay key dynamically?


I want to set the Razorpay key dynamically.

Can anyone help me with this ?

I have tried with

implementation 'com.razorpay:checkout:1.5.13'

Checkout checkout = new Checkout();
checkout.setKeyID(MY_KEY_HERE);

Still it gives me error to set RazorPay API key in manifest.

Later i tried with custom by setting .aar in libs folder also and tried with

implementation project(name: "razorpay-android-3.8.8", ext: 'aar')

Then it gave me error while building gradle as:

ERROR: Required keys [path] are missing from map {name=razorpay-android-3.8.8, ext=aar}.


Solution

  • Issue resolved with this.

    Steps followed:

    Checkout.preload(PaymentActivity.this);
    Checkout checkout = new Checkout();
    checkout.setKeyID(MY_KEY_HERE);
    
    
    final Activity activity = this;
    
    checkout.open(activity, options);