Class: Square::Locations::Transactions::Client
- Inherits:
-
Object
- Object
- Square::Locations::Transactions::Client
- Defined in:
- lib/square/locations/transactions/client.rb
Instance Method Summary collapse
-
#capture(request_options: {}, **params) ⇒ Square::Types::CaptureTransactionResponse
Captures a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) endpoint with a ‘delay_capture` value of `true`.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetTransactionResponse
Retrieves details for a single transaction.
- #initialize(client:) ⇒ Square::Locations::Transactions::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListTransactionsResponse
Lists transactions for a particular location.
-
#void(request_options: {}, **params) ⇒ Square::Types::VoidTransactionResponse
Cancels a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) endpoint with a ‘delay_capture` value of `true`.
Constructor Details
#initialize(client:) ⇒ Square::Locations::Transactions::Client
8 9 10 |
# File 'lib/square/locations/transactions/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#capture(request_options: {}, **params) ⇒ Square::Types::CaptureTransactionResponse
Captures a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) endpoint with a ‘delay_capture` value of `true`.
See [Delayed capture transactions](developer.squareup.com/docs/payments/transactions/overview#delayed-capture) for more information.
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/square/locations/transactions/client.rb', line 64 def capture(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/locations/#{params[:location_id]}/transactions/#{params[:transaction_id]}/capture" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::CaptureTransactionResponse.load(_response.body) end raise _response.body end |
#get(request_options: {}, **params) ⇒ Square::Types::GetTransactionResponse
Retrieves details for a single transaction.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/square/locations/transactions/client.rb', line 42 def get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/locations/#{params[:location_id]}/transactions/#{params[:transaction_id]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::GetTransactionResponse.load(_response.body) end raise _response.body end |
#list(request_options: {}, **params) ⇒ Square::Types::ListTransactionsResponse
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](developer.squareup.com/docs/working-with-apis/pagination): 50
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/square/locations/transactions/client.rb', line 20 def list(request_options: {}, **params) _query_param_names = %w[begin_time end_time sort_order cursor] _query = params.slice(*_query_param_names) params = params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/locations/#{params[:location_id]}/transactions", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::ListTransactionsResponse.load(_response.body) end raise _response.body end |
#void(request_options: {}, **params) ⇒ Square::Types::VoidTransactionResponse
Cancels a transaction that was created with the [Charge](api-endpoint:Transactions-Charge) endpoint with a ‘delay_capture` value of `true`.
See [Delayed capture transactions](developer.squareup.com/docs/payments/transactions/overview#delayed-capture) for more information.
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/square/locations/transactions/client.rb', line 86 def void(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/locations/#{params[:location_id]}/transactions/#{params[:transaction_id]}/void" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::VoidTransactionResponse.load(_response.body) end raise _response.body end |