当我尝试使用 java sdk 创建 Stripe Customer 时,它抛出“无效对象”
我正在尝试创建一个带有地址的 Stripe Customer,但我无法这样做,因为它最终会引发无效对象错误。如果我删除该地址,我就可以创建客户。但我的要求是用他/她的地址创建客户。
这是我试图执行的代码。
Address address = new Address();
address.setPostalCode("250532");
address.setState("Maharashtra");
address.setLine2("20/2, Ganesh Street");
address.setCity("Mumbai");
address.setCountry("IN");
Map<String, Object> customerParams = new HashMap<>();
customerParams.put("email", "[email protected]");
customerParams.put("name", "Radhey");
customerParams.put("description", "Test Customer");
customerParams.put("address", address);
customerParams.put("source", token);
Customer customer = Customer.create(customerParams);
它在代码的最后一行抛出无效对象错误。
下面给出的是堆栈跟踪:
com.stripe.exception.InvalidRequestException: Invalid object
at com.stripe.net.LiveStripeResponseGetter.handleAPIError(LiveStripeResponseGetter.java:645)
at com.stripe.net.LiveStripeResponseGetter._request(LiveStripeResponseGetter.java:490)
at com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:73)
at com.stripe.net.APIResource.request(APIResource.java:161)
at com.stripe.model.Customer.create(Customer.java:380)
at com.stripe.model.Customer.create(Customer.java:265)
at stripe.Test.chargeCreditCard(Test.java:51)
at stripe.Test.main(Test.java:19)
I am trying to create a Stripe Customer with address and I not able to do so because it ends up throwing invalid object error. If I remove the address I am able to create the customer. But my requirement is to create the customer with his/her address.
This is the code that I am trying to execute.
Address address = new Address();
address.setPostalCode("250532");
address.setState("Maharashtra");
address.setLine2("20/2, Ganesh Street");
address.setCity("Mumbai");
address.setCountry("IN");
Map<String, Object> customerParams = new HashMap<>();
customerParams.put("email", "[email protected]");
customerParams.put("name", "Radhey");
customerParams.put("description", "Test Customer");
customerParams.put("address", address);
customerParams.put("source", token);
Customer customer = Customer.create(customerParams);
It is throwing invalid object error on the last line of the code.
Below given is the stacktrace:
com.stripe.exception.InvalidRequestException: Invalid object
at com.stripe.net.LiveStripeResponseGetter.handleAPIError(LiveStripeResponseGetter.java:645)
at com.stripe.net.LiveStripeResponseGetter._request(LiveStripeResponseGetter.java:490)
at com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:73)
at com.stripe.net.APIResource.request(APIResource.java:161)
at com.stripe.model.Customer.create(Customer.java:380)
at com.stripe.model.Customer.create(Customer.java:265)
at stripe.Test.chargeCreditCard(Test.java:51)
at stripe.Test.main(Test.java:19)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
评论部分@RyanM 的解决方案对我有用。
The solution by @RyanM in the comment section worked for me.