kotlin paymentButtonContainer.设置未解析引用

ghhkc1vu  于 2023-02-09  发布在  Kotlin
关注(0)|答案(1)|浏览(122)

对于paymentButtonContainer.setup,我得到未解析引用的错误:然而,我已经按照https://developer.paypal.com/limited-release/paypal-mobile-checkout/android/上的说明在xml文件中声明了按钮容器。
尝试使用binding. paymentButtonContainer. setup。但是,系统由于以下错误而崩溃:
原因:安卓系统.view.inflateException:com.example.paypal:layout/activity_main中的二进制XML文件第11行:膨胀类com.paypal.checkout.paymentbutton.paymentbuttonContainer时出错
主活动.kt中的代码

val config = CheckoutConfig(
            application,
            clientId = "*********my client id***************",
            environment = Environment.SANDBOX,
            currencyCode = CurrencyCode.USD,
            userAction = UserAction.PAY_NOW,
            settingsConfig = SettingsConfig(
                loggingEnabled = true
            )
        )
        PayPalCheckout.setConfig(config)

 paymentButtonContainer.setup(
            createOrder =
            CreateOrder { createOrderActions ->
                val order =
                    Order(
                        intent = OrderIntent.CAPTURE,
                        appContext = AppContext(userAction = UserAction.PAY_NOW),
                        purchaseUnitList =
                        listOf(
                            PurchaseUnit(
                                amount =
                                Amount(currencyCode = CurrencyCode.USD, value = "10.00")
                            )
                        )
                    )
                createOrderActions.create(order)
            },
            onApprove =
            OnApprove { approval ->
                approval.orderActions.capture { captureOrderResult ->
                    Log.i("CaptureOrder", "CaptureOrderResult: $captureOrderResult")
                }
            }
        )

activity_main. xml中的代码

<com.paypal.checkout.paymentbutton.PaymentButtonContainer
        android:id="@+id/paymentButtonContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:paypal_button_color="silver"
        app:paypal_button_label="pay"
        app:paypal_button_shape="rectangle"
        app:paypal_button_size="large"
        app:paypal_button_enabled="true" />
vh0rcniy

vh0rcniy1#

尝试在Gradle文件中更改您的实施
实现'com.贝宝.结帐:安卓软件开发包:0.8.8'

相关问题