#RichHamilton - .NET .JS

1 messages · Page 1 of 1 (latest)

lean osprey
#

What do you mean? What products? What website?

What are you trying to build?

craggy crater
#

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

lean osprey
#

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.

craggy crater
#

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();
}
}
}

lean osprey
craggy crater
#

It has a client secret?
Or I need to create a client secret?

lean osprey
#

No you cannot create a client secret. It's encoded by Stripe when your .NET server code creates the Payment Intent.

#

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

craggy crater
#

OK, I am trying this - thankyou

craggy crater
#

So now I'm getting
Stripe.StripeException: 'No such payment_intent:
when using
var intent = service.Get("pi_xxxxxx");

sonic cliff
#

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

craggy crater
#

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?

sonic cliff
#

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();```
craggy crater
#

Its not liking Get() without an ID

#

I just don't understand the flow of what I'm meant to be doing

sonic cliff
#

Gotcha. I will look back at the process, one moment. Where are you currently getting the payment intent ID from?

craggy crater
#

ok, I think I have it

var service = new PaymentIntentService();
var intent = service.Create(options);

sonic cliff
#

Yes, you should be able to look up the ID from that if you created it.

#

Where did that other ID come from? Was it the example one in the docs?