付款成功后。我打印_r($ customer)获取卡和费用信息。我收到此消息,我只能从Stripe_Customer Object
变量获取Stripe_Card Object
信息而不是$customer
Stripe_Card Object ([_apiKey:protected] => sk_test_... [_values:protected]
=> Array ( [id] => card_1BLsOAJ6IzxnlSnmpPloNXUN
[object] => card [address_city] => lahore
[address_country] => Pakistan
只有数组的第一个Stripe_Customer Object
才能轻易获得,例如
echo $customer['id']
我尝试多次使用这些方法获取卡片对象的信息但不适合我
echo $customer->source->card->address_country;
echo $customer->source->address_country;
echo $customer['card'];
echo $customer['address_country'];
echo $customer['card']['address_country'];
答案 0 :(得分:3)
客户可以同时拥有多个来源。 Customer上的source
属性是记录在案的here列表。如果您想访问卡片对象,则需要执行以下操作:
$card = $customer->sources->data[0];
$cardId = $card->id;
$cardLast4 = $card->last4;
// etc.