列出客户的所有Stripe事件

问题描述 投票:2回答:1

我已将Wordpress连接到Stripe,并希望在其Wordpress管理员用户页面中显示每个用户的Stripe事件历史记录。本质上,选择一个客户并单击时,我希望在Stripe管理员中使用相同的视图:“查看更多事件”,其结果是:https://dashboard.stripe.com/test/events?related_object=cus_ **********

我在Stripe API文档中的任何地方都找不到解决此问题的方法,因此我目前正在尝试获取所有事件,然后返回属于当前客户的任何事件。这似乎不必要地复杂,所以我希望有更好的方法。感谢您的帮助。

\Stripe\Stripe::setApiKey($stripe_api_key);

$stripe_customer = \Stripe\Customer::retrieve($stripe_customer_id);
$all_stripe_events = \Stripe\Event::all(['limit' => 10000]);

$event_data = $all_stripe_events->data;

foreach($event_data as $event) {
... compare every event against the current customer ...
}
php wordpress stripe-payments
1个回答
0
投票

API docs中没有记录,但是在检索Stripe仪表板使用的事件时,您应该能够传递相同的related_object参数。

我不知道PHP,但这在Ruby客户端中有效:

Stripe::Event.list(related_object: "cus_SOMEUNIQUEID", limit: 10000)

因此,如果这恰好是有效的PHP语法,我希望可以使用类似的方法:

\Stripe\Event::all(['related_object' => 'cus_SOMEUNIQUEID', 'limit' => 10000]);
© www.soinside.com 2019 - 2024. All rights reserved.