【问题标题】:Unable to retrieve metadata from StripePaymentIntent object无法从 StripePaymentIntent 对象检索元数据
【发布时间】:2021-05-10 17:08:27
【问题描述】:

我无法从 Stripe 中的成功付款记录中检索/查看我设置的元数据。在 .NET 核心服务器端,我正在创建一个支付意图并使用条带 .NET Core SDK 将意图秘密返回给客户端,如下所示:

    [HttpGet]
    public async Task<IActionResult> Index()
    {
        StripeConfiguration.ApiKey = stripeSecretKey;
        var options = new PaymentIntentCreateOptions
        {
            Amount = 2999,
            Currency = "CAD",
            PaymentMethodTypes = new List<string>(){"card"},
            Metadata = new Dictionary<string,string>()
            {
               {"stripePaymentFormId", "value1"}
               {"camperId", "value2"}
            }
        };
        var service = new PaymentIntentService();
        var paymentIntent = service.Create(options);
        return View(paymentIntent.ClientSecret);
     }

当我检查条带仪表板时,存在带有所需元数据的不完整付款对象:

在客户端,我使用 intentClient Secret 执行“confirmCardPayment”操作:

    stripe.confirmCardPayment(intentClientSecret, {
      payment_method: {
        card: card,
        type: 'card',
        billing_details: {
          name: `${billingName} ${billingLastName}`
        }
      },
    }).then(function (result) {
        //Handle success and errors
    }

成功处理后,“付款成功”记录将添加到仪表板(不同的 ID)。金额和货币是从原始意图结转的,但是此新支付对象中缺少元数据:

问题:

  1. Stripe 为每笔交易创建 2 条支付记录(1 条成功,1 条不完整)是否正常?
  2. 我是否需要在 stripe.confirmCardPayment 期间再次明确传递我的元数据?

【问题讨论】:

    标签: javascript c# asp.net-core stripe-payments


    【解决方案1】:
    1. Stripe 创建 2 个 PaymentIntent 是不正常的,我会查看您的代码,因为您的流程中可能不止一次运行同一个块
    2. 您在哪里检索元数据?如果它在客户端上,则预计不会在您从成功的 confirmCardPayment 调用中获得的 result 对象中的 PaymentIntent 中获取元数据。元数据可能包含敏感项目,因此您只能通过使用 API 密钥检索 PaymentIntent 来查看元数据。

    【讨论】:

      猜你喜欢
      • 2016-06-17
      • 1970-01-01
      • 1970-01-01
      • 2018-08-19
      • 2013-11-16
      • 2016-07-22
      • 1970-01-01
      相关资源
      最近更新 更多