无法从 StripePaymentIntent 对象中检索元数据

时间:2021-02-06 15:58:28

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

我无法从 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);
     }

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

在客户端,我使用 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)。金额和货币是从原始意图结转的,但是这个新的支付对象缺少元数据: enter image description here

问题:

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

1 个答案:

答案 0 :(得分:0)

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