如何在不创建 PaymentSource 的情况下将 Stripe 令牌传递给收费对象?

How to pass the Stripe token to the charge object without creating a PaymentSource?

似乎有两种方法可以创建条纹电荷:

1) 使用属性映射,其中 Stripe 标记只是另一个字符串 属性:

Map<String, Object> chargeParams = new HashMap<String, Object>();
chargeParams.put("amount", 400);
chargeParams.put("currency", "usd");
chargeParams.put("source", "tok_15jGykA1uVHZiLuVZf6lmzyd"); 
chargeParams.put("description", "some desc");
Charge.create(chargeParams);

2) 直接在 Charge 对象上设置参数:

Charge charge = new Charge();
charge.setAmount(400);
charge.setCurrency("USD");
charge.setDescription("some desc");
charge.setSource("tok_15jGykA1uVHZiLuVZf6lmzyd");  // doesn't work!

我更喜欢使用选项 2,但我似乎做不到。我不能将 String 令牌直接传递给 Charge 对象,这似乎很愚蠢。它要我创建一个 PaymentSource,并将其传递给 setSource()。但是我没有 PaymentSource。只是令牌。

有人成功过吗?

根据 Stripes 团队的说法,这不受支持。他们选择让 Java 库接受参数映射,这样开发人员就不必在每次进行非向后兼容更改时都升级到最新版本的 Stripes。很公平。