PayPal android 集成无限加载付款

问题描述 投票:0回答:2

我正在尝试使用他们的沙箱帐户文档来实现贝宝付款。所以,我的代码如下所示:

fun setupPayPal(
        payPalButton: PayPalButton, bottomSheetDialog: BottomSheetDialog,
        orderRequest: OrderRequest
    ) {
        val config = CheckoutConfig(
            application = fragmentActivity.application,
            clientId = Config.PAYPAL_CLIENT_ID,
            environment = Environment.SANDBOX,
            returnUrl = "com.example.shopkotlin://paypalpay",
            currencyCode = CurrencyCode.USD,
            userAction = UserAction.PAY_NOW,
            settingsConfig = SettingsConfig(
            loggingEnabled = true
        ))

        PayPalCheckout.setConfig(config)

        payPalButton.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")
                            )
                        ),
                        processingInstruction = ProcessingInstruction.ORDER_COMPLETE_ON_PAYMENT_APPROVAL
                    )
                createOrderActions.create(order)
            },
            onApprove =
            OnApprove { approval ->
                approval.orderActions.capture {
                    orderRequest.paymentMethod = "PayPal"
                    orderViewModel!!.createOrder(token, orderRequest)
                    bottomSheetDialog.cancel()
                }
            },
            onError = OnError { errorInfo ->
                println("error $errorInfo")
            }
        )
    }

问题是它启动正常,我正在登录,但是它卡住了,并且在 sandbox.paypal.com 上无限加载,我正在使用 Kotlin,在我的 Java 应用程序上,相同的代码可以像 charm 一样工作,但是这个没有,确实有人知道为什么吗?我查看了日志,到目前为止没有错误。

kotlin
2个回答
1
投票

通过正确更改返回 URL 进行修复。在

paypal.developer
中,我们应该按照我的代码中的方式设置 URL,但是我们必须确保 URL 匹配,签入
build.gradle
(模块)。


0
投票

检查你的returnUrl是否正确。 转到 Paypal 开发人员中的仪表板 -> 应用程序和凭据 -> 您的应用程序 -> 功能 -> 其他功能 -> 选中“使用 Paypal 登录” -> 高级设置并设置您的 returnUrl。

您可以使用命名空间,如下所示:your.app.package://paypaypal。

当然,还有其余的配置,例如清单,例如:

        ...<intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <data android:scheme="your.app.package"/>...

问候

© www.soinside.com 2019 - 2024. All rights reserved.