【问题标题】:list all Stripe events for a customer列出客户的所有 Stripe 事件
【发布时间】:2020-02-20 06:48:20
【问题描述】:

我已将 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】:

    这在 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]);
    

    【讨论】:

    • 谢谢!这解决了我的问题。我使用 Python 快速对此进行了测试,这对我有用: all_events = stripe.Event.list(limit=1000, related_object='cus_GfEBJ7wj9GJXXXX')
    猜你喜欢
    • 2018-02-01
    • 2021-06-11
    • 2021-06-16
    • 2021-04-09
    • 2016-11-22
    • 1970-01-01
    • 2013-03-14
    • 2021-03-05
    • 2020-05-28
    相关资源
    最近更新 更多