首页 > 解决方案 > Paypal native checkout sdk android paypal按钮在一次付款完成或取消后不呈现

问题描述

我目前正在使用 Paypal Native Checkout SDK https://developer.paypal.com/docs/business/native-checkout/android/。第一次一切正常,但如果我完成或取消贝宝付款,按钮不会再次呈现,日志返回错误 I/PaymentButtonEligibility:资格:错误。

有谁知道解决方案?

class App: Application() {
    override fun onCreate() {
        super.onCreate()
        val config = CheckoutConfig(
        application = this,
        clientId = "....",
        environment = Environment.SANDBOX,
        returnUrl = "my.com.testpaypal://paypalpay",
        currencyCode = CurrencyCode.MYR,
        userAction = UserAction.PAY_NOW,
        paymentButtonIntent = PaymentButtonIntent.CAPTURE,
        settingsConfig = SettingsConfig(
            loggingEnabled = true
        )
    )
    PayPalCheckout.setConfig(config)
}

}

class TestActivity : AppCompatActivity() {

    private lateinit var binding: ActivityTestBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityTestBinding.inflate(layoutInflater)
        setContentView(binding.root)

        binding.btnPay.setup(
            createOrder = CreateOrder { createOrderActions ->
                val order = Order(
                intent = OrderIntent.CAPTURE,
                appContext = AppContext(
                    userAction = UserAction.PAY_NOW
                ),
                purchaseUnitList = listOf(
                    PurchaseUnit(
                        //items = List<Items>(1) { _ -> },

                        amount = Amount(
                            currencyCode = CurrencyCode.MYR,
                            value = "12"
                        )
                    )
                )
            )
            createOrderActions.create(order)
        },
        onApprove = OnApprove { approval ->
            approval.orderActions.capture { captureOrderResult ->
                Log.i("CaptureOrder", "CaptureOrderResult: $captureOrderResult")
            }
        },
        onCancel = OnCancel {
            Log.i("OnCancel", "Buyer canceled the PayPal experience.")
        },
        onError = OnError { errorInfo ->
            Log.i("OnError", "Error: $errorInfo")
        }
    )
}

}

  1. 按钮可以渲染
  2. 贝宝本机结帐sdk ui
  3. 按钮无法渲染

标签: androidkotlinpaypalsdk

解决方案


推荐阅读