#RichHamilton - .NET .JS
1 messages · Page 1 of 1 (latest)
I am building a website in .Net Framework (Umbraco)
We have products on there
I am building the payment process
But really can't work out how to integrate Stripe and the process I need to go through
First I tried the hosted form but that isn't working
so now looking at a mixture of the backend Stripe.Net and stripe.js
with an element on the page
I don't want Stripe to care about products - it just needs the Cart totals etc as every product could be bespoke
In that case you can use something basic like Payment Intents. They just need amounts, currency, and the payment method to charge
This doc has both .NET server examples and .js front-end examples for how you would build a complete payment flow
That way your site can handle all the Product and Price info yourself. Just pass the total to be charged to Stripe and accept a payment.
How do I get the ClientSecret?
using System;
using Microsoft.AspNetCore.Mvc;
using Stripe;
namespace StripeExampleApi.Controllers
{
[Route("/[controller]")]
public class CheckoutController : Controller
{
public IActionResult Index()
{
var intent = // ... Fetch or create the PaymentIntent
ViewData["ClientSecret"] = intent.ClientSecret;
return View();
}
}
}
You first create or retrieve a Payment Intent. That Payment Intent will have a client_secret property
https://stripe.com/docs/api/payment_intents/object#payment_intent_object-client_secret.
It has a client secret?
Or I need to create a client secret?
No you cannot create a client secret. It's encoded by Stripe when your .NET server code creates the Payment Intent.
So, once you know the amount you want to charge your customer, you create the payment intent as shown here:
https://stripe.com/docs/api/payment_intents/create?lang=dotnet
This will return the payment intent object and one of the properties will be the client_secret
That is what you pass to the front-end to collect payment method info
OK, I am trying this - thankyou
So now I'm getting
Stripe.StripeException: 'No such payment_intent:
when using
var intent = service.Get("pi_xxxxxx");
Do you have an example payment intent ID that you got that for?
Most commonly that means you are are on an account that does not have access to that payment intent
Are you using Stripe Connect here? This often happens between platforms and their connected accounts
ok
var service = new PaymentIntentService();
service.Create(options);
var intent = service.Get("pi_1EUmyo2x6R10KRrhUuJXu9m0");
But I don't know where I should get that ID from?
That is a valid ID. Not immediately sure why you cannot pull it. Can you try this and tell me what the ID of the account you get back is?
service.Get();```
Its not liking Get() without an ID
I just don't understand the flow of what I'm meant to be doing
Gotcha. I will look back at the process, one moment. Where are you currently getting the payment intent ID from?
ok, I think I have it
var service = new PaymentIntentService();
var intent = service.Create(options);