在 java 中条纹 InvalidRequestException
Stripe InvalidRequestException in java
我正在尝试在我的 android 应用程序中测试 Stripe 支付 API。 Android app发送token(token由Stripe提供给Android app)到服务器,然后服务器使用token通过Stripe charge向用户收费API。由于我正在测试该过程,因此我使用的是 Stripe 提供的虚拟值,但是当我发起收费呼叫时,我在服务器端收到 InvalidRequestException
。我很难测试它。
为了清楚起见,我还添加了一张图片。
这是我的代码。
try {
Map<String, Object> chargeParams = new HashMap<String, Object>();
chargeParams.put("amount", jsonNode.get("amount")); // amount in cents, again
chargeParams.put("currency", "USD");
chargeParams.put("source", token);
chargeParams.put("description", "charge from server");
Charge charge = Charge.create(chargeParams);
String des = charge.getDescription();
}
catch (CardException e) {
// The card has been declined
}
如何测试这个过程?
请指引我正确的方向。
在屏幕截图中,查看详细的错误消息。它告诉您出了什么问题:您的集成正在将字符串 "<com.stripe.android.model.Token@..."
作为令牌发送到 Stripe 的 API.
从您的 Android 应用程序,您可能会将令牌的字符串表示形式发送到服务器。相反,您只需发送令牌 ID。令牌 ID 是一个以 tok_
开头后跟随机字母数字字符的字符串。您可以通过调用 getId()
.
来访问它
我正在尝试在我的 android 应用程序中测试 Stripe 支付 API。 Android app发送token(token由Stripe提供给Android app)到服务器,然后服务器使用token通过Stripe charge向用户收费API。由于我正在测试该过程,因此我使用的是 Stripe 提供的虚拟值,但是当我发起收费呼叫时,我在服务器端收到 InvalidRequestException
。我很难测试它。
为了清楚起见,我还添加了一张图片。
这是我的代码。
try {
Map<String, Object> chargeParams = new HashMap<String, Object>();
chargeParams.put("amount", jsonNode.get("amount")); // amount in cents, again
chargeParams.put("currency", "USD");
chargeParams.put("source", token);
chargeParams.put("description", "charge from server");
Charge charge = Charge.create(chargeParams);
String des = charge.getDescription();
}
catch (CardException e) {
// The card has been declined
}
如何测试这个过程? 请指引我正确的方向。
在屏幕截图中,查看详细的错误消息。它告诉您出了什么问题:您的集成正在将字符串 "<com.stripe.android.model.Token@..."
作为令牌发送到 Stripe 的 API.
从您的 Android 应用程序,您可能会将令牌的字符串表示形式发送到服务器。相反,您只需发送令牌 ID。令牌 ID 是一个以 tok_
开头后跟随机字母数字字符的字符串。您可以通过调用 getId()
.