【问题标题】:Android Stripe Saved card missing from payment sheet付款表中缺少 Android Stripe Saved 卡
【发布时间】:2022-11-08 22:36:22
【问题描述】:

获取 customerId、ephemeralKey 和 clientSecret 后,我​​使用 Configuration 对象(包括应用名称、customerConfiguration(customerId、ephemeralKey 和 GooglePayConfiguration.

然后我调用presentWithPaymentIntent(clientSecrent, customerConfiguration),其中客户配置是第一步创建的对象。

文档说,如果您通过客户配置并且用户选中“保存以备将来付款”复选框,则在下一次付款时,PaymentSheet 将显示已保存的卡,但出于某种原因,对我来说它没有。

我已经检查了 customerId 对于当前客户来说它总是一样的,只有 ephemeralKey 改变了新的付款,这似乎是正确的。

知道我可能做错了什么吗? iOS 客户端按预期工作,因此服务器端配置正常。

谢谢!

代码示例:

PaymentSheet.GooglePayConfiguration googlePayConfiguration = new PaymentSheet.GooglePayConfiguration(getGooglePayEnvironment(), countryCode);
        PaymentSheet.CustomerConfiguration customerConfiguration = new PaymentSheet.CustomerConfiguration(mViewModel.getCustomerId(), mViewModel.getEphemeralKey());

        PaymentSheet.Configuration configuration = new PaymentSheet.Configuration(getString(R.string.app_name),
                customerConfiguration,
                googlePayConfiguration,
                null,
                null);

mPaymentSheet.presentWithPaymentIntent(mViewModel.getClientSecret(), configuration);

【问题讨论】:

  • 您能否分享您在致电以出示付款单时使用的代码以及您的后端提供的数据样本?我假设您大致遵循本指南:stripe.com/docs/payments/accept-a-payment?platform=android
  • @RyanM 感谢您的评论。是的,我点击了那个链接。我用代码示例编辑了我的问题。
  • 您可以记录customerConfiguration 的值并将其作为单独的sn-p 共享吗?未显示已保存付款方式的一个常见原因是预期与提供的配置值不匹配。

标签: android stripe-payments payment stripe-payment-intent


【解决方案1】:

您的问题没有显示在视图模型中执行的代码,所以我将给出一个保存/加载卡片数据的工作示例:

  • 获取临时密钥 - 要从服务器获取密钥,您需要 发送一个 POST 请求,您必须附加一个自定义 ID。这 请求可能会有所不同,具体取决于您服务器上的实现。 在来自服务器的响应中,我们收到一个临时密钥。条纹 将其发送到名为“secret”的服务器。重要的!如果您不使用自己的服务器来保护您的密钥,那么您需要 从https://api.stripe.com/v1/ephemeral_keys 中准确获取名为“secret”的字段

  • 发送付款意图。最有可能的是,这个实现也将是 转移到您的服务器,并将被替换为 您的服务器,它将生成付款意图并向您发送 但是,返回必要的数据,默认的主体实现将看起来 像这样:

https://api.stripe.com/v1/payment_intents BODY PARAMS

 customer=$customerId
 amount=$amount
 currency=usd

此请求将返回密钥意图,我们将在初始化付款表期间使用该密钥意图。

下一步是设置工作表。使用以下代码:

val customerConf = PaymentSheet.CustomerConfiguration(viewModel.customerId, ephemeralKey)
val sheetConf = PaymentSheet.Configuration(
        merchantDisplayName = "Some product name",
        customer = customerConf,
        allowsDelayedPaymentMethods = false
)
paymentSheet.presentWithPaymentIntent(intentSecret, sheetConf)

因此,您将在重新付款后收到您的卡的保留。

Payment by saved card. Image

我还建议您为 android 应用程序创建一个测试用户,并在单击复选框并付款后在仪表板上检查卡数据是否已保存

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-11
    • 2021-01-10
    • 2023-03-09
    • 2020-08-16
    • 2021-09-02
    • 2012-03-29
    • 2018-09-12
    • 2017-04-16
    相关资源
    最近更新 更多