简体   繁体   English

在Java中使用Stripe API设置自动续订

[英]Setting up automatic renewals with Stripe API in Java

I am trying to set up Automatic Renewal feature for my Java Spring MVC web application, using Stripe API . 我正在尝试使用Stripe APIJava Spring MVC Web应用程序设置Automatic Renewal功能。 I have added the following Maven dependency in my pom.xml file: 我在pom.xml文件中添加了以下Maven依赖项:

<dependency>
  <groupId>com.stripe</groupId>
  <artifactId>stripe-java</artifactId>
  <version>5.8.0</version>
</dependency>

I am trying to follow the instructions from https://stripe.com/docs/subscriptions/quickstart#define-plan . 我正在尝试按照https://stripe.com/docs/subscriptions/quickstart#define-plan的说明进行操作。

When I try to create a plan as specified in the link using the exact same code, the code shows only errors. 当我尝试使用完全相同的代码创建链接中指定的计划时,该代码仅显示错误。 I use eclipse and there is nothing shown to be imported. 我使用eclipse ,没有显示要导入的内容。 Looks like something is missing, but could not find anything from the stripe documentation. 看起来好像缺少了一些东西,但是从条纹文档中找不到任何东西。

// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.apiKey = "sk_test_...";

Map<String, Object> params = new HashMap<String, Object>();
params.put("name", "Basic Plan");
params.put("id", "basic-monthly");
params.put("interval", "month");
params.put("currency", "usd");
params.put("amount", 0);

Plan plan = Plan.create(params);

Is there any examples of setting up automatic renewals with Stripe API. 是否有使用Stripe API设置自动续订的示例。

Your code is correct. 您的代码是正确的。 According to what you said, it sounds like the issue you're having is with importing Stripe's Java library into your project, not actually using the library. 根据您所说的,这听起来像是您将Stripe的Java库导入项目而不是实际使用该库时遇到的问题。

Did you add the following at the beginning of your code? 您是否在代码开头添加了以下内容?

import com.stripe.Stripe;
import com.stripe.model.Plan;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM