StripeException:提供的API密钥无效:Stripe.Net

Ale*_*ohr 2 stripe.net asp.net-core-mvc

我的程序成功创建了一个令牌并传递它.然后,它为Stripe的客户创建所有相关信息.

                var customer = new StripeCustomerCreateOptions();

            customer.Email = $"{user.Email}";
            customer.Description = $"{user.Email} [{userId}]";
            customer.PlanId = planId;
            customer.SourceToken = stripeToken;
            customer.Quantity = 1;
            var customerService = new StripeCustomerService();
            StripeCustomer stripeCustomer = customerService.Create(customer);
Run Code Online (Sandbox Code Playgroud)

我确认所有这些都正确地将它们的值传递给客户对象但是,我在标题中得到了错误.我错过了什么?

Ale*_*ohr 6

呃...我是个白痴......我错过了一条线来设置我的API密钥,如下所示:

StripeConfiguration.SetApiKey(StripePrivateKey);
Run Code Online (Sandbox Code Playgroud)