I'm developing a web app in dotnet 6 C# core razor pages. I have setup an Azure key vault with my Stripe Api Key and Publishable Key. I use the following code to access the key from the Key Vault.
public readonly IConfiguration _configuration;
PublicKey = _configuration["PublishableKey"].ToString();
This code I have tested and it does return the Publishable Key. I then need to inject that key into a javascript file checkout.js.
const stripe = Stripe('');
I tried this in the cshtml file,
@using Microsoft.Extensions.Configuration
@inject IConfiguration Configuration
@Configuration["PublishableKey"].ToString()
That worked in the cshtml file. I then tried this in the javerscript file checkout.js.
const stripe = Stripe('@Configuration["PublishableKey"].ToString()')
I also tried.
@Model.PublicKey
But neither returned the key. How do I reference this key in the javascript file? Your help would be appreciated Thank-you.