代码之家  ›  专栏  ›  技术社区  ›  chaitanya gupta

com.strip.exception。InvalidRequestException:根据印度法规,出口交易需要客户姓名和地址。春季靴

  •  0
  • chaitanya gupta  · 技术社区  · 4 年前

    我在春季靴子项目中集成了条纹

        @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.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); // ^ 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.strip.exception。InvalidRequestException:客户cus_JIMd90oUI9V8e6没有ID为tok_1Iflu8AuNrJFnosEZI2huyYo的链接源。;代码:缺失

    当我把货币换成inr时,问题就解决了,但我不想换货币

    0 回复  |  直到 4 年前
        1
  •  0
  •   cicada_    4 年前

    我在使用Stripe API创建收费时也收到了此异常。

    我对Java不太熟悉,但假设没有其他错误。

    试试这个: 改变 这个 货币 美元 INR .

    这对我有效,所以希望对你也有效。