Jos*_*osh 3 php wordpress stripe-payments
我已将 WordPress 连接到 Stripe,并希望在其 WordPress 管理用户页面中显示每个用户的 Stripe 事件历史记录。本质上,我想要在选择客户并单击“查看更多事件”时在 Stripe 管理中使用相同的视图,结果如下: https: //dashboard.stripe.com/test/events ?lated_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 ...
}
Run Code Online (Sandbox Code Playgroud)
API 文档中没有记录这一点,但您应该能够传递相同的内容related_object在检索 Stripe 仪表板使用的事件时传递相同的参数。
我不懂 PHP,但这可以在 Ruby 客户端上运行:
Stripe::Event.list(related_object: "cus_SOMEUNIQUEID", limit: 10000)
Run Code Online (Sandbox Code Playgroud)
所以我希望这样的东西能够工作,如果这恰好是有效的 PHP 语法:
\Stripe\Event::all(['related_object' => 'cus_SOMEUNIQUEID', 'limit' => 10000]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
957 次 |
| 最近记录: |