#thomasnevink

1 messages · Page 1 of 1 (latest)

formal emberBOT
river pasture
#

Hello 👋
Is that from .NET SDK?

#

What version of the SDK are you running?

#

Can you share the exact code?

south dawn
river pasture
#

Can you share the exact code you're using?

south dawn
river pasture
#

Can you share it in text and not pictures?

south dawn
#

Sure

#

[HttpPost]
[Route("create")]
public ActionResult Create(PaymentIntentCreateRequest request)
{
int orderAmount = CalculateOrderAmount(request.Items);

        var options = new PaymentIntentCreateOptions
        {
            Amount = orderAmount,
            Currency = "INR",
            AutomaticPaymentMethods = new PaymentIntentAutomaticPaymentMethodsOptions // optional
            {
                Enabled = true,
            },
            Metadata = new Dictionary<string, string>
            {
                {"Identifier", "321"},
                {"AdditionalInfo", "xyz"}
            }
        };

        if (request.SavePaymentMethod)
        {
            //// To set a card up for future payments, you must attach it to a Customer.
            //// Create a Customer object when your customer creates an account with your business.
            //// Customer objects allow for reusing payment methods and tracking across multiple payments.
            // Create a Customer with a payment method attached
            var customerOptions = new CustomerCreateOptions();

            var customerService = new CustomerService();
            var customer = customerService.Create(customerOptions);
            options.Customer = customer.Id;
            options.SetupFutureUsage = "off_session";
        }
        else
        {
            options.SetupFutureUsage = "on_session"; // Use on_session if you don't want to save the payment method
        }

        var paymentIntents = new PaymentIntentService();
        var paymentIntent = paymentIntents.Create(options);

        return Json(new { clientSecret = paymentIntent.ClientSecret });
    }
river pasture
#

Thanks

#

looking

#

Let me ask a colleague

lethal sedge
#

Hello, looking in to this. Are you able to access other objects in out library or do you get this error for them too?

river pasture
#

@south dawn want to make sure you're seeing our messages

south dawn
#

Sorry, was in a meeting

#

No only for AutomaticPaymentMethods

lethal sedge
#

Gotcha, I'm running that same code in my local .NET install with the same .NET version. It is hard to say what may be the issue here

south dawn
#

I'm running it in VS 2019, is that a problem?

lethal sedge
#

Not sure if we have a minimum required VS version but I will check in to it

#

I used VSCode so that is a difference in our setups

#

And what .NET version are you building with? Can check mine as well