找不到 com.razorpay.PaymentResultListener 的 class 文件

class file for com.razorpay.PaymentResultListener not found

我正在我的 Android 项目中实施 Razorpay 支付集成。我在执行 onPaymentErroronPaymentSuccess 回调时遇到了一些错误。

这就是我集成它的方式,

build.gradle

implementation 'com.razorpay:checkout:1.5.12'

Activity

class BuyNowActivity : AppCompatActivity, PaymentResultListener {

lateinit var dataBinding : ViewDataBinding

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_buynow)
    preloadCheckoutEssentials()
    dataBinding.loginButton.setOnClickListener {
        startPayment()
    }
}

private fun preloadCheckoutEssentials() {
    Checkout.preload(applicationContext);
}

fun startPayment() {

    val checkout = Checkout()

    //checkout.setImage(R.drawable.logo)

    val activity: Activity = this

    val options = JSONObject()

    options.put("name", "Merchant Name")

    options.put("description", "Reference No. #123456")
    options.put("order_id", "order_9A33XWu170gUtm")
    options.put("currency", "INR")

    options.put("amount", "500")

    try {
        checkout.open(activity, options)
    } catch (e: Exception) {
        Timber.e(TAG, "Error in starting Razorpay Checkout")
    }
}

override fun onPaymentError(code: Int, response: String?) {
    Toast.makeText(this, "$code, AND $response", Toast.LENGTH_LONG).show()
}

override fun onPaymentSuccess(razorpayPaymentID: String?) {
    Toast.makeText(this, razorpayPaymentID, Toast.LENGTH_LONG).show()
}

/*override fun onPaymentError(code: Int, response: String?, p2: PaymentData?) {
    Toast.makeText(this, "$code, AND $response", Toast.LENGTH_LONG).show()
}

override fun onPaymentSuccess(razorpayPaymentID: String?, p1: PaymentData?) {
    Toast.makeText(this, razorpayPaymentID, Toast.LENGTH_LONG).show()
}*/

}

Android清单

<meta-data
        android:name="com.razorpay.ApiKey"
        android:value="APIKeyHere" />

写完所有这些代码后,每当我尝试构建项目时,构建都会失败并出现以下异常,

class file for com.razorpay.PaymentResultListener not found
Consult the following stack trace for details.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for 
com.razorpay.PaymentResultListener not found

有没有人可以帮我解决这个问题?谢谢是提前。

如果您创建了一个多模块项目,并且您的 paymentgateway 模块是独立的,

替换

implementation 'com.razorpay:checkout:1.5.12'

api 'com.razorpay:checkout:1.5.12'