All Projects → square → Connect Java Sdk

square / Connect Java Sdk

Licence: apache-2.0
Java client library for the Square Connect v2 API

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Connect Java Sdk

Mailchimp Api 3.0 Php
A feature rich object-oriented PHP library for interacting with MailChimp's API v3 💌🐵
Stars: ✭ 61 (+69.44%)
Mutual labels:  ecommerce, sdk
Ecommerce Laravel Bootstrap
Responsive, Multi-Vendor, MultiLanguage Online Store Platform (shopping cart solution)
Stars: ✭ 99 (+175%)
Mutual labels:  ecommerce, payments
Gopay
💰 Integrace Gopay pro Nette Framework
Stars: ✭ 68 (+88.89%)
Mutual labels:  ecommerce, payments
Sdk Dotnet
.Net SDK for Authorize.Net API
Stars: ✭ 124 (+244.44%)
Mutual labels:  payments, sdk
Digota
ecommerce microservice
Stars: ✭ 382 (+961.11%)
Mutual labels:  ecommerce, payments
Nodejs
Everything related to the Node.js ecosystem for the commercetools platform.
Stars: ✭ 47 (+30.56%)
Mutual labels:  ecommerce, sdk
Ios Print Sdk
iOS Print SDK. Easily add print on demand functionality to your app within minutes! Print Postcards, Magnets, Photo Prints, Posters, Stickers, T-Shirts, PhotoBooks, etc.
Stars: ✭ 99 (+175%)
Mutual labels:  ecommerce, sdk
Hanzo.js
🚀 Hanzo JavaScript SDK. Develop cutting-edge decentralized applications.
Stars: ✭ 128 (+255.56%)
Mutual labels:  payments, sdk
Braintree android
Braintree SDK for Android
Stars: ✭ 343 (+852.78%)
Mutual labels:  payments, sdk
In App Payments Flutter Plugin
Flutter Plugin for Square In-App Payments SDK
Stars: ✭ 256 (+611.11%)
Mutual labels:  payments, sdk
Braintree Android Drop In
Braintree Drop-In SDK for Android
Stars: ✭ 78 (+116.67%)
Mutual labels:  payments, sdk
Worldpay Within Sdk
Worldpay Within SDK to allow payments within IoT. Written in Go.
Stars: ✭ 12 (-66.67%)
Mutual labels:  payments, sdk
Checkout.js
💳 Quickly capture payments with the best checkout flow for crowdfunding and product launches.
Stars: ✭ 92 (+155.56%)
Mutual labels:  ecommerce, payments
Commerce.js
Open source, JS eCommerce SDK for building headless, Jamstack applications. Build custom storefronts, carts, and checkouts in any frontend framework, platform, or device. Integrates with Stripe, Square, PayPal, Paymill and Razorpay with support for 135+ currencies.
Stars: ✭ 112 (+211.11%)
Mutual labels:  ecommerce, sdk
Bitgosdk Php
BitGo SDK written in PHP
Stars: ✭ 22 (-38.89%)
Mutual labels:  payments, sdk
Checkout Sdk Node
Checkout.com SDK for Node.js. Documentation here:
Stars: ✭ 28 (-22.22%)
Mutual labels:  payments, sdk
Facebook
A Facebook Graph API SDK For Go.
Stars: ✭ 948 (+2533.33%)
Mutual labels:  sdk
Think Wechat
企业微信SDK for ThinkPHP5
Stars: ✭ 34 (-5.56%)
Mutual labels:  sdk
Ln Pay
A minimalistic payment only wallet for Lightning Network
Stars: ✭ 29 (-19.44%)
Mutual labels:  payments
Openapi Core Ruby Sdk
Alibaba Cloud Core SDK for Ruby
Stars: ✭ 29 (-19.44%)
Mutual labels:  sdk

Square logo

Square Connect Java SDK - RETIRED


Maven Central Apache-2 license

NOTICE: Square Connect Java SDK retired

The Square Connect Java SDK is retired (EOL) as of 2019-12-17 and will no longer receive bug fixes or product updates. To continue receiving API and SDK improvements, please follow the instructions below to migrate to the new Square Java SDK.

The old Connect SDK documentation is available under the /docs folder.





Migrate to the Square Java SDK

Follow the instructions below to migrate your apps from the deprecated com.squareup.connect library to the new com.squareup.square library.

Update your project

Update the dependency in your Maven or Gradle project.

Update Maven

Update the Square dependency in the POM for your project:

<dependency>
    <groupId>com.squareup</groupId>
    <artifactId>square</artifactId>
    <version>4.0.0.20191217</version>
    <scope>compile</scope>
</dependency>

Update Gradle

Replace the com.squareup.connect dependency in the build file of your project:

implementation "com.squareup:square:4.0.0.20191217"

Update your code

  1. Change all instances of import com.squareup.connect' to import com.squareup.square.
  2. Update client instantiation to follow the method outlined below.
  3. Use thenAccept and exceptionally rather than try and catch for flow control.

To simplify your code, we also recommend that you use method chaining to access APIs instead of explicitly instantiating multiple clients.

Client instantiation

import com.squareup.square.SquareClient;
import com.squareup.square.Environment;

SquareClient square = new SquareClient.Builder()
    .environment(Environment.SANDBOX)
    .accessToken("YOUR_SANDBOX_ACCESS_TOKEN")
    .build();

Accessing response data

Using listLocations as an example

square.getLocationsApi().listLocationsAsync().thenAccept(result -> {
    // Business logic
    }).exceptionally(exception -> {
    // Exception handling
    return null;
});



Example code migration

As a specific example, consider the code used to create a new customer profile with the following CreateCustomerRequest object:

Address bodyAddress = new Address.Builder()
    .addressLine1("500 Electric Ave")
    .addressLine2("Suite 600")
    .locality("New York")
    .administrativeDistrictLevel1("NY")
    .postalCode("10003")
    .country("US")
    .build();

CreateCustomerRequest body = new CreateCustomerRequest.Builder()
    .givenName("Amelia")
    .familyName("Earhart")
    .emailAddress("[email protected]")
    .address(bodyAddress)
    .phoneNumber("1-212-555-4240")
    .referenceId("YOUR_REFERENCE_ID")
    .note("a customer")
    .build();

With the deprecated squareup.connect library, this is how you instantiate a client for the Customers API, format the request, and call the endpoint:

ApiClient defaultClient = Configuration.getDefaultApiClient();
CustomersApi customersApi = new CustomersApi();

try {
    CreateCustomerResponse result = customersApi.createCustomer(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CustomersApi.createCustomer");
    e.printStackTrace();
}

Now consider equivalent code using the new squareup.square library:

// Instantiate the client
SquareClient square = new SquareClient.Builder()
    .environment(Environment.SANDBOX)
    .accessToken("YOUR_SANDBOX_ACCESS_TOKEN")
    .build();

// Call the endpoint
square.getCustomersApi().createCustomerAsync(body).thenAccept(result -> {
    System.out.println("Successfully created customer with id:"+ result.getCustomer().getId());
}).exceptionally(e -> {
    System.err.println("Exception when calling CustomersApi.createCustomer");
    e.printStackTrace();
    return null;
});

That's it!

What was once a multi-object process can be handled asynchronously with a single client. Migrating to the com.squareup.square library reduces boilerplate and lets you focus on the parts of your code that really matter.




Ask the community

Please join us in our Square developer community if you have any questions!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].