Git Product home page Git Product logo

square-php-sdk's Introduction

Square PHP SDK

Build PHP version Apache-2 license

Use this library to integrate Square payments into your app and grow your business with Square APIs including Catalog, Customers, Employees, Inventory, Labor, Locations, and Orders.

Requirements

Use of the Square PHP SDK requires:

  • PHP 7.4 through PHP ^8.0

Installation

For more information, see Set Up Your Square SDK for a PHP Project.

Quickstart

For more information, see Square PHP SDK Quickstart.

Usage

For more information, see Using the Square PHP SDK.

Tests

First, clone the repo locally and cd into the directory.

git clone https://github.com/square/square-php-sdk.git
cd square-php-sdk

Next, make sure you've downloaded Composer, following the instructions here and then run the following command from the root of the repository:

composer install

Before running the tests, find a sandbox token in your Developer Dashboard and set environment variables:

export SQUARE_ACCESS_TOKEN=mytoken
export SQUARE_ENVIRONMENT=sandbox

Run the tests:

composer run test

All environment variables:

  • SQUARE_TIMEOUT - number
  • SQUARE_NUMBER_OF_RETRIES - number
  • SQUARE_MAXIMUM_RETRY_WAIT_TIME - number
  • SQUARE_SQUARE_VERSION - string
  • SQUARE_USER_AGENT_DETAIL - string
  • SQUARE_CUSTOM_URL - string
  • SQUARE_ACCESS_TOKEN - string
  • SQUARE_ENVIRONMENT - string - one of production, sandbox, custom

SDK Reference

Payments

Terminal

Orders

Subscriptions

Invoices

Items

Customers

Loyalty

Gift Cards

Bookings

Business

Team

Financials

Online

Authorization

Webhook Subscriptions

Deprecated APIs

The following Square APIs are deprecated:

square-php-sdk's People

Contributors

daphnechiu avatar deanpapastrat avatar dotspencer avatar gkchestertron avatar jessdelacruzsantos avatar jessemartin avatar jguze avatar joanc-sq avatar mcurtis-squareup avatar mohsin-sq avatar okenshields avatar shaofu88 avatar square-sdk-deployer avatar steefan-square avatar zenmasterjobo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

square-php-sdk's Issues

The `Authorization` http header of your request was malformed.

Square PHP SDK version: 7.0.0.20201118
PHP version: 7.4.0

I'm trying to create a customer using the Square PHP SDK:

$client = new SquareClient([
    'accessToken' => $myAccessToken,
    'environment' => Environment::SANDBOX,
]);

$request = new CreateCustomerRequest();
$request->setGivenName('Billy');
$request->setFamilyName('Bob');
$request->setEmailAddress('[email protected]');
$request->setReferenceId('ABC-123');
$request->setNote('Hello world');

$customerRequest = $client->getCustomersApi()->createCustomer($request);

$customerRequest->getBody() returns the following error:

{
    "errors": [
        {
            "code": "UNAUTHORIZED",
            "detail": "The `Authorization` http header of your request was malformed. The header value is expected to be of the format \"Bearer TOKEN\" (without quotation marks), where TOKEN is to be replaced with your access token (e.g. \"Bearer ABC123def456GHI789jkl0\"). For more information, see https://docs.connect.squareup.com/api/connect/v2/#requestandresponseheaders. If you are seeing this error message while using one of our officially supported SDKs, please report this to [email protected].",
            "category": "AUTHENTICATION_ERROR"
        }
    ]
}

I stepped into CustomersApi::createCustomer() and dumped $_headers after it has been merged with the additional headers from config, here's the result:

array (
  'user-agent' => 'Square-PHP-SDK/7.0.0.20201118',
  'Accept' => 'application/json',
  'content-type' => 'application/json',
  'Square-Version' => '2020-11-18',
  'Authorization' => 'Bearer ABCDABCD12341234abcdefg_12345-98765a1234qwertokijhasdf--QWERTY12',
) 

I've masked the actual access token here, but the structure and length remains the same.

As far as I can tell this is configured correctly. Am I doing something wrong? Thanks in advance 😄

Order type and sources should be cleaned up

Describe the bug
The order sources and tender types are confusing and difficult to code for.

Expected behavior
Clean and concise order sources and tender types

To Reproduce
Steps to reproduce the bug:

  1. Retrieve order that was processed as house account or invoice

Square SDK version
25.2.0.20230315

Additional context
Order tenders that are rung up with a "house account" display in the API as "OTHER". This should be changed to "HOUSE_ACCOUNT". When an invoice is created it too displays in the API tender type as "OTHER" and the order source is blank. When pulling from the deprecated transaction API on the API explorer the product displays "INVOICES", but that is not in the orders API. The order source should be changed to "INOVICE" and the tender type should be whatever tender was used to pay for the order "CARD", "CHECK", "ACH", etc. I'm pretty sure this affects the entire API and not just the PHP SDK, but I don't see the main API listed as publicly available.

open_basedir restriction error in JsonMapper

I was using an older version of the Square API (12.0.0.20210616), which worked ok, but sent the wrong amount to the Square checkout page. For example, 1999 was being displayed as 19.98 on the checkout page. So, I upgraded to the newest version (19.1.1.20220616) to see if that would fix it, but now when I run it I'm getting:

parse_ini_file(): open_basedir restriction in effect. File(/opt/path/etc/php.ini) is not within the allowed path(s): (/home/users/username/www:/home/users/username/files:/home/users/username/tmp)

The error triggers on the line 119 in:
vendor/apimatic/jsonmapper/src/JsonMapper.php

This is the code I have to trigger the checkout page:

$client = new SquareClient([
'accessToken' => 'abc123',
'environment' => 'sandbox',
'numberOfRetries' => 5,
'timeout' => 120
]);
try {
// Call api
$api = $client->getCheckoutApi();
// Set money prefs
$mon = new Money();
$mon->setCurrency('GBP');
$mon->setAmount(1999);
// Item info
$item = new OrderLineItem(1);
$item->setName('Order Items');
$item->setBasePriceMoney($mon);
// Create order
$order = new Order(LOC_ID);
$order->setLineItems([$item]);
$order->setReferenceId($data['ref']);
// Create order request
$request = new CreateOrderRequest();
$request->setOrder($order);
// Set idempotency key
$checkout = new CreateCheckoutRequest(uniqid(), $request);
$checkout->setPrePopulateBuyerEmail('[email protected]');
$checkout->setRedirectUrl('https://www.page.com/');
// Fire it up
$response = $api->createCheckout(
LOC_ID,
$checkout
);
$response->getResult()->getCheckout()->getCheckoutPageUrl();
} catch (ApiException $e) {
// Catch error here
}

Any help would be appreciated, thank you. I understand why the error triggers, but not sure why it's trying to read the ini settings and reading them in an incorrect location?

No way to specify the integration ID

You can find here square/connect-php-sdk#94 previous issue where discussed the intergration of the "integration ID" in the charge request as integration_id is not present.
In the new API IntegrationChargeRequest has been replaced by CreatePaymentRequest but in it I still don't see integration for the "integration ID". Probably we should use setReferenceId() or setNote() but I don't think this is correct.
I also tried to inject a new parameter in CreatePaymentRequest:jsonSerialize() but in the request "POST /v2/payments" I don't see this parameter:
{ "source_id": "[redacted]", "idempotency_key": "621e56db0b7d62.20941928", "amount_money": { "amount": 2000, "currency": "USD" }, "autocomplete": true, "order_id": "sdBPTC6oQ53XN3MaoShjCHmk6h4F", "buyer_email_address": "[email protected]", "billing_address": { "address_line_1": "test", "address_line_2": "", "locality": "test", "administrative_district_level_1": "", "postal_code": "", "country": "" } }
It looks like this parameter was removed somewhere on API side.
Is there a way to add a new parameter into CreatePaymentRequest:jsonSerialize() or do you plan to add it to the API ?

SquareClient.php throwing an uncaught exception (type string expected, null received)

In my development environment, I'm testing the new PHP SDK before going live.

I'm in the Environment::SANDBOX for sure but getting this error:

[15-Jun-2020 13:03:07 America/New_York] PHP Notice: Undefined index: Environment::SANDBOX, in /path/to/vendor/square/square/src/SquareClient.php on line 139 [15-Jun-2020 13:03:07 America/New_York] PHP Fatal error: Uncaught TypeError: Return value of Square\SquareClient::getBaseUri() must be of the type string, null returned in /path/to/vendor/square/square/src/SquareClient.php:139 Stack trace: #0 /path/to/vendor/square/square/src/Apis/LocationsApi.php(42): Square\SquareClient->getBaseUri() #1 /path/to/admin/content/process_card.php(23): Square\Apis\LocationsApi->listLocations() #2 /path/to/admin/index.php(151): include('/home/cprtocom/...') #3 {main} thrown in /path/to/vendor/square/square/src/SquareClient.php on line 139
Any assistance in determining what I (or less likely the SDK) is doing wrong here would be greatly appreciated.
Thanks,
-Ray

Uncaught Error: Class 'SquareClient' not found

I started on working with new php sdk and it gives me an error. I checked code inside sdk and there is no class 'SquareClient', but other classes(LocationsApi,Environment) are found. What I am doing wrong? Is this sdk production ready?

require_once "square_sdk/vendor/autoload.php";
use Square\SquareClient;
$sq_client = new SquareClient([
	'accessToken' => $square_access_token,
	'environment' => Environment::SANDBOX,
]);

Verified card get ADDRESS_VERIFICATION_FAILURE error when processing Square Payment.

Hi
First, we process the card details a via Square Js then call verifyBuyer with verification details and payment info.
If above success then sends the Card Noce and Verification Token to the backend to process the Payment.

Issue

We successfully verify the buyer got the card token/customer-id (When creating customer) then we get ADDRESS_VERIFICATION_FAILURE error when we charge the amount. How can we get Address error when we already pass verifyBuyer and able to save the card.

This is just one issue. there are lots of blocking from square and error message doesn't describe anything helpful.

  1. Js Code

image

  1. Payment Process

image

catalog image upload issue

hi i am trying to upload the image from my server to the square .but it wont work
here is the code
$image_data = new \Square\Models\CatalogImage();
$image_data->setName('Image name');
$image_data->setCaption('Image caption');

$image = new \Square\Models\CatalogObject('IMAGE', '#image_id');
$image->setImageData($image_data);

$request = new \Square\Models\CreateCatalogImageRequest($unique_id, $image);

// Modify this to point to your desired file.
$imageFile = \Square\Utils\FileWrapper::createFromPath('../uploadm/filename.jpeg',"image/jpeg",'naxirr');

$api_response = $client->getCatalogApi()->createCatalogImage($request, $imageFile);

here is the response .

Square\Http\ApiResponse Object ( [request:Square\Http\ApiResponse:private] => Square\Http\HttpRequest Object ( [httpMethod:Square\Http\HttpRequest:private] => Post [headers:Square\Http\HttpRequest:private] => Array ( [user-agent] => Square-PHP-SDK/13.1.0.20210818 [Accept] => application/json [Square-Version] => 2021-08-18 [Authorization] => Bearer EAAAEMCFLbaZlXmp6n_xThLlcUgAc_7wZr8tctfwV5pzz2QSQYRvh9tXzg4gjMfS ) [queryUrl:Square\Http\HttpRequest:private] => https://connect.squareupsandbox.com/v2/catalog/images [parameters:Square\Http\HttpRequest:private] => Array ( [request] => {"idempotency_key":"20220802012434"} [image_file] => CURLFile Object ( [name] => ../uploadm/filename.jpeg [mime] => image/jpeg [postname] => naxirr ) ) ) [statusCode:Square\Http\ApiResponse:private] => 400 [reasonPhrase:Square\Http\ApiResponse:private] => [headers:Square\Http\ApiResponse:private] => Array ( [0] => HTTP/2 400 [content-encoding] => gzip [content-type] => application/json [square-version] => 2021-08-18 [vary] => Origin, Accept-Encoding [x-content-type-options] => nosniff [x-download-options] => noopen [x-frame-options] => SAMEORIGIN [x-permitted-cross-domain-policies] => none [x-speleo-traceid] => FABMTJagGQVZA [x-xss-protection] => 1; mode=block [date] => Tue, 08 Feb 2022 13:24:35 GMT [content-length] => 141 [strict-transport-security] => max-age=631152000; includeSubDomains; preload ) [result:Square\Http\ApiResponse:private] => [body:Square\Http\ApiResponse:private] => {"errors":[{"category":"INVALID_REQUEST_ERROR","code":"MISSING_REQUIRED_PARAMETER","detail":"Field must be set","field":"image"}]} [errors:Square\Http\ApiResponse:private] => Array ( [0] => Square\Models\Error Object ( [category:Square\Models\Error:private] => INVALID_REQUEST_ERROR [code:Square\Models\Error:private] => MISSING_REQUIRED_PARAMETER [detail:Square\Models\Error:private] => Field must be set [field:Square\Models\Error:private] => image ) ) [cursor:Square\Http\ApiResponse:private] => )

Array ( [0] => Square\Models\Error Object ( [category:Square\Models\Error:private] => INVALID_REQUEST_ERROR [code:Square\Models\Error:private] => MISSING_REQUIRED_PARAMETER [detail:Square\Models\Error:private] => Field must be set [field:Square\Models\Error:private] => image ) )

Fatal error when `php_uname()` is disabled for security reasons.

Describe the bug
There are many web hosting providers that disable a number of built-in PHP functions due to security reasons. When the php_uname() function is disabled on a web host SDK throws the fatal error.

PHP Fatal error:  Uncaught Error: Call to undefined function Core\Utils\php_uname() in /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/vendor/apimatic/core/src/Utils/CoreHelper.php:159
Stack trace:
#0 /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/vendor/apimatic/core/src/ClientBuilder.php(181): Core\Utils\CoreHelper::getOsInfo()
#1 /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/vendor/apimatic/core/src/ClientBuilder.php(195): Core\ClientBuilder->addUserAgentToGlobalHeaders()
#2 /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/vendor/square/square/src/SquareClient.php(172): Core\ClientBuilder->build()
#3 /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/includes/API.php(71): Square\SquareClient->__construct(Array)
#4 /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/includes/Plugin.php(704): WooCommerce\Square\API->__construct('**', true)
#5 /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/includes/Settings.php(782): WooCommerce\Square\Plugin->get_api('**', true)
#6 /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/includes/Settings.php(368): WooCommerce\Square\Settings->get_locations()
#7 /Users/**/**/**/**/public/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-settings-api.php(87): WooCommerce\Square\Settings->get_form_fields()
#8 /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/includes/Admin/Settings_Page.php(86): WC_Settings_API->admin_options()
#9 /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/includes/Admin/Settings_Page.php(74): WooCommerce\Square\Admin\Settings_Page->output_general_section()
#10 /Users/**/**/**/**/public/wp-includes/class-wp-hook.php(308): WooCommerce\Square\Admin\Settings_Page->output('')
#11 /Users/**/**/**/**/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
#12 /Users/**/**/**/**/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#13 /Users/**/**/**/**/public/wp-content/plugins/woocommerce/includes/admin/views/html-admin-settings.php(40): do_action('woocommerce_set...')
#14 /Users/**/**/**/**/public/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-settings.php(153): include('***')
#15 /Users/**/**/**/**/public/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-menus.php(291): WC_Admin_Settings::output()
#16 /Users/**/**/**/**/public/wp-includes/class-wp-hook.php(308): WC_Admin_Menus->settings_page('')
#17 /Users/**/**/**/**/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
#18 /Users/**/**/**/**/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#19 /Users/**/**/**/**/public/wp-admin/admin.php(259): do_action('woocommerce_pag...')
#20 {main}
  thrown in /Users/**/**/**/**/public/wp-content/plugins/woocommerce-square/vendor/apimatic/core/src/Utils/CoreHelper.php on line 159

Expected behavior
Square SDK should work fine without any fatal error if php_uname is disabled.

To Reproduce
Steps to reproduce the bug:

  1. Set up an environment with php_uname disabled.
  2. Try to initiate SquareClient. You will get the fatal error.

Screenshots
If applicable, add screenshots to help explain the bug.

Square SDK version
24.0.0.20221116

Additional context
Add any other context about the problem here.

PHP Type Error

The HttpRequest class has non-nullable return types on the getter methods, but the properties being returned are all nullable on the class. While most of them would be nonsensical to be null, parameters seems like it could be commonly null, as is the case with /locations:

Square\Http\HttpRequest::__set_state(array
   'httpMethod' => 'Get',
   'headers' => array (
      'user-agent' => 'Square-PHP-SDK/17.3.0.20220316 (2022-03-16) Zend/4.0.16 (Darwin-21.4.0) ',
      'Accept' => 'application/json',
      'Square-Version' => '2022-03-16',
      'Authorization' => 'Bearer ************',
   ),
   'queryUrl' => 'https://connect.squareupsandbox.com/v2/locations',
   'parameters' => NULL,
))

This leads to a PHP fatal error when accessing $ApiResponse->getRequest()->getParameters() in a reusable error handler.

Missing on_by_default property from catalogueModifier Model

When calling the v2/catalog/list? endpoint item modifiers are missing the on_by_default property because this is not present in the catalogueModifier model.

Suggest modifying to:

`<?php

declare(strict_types=1);

namespace Square\Models;

use stdClass;

/**

  • A modifier applicable to items at the time of sale.
    /
    class CatalogModifier implements \JsonSerializable
    {
    /
    *

    • @var string|null
      */
      private $name;

    /**

    • @var Money|null
      */
      private $priceMoney;

    /**

    • @var int|null
      */
      private $ordinal;

    /**

    • @var bool|null
      */
      private $onByDefault;

    /**

    • @var string|null
      */
      private $modifierListId;

    /**

    • Returns Name.
    • The modifier name. This is a searchable attribute for use in applicable query filters, and its
    • value length is of Unicode code points.
      */
      public function getName(): ?string
      {
      return $this->name;
      }

    /**

    • Sets Name.
    • The modifier name. This is a searchable attribute for use in applicable query filters, and its
    • value length is of Unicode code points.
    • @maps name
      */
      public function setName(?string $name): void
      {
      $this->name = $name;
      }

    /**

    • Returns Price Money.
    • Represents an amount of money. Money fields can be signed or unsigned.
    • Fields that do not explicitly define whether they are signed or unsigned are
    • considered unsigned and can only hold positive amounts. For signed fields, the
    • sign of the value indicates the purpose of the money transfer. See
    • [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-
    • monetary-amounts)
    • for more information.
      */
      public function getPriceMoney(): ?Money
      {
      return $this->priceMoney;
      }

    /**

    • Sets Price Money.
    • Represents an amount of money. Money fields can be signed or unsigned.
    • Fields that do not explicitly define whether they are signed or unsigned are
    • considered unsigned and can only hold positive amounts. For signed fields, the
    • sign of the value indicates the purpose of the money transfer. See
    • [Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-
    • monetary-amounts)
    • for more information.
    • @maps price_money
      */
      public function setPriceMoney(?Money $priceMoney): void
      {
      $this->priceMoney = $priceMoney;
      }

    /**

    • Returns Ordinal.
    • Determines where this CatalogModifier appears in the CatalogModifierList.
      */
      public function getOrdinal(): ?int
      {
      return $this->ordinal;
      }

    /**

    • Sets Ordinal.
    • Determines where this CatalogModifier appears in the CatalogModifierList.
    • @maps ordinal
      */
      public function setOrdinal(?int $ordinal): void
      {
      $this->ordinal = $ordinal;
      }

    /**

    • Returns Modifier List Id.
    • The ID of the CatalogModifierList associated with this modifier.
      */
      public function getModifierListId(): ?string
      {
      return $this->modifierListId;
      }

    /**

    • Sets Modifier List Id.
    • The ID of the CatalogModifierList associated with this modifier.
    • @maps modifier_list_id
      */
      public function setModifierListId(?string $modifierListId): void
      {
      $this->modifierListId = $modifierListId;
      }

    /**

    • Returns onByDefault.

    */
    public function getOnByDefault(): ?bool
    {
    return $this->onByDefault;
    }

    /**

    • Sets onByDefault.
    • @maps onByDefault
      */
      public function setOnByDefault(?bool $onByDefault): void
      {
      $this->onByDefault = $onByDefault;
      }

    /**

    • Encode this object to JSON

    • @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields

    •    are set. (default: false)
      
    • @return mixed
      */
      public function jsonSerialize(bool $asArrayWhenEmpty = false)
      {
      $json = [];
      if (isset($this->name)) {
      $json['name'] = $this->name;
      }
      if (isset($this->priceMoney)) {
      $json['price_money'] = $this->priceMoney;
      }
      if (isset($this->ordinal)) {
      $json['ordinal'] = $this->ordinal;
      }
      if (isset($this->onByDefault)) {
      $json['on_by_default'] = $this->onByDefault;
      }
      if (isset($this->modifierListId)) {
      $json['modifier_list_id'] = $this->modifierListId;
      }
      $json = array_filter($json, function ($val) {
      return $val !== null;
      });

      return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
      }
      }
      `

Card Doc Link Missing

Hi,
Please fix the card link in the Payment Section.

Also, How to delete a customer card with a new Card API? There is only disable card method.

PHP version required

I'm just clarifying what the minimum PHP version that is required for this SDK. The Readme says 7.4 but the composer.json file shows >=7.2. I currently have v7.3.16 of PHP. Is PHP 7.4 truly required, if so the composer file should be updated.

Request to create an item variation through the UpsertCatalogObject call using POST /v2/catalog/object endpoint creates additional variation "Regular"

I used the UpsertCatalogObject API using these information.

Application ID sandbox-xxxxx--XXXXXXXXXXX
Merchant ID XXXXXXXXXXX
API Catalog
Endpoint NameUpsertCatalogObject
Status 200
Path POST /v2/catalog/object
Square Version 2020-09-23
User Agent Square-PHP-SDK/6.4.0.20200923
Timestamp 6/13/2021, 12:04:52 PM GMT+5:30

{
"idempotency_key": "60c5a70b1f115",
"object": {
"type": "ITEM_VARIATION",
"id": "#8ed1fc15",
"item_variation_data": {
"item_id": "TM22UNGDY53S7I4B4EGI7AJX",
"name": "A1",
"sku": "4cda8f53",
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 1000,
"currency": "USD"
}
}
}
}

And got this response from the API.

{
"catalog_object": {
"type": "ITEM_VARIATION",
"id": "XXXXXXXXXXXXXXXX",
"updated_at": "2021-06-13T06:34:52.166Z",
"version": 1623566092166,
"is_deleted": false,
"present_at_all_locations": true,
"item_variation_data": {
"item_id": "XXXXXXXXXXXXXXXX",
"name": "A1",
"sku": "4cda8f53",
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 1000,
"currency": "USD"
}
}
},
"id_mappings": [
{
"client_object_id": "#8ed1fc15",
"object_id": "XXXXXXXXXXXXXXXX"
}
]
}

I only gave one variant to create, but, it created an additional variant "Regular" when I checked in the Squareup items dashboard.

image

Any idea why this is happening ?

PHP8.2

Hi I have an application that requires PHP8.2
Can this work with PHP8.2?

"failed to open stream: No such file or directory" in error in JsonMapper.php file.

Describe the bug
We are using this Square SDK on the WooCommece-Square plugin and the below error is faced by some of our customers.

[07-Dec-2022 17:03:15 UTC] PHP Warning:  parse_ini_file(/usr/local/php7.4/conf/php.ini): failed to open stream: No such file or directory in /srv/htdocs/wp-content/plugins/woocommerce-square/vendor/apimatic/jsonmapper/src/JsonMapper.php on line 119

This is happening because certain hosting services don't allow to access resources outside the public directory due to security reasons, which is something a dependency of the Square SDK (JsonMapper) tries to do.

I noticed that the JsonMapper repo also has reported an issue for the same here apimatic/jsonmapper#28. We may check if it gets resolved there OR maybe we can look for an alternative for JsonMapper to get rid of this and make it possible to use Square SDK on all hosting providers.

Expected behavior
Square SDK should work without any errors.

To Reproduce
Steps to reproduce the bug:
Initialize the Square Client and try to call Square API. As this error comes on several hosting providers only it is unlikely that you will get it to reproduce locally directly. Please let me know if you need any further information on reproduce issue.
Based on information from customers, they are experiencing this error on Pressable and Kinsta hosting provider

Screenshots
If applicable, add screenshots to help explain the bug.

Square SDK version
24.0.0.20221116

Additional context
A similar issue reported earlier #87

Reference issues in woocommerce-square repo
https://github.com/woocommerce/woocommerce-square/issues/924
https://github.com/woocommerce/woocommerce-square/issues/990

Uncaught Error: Class 'Square\SquareClient' not found

I've checked and all the necessary files are being included with the following call:
require '/vendor/autoload.php';

I get the following error:
Uncaught Error: Class 'Square\SquareClient' not found...
...Stack trace: #0 {main} thrown

I think I have the correct code to get this working, but obviously something is going wrong.

use Square\SquareClient;
use Square\Environment;

$client = new SquareClient([
'accessToken' => 'I-put-my-token-here',
'environment' => Environment::SANDBOX,
]);

Fatal error: Uncaught Error: Class "Models\Booking"

I am getting issue for booking . can any one let me know what the exact issue ?
Fatal error: Uncaught Error: Class "Models\Booking" not found in C:\xampp\htdocs\square-php-sdk-1\index.php:75 Stack trace: #0 {main} thrown in C:\xampp\htdocs\square-php-sdk-1\index.php on line 75

Fatal Error for DELIVERY Orders

Describe the bug
Retrieving orders (either individual or all over a time frame) receive a fatal ApiException DELIVERY is invalid for Square\Models\OrderFulfillmentType.

PHP Fatal error:  Uncaught Square\Exceptions\ApiException: DELIVERY is invalid for Square\Models\OrderFulfillmentType. in /home/ryan/dev/workspace/gcj-analyzer/vendor/square/square/src/ApiHelper.php:123
Stack trace:
#0 /home/ryan/dev/workspace/gcj-analyzer/vendor/square/square/src/Apis/OrdersApi.php(453): Square\ApiHelper::mapClass()
#1 /home/ryan/dev/workspace/gcj-analyzer/src/Parsers/SquareParser.php(316): Square\Apis\OrdersApi->retrieveOrder()
#2 /home/ryan/dev/workspace/gcj-analyzer/bin/GetData.php(202): App\Parsers\SquareParser->retrieveOrder()
#3 {main}
  thrown in /home/ryan/dev/workspace/gcj-analyzer/vendor/square/square/src/ApiHelper.php on line 123

Expected behavior
No error
If I add a delivery public const just like the PICKUP and SHIPMENT that are already in the OrderFulfillmentType class and add it to the _ALL_TYPES array, it works just fine.

To Reproduce
I am using the searchOrders API to retrieve all orders over the day. Below is my method. $startDate and $endDate are passed into the method

$created_at = new TimeRange();
$created_at->setStartAt($startDate->format(DATE_RFC3339));
$created_at->setEndAt($endDate->format(DATE_RFC3339));

$date_time_filter = new SearchOrdersDateTimeFilter();
$date_time_filter->setCreatedAt($created_at);

$filter = new SearchOrdersFilter();
$filter->setDateTimeFilter($date_time_filter);

$query = new SearchOrdersQuery();
$query->setFilter($filter);

$body = new SearchOrdersRequest();
$body->setLocationIds(LOCATIONS);
$body->setQuery($query);

$this->api_response = $this->client->getOrdersApi()->searchOrders($body);

if (!$this->api_response->isSuccess()) {
    die($this->api_response->getErrors());
}

Running the same query on the API explorer returns the correct info because it looks like the error

Square SDK version
19.0.1.20220512

Feature Request: Include line items on Invoice Object

The Square\Models\Invoice Object does not include lineItems like the Order Object. For our business process, we need to be able to query the Invoices and move that data over into Quickbooks Online. The Invoice object, before it has been paid, has no line items or order id associated with it. So as far as I can tell, there's no way to query a list of line items or get other detailed information like taxes applied from an invoice.

Note, once an invoice is paid this information is available through the associated order. But this is not what we're talking about. We need the invoice in our quickbooks environment before the invoice gets paid. Additionally, sometimes the invoice is never paid through square, but only in the accounting system.

Please update the API and expose these invoice data points.

unirest-php has removed static entities in the latest release

Describe the bug
The latest release of unirest-php has removed static entities causing fatal php errors starting with BaseApi.php line 63.

Expected behavior
The sample code to work.

To Reproduce
Steps to reproduce the bug:

  1. Follow the instructions for manual configuration
  2. use unirest-php-3.0.0 (the latest version)
  3. The code fails
  4. use unirest-php-2.3.0
  5. The code works

Square SDK version
square-php-sdk-20.1.0.20220720

Additional context
Add any other context about the problem here.

Singular name, should be plural?

Maybe the reason for the $merchant properly being singular is that there is usually just a single entity, but in the interest of consistency, should it not be plural?

I discovered this when attempting to call listMerchants() when it is actually called listMerchant(), an illogical name.

Do you want pull-requests to correct issues like this, or can your team handle it?

415 Unsupported Media Type while trying to use getInvoice

Describe the bug
While calling getInvoice using latest SDK, I get 415 unsupported media type. This request works fine in API explorer.

Expected behavior
Invoice must be returned normally

To Reproduce
Steps to reproduce the bug:

  1. Create an invoice in sandbox
  2. Try get it with $client->getInvoicesApi()->getInvoice('inv:...')
  3. Get 415 response code

Screenshots
From sandbox API log:
image

Request:

content-type: text/plain; charset=utf-8
square-version: 2023-01-19
accept-encoding: deflate, gzip
accept: application/json
user-agent: Square-PHP-SDK/25.1.0.20230119 (2023-01-19) Zend/4.1.12 (omitted due to privacy reasons)

Response:

date: Wed, 08 Feb 2023 14:46:07 GMT
transfer-encoding: chunked
vary: Accept
x-frame-options: SAMEORIGIN
connection: keep-alive
content-type: text/plain; charset=utf-8
cache-control: no-cache

Square SDK version
25.1.0.20230119

Additional context
Add any other context about the problem here.

getSquareItems not filtering types

In the following example, listCatalog is not filtering by types, such as ITEM.'

function getSquareCatalog($types = 'ITEM'){
  $client = getApiClient();
  $catalogApi = $client->getCatalogApi();
  $cursor = 'initial';
  $catalog = array();

  while ($cursor){
    if ($cursor == 'initial'){$cursor = null;}
    $apiResponse = $catalogApi->listCatalog($cursor, $types);

    if ($apiResponse->isSuccess()) {
      $listCatalogResponse = $apiResponse->getResult();
      $catalog= array_merge ($catalog, $listCatalogResponse->getObjects());

      $cursor = $listCatalogResponse->getCursor();
    }
  }
  return $catalog;
}

print("<pre>".print_r(getSquareCatalog(),true)."</pre>");

Returns all item types including ITEM, CATEGORY, TAX, DISCOUNT

Op Cache can break response types, leading to a PHP Error

We discovered an issue that would cause ApiHelper::mapClass() to return the correct class, but with properties using stdClass instead of the expected Square type, resulting in a PHP Error being thrown if the getter methods are invoked.

For example, when this issue is encountered, CustomersApi->listCustomers() returns a ListCustomersResponse instance via ApiResponse->getResult(), but getCustomers() returns an array of stdClass objects. This results in an error like Call to undefined method stdClass::getId() to be thrown when using any of the type's methods. All of the List models exhibit this behavior.

Issue Details

ApiHelper->mapClass() uses jsonmapper to convert JSON response objects into the correct types. JsonMapper does this by using the Reflection API to get the phpDoc comments to infer the types. For example, by parsing @var Customer[]|null for ListCustomersResponse->customers to determine that it should instantiate an array of Customer objects.

The PHP Error we encountered was caused by phpDoc comments being ignored by the PHP Op Cache due to opcache.save_comments being disabled in our PHP configuration. With that setting, JsonMapper can not determine the types of the properties so it leaves the stdClass instances originally returned by json_decode().

Requested Action

  1. The PHP SDK documentation here should include a notice that it is incompatible with this configuration
  2. The Square team should file a ticket against JsonMapper
    1. Instantiating a mapper should throw a configuration exception if opcache.save_comments is set to off, similar to Doctrine's AnnotationException checks.

Error: Class 'Square\SquareClient' not found

Describe the bug
For some reason, I get the following error: Error: Class 'Square\SquareClient' not found which is odd. I can definitely see the file.
Works on my local, but not on the server the site is hosted on.
Annoyingly, I have to transfer files the ancient way (FTP), so no composer. So I suspect composer might be needed on the server, but I genuinely have no idea. Would love some guidance if there's a manual way to install this properly.
(Also have in mind I am literally transferring everything composer would have downloaded to my local anyway)

Expected behavior
A clear and concise description of what you expected to happen.

Square SDK version
I think its version 17. (Sadly upgrading from this isn't an option as the package I'm actually using relies on this particular version)

I toggled between php 7.4 and php 8 but no luck.
Forgive me if this has been reported and solved already. I couldn't find anything

If anyone is familiar with Drupal, I'm using the Commerce Square module - https://www.drupal.org/project/commerce_square/ that depends on the square sdk

difference in api explorer and sdk for creating a device code with product type set

Describe the bug
In API explorer for API version 2023-01-19 it has it passing the product_type into the DeviceCode class

$device_code = new \Square\Models\DeviceCode('TERMINAL_API');

In SDK version 25.1.0.20230119 it isn't setup to accept the product_type in the construct of the class since there isn't one.

Is this an API Explorer bug/typo and should we pass in the product type instead?

$device_code = new \Square\Models\DeviceCode();
$device_code->setProductType('TERMINAL_API');

Update Customer empty request payload returns error

return $arr;

image

When we called ->updateCustomer() on the package, if we sent up no parameters to the endpoint, it would return this error.
As referenced in the code above, we believe that this is happening because the package is not performing any parsing because we sent no parameters (is returning [] instead of expected {}).

I believe that if the endpoint contains no parameters, it should do something like
json_encode( $array, JSON_FORCE_OBJECT ) to force {} instead of [].

Has error related to booking api

Describe the bug
Copied the example code (list booking) from docs and got the error.
Tried team-member-booking-profiles got same error.
Tried list-customers and it worked fine.

Expected behavior
Expect to see the list of booking

To Reproduce
Copy the php code from this https://developer.squareup.com/reference/square/bookings-api/list-bookings

Code detail:

   $api_response = $client->getBookingsApi()->listBookings();
    if ($api_response->isSuccess()) {
        $result = $api_response->getResult();
        var_dump($result);
    } else {
        $errors = $api_response->getErrors();
        var_dump("Error");
        var_dump($errors);
    }

Result

string(5) "Error"
array(1) {
  [0]=>
  object(Square\Models\Error)#39 (4) {
    ["category":"Square\Models\Error":private]=>
    string(8) "V1_ERROR"
    ["code":"Square\Models\Error":private]=>
    string(7) "Unknown"
    ["detail":"Square\Models\Error":private]=>
    NULL
    ["field":"Square\Models\Error":private]=>
    NULL
  }
}

Square SDK version
24.0.0.20221116

when uploading image it is adding image/jpeg for Content-Type ?

In latest v25 I noticed in the createCatalogImage function is it adding image/jpeg as Content-Type ?
Even though it accepts more than just jpeg ?

This CreateCatalogImage endpoint accepts HTTP multipart/form-data requests with a JSON part and an image file part in JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
public function createCatalogImage(
        ?CreateCatalogImageRequest $request = null,
        ?FileWrapper $imageFile = null
    ): ApiResponse {
        $_reqBuilder = $this->requestBuilder(RequestMethod::POST, '/v2/catalog/images')
            ->auth('global')
            ->parameters(
                FormParam::init('request', $request)
                    ->encodingHeader('Content-Type', 'application/json; charset=utf-8'),
                FormParam::init('image_file', $imageFile)->encodingHeader('Content-Type', 'image/jpeg')
            );

        $_resHandler = $this->responseHandler()->type(CreateCatalogImageResponse::class)->returnApiResponse();

        return $this->execute($_reqBuilder, $_resHandler);
    }

Different item object types are returned based on which API call you use.

As I've explained in this forum post, the Square API is returning different object types depending on the type of call you make. Additionally, it's returning different object types within the same call.

The following listCatalog function will return items of stdClass type.

function getSquareItems($type = 'ITEM'){
  $client = getApiClient();
  $catalogApi = $client->getCatalogApi();
  $cursor = 'initial';
  $items = array();

  while ($cursor){
    if ($cursor == 'initial'){$cursor = null;}
    $apiResponse = $catalogApi->listCatalog($cursor, $type);

    if ($apiResponse->isSuccess()) {
      $listCatalogResponse = $apiResponse->getResult();
      $items = array_merge ($items, $listCatalogResponse->getObjects());

      $cursor = $listCatalogResponse->getCursor();
    } else {
      $errors = $apiResponse->getErrors();
      sendNotification('Error in getSquareItems', 'ERROR');
      sendNotification($errors, 'ERROR');
    }
  }
  return $items;
}

Example output

Array
(
    [0] =>
stdClass Object
        (
            [type] => ITEM
            [id] => 54UILILDH27K7LTLLE54DNYS
            [updated_at] => 2020-07-11T00:09:58.626Z
            [version] => 1594426198626
            [is_deleted] => 
            [present_at_all_locations] => 1
            [item_data] => stdClass Object
                (
                    [name] => Test Item 1
                    [description] => test desc 1
                    [visibility] => PRIVATE
                    [tax_ids] => Array
                        (
                            [0] => Y3JU6BZL2EQUA4VRRDPSQTC4
                        )

                    [variations] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [type] => ITEM_VARIATION
                                    [id] => M2L62Y3VUFCM2W3NGXCUS4N2
                                    [updated_at] => 2020-07-11T00:09:58.626Z
                                    [version] => 1594426198626
                                    [is_deleted] => 
                                    [present_at_all_locations] => 1
                                    [item_variation_data] => stdClass Object
                                        (
                                            [item_id] => 54UILILDH27K7LTLLE54DNYS
                                            [name] => Regular
                                            [sku] => asdf
                                            [ordinal] => 1
                                            [pricing_type] => FIXED_PRICING
                                            [price_money] => stdClass Object
                                                (
                                                    [amount] => 500
                                                    [currency] => USD
                                                )

                                            [location_overrides] => Array
                                                (
                                                    [0] => stdClass Object
                                                        (
                                                            [location_id] => ZE0YNMZC64NAD
                                                            [track_inventory] => 1
                                                        )

                                                )

                                            [track_inventory] => 1
                                        )

                                )

                        )

                    [product_type] => REGULAR
                    [skip_modifier_screen] => 
                )

        )
)

Meanwhile, the following retrieveCatalogObject function will create output with a different object type.

function getItem($objectId){
  $client = getApiClient();
  $catalogApi = $client->getCatalogApi();

  $apiResponse = $catalogApi->retrieveCatalogObject($objectId, false);

  if ($apiResponse->isSuccess()) {
      $retrieveCatalogObjectResponse = $apiResponse->getResult();
      $catalogObject = $retrieveCatalogObjectResponse->getObject();
  } else {
      $errors = $apiResponse->getErrors();
  }

  return $catalogObject;
}

Example output

Square\Models\CatalogObject Object
(
    [type:Square\Models\CatalogObject:private] => ITEM
    [id:Square\Models\CatalogObject:private] => 54UILILDH27K7LTLLE54DNYS
    [updatedAt:Square\Models\CatalogObject:private] => 2020-07-11T00:09:58.626Z
    [version:Square\Models\CatalogObject:private] => 1594426198626
    [isDeleted:Square\Models\CatalogObject:private] => 
    [customAttributeValues:Square\Models\CatalogObject:private] => 
    [catalogV1Ids:Square\Models\CatalogObject:private] => 
    [presentAtAllLocations:Square\Models\CatalogObject:private] => 1
    [presentAtLocationIds:Square\Models\CatalogObject:private] => 
    [absentAtLocationIds:Square\Models\CatalogObject:private] => 
    [imageId:Square\Models\CatalogObject:private] => 
    [itemData:Square\Models\CatalogObject:private] => Square\Models\CatalogItem Object
        (
            [name:Square\Models\CatalogItem:private] => Test Item 1
            [description:Square\Models\CatalogItem:private] => test desc 1
            [abbreviation:Square\Models\CatalogItem:private] => 
            [labelColor:Square\Models\CatalogItem:private] => 
            [availableOnline:Square\Models\CatalogItem:private] => 
            [availableForPickup:Square\Models\CatalogItem:private] => 
            [availableElectronically:Square\Models\CatalogItem:private] => 
            [categoryId:Square\Models\CatalogItem:private] => 
            [taxIds:Square\Models\CatalogItem:private] => Array
                (
                    [0] => Y3JU6BZL2EQUA4VRRDPSQTC4
                )

            [modifierListInfo:Square\Models\CatalogItem:private] => 
            [variations:Square\Models\CatalogItem:private] => Array
                (
                    [0] => stdClass Object
                        (
                            [type] => ITEM_VARIATION
                            [id] => M2L62Y3VUFCM2W3NGXCUS4N2
                            [updated_at] => 2020-07-11T00:09:58.626Z
                            [version] => 1594426198626
                            [is_deleted] => 
                            [present_at_all_locations] => 1
                            [item_variation_data] => stdClass Object
                                (
                                    [item_id] => 54UILILDH27K7LTLLE54DNYS
                                    [name] => Regular
                                    [sku] => asdf
                                    [ordinal] => 1
                                    [pricing_type] => FIXED_PRICING
                                    [price_money] => stdClass Object
                                        (
                                            [amount] => 500
                                            [currency] => USD
                                        )

                                    [location_overrides] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [location_id] => ZE0YNMZC64NAD
                                                    [track_inventory] => 1
                                                )

                                        )

                                    [track_inventory] => 1
                                )

                        )

                )

            [productType:Square\Models\CatalogItem:private] => REGULAR
            [skipModifierScreen:Square\Models\CatalogItem:private] => 
            [itemOptions:Square\Models\CatalogItem:private] => 
        )

    [categoryData:Square\Models\CatalogObject:private] => 
    [itemVariationData:Square\Models\CatalogObject:private] => 
    [taxData:Square\Models\CatalogObject:private] => 
    [discountData:Square\Models\CatalogObject:private] => 
    [modifierListData:Square\Models\CatalogObject:private] => 
    [modifierData:Square\Models\CatalogObject:private] => 
    [timePeriodData:Square\Models\CatalogObject:private] => 
    [productSetData:Square\Models\CatalogObject:private] => 
    [pricingRuleData:Square\Models\CatalogObject:private] => 
    [imageData:Square\Models\CatalogObject:private] => 
    [measurementUnitData:Square\Models\CatalogObject:private] => 
    [itemOptionData:Square\Models\CatalogObject:private] => 
    [itemOptionValueData:Square\Models\CatalogObject:private] => 
    [customAttributeDefinitionData:Square\Models\CatalogObject:private] => 
    [quickAmountsSettingsData:Square\Models\CatalogObject:private] => 
)

You can see above that this actually returned by Square CatalogItem fields as well as stdClass fields in the same object.

But that's not the only issue. It seems that when the Square API returns a CatalogItem field, it returns fields with no underscores in their name and when it returns a stdClass object, it has underscores. For instance, one of the results above has itemData, while the other has item_data. Unfortunately my fix that I mentioned in the forum posting of casting it to the stdClass type won't work because you're providing me with completely different field names depending on which API endpoints I call.

The same issue of mixed object types exists in the return object of upsertCatalogObject.

Fatal error: Uncaught Error: Cannot access private property Square\Models\Location::$id

Hi,
After updating SDK using composer, I am getting
"Fatal error: Uncaught Error: Cannot access private property Square\Models\Location::$id" in Line 26,
when I tried printing a Locations ID as,
print_r($location->id); instead of print_r($location);
I am using first API for Square example from,
https://github.com/umaraliyar/square-php-sdk

It was working as expected when I use "6.0.0.20200625"

I am not getting a clue what I am missing.

Could not find required constructor arguments for "\\Square\\Models\\AdditionalRecipient: description"

API version: 2021-01-21
SDK version: 8.1.0.20210121

JsonMapperException is thrown when calling OrdersApi::searchOrders.

This is due to the fact that the description attribute on Models\AdditionalRecipient is required.

This field should be optional/nullable.

Example:

{
    "additional_recipients": [{"location_id": "XXXXXXXXXX","amount_money": {"amount": 10,"currency": "USD"},"receivable_id": "XXXXXXXXXX"}]
}

getShippingAddress() Method in Payment Model returns NULL

I create a checkout Object and put setAskForShippingAddress() to true, and it does indeed collect shipping address during the hosted checkout.

However, the API Docs do not specify as to how to fetch that back. The $api_response = $client->getCheckoutApi()->createCheckout('$location_id', $checkout_data_body) does not return it. Your payment.updated webhook does not send back the shipping address either on payment completion (I do however get the payment_id and order_id, but neither the Payment or Order API contain the shipping address).

How do get the shipping address filled by customer during the hosted checkout?

UPDATE

I was going through the Models and the Payment model does have a method but it returns NULL. This is the var_dump() snippet of $apiResponse = $paymentsApi->getPayment($paymentId):

      ["referenceId":"Square\Models\Payment":private]=>
      NULL
      ["customerId":"Square\Models\Payment":private]=>
      NULL
      ["employeeId":"Square\Models\Payment":private]=>
      NULL
      ["refundIds":"Square\Models\Payment":private]=>
      NULL
      ["buyerEmailAddress":"Square\Models\Payment":private]=>
      NULL
      ["billingAddress":"Square\Models\Payment":private]=>
      NULL
      ["shippingAddress":"Square\Models\Payment":private]=>

This is still an issue. Help.

Catalog Image Upload Issue

I'm attempting to upload an image from an s3 bucket to a catalog image. Following the docs here's what I have:

$imageData = new CatalogImage();
$imageData->setCaption('Some image name');

$imageObject = new CatalogObject(CatalogObjectType::IMAGE, '#TESTIMAGE');
$imageObject->setImageData($imageData);

// Update catalog object in the api
$requestId = (string) Str::uuid();
$imageUploadBody = new CreateCatalogImageRequest($requestId, $imageObject);
$imageUploadBody->setObjectId($externalId); // $externalId is a valid CatalogItem Id
$imageUploadBody->setImage($imageObject);

// Save local copy of image (in prod this is coming from my s3 bucket)
$filePath = sys_get_temp_dir() . '/filename.jpeg';
$fileUrl = 'https://www.aworldofdifference.co.nz/pics/45,3,1,6,3,0/20151002142909/test-jpg.jpeg';
file_put_contents($filePath, file_get_contents($fileUrl));

// Configure object url
$imageFile = FileWrapper::createFromPath($filePath);
$apiResponse = $this->catalogApi->createCatalogImage($imageUploadBody, $imageFile);

However I'm getting the following error from square after I do the upload even though the file type of the provided file is a .jpeg (ie a supported type).

array:1 [
  0 => Square\Models\Error {#1613 
    -category: "INVALID_REQUEST_ERROR"
    -code: "INVALID_CONTENT_TYPE"
    -detail: "Only [image/jpeg image/pjpeg image/png image/x-png image/gif] content type allowed. but got application/octet-stream"
    -field: null
  }
]

In an ideal world I'd like to just supply the public image url from my bucket to the catalog uploaded but under the hood it looks like FileWrapper::createFromPath() is using CurlFile which my understanding is does not support remote file upload. https://github.com/square/square-php-sdk/blob/master/src/Utils/FileWrapper.php#L63

I've been hacking at this for quite some time now without a good solution to show for it so any advice would be much appreciated. Thanks!

Deprecation notice in listCustomerGroups method

When calling the listCustomerGroups method from the API, in PHP 8.1, I get the following PHP Notice:

PHP Deprecated: Return type of Square\Models\ListCustomerGroupsResponse::jsonSerialize(bool $asArrayWhenEmpty = false) should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .../vendor/square/square/src/Models/ListCustomerGroupsResponse.php on line 124�

I am not sure if this notice also exists in other API calls

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.