Checkout session returns private data

Hi
This may be user misunderstanding… I am trying to implement a quick pay link for our website in the Sandbox. I’ve tried the data in the API tester and it gives me a result, but when I try it on my server, it returns a private array and any attempt to access it gives the error “Uncaught Error: Cannot access private property Square\Models\CreatePaymentLinkResponse”

My code is below (I’ve hidden the location id):

$price_money = new \Square\Models\Money();
$price_money->setAmount(3800);
$price_money->setCurrency(‘GBP’);

$quick_pay = new \Square\Models\QuickPay(
‘Tickets x 2’,
$price_money,
‘xxxxxxxxxxxxx’
);

$checkout_options = new \Square\Models\CheckoutOptions();
$checkout_options->setAllowTipping(false);
$checkout_options->setAskForShippingAddress(false);
$checkout_options->setEnableCoupon(false);
$checkout_options->setEnableLoyalty(false);

$sik = ‘tct-’.uniqid();

$body = new \Square\Models\CreatePaymentLinkRequest();
$body->setIdempotencyKey($sik);
$body->setDescription(‘Tickets’);
$body->setQuickPay($quick_pay);
$body->setCheckoutOptions($checkout_options);

$api_response = $client->getCheckoutApi()->createPaymentLink($body);

I get a full response, headed by:
[errors:Square\Models\CreatePaymentLinkResponse:private] =>

Any assistance gratefully received

Martin

The error you’re facing seems to be related to trying to access the private property errors within the Square\Models\CreatePaymentLinkResponse class. Since this property is marked as private, you can’t directly access it from outside the class.

To handle the response, you should use the public methods or getters provided by the CreatePaymentLinkResponse class. :slightly_smiling_face:

Hi Bryan
Thanks for that - not sure I understand though. I’ve used the API tester to generate the code so not sure what additional steps I need to take.
I’ve extensively looked at the documentation but am still unclear.
Perhaps time to give up!
Cheers
Martin

When you say API tester do you mean our API Explorer? If so on your server did you setup the SDK properly? Cause all of the examples from the API Explorer use the SDK if there not CURL. :slightly_smiling_face: