【问题标题】:Can't get list of charges for customer无法获取客户的费用清单
【发布时间】:2019-02-23 10:55:20
【问题描述】:

我正在按照本指南进行收费:https://stripe.com/docs/connect/shared-customers

1) 店铺客户:

Map<String, Object> params = new HashMap<>();
params.put("email", "paying.user@example.com");
params.put("source", "tok_visa");
Customer customer = Customer.create(params);

2) 制作令牌:

Map<String, Object> params = new HashMap<String, Object>();
params.put("customer", customer.getId());
RequestOptions requestOptions = RequestOptions.builder().setStripeAccount("{CONNECTED_STRIPE_ACCOUNT_ID}").build();
Token token = Token.create(params, requestOptions);`

3) 创建费用:

Map<String, Object> params = new HashMap<>();
params.put("amount", 1000);
params.put("currency", "usd");
params.put("source", token.getId());
RequestOptions requestOptions = RequestOptions.builder().setStripeAccount("{CONNECTED_STRIPE_ACCOUNT_ID}").build();
Charge charge = Charge.create(params, requestOptions);`

费用创建成功。 但是我尝试获取该客户的所有费用清单,但我什么也没收到:

Map<String, Object> params = new HashMap<>();
params.put("customer", customer.getId());
Charge.list(params); //no charges in response

那么如何获取以这种方式创建的该客户的所有费用?

【问题讨论】:

  • 您是否将结果保存在ChargeCollection 中?喜欢ChargeCollection collection = Charge.list(params, requestOptions);
  • 我当然会保存它...但是它不包含任何费用...
  • 你试过params.get(customer.getId())吗?
  • 你如何迭代集合以及你得到什么输出?它会给你任何警告或错误吗?
  • “object”:“list”,“data”:[],“has_more”:false,“total_count”:null,“url”:“/v1/charges”,“count”: null,“request_options”:{“api_key”:“{STRIPE_API_KEY}”,“client_id”:null,“stripe_version”:“2017-08-15”,“idempotency_key”:null,“stripe_account”:null,“connect_timeout” : 30000, "read_timeout": 80000 }, "request_params": { "customer": "{CUSTOMER_ID}" } }

标签: java hashmap stripe-payments


【解决方案1】:

您需要列出在关联帐户上创建的费用。这意味着,您需要传递用于创建费用的相同请求选项。

RequestOptions requestOptions = RequestOptions.builder().setStripeAccount("{CONNECTED_STRIPE_ACCOUNT_ID}").build();
Map<String, Object> params = new HashMap<>();
params.put("customer", customer.getId());
Charge.list(params, requestOptions); //no charges in response

【讨论】:

  • 在这种情况下,我收到“没有这样的客户”错误。 (因为关联账户上没有这样的客户,在我的账户上)
猜你喜欢
  • 2019-11-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-21
  • 2019-12-17
  • 2017-03-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多