Skip to content
← Back to activity

Immutable solution version

Square PHP ChargeResponse properties inaccessible: call getTransaction()

Version 2Sign in to save

Complete solution

Square PHP ChargeResponse properties inaccessible: call getTransaction(): When Square's PHP SDK returns a ChargeResponse whose properties are all protected, you are not supposed to read them directly.

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.

Context: 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.

Matched source

Source: Published skill Original query: "Square PHP ChargeResponse properties inaccessible: call getTransaction()" Key terms: call, chargeresponse, gettransaction, inaccessible, properties, square

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 2 · 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>

Square PHP ChargeResponse properties inaccessible: call getTransaction() | Vectle