I'm able to successfully charge using the transaction API following the example on github. Executing the charge looks like this:
$result = $transaction_api->charge($access_token, $location_id, $request_body);
echo "<pre>";
print_r($result);
echo "</pre>";
Here's the output:
SquareConnect\Model\ChargeResponse Object
(
[errors:protected] =>
[transaction:protected] => SquareConnect\Model\Transaction Object
(
[id:protected] => REMOVED FROM POST
[location_id:protected] => REMOVED FROM POST
[created_at:protected] => 2016-04-30T23:42:33Z
[tenders:protected] => Array
(
[0] => SquareConnect\Model\Tender Object
(
[id:protected] => REMOVED FROM POST
[location_id:protected] => REMOVED FROM POST
[transaction_id:protected] => 02d1d965-51fd-5023-68f5-0fcd148a263b
[created_at:protected] => 2016-04-30T23:42:33Z
[note:protected] => Online Transaction
[amount_money:protected] => SquareConnect\Model\Money Object
(
[amount:protected] => 6000
[currency:protected] => USD
)
[processing_fee_money:protected] =>
[customer_id:protected] =>
[type:protected] => CARD
[card_details:protected] => SquareConnect\Model\TenderCardDetails Object
(
[status:protected] => CAPTURED
[card:protected] => SquareConnect\Model\Card Object
(
[id:protected] =>
[card_brand:protected] => VISA
[last_4:protected] => 5858
[exp_month:protected] =>
[exp_year:protected] =>
[cardholder_name:protected] =>
[billing_address:protected] =>
)
[entry_method:protected] => KEYED
)
[cash_details:protected] =>
)
)
[refunds:protected] =>
[reference_id:protected] =>
[product:protected] => EXTERNAL_API
)
)
My problem is that, while some places (such as here) indicate that I'm supposed to get an array back from the charge method, I instead get a ChargeResponse object.
Within this object is a transaction object that contains all of the relevant information that I want to display to the customer once the transaction is complete, but it's protected, so trying to echo a transaction id, created_at time, or amount from this returned object fails.
I'm certain I'm doing something wrong, but I'm lost as to how to capture properties from the ChargeResponse object so that I can do useful things with it.
For instance, I've tried
echo($result->transaction['id']);
but all I get is:
Fatal error: Cannot access protected property
This may not even be the right way to attempt something like this, so I'm completely open to suggestions.