检索客户来源时的条带化响应
我正在尝试通过提供客户ID来检索特定客户的所有卡。根据the documentation,我期待得到以下响应:
StripeCollection JSON: {
"object" => "list",
"url" => "/v1/customers/cu_16jdAj2eZvKYlo2CbrCP4HRs/sources",
"has_more" => false,
"data" => [
[0] => StripeCard JSON: {
"id": "card_14bIFkou9GUI42eZvKYlo2Cs",
"object": "card",
"last4": "4242",
"brand": "Visa",
"funding": "credit",
"exp_month": 11,
"exp_year": 2018,
"country": "US",
"name": "callingsudhanshu@gmail.com",
"address_line1": null,
"address_line2": null,
"address_city": null,
"address_state": null,
"address_zip": null,
"address_country": null,
"cvc_check": null,
"address_line1_check": null,
"address_zip_check": null,
"tokenization_method": null,
"dynamic_last4": null,
"metadata": {
},
"customer": "cus_6Nb0wxYHigk2mX"
}
[1] => <StripeCard[...] ...>
[2] => <StripeCard[...] ...>
]
}
这是我对斯利普提出的要求。正在尝试从$card_list
中提取data
(即,所有卡片的数组):
StripeStripe::setApiKey($this->stripe_sk);
$card_list = StripeCustomer::retrieve($customer_id)->sources->all(array(
'object' => 'card'
));
// Return a list of all cards.
$card_list = $card_list->data;
return $card_list;
我想知道为什么来自$card_list
的条带响应包含额外/意外数据。以下是我实际得到的信息:
array(1) {
[0]=>
object(StripeCard)#292 (5) {
["_opts":protected]=>
object(StripeUtilRequestOptions)#294 (2) {
["headers"]=>
array(0) {
}
["apiKey"]=>
string(32) "sk_test_d3..."
}
["_values":protected]=>
array(23) {
["id"]=>
string(29) "card_16jLIwLBSNgilYpnoEiPhNhA"
["object"]=>
string(4) "card"
["last4"]=>
string(4) "4242"
["brand"]=>
string(4) "Visa"
["funding"]=>
string(6) "credit"
["exp_month"]=>
int(8)
["exp_year"]=>
int(2016)
["fingerprint"]=>
string(16) "T5RzXLIiXrF0nyqH"
["country"]=>
string(2) "US"
["name"]=>
NULL
["address_line1"]=>
NULL
["address_line2"]=>
NULL
["address_city"]=>
NULL
["address_state"]=>
NULL
["address_zip"]=>
NULL
["address_country"]=>
NULL
["cvc_check"]=>
string(4) "pass"
["address_line1_check"]=>
NULL
["address_zip_check"]=>
NULL
["tokenization_method"]=>
NULL
["dynamic_last4"]=>
NULL
["metadata"]=>
object(StripeAttachedObject)#261 (5) {
["_opts":protected]=>
object(StripeUtilRequestOptions)#294 (2) {
["headers"]=>
array(0) {
}
["apiKey"]=>
string(32) "sk_test_d..."
}
["_values":protected]=>
array(0) {
}
["_unsavedValues":protected]=>
object(StripeUtilSet)#262 (1) {
["_elts":"StripeUtilSet":private]=>
array(0) {
}
}
["_transientValues":protected]=>
object(StripeUtilSet)#306 (1) {
["_elts":"StripeUtilSet":private]=>
array(0) {
}
}
["_retrieveOptions":protected]=>
array(0) {
}
}
["customer"]=>
string(18) "cus_6xCtshHPQiYSdI"
}
["_unsavedValues":protected]=>
object(StripeUtilSet)#270 (1) {
["_elts":"StripeUtilSet":private]=>
array(0) {
}
}
["_transientValues":protected]=>
object(StripeUtilSet)#120 (1) {
["_elts":"StripeUtilSet":private]=>
array(0) {
}
}
["_retrieveOptions":protected]=>
array(0) {
}
}
}
希望有人能解释一下我在这里得到的回答的"扩展"版本。提前感谢!
api
几天前我遇到了这个问题,我已经设法使用json_encode()
推荐答案解决了这个问题(我需要将其作为AJAX返回导出)。
$cards = StripeCustomer::retrieve($_SESSION['stripe_customer_id'])->sources->all(array("object" => "card"));
$list = json_encode($cards->data);
echo($list);
希望这能有所帮助。
btw:您的回复与var_dump()
输出类似。
相关文章