{"id":13485803,"url":"https://github.com/square/connect-java-sdk","last_synced_at":"2025-03-27T19:31:47.595Z","repository":{"id":54930989,"uuid":"85248752","full_name":"square/connect-java-sdk","owner":"square","description":"Java client library for the Square Connect v2 API","archived":true,"fork":false,"pushed_at":"2021-01-20T22:25:45.000Z","size":1967,"stargazers_count":40,"open_issues_count":3,"forks_count":25,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-20T17:11:33.237Z","etag":null,"topics":["ecommerce","java","payments","sdk","square","squareup"],"latest_commit_sha":null,"homepage":null,"language":"Java","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":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-16T22:54:55.000Z","updated_at":"2025-03-05T03:57:28.000Z","dependencies_parsed_at":"2022-08-14T06:50:45.382Z","dependency_job_id":null,"html_url":"https://github.com/square/connect-java-sdk","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fconnect-java-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fconnect-java-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fconnect-java-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fconnect-java-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/square","download_url":"https://codeload.github.com/square/connect-java-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245526978,"owners_count":20629916,"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":["ecommerce","java","payments","sdk","square","squareup"],"created_at":"2024-07-31T18:00:31.942Z","updated_at":"2025-03-27T19:31:46.527Z","avatar_url":"https://github.com/square.png","language":"Java","readme":"![Square logo]\n\n# Square Connect Java SDK - RETIRED\n\n---\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.squareup/connect/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.squareup/connect)\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 Java SDK retired\n\nThe Square Connect Java SDK is retired (EOL) as of 2019-12-17 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 Java SDK](https://github.com/square/square-java-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 Java SDK](#migrate-to-the-square-java-sdk)\n  * [Update your project](#update-your-project)\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 Java SDK\n\nFollow the instructions below to migrate your apps from the deprecated\n`com.squareup.connect` library to the new `com.squareup.square` library.\n\n### Update your project\n\nUpdate the dependency in your Maven or Gradle project.\n\n#### Update Maven\n\nUpdate the Square dependency in the POM for your project:\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.squareup\u003c/groupId\u003e\n    \u003cartifactId\u003esquare\u003c/artifactId\u003e\n    \u003cversion\u003e4.0.0.20191217\u003c/version\u003e\n    \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n#### Update Gradle\n\nReplace the `com.squareup.connect` dependency in the build file of your project:\n\n```\nimplementation \"com.squareup:square:4.0.0.20191217\"\n```\n\n### Update your code\n\n1. Change all instances of `import com.squareup.connect'` to `import com.squareup.square`.\n1. Update client instantiation to follow the method outlined below.\n1. Use `thenAccept` and `exceptionally` rather than `try` and `catch` for flow control.\n\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\n```java\nimport com.squareup.square.SquareClient;\nimport com.squareup.square.Environment;\n\nSquareClient square = new SquareClient.Builder()\n    .environment(Environment.SANDBOX)\n    .accessToken(\"YOUR_SANDBOX_ACCESS_TOKEN\")\n    .build();\n```\n\n#### Accessing response data\nUsing listLocations as an example\n```java\nsquare.getLocationsApi().listLocationsAsync().thenAccept(result -\u003e {\n    // Business logic\n    }).exceptionally(exception -\u003e {\n    // Exception handling\n    return null;\n});\n```\n\n\u003cbr/\u003e\n\n---\n\n\u003cbr/\u003e\n\n## Example code migration\n\nAs a specific example, consider the code used to create a new customer\nprofile with the following `CreateCustomerRequest` object:\n\n```java\nAddress bodyAddress = new Address.Builder()\n    .addressLine1(\"500 Electric Ave\")\n    .addressLine2(\"Suite 600\")\n    .locality(\"New York\")\n    .administrativeDistrictLevel1(\"NY\")\n    .postalCode(\"10003\")\n    .country(\"US\")\n    .build();\n\nCreateCustomerRequest body = new CreateCustomerRequest.Builder()\n    .givenName(\"Amelia\")\n    .familyName(\"Earhart\")\n    .emailAddress(\"Amelia.Earhart@example.com\")\n    .address(bodyAddress)\n    .phoneNumber(\"1-212-555-4240\")\n    .referenceId(\"YOUR_REFERENCE_ID\")\n    .note(\"a customer\")\n    .build();\n```\n\nWith the deprecated `squareup.connect` library, this is how you instantiate a client\nfor the Customers API, format the request, and call the endpoint:\n\n```java\nApiClient defaultClient = Configuration.getDefaultApiClient();\nCustomersApi customersApi = new CustomersApi();\n\ntry {\n    CreateCustomerResponse result = customersApi.createCustomer(body);\n    System.out.println(result);\n} catch (ApiException e) {\n    System.err.println(\"Exception when calling CustomersApi.createCustomer\");\n    e.printStackTrace();\n}\n```\n\nNow consider equivalent code using the new `squareup.square` library:\n\n```java\n// Instantiate the client\nSquareClient square = new SquareClient.Builder()\n    .environment(Environment.SANDBOX)\n    .accessToken(\"YOUR_SANDBOX_ACCESS_TOKEN\")\n    .build();\n\n// Call the endpoint\nsquare.getCustomersApi().createCustomerAsync(body).thenAccept(result -\u003e {\n    System.out.println(\"Successfully created customer with id:\"+ result.getCustomer().getId());\n}).exceptionally(e -\u003e {\n    System.err.println(\"Exception when calling CustomersApi.createCustomer\");\n    e.printStackTrace();\n    return null;\n});\n```\n\nThat's it!\n\nWhat was once a multi-object process can be handled asynchronously with a single\nclient. Migrating to the `com.squareup.square` library reduces boilerplate and lets\nyou focus on the parts of your code that really matter.\n\n\n\u003cbr/\u003e\n\n---\n\n\u003cbr/\u003e\n\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 Logo]: https://docs.connect.squareup.com/images/github/github-square-logo.svg\n[Square Java SDK]: https://github.com/square/square-java-sdk\n[Square developer community]: https://squ.re/slack\n","funding_links":[],"categories":["Projects","项目"],"sub_categories":["Financial","财务"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Fconnect-java-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquare%2Fconnect-java-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Fconnect-java-sdk/lists"}