此示例不正确,因为
cancel_at_period_end
是顶级参数。
代码应为:
Subscription subscription = Subscription.retrieve("sub_49ty4767H20z6a");
Map<String, Object> item = new HashMap<>();
item.put("id", subscription.getSubscriptionItems().getData().get(0).getId());
item.put("plan", "plan_CBb6IXqvTLXp3f");
Map<String, Object> items = new HashMap<>();
items.put("0", item);
Map<String, Object> params = new HashMap<>();
params.put("items", items);
params.put("cancel_at_period_end", false);
subscription.update(params);