So I’m using the Square API Create payment link generator… I’m getting the repones from square and can display using var dump. Great! but how do I get the values from the obj. they are labeled as protected but there must be some way as this relies on the user being redirected to the square payment interface..
example repones:
`object(SquareModelsCreatePaymentLinkResponse)#62 (3) {
["errors":"SquareModelsCreatePaymentLinkResponse":private]=>
NULL
["paymentLink":"SquareModelsCreatePaymentLinkResponse":private]=>
object(SquareModelsPaymentLink)#94 (11) {
["id":"SquareModelsPaymentLink":private]=>
string(16) "33LIC7WVU7JYAVVG"
["version":"SquareModelsPaymentLink":private]=>
int(1)
["description":"SquareModelsPaymentLink":private]=>
array(0) {
}
["orderId":"SquareModelsPaymentLink":private]=>
string(29) "DxmwR6jXwaRxj6BlYrk4HKRWBn8YY"
["checkoutOptions":"SquareModelsPaymentLink":private]=>
NULL
["prePopulatedData":"SquareModelsPaymentLink":private]=>
NULL
["url":"SquareModelsPaymentLink":private]=>
string(30) "https://square.link/u/FDmlLX2O"
["longUrl":"SquareModelsPaymentLink":private]=>
string(87) "https://checkout.square.site/merchant/MLCND5V3MXBY1/order/DxmwR6jXwaRxj6BlYrk4HKRWBn8YY"
["createdAt":"SquareModelsPaymentLink":private]=>
string(20) "2024-04-23T08:35:56Z"
["updatedAt":"SquareModelsPaymentLink":private]=>
NULL
["paymentNote":"SquareModelsPaymentLink":private]=>
array(0) {
}
}`
what i have
$api_response = $client->getCheckoutApi()->createPaymentLink($body);
echo '<pre>';
if ($api_response->isSuccess()) {
$result = $api_response->getResult();
var_dump($result);
} else {
$errors = $api_response->getErrors();
}
but i now need to use something like
$url = $result->$paymentLink->$url;
header("lcoation: $url");
but this is not obviously coming up with a result
New contributor
Gareth Davies is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.