我在春季靴子项目中集成了条纹
@PostMapping("/create-charge")
public @ResponseBody Response createCharge(String email, String token) {
if (token == null) {
return new Response(false, "Stripe payment token is missing. Please, try again later.");
}
String chargeId = stripeService.createCharge(email, token, 999);
if (chargeId == null) {
return new Response(false, "An error occurred while trying to create a charge.");
}
return new Response(true, "Success! Your charge id is " + chargeId);
}
我的服务
public String createCharge(String email, String token, int amount) {
String id = null;
try {
Stripe.apiKey = API_SECRET_KEY;
Map<String, Object> chargeParams = new HashMap<>();
chargeParams.put("amount", amount);
chargeParams.put("currency", "usd");
chargeParams.put("description", "Charge for " + email);
chargeParams.put("source", token);
Charge charge = Charge.create(chargeParams);
id = charge.getId();
} catch (Exception ex) {
ex.printStackTrace();
}
return id;
}
我有例外
com.strip.exception。InvalidRequestException:根据印度法规,出口交易需要客户姓名和地址。更多信息请点击此处:
https://stripe.com/docs/india-exports
我应该如何传递请求中的地址?
我试着这样传递地址
Stripe.apiKey = API_SECRET_KEY;
Map<String, Object> chargeParams = new HashMap<>();
chargeParams.put("amount", amount);
chargeParams.put("currency", "usd");
chargeParams.put("description", "Charge for " + email);
chargeParams.put("source", token);
Map<String, Object> customerParams = new HashMap<>();
Map<String, String> addressParams = new HashMap<>();
customerParams.put("description", "Customer for " + email);
customerParams.put("email", email);
customerParams.put("address", addressParams);
addressParams.put("city", "varanasi");
addressParams.put("country", "india");
customerParams.put("source", token);
Customer customer = Customer.create(customerParams);
chargeParams.put("customer", customer.getId());
Charge charge = Charge.create(chargeParams);
id = charge.getId();
但现在有例外了
com.strip.exception。InvalidRequestException:客户cus_JIMd90oUI9V8e6没有ID为tok_1Iflu8AuNrJFnosEZI2huyYo的链接源。;代码:缺失
当我把货币换成inr时,问题就解决了,但我不想换货币