stripe-payments - 无法获取 Stripe Checkout 会话对象
问题描述
Stripe.Net v34.16.0 在创建结帐会话对象时反弹我的代码,响应如下:
StripeException:没有这样的计划:plan_myPlanId;实时模式中存在类似的对象,但使用了测试模式密钥来发出此请求。
我没有在 Stripe Dashboard 中看到将给定计划指定为测试计划的方法。我也看不到任何类似于模式属性的东西.. 我的代码
public async Task<IActionResult> Index()
{
//var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
//user = await _userManager.FindByIdAsync(userId);
StripeConfiguration.ApiKey = "sk_test_mytestkey";
var options = new Stripe.Checkout.SessionCreateOptions
{
PaymentMethodTypes = new List<string> {
"card",
},
SubscriptionData = new Stripe.Checkout.SessionSubscriptionDataOptions
{
Items = new List<SessionSubscriptionDataItemOptions> {
new SessionSubscriptionDataItemOptions {
Plan = "plan_myplanid",
},
},
},
//to do
SuccessUrl = "localhost://home",
CancelUrl = "localhost://home",
//CancelUrl = "https://example.com/cancel",
};
var service = new Stripe.Checkout.SessionService();
Stripe.Checkout.Session session = service.Create(options); //error out here
StripeCheckoutSessionId stripeCheckoutSessionId = new StripeCheckoutSessionId();
stripeCheckoutSessionId.StripeSessionID = session.Id;
return View(stripeCheckoutSessionId);
}
我指的是 .Net 选项卡中的 Stripe 示例代码:https ://stripe.com/docs/payments/checkout/subscriptions/starting
感谢您在纠正我的错误方面的指导。
解决方案
推荐阅读
- python - 如何使用 python 在地理地图上将边缘绘制为 3D 弧?
- android - 如何在我的应用程序中添加小提示或消息,我应该使用库吗?
- drupal - BrowserSync 和 Gulp 是否在本地主机上构建 drupal 时相互补充或竞争
- javascript - 你会如何在 Angular 6 中设计这个组件?
- opencv - 在 ARM Docker 容器中构建 OPENCV 时出现问题
- jquery - 基于国家代码的jquery简单重定向代码
- css - 加载 CSS 后渲染 SVG (React styled-components)
- python - 在 python 中打印图像中对象的边界大小时出现错误
- java - 当出现异常时,回滚完成的操作,但将异常存储在表中
- ios - PageViewController 不工作