Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
How do I set the path in a fetch api

I'm attempting to implement stripe into my project. The code below is from the Stripe integration for asp.net MVC. But I have no MVC, it is asp.net core 5 razor pages project. So I'm modifying there code to suit razor.

This is the script.

// A reference to Stripe.js initialized with a fake API key.
 const stripe = Stripe("abc");

// The items the customer wants to buy
const items = [{ id: "Art Works" }];

let elements;

initialize();
checkStatus();

document
.querySelector("#payment-form")
.addEventListener("submit", handleSubmit);

// Fetches a payment intent and captures the client secret
async function initialize() {
        const response = await fetch('./?handler=create', {
        method: "POST",
        headers: { "Content-Type": "application/json" },
       body: JSON.stringify({ items }),
    });
    const { clientSecret } = await response.json();

    const appearance = {
        theme: 'stripe',
   };
elements = stripe.elements({ appearance, clientSecret });

     const paymentElement = elements.create("payment");
     paymentElement.mount("#payment-element");
}

This seems to be the offending code "const response = await fetch('./?handler=create'," I know the fetch url is incorrect.

This is the handler I'm trying to fetch on the page behind index.cshtml

 public IActionResult OnPostCreate(PaymentIntentCreateRequest request)
    {
        var paymentIntentService = new PaymentIntentService();
        var paymentIntent = paymentIntentService.Create(new PaymentIntentCreateOptions
        {
            Amount = CalculateOrderAmount(request.Items),
            Currency = "AUD",
            PaymentMethodTypes = new List<string>
            {
              "card",
            },
        });

        return new JsonResult(new { clientSecret = paymentIntent.ClientSecret });
    }

Any help would be appreciated Thank you.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda