{"id":13624177,"url":"https://github.com/square/connect-php-sdk","last_synced_at":"2025-04-15T20:33:37.252Z","repository":{"id":57058369,"uuid":"54998361","full_name":"square/connect-php-sdk","owner":"square","description":"PHP client library for the Square Connect APIs","archived":true,"fork":false,"pushed_at":"2020-06-29T20:54:08.000Z","size":2135,"stargazers_count":115,"open_issues_count":8,"forks_count":55,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-04-06T23:30:00.645Z","etag":null,"topics":["sdk"],"latest_commit_sha":null,"homepage":"https://developer.squareup.com/docs","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/square.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-29T17:58:12.000Z","updated_at":"2025-03-09T00:50:00.000Z","dependencies_parsed_at":"2022-08-24T07:30:31.254Z","dependency_job_id":null,"html_url":"https://github.com/square/connect-php-sdk","commit_stats":null,"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fconnect-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fconnect-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fconnect-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fconnect-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/square","download_url":"https://codeload.github.com/square/connect-php-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249148417,"owners_count":21220527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sdk"],"created_at":"2024-08-01T21:01:39.786Z","updated_at":"2025-04-15T20:33:33.020Z","avatar_url":"https://github.com/square.png","language":"PHP","funding_links":[],"categories":["Configuration","配置 Configuration","PHP"],"sub_categories":["Third Party APIs","第三方api Third Party APIs"],"readme":"# Square Connect PHP SDK - RETIRED replaced by [square/square-php-sdk](https://github.com/square/square-php-sdk)\n\n---\n\n[![Build Status](https://travis-ci.org/square/connect-php-sdk.svg?branch=master)](https://travis-ci.org/square/connect-php-sdk)\n[![PHP version](https://badge.fury.io/ph/square%2Fconnect.svg)](https://badge.fury.io/ph/square%2Fconnect)\n[![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n==================\n\n## NOTICE: Square Connect PHP SDK retired\n\nThe Square Connect PHP SDK is retired (EOL) as of 2020-06-10 and will no longer\nreceive bug fixes or product updates. To continue receiving API and SDK\nimprovements, please follow the instructions below to migrate to the new\n[Square PHP SDK].\n\n\nThe old Connect SDK documentation is available under the\n[`/docs` folder](./docs/README.md).\n\n\u003cbr/\u003e\n\n---\n\n* [Migrate to the Square PHP SDK](#migrate-to-the-square-php-sdk)\n  * [Update your code](#update-your-code)\n* [Example code migration](#example-code-migration)\n* [Ask the Community](#ask-the-community)\n\n---\n\n\u003cbr/\u003e\n\n## Migrate to the Square PHP SDK\n\nFollow the instructions below to migrate your apps from the deprecated\n`square/connect` sdk to the new library.\n\nYou need to update your app to use the Square PHP SDK instead of the Connect PHP SDK\nThe Square PHP SDK uses the `square/square` identifier.\n\n1. On the command line, run:\n```\n$ php composer.phar require square/square\n```\n*-or-*\n\n2. Update your composer.json:\n```\n\"require\": {\n    ...\n    \"square/square\": \"^5.0.0\",\n    ...\n}\n```\n### Update your code\n\n1. Change all instances of `use SquareConnect\\...` to `use Square\\...`.\n1. Replace `SquareConnect` models with the new `Square` equivalents\n1. Update client instantiation to follow the method outlined below.\n1. Update code for accessing response data to follow the method outlined below.\n1. Check `$apiResponse-\u003eisSuccess()` or `$apiResponse-\u003eisError()` to determine if the call was a success.\n\nTo simplify your code, we also recommend that you use method chaining to access\nAPIs instead of explicitly instantiating multiple clients.\n\n#### Client instantiation\n\nConnect SDK\n```php\nrequire 'vendor/autoload.php';\n\nuse SquareConnect\\Configuration;\nuse SquareConnect\\ApiClient;\n\n$access_token = 'YOUR_ACCESS_TOKEN';\n# setup authorization\n$api_config = new Configuration();\n$api_config-\u003esetHost(\"https://connect.squareup.com\");\n$api_config-\u003esetAccessToken($access_token);\n$api_client = new ApiClient($api_config);\n\n```\nSquare SDK\n\n```php\nrequire 'vendor/autoload.php';\n\nuse Square\\SquareClient;\nuse Square\\Environment;\n\n// Initialize the Square client.\n$api_client = new SquareClient([\n  'accessToken' =\u003e \"YOUR_ACCESS_TOKEN\",\n  'environment' =\u003e Environment::SANDBOX\n]); // In production, the environment arg is 'production'\n```\n\n## Example code migration\n\nAs a specific example, consider the following code for creating a new payment\nfrom the following nonce:\n\n```php\n# Fail if the card form didn't send a value for `nonce` to the server\n$nonce = $_POST['nonce'];\nif (is_null($nonce)) {\n  echo \"Invalid card data\";\n  http_response_code(422);\n  return;\n}\n```\n\nWith the deprecated `square/connect` library, this is how you instantiate a client\nfor the Payments API, format the request, and call the endpoint:\n\n```php\nuse SquareConnect\\Api\\PaymentsApi;\nuse SquareConnect\\ApiException;\n\n$payments_api = new PaymentsApi($api_client);\n$request_body = array (\n  \"source_id\" =\u003e $nonce,\n  \"amount_money\" =\u003e array (\n    \"amount\" =\u003e 100,\n    \"currency\" =\u003e \"USD\"\n  ),\n  \"idempotency_key\" =\u003e uniqid()\n);\ntry {\n  $result = $payments_api-\u003ecreatePayment($request_body);\n  echo \"\u003cpre\u003e\";\n  print_r($result);\n  echo \"\u003c/pre\u003e\";\n} catch (ApiException $e) {\n  echo \"Caught exception!\u003cbr/\u003e\";\n  print_r(\"\u003cstrong\u003eResponse body:\u003c/strong\u003e\u003cbr/\u003e\");\n  echo \"\u003cpre\u003e\"; var_dump($e-\u003egetResponseBody()); echo \"\u003c/pre\u003e\";\n  echo \"\u003cbr/\u003e\u003cstrong\u003eResponse headers:\u003c/strong\u003e\u003cbr/\u003e\";\n  echo \"\u003cpre\u003e\"; var_dump($e-\u003egetResponseHeaders()); echo \"\u003c/pre\u003e\";\n}\n```\n\nNow consider equivalent code using the new `square/square` library:\n\n```php\nrequire 'vendor/autoload.php';\n\nuse Square\\Environment;\nuse Square\\Exceptions\\ApiException;\nuse Square\\SquareClient;\nuse Square\\Models\\CreatePaymentRequest;\nuse Square\\Models\\Money;\n\n$payments_api = $api_client-\u003egetPaymentsApi();\n\n$money = new Money();\n$money-\u003esetAmount(100);\n$money-\u003esetCurrency('USD');\n$create_payment_request = new CreatePaymentRequest($nonce, uniqid(), $money);\ntry {\n  $response = $payments_api-\u003ecreatePayment($create_payment_request);\n  if ($response-\u003eisError()) {\n    echo 'Api response has Errors';\n    $errors = $response-\u003egetErrors();\n    exit();\n  }\n  echo '\u003cpre\u003e';\n  print_r($response);\n  echo '\u003c/pre\u003e';\n} catch (ApiException $e) {\n  echo 'Caught exception!\u003cbr/\u003e';\n  exit();\n}\n```\n\nThat's it!\n\n\n\n\u003cbr/\u003e\n\n---\n\n\u003cbr/\u003e\n\n## Ask the community\n\nPlease join us in our [Square developer community] if you have any questions!\n\n\n[//]: # \"Link anchor definitions\"\n[Square PHP SDK]: https://github.com/square/square-php-sdk\n[Square developer community]: https://squ.re/slack","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Fconnect-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquare%2Fconnect-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Fconnect-php-sdk/lists"}