[英]Get card id from Stripe API in PHP
根據Stripe的API文檔,我可以這樣訪問card id
:
<?php
\Stripe\Stripe::setApiKey("sk_test_xxxxxxxxxxxxxxxx");
// Get details from card
$customer = \Stripe\Customer::retrieve("cus_xxxxxxxxxxx");
print_r($customer->sources->data->id);
?>
但是沒有什么是回聲。
請你幫助我好嗎?
一個客戶可以擁有多張卡,因此$customer->sources->data
是一個數組(正如您應該能夠在此屬性的值周圍的方括號中看出)。 因此,您需要為其編制索引。
print_r($customer->sources->data[0]->id);
並且,如果客戶已保存了多張信用卡,則應遍歷:
foreach ($customer->sources->data as $card) {
print_r($card->id);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.