简体   繁体   English

Stripe API更新客户信用卡详细信息 - Java

[英]Stripe API Update Customer Credit Card Details - Java

Cannot figure out for the life of me how to do this. 无法弄清楚我的生活怎么做。 I've tested the following which isn't working; 我测试过以下哪些不起作用;

String stripeCustomerID = "123";
Customer cu = Customer.retrieve(stripeCustomerID);
cu.setDefaultSource(token);
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("default_source", token);
enter code here`cu.update(updateParams);

This is the only place the Stripe API documentation hasn't had the answer. 这是Stripe API文档唯一没有答案的地方。

Has anyone implemented this previously? 有没有人以前实现过这个?

Regards, Michael 问候,迈克尔

default_source is expecting a card id not a token id. default_source期望卡ID不是令牌ID。 Thus you either need to: 因此,您需要:

1) Add the card to the customer and then update the default_source property 1)将卡添加到客户,然后更新default_source属性
or 要么
2) You can set the source property of the customer to the token. 2)您可以将客户的source属性设置为令牌。 By setting source you will add the new card, delete the old default_source, and then set the new one as the default, all in the same API call. 通过设置source您将添加新卡,删除旧的default_source,然后将新的默认值设置为默认值,所有这些都在同一API调用中。

Answer thanks to Matthew; 谢谢马修;

Customer cu = Customer.retrieve(stripeCustomerID);
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("source", token);
cu.update(updateParams);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM