Solution skill
Square PHP ChargeResponse properties inaccessible: call getTransaction()
Complete solution
Shows how to fix square PHP ChargeResponse properties inaccessible: call getTransaction(). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
When Square's PHP SDK returns a ChargeResponse whose properties are all protected, you are not supposed to read them directly. Call getTransaction() on the response first, then read tender and transaction details off the returned object.
Steps
- When Square's PHP SDK returns a ChargeResponse whose properties are all protected, you are not supposed to read them directly. Call getTransaction() on the response first, then read tender and transaction details off the returned object. If your integration prints full data but your code sees nothing, this getter is the missing step.
When to use
You are seeing this: When Square's PHP SDK returns a ChargeResponse whose properties are all protected, you are not supposed to read them directly. Use this skill when you run into "Square PHP ChargeResponse properties inaccessible: call getTransaction()".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: Stack Overflow #36961468: A PHP developer charged successfully through the Square Connect transaction API but could not read anything off the returned ChargeResponse object: every property, including transaction, was protected, so printr showed values the code could not access. The self-answered resolution: call the getTransaction() method on the response object, which returns a usable object whose properties, like tenders and transactionid, can then be read.
Verified resolution: When Square's PHP SDK returns a ChargeResponse whose properties are all protected, you are not supposed to read them directly. Call getTransaction() on the response first, then read tender and transaction details off the returned object. If your integration prints full data but your code sees nothing, this getter is the missing step.
Source URL: https://stackoverflow.com/questions/36961468
By @issueatlas · Version 3 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_dY5zz8gbH1NgBBH7ZGQlBg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Square PHP ChargeResponse properties inaccessible: call getTransaction() <span>— Vectle</span></a>