Skip to content

danrice67/connect-java-sdk

 
 

Repository files navigation

Square Connect V2 Java SDK Maven Central

Requirements

Java 8

Building the API client library requires Maven to be installed.

Installation

Maven users

Add this dependency to your project's POM:

<dependency>
    <groupId>com.squareup</groupId>
    <artifactId>connect</artifactId>
    <version>2.0.2</version>
    <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "com.squareup:connect:2.0.2"

Build and Install locally

To install the API client library to your local Maven repository, simply execute:

mvn install

Others

At first generate the JAR by executing:

mvn package

Then manually install the following JARs:

  • target/connect-2.0.2.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

import com.squareup.connect.*;
import com.squareup.connect.auth.*;
import com.squareup.connect.models.*;
import com.squareup.connect.api.CheckoutApi;

import java.io.File;
import java.util.*;

public class CheckoutApiExample {

    public static void main(String[] args) {
        
        CheckoutApi apiInstance = new CheckoutApi();
        String authorization = "authorization_example"; // String | The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
        String locationId = "locationId_example"; // String | The ID of the business location to associate the checkout with.
        CreateCheckoutRequest body = new CreateCheckoutRequest(); // CreateCheckoutRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
        try {
            CreateCheckoutResponse result = apiInstance.createCheckout(authorization, locationId, body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling CheckoutApi#createCheckout");
            e.printStackTrace();
        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://connect.squareup.com

Class Method HTTP request Description
CheckoutApi createCheckout POST /v2/locations/{location_id}/checkouts CreateCheckout
CustomerApi createCustomer POST /v2/customers CreateCustomer
CustomerApi deleteCustomer DELETE /v2/customers/{customer_id} DeleteCustomer
CustomerApi listCustomers GET /v2/customers ListCustomers
CustomerApi retrieveCustomer GET /v2/customers/{customer_id} RetrieveCustomer
CustomerApi updateCustomer PUT /v2/customers/{customer_id} UpdateCustomer
CustomerCardApi createCustomerCard POST /v2/customers/{customer_id}/cards CreateCustomerCard
CustomerCardApi deleteCustomerCard DELETE /v2/customers/{customer_id}/cards/{card_id} DeleteCustomerCard
LocationApi listLocations GET /v2/locations ListLocations
RefundApi createRefund POST /v2/locations/{location_id}/transactions/{transaction_id}/refund CreateRefund
RefundApi listRefunds GET /v2/locations/{location_id}/refunds ListRefunds
TransactionApi captureTransaction POST /v2/locations/{location_id}/transactions/{transaction_id}/capture CaptureTransaction
TransactionApi charge POST /v2/locations/{location_id}/transactions Charge
TransactionApi listTransactions GET /v2/locations/{location_id}/transactions ListTransactions
TransactionApi retrieveTransaction GET /v2/locations/{location_id}/transactions/{transaction_id} RetrieveTransaction
TransactionApi voidTransaction POST /v2/locations/{location_id}/transactions/{transaction_id}/void VoidTransaction

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

oauth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://connect.squareup.com/oauth2/authorize?&lt;PARAMETERS>
  • Scopes:
    • MERCHANT_PROFILE_READ: GET endpoints related to a merchant's business and location entities. Almost all Connect API applications need this permission in order to obtain a merchant's location IDs
    • PAYMENTS_READ: GET endpoints related to transactions and refunds
    • PAYMENTS_WRITE: POST, PUT, and DELETE endpoints related to transactions and refunds. E-commerce applications must request this permission
    • CUSTOMERS_READ: GET endpoints related to customer management
    • CUSTOMERS_WRITE: POST, PUT, and DELETE endpoints related to customer management
    • SETTLEMENTS_READ: GET endpoints related to settlements (deposits)
    • BANK_ACCOUNTS_READ: GET endpoints related to a merchant's bank accounts
    • ITEMS_READ: GET endpoints related to a merchant's item library
    • ITEMS_WRITE: POST, PUT, and DELETE endpoints related to a merchant's item library
    • ORDERS_READ: GET endpoints related to a merchant's Square online store.
    • ORDERS_WRITE: POST, PUT, and DELETE endpoints related to a merchant's Square online store
    • EMPLOYEES_READ: GET endpoints related to employee management
    • EMPLOYEES_WRITE: POST, PUT, and DELETE endpoints related to employee management
    • TIMECARDS_READ: GET endpoints related to employee timecards
    • TIMECARDS_WRITE: POST, PUT, and DELETE endpoints related to employee timecards

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Author

developers@squareup.com

About

Java client library for the Square Connect v2 API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%