我正在尝试使用 Stripe API
为我的 Java Spring MVC
Web 应用程序设置自动续订
功能。我在我的 pom.xml
文件中添加了以下 Maven
依赖项:
<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>5.8.0</version>
</dependency>
我正在尝试按照 https://stripe.com/docs/subscriptions/quickstart#define-plan 的说明进行操作.
当我尝试使用完全相同的代码创建链接中指定的计划时,代码仅显示错误。我使用 eclipse ,但没有显示任何要导入的内容。看起来好像缺少了一些东西,但无法从 stripe 文档中找到任何内容。
// 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);
是否有使用 Stripe API 设置自动续订的示例。
最佳答案
您的代码是正确的。根据您的说法,听起来您遇到的问题是将 Stripe 的 Java 库导入到您的项目中,而不是实际使用该库。
您是否在代码开头添加了以下内容?
import com.stripe.Stripe;
import com.stripe.model.Plan;
关于java - 使用 Java 中的 Stripe API 设置自动续订,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46097271/