如何从条纹中的客户对象获取费用信息



付款成功后。 我print_r($customer)获取卡和收费信息。我收到了这个,我只能从变量中获取第一个Stripe_Customer Object信息$customer但不能Stripe_Card Object

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'];

一个客户可以同时拥有多个来源。客户上的source属性是此处记录的列表。如果要访问卡对象,则需要执行以下操作:

$card = $customer->sources->data[0];
$cardId = $card->id;
$cardLast4 = $card->last4;
// etc.

最新更新