Here is my php code for stripe transaction for taking the application fee from customer using my platform:
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
$charge = \Stripe\Charge::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);
and here is my response (partial)
Stripe\Charge Object
(
[_opts:protected] => Stripe\Util\RequestOptions 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] => Stripe\Card Object
i am having difficulty for how i can catch the the value "id => ch_16K6q5HzfYmjyH786HG5a2gp" from _values:protected array
i have tried the following syntaxes
$charge->_values:protected and $charge['_values:protected']
but not able to grab the response, can any one here to help to catch the response in stripe connect transactions using php
For anyone that may come across this, Stripe's PHP library has a function to create an array
public function jsonSerialize()
{
return $this->__toArray(true);
}
Use this to get an workable Array from the Object. Ex.
$charge->jsonSerialize();
try this instead of dumping the entire object
print $charge->id;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With