java - com.stripe.exception.InvalidRequestException:根据印度法规,出口交易需要客户姓名和地址。在春季靴子中
问题描述
我在我的 Spring Boot 项目中集成了条带
@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); //$9.99 USD
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); // ^ obtained with Stripe.js
//create a charge
Charge charge = Charge.create(chargeParams);
id = charge.getId();
} catch (Exception ex) {
ex.printStackTrace();
}
return id;
}
我收到异常 com.stripe.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); // ^ obtained with Stripe.js
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); // ^ obtained with Stripe.js
//create a new customer
Customer customer = Customer.create(customerParams);
chargeParams.put("customer", customer.getId());
//create a charge
Charge charge = Charge.create(chargeParams);
id = charge.getId();
但现在出现异常 com.stripe.exception.InvalidRequestException: Customer cus_JIMd90oUI9V8e6 does not have a linked source with ID tok_1Iflu8AuNrJFnosEZI2huyYo.; 代码:缺失
当我将货币更改为 inr 时,问题已解决,但我不想更改货币
解决方案
我在使用 Stripe API 创建费用时也收到了这个异常。
我对Java不太熟悉,但假设没有其他错误。
试试这个:将货币从USD更改为INR。
这对我有用,所以希望对你也有用。
推荐阅读
- javascript - 制作具有不同颜色的传单自定义图标
- angular - NestJs - Angular - 部署策略
- java - 实体映射中序列的增量大小设置为[50],而关联的数据库序列增量大小为1
- android - Android Studio-Kotlin:价值
这是我的 php 文件:我想根据 donasi 表中的最后一个 id 将数据插入 detaildonasi
<?php $conn = new mysqli("localhost","root",
- ios - 处理 json 中接收的字符串和 int
- android - 实时数据更新数据绑定上的嵌套滚动视图跳转
- wordpress - 搜索结果中的 Woocommerce 标签
- c# - SDL#:为什么将 IntPtr 初始化为 null?
- swift - 如何在 IBAction 中快速选择三个按钮之一
- android - 如何在离子中显示共享底页以进行文件共享?