帮助捕获条带连接事务中的响应吗
这是我的php代码,用于使用我的平台从客户那里收取申请费:
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
$charge = StripeCharge::create(
array(
"amount" => 1000, // amount in cents
"currency" => "usd",
"source" => $token,
"description" => "Event charge",
"application_fee" => 123 // amount in cents
),
array("stripe_account" => $sInfo->stripe_user_id)
);
echo '<pre>';
print_r($charge);
这是我的回复(部分)
StripeCharge Object
(
[_opts:protected] => StripeUtilRequestOptions Object
(
[headers] => Array
(
[Stripe-Account] => acct_16JkaUHzfYmjyH68
)
[apiKey] => sk_test_mHnhDuaVjnKmdkEApnYAKfGY
)
[_values:protected] => Array
(
[id] => ch_16K6q5HzfYmjyH786HG5a2gp
[object] => charge
[created] => 1435840249
[livemode] =>
[paid] => 1
[status] => succeeded
[amount] => 1000
[currency] => usd
[refunded] =>
[source] => StripeCard Object
我很难从_values:protected array 中获取值"id=>ch_16K6q5HzfYmjyH786HG5a2gp"
我试过以下语法
$charge->_values:protected and $charge['_values:protected']
但是无法获取响应,这里的任何人都可以使用php
对于任何可能遇到这种情况的人,Stripe的PHP库都有一个创建数组的功能
public function jsonSerialize()
{
return $this->__toArray(true);
}
使用它可以从对象中获得一个可行的数组。示例
$charge->jsonSerialize();
尝试此操作,而不是转储整个对象
print $charge->id;
尝试将对象转换为简单数组形式的
$charge->__toArray(TRUE);