Unable to retrieve metadata from StripePaymentIntent object

Viewed 455

I am unable to retrieve/view the metadata I am setting from my Succeeded Payment record in Stripe. On the .NET core server side I am creating a payment intent and returning the intent secret to the client as follows using the stripe .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);
     }

When I check the stripe dashboard an incomplete payment object exists with the needed metadata: enter image description here

On the client side I am using the intentClient Secret to perform a "confirmCardPayment" action:

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

Upon successful processing, a "Payment Succeeded" record is added to the dashboard (different id). The amount and currency are carried over from the original intent, however the metadata is missing from this new payment object: enter image description here

Questions:

  1. Is this normal for Stripe to create 2 payment records (1 succeeded and 1 incomplete) for every transaction?
  2. Do I need to explicitly pass my metadata a second time during stripe.confirmCardPayment?
1 Answers
  1. It's not normal for Stripe to create 2 PaymentIntents, I'd look at your code as it's likely that the same block is being run more than once in your flow
  2. Where are you retrieving the metadata? If it's on the client, it's expected to not get metadata in the PaymentIntent that you get in the result object from a successful confirmCardPayment call. Metadata could possible contain sensitive items, so you can only see metadata by retrieving the PaymentIntent using a secret API key.
Related