Propulated data issues when creating payment request link

I’m having some issues setting prepopulated data on a payment link.

The following php code always results in this error:

Error: Call to undefined method Square\Models\CreatePaymentLinkRequest::setPrePopulateData() in Drupal\rnmha_registrations\Controller\RegistrationsCheckout->build() (line 148 of profiles/custom/rnmha/modules/custom/rnmha_registrations/src/Controller/RegistrationsCheckout.php). 

Current Code:

      $payment_link_request = new CreatePaymentLinkRequest(uniqid());
      $payment_link_request->setOrder($create_order_request->getOrder());
      $host = \Drupal::request()->getSchemeAndHttpHost();

      // Create CheckoutOptions object
      $checkout_options = new CheckoutOptions();
      $checkout_options
        ->setRedirectUrl($host . '/confirmation');

      $buyer_address = new Address();
      $buyer_address->setAddressLine1('1455 MARKET ST #600');
      $buyer_address->setLocality('San Jose');
      $buyer_address->setAdministrativeDistrictLevel1('CA');
      $buyer_address->setPostalCode('94103');
      $buyer_address->setCountry('US');

      $pre_populated_data = new PrePopulatedData();
      $pre_populated_data->setBuyerEmail('[email protected]');
      $pre_populated_data->setBuyerPhoneNumber('1-415-555-1212');
      $pre_populated_data->setBuyerAddress($buyer_address);

      // Set CheckoutOptions to the payment link request
      $payment_link_request->setCheckoutOptions($checkout_options);
      $payment_link_request->setPrePopulateData($pre_populated_data);

The method is definitely at the of the file:

use Square\Models\CreatePaymentLinkRequest;

I copied the example for the documentation (Optional Checkout Configurations) and it fails.

I also try to set the $prepopulated data on the $checkout_options but that also creates an error (suggested by VS Code copilot):

Error: Call to undefined method Square\Models\CheckoutOptions::setPrePopulateData() in Drupal\rnmha_registrations\Controller\RegistrationsCheckout->build() (line 128 of profiles/custom/rnmha/modules/custom/rnmha_registrations/src/Controller/RegistrationsCheckout.php).