SquareConnect::TransactionsApi

July 10, 2019 ยท View on GitHub

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

MethodHTTP requestDescription
capture_transactionPOST /v2/locations/{location_id}/transactions/{transaction_id}/captureCaptureTransaction
chargePOST /v2/locations/{location_id}/transactionsCharge
create_refundPOST /v2/locations/{location_id}/transactions/{transaction_id}/refundCreateRefund
list_refundsGET /v2/locations/{location_id}/refundsListRefunds
list_transactionsGET /v2/locations/{location_id}/transactionsListTransactions
retrieve_transactionGET /v2/locations/{location_id}/transactions/{transaction_id}RetrieveTransaction
void_transactionPOST /v2/locations/{location_id}/transactions/{transaction_id}/voidVoidTransaction

capture_transaction

CaptureTransactionResponse capture_transaction(location_id, transaction_id)

CaptureTransaction

Captures a transaction that was created with the Charge endpoint with a delay_capture value of true. See the Delay Capture of Funds recipe for more information.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::TransactionsApi.new

location_id = "location_id_example" # String | 

transaction_id = "transaction_id_example" # String | 


begin
  #CaptureTransaction
  result = api_instance.capture_transaction(location_id, transaction_id)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling TransactionsApi->capture_transaction: #{e}"
end

Parameters

NameTypeDescriptionNotes
location_idString
transaction_idString

Return type

CaptureTransactionResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

charge

ChargeResponse charge(location_id, body)

Charge

Charges a card represented by a card nonce or a customer's card on file. Your request to this endpoint must include either: - A value for the card_nonce parameter (to charge a card nonce generated with the SqPaymentForm) - Values for the customer_card_id and customer_id parameters (to charge a customer's card on file) When this response is returned, the amount of Square's processing fee might not yet be calculated. To obtain the processing fee, wait about ten seconds and call RetrieveTransaction. See the processing_fee_money field of each Tender included in the transaction.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::TransactionsApi.new

location_id = "location_id_example" # String | The ID of the location to associate the created transaction with.

body = SquareConnect::ChargeRequest.new # ChargeRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.


begin
  #Charge
  result = api_instance.charge(location_id, body)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling TransactionsApi->charge: #{e}"
end

Parameters

NameTypeDescriptionNotes
location_idStringThe ID of the location to associate the created transaction with.
bodyChargeRequestAn object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

ChargeResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

create_refund

CreateRefundResponse create_refund(location_id, transaction_id, body)

CreateRefund

Initiates a refund for a previously charged tender. You must issue a refund within 120 days of the associated payment. See this article for more information on refund behavior. NOTE: Card-present transactions with Interac credit cards cannot be refunded using the Connect API. Interac transactions must refunded in-person (e.g., dipping the card using POS app).

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::TransactionsApi.new

location_id = "location_id_example" # String | The ID of the original transaction's associated location.

transaction_id = "transaction_id_example" # String | The ID of the original transaction that includes the tender to refund.

body = SquareConnect::CreateRefundRequest.new # CreateRefundRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.


begin
  #CreateRefund
  result = api_instance.create_refund(location_id, transaction_id, body)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling TransactionsApi->create_refund: #{e}"
end

Parameters

NameTypeDescriptionNotes
location_idStringThe ID of the original transaction's associated location.
transaction_idStringThe ID of the original transaction that includes the tender to refund.
bodyCreateRefundRequestAn object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

CreateRefundResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

list_refunds

ListRefundsResponse list_refunds(location_id, opts)

ListRefunds

Lists refunds for one of a business's locations. In addition to full or partial tender refunds processed through Square APIs, refunds may result from itemized returns or exchanges through Square's Point of Sale applications. Refunds with a status of PENDING are not currently included in this endpoint's response. Max results per page: 50

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::TransactionsApi.new

location_id = "location_id_example" # String | The ID of the location to list refunds for.

opts = { 
  begin_time: "begin_time_example", # String | The beginning of the requested reporting period, in RFC 3339 format.  See [Date ranges](#dateranges) for details on date inclusivity/exclusivity.  Default value: The current time minus one year.
  end_time: "end_time_example", # String | The end of the requested reporting period, in RFC 3339 format.  See [Date ranges](#dateranges) for details on date inclusivity/exclusivity.  Default value: The current time.
  sort_order: "sort_order_example", # String | The order in which results are listed in the response (`ASC` for oldest first, `DESC` for newest first).  Default value: `DESC`
  cursor: "cursor_example" # String | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query.  See [Pagination](/basics/api101/pagination) for more information.
}

begin
  #ListRefunds
  result = api_instance.list_refunds(location_id, opts)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling TransactionsApi->list_refunds: #{e}"
end

Parameters

NameTypeDescriptionNotes
location_idStringThe ID of the location to list refunds for.
begin_timeStringThe beginning of the requested reporting period, in RFC 3339 format. See Date ranges for details on date inclusivity/exclusivity. Default value: The current time minus one year.[optional]
end_timeStringThe end of the requested reporting period, in RFC 3339 format. See Date ranges for details on date inclusivity/exclusivity. Default value: The current time.[optional]
sort_orderStringThe order in which results are listed in the response (`ASC` for oldest first, `DESC` for newest first). Default value: `DESC`[optional]
cursorStringA pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See Pagination for more information.[optional]

Return type

ListRefundsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

list_transactions

ListTransactionsResponse list_transactions(location_id, opts)

ListTransactions

Lists transactions for a particular location. Transactions include payment information from sales and exchanges and refund information from returns and exchanges. Max results per page: 50

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::TransactionsApi.new

location_id = "location_id_example" # String | The ID of the location to list transactions for.

opts = { 
  begin_time: "begin_time_example", # String | The beginning of the requested reporting period, in RFC 3339 format.  See [Date ranges](#dateranges) for details on date inclusivity/exclusivity.  Default value: The current time minus one year.
  end_time: "end_time_example", # String | The end of the requested reporting period, in RFC 3339 format.  See [Date ranges](#dateranges) for details on date inclusivity/exclusivity.  Default value: The current time.
  sort_order: "sort_order_example", # String | The order in which results are listed in the response (`ASC` for oldest first, `DESC` for newest first).  Default value: `DESC`
  cursor: "cursor_example" # String | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query.  See [Pagination](/basics/api101/pagination) for more information.
}

begin
  #ListTransactions
  result = api_instance.list_transactions(location_id, opts)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling TransactionsApi->list_transactions: #{e}"
end

Parameters

NameTypeDescriptionNotes
location_idStringThe ID of the location to list transactions for.
begin_timeStringThe beginning of the requested reporting period, in RFC 3339 format. See Date ranges for details on date inclusivity/exclusivity. Default value: The current time minus one year.[optional]
end_timeStringThe end of the requested reporting period, in RFC 3339 format. See Date ranges for details on date inclusivity/exclusivity. Default value: The current time.[optional]
sort_orderStringThe order in which results are listed in the response (`ASC` for oldest first, `DESC` for newest first). Default value: `DESC`[optional]
cursorStringA pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See Pagination for more information.[optional]

Return type

ListTransactionsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

retrieve_transaction

RetrieveTransactionResponse retrieve_transaction(location_id, transaction_id)

RetrieveTransaction

Retrieves details for a single transaction.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::TransactionsApi.new

location_id = "location_id_example" # String | The ID of the transaction's associated location.

transaction_id = "transaction_id_example" # String | The ID of the transaction to retrieve.


begin
  #RetrieveTransaction
  result = api_instance.retrieve_transaction(location_id, transaction_id)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling TransactionsApi->retrieve_transaction: #{e}"
end

Parameters

NameTypeDescriptionNotes
location_idStringThe ID of the transaction's associated location.
transaction_idStringThe ID of the transaction to retrieve.

Return type

RetrieveTransactionResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

void_transaction

VoidTransactionResponse void_transaction(location_id, transaction_id)

VoidTransaction

Cancels a transaction that was created with the Charge endpoint with a delay_capture value of true. See the Delay Capture of Funds recipe for more information.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::TransactionsApi.new

location_id = "location_id_example" # String | 

transaction_id = "transaction_id_example" # String | 


begin
  #VoidTransaction
  result = api_instance.void_transaction(location_id, transaction_id)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling TransactionsApi->void_transaction: #{e}"
end

Parameters

NameTypeDescriptionNotes
location_idString
transaction_idString

Return type

VoidTransactionResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json