Class: SquareConnect::TransactionsApi
- Inherits:
-
Object
- Object
- SquareConnect::TransactionsApi
- Defined in:
- lib/square_connect/api/transactions_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#capture_transaction(location_id, transaction_id, opts = {}) ⇒ CaptureTransactionResponse
CaptureTransaction Captures a transaction that was created with the [Charge](#endpoint-charge) endpoint with a ‘delay_capture` value of `true`.
-
#capture_transaction_with_http_info(location_id, transaction_id, opts = {}) ⇒ Array<(CaptureTransactionResponse, Fixnum, Hash)>
CaptureTransaction Captures a transaction that was created with the [Charge](#endpoint-charge) endpoint with a `delay_capture` value of `true`.
-
#charge(location_id, body, opts = {}) ⇒ ChargeResponse
Charge Charges a card represented by a card nonce or a customer’s card on file.
-
#charge_with_http_info(location_id, body, opts = {}) ⇒ Array<(ChargeResponse, Fixnum, Hash)>
Charge Charges a card represented by a card nonce or a customer's card on file.
-
#create_refund(location_id, transaction_id, body, opts = {}) ⇒ CreateRefundResponse
CreateRefund Initiates a refund for a previously charged tender.
-
#create_refund_with_http_info(location_id, transaction_id, body, opts = {}) ⇒ Array<(CreateRefundResponse, Fixnum, Hash)>
CreateRefund Initiates a refund for a previously charged tender.
-
#initialize(api_client = ApiClient.default) ⇒ TransactionsApi
constructor
A new instance of TransactionsApi.
-
#list_refunds(location_id, opts = {}) ⇒ ListRefundsResponse
ListRefunds Lists refunds for one of a business’s locations.
-
#list_refunds_with_http_info(location_id, opts = {}) ⇒ Array<(ListRefundsResponse, Fixnum, Hash)>
ListRefunds Lists refunds for one of a business's locations.
-
#list_transactions(location_id, opts = {}) ⇒ ListTransactionsResponse
ListTransactions Lists transactions for a particular location.
-
#list_transactions_with_http_info(location_id, opts = {}) ⇒ Array<(ListTransactionsResponse, Fixnum, Hash)>
ListTransactions Lists transactions for a particular location.
-
#retrieve_transaction(location_id, transaction_id, opts = {}) ⇒ RetrieveTransactionResponse
RetrieveTransaction Retrieves details for a single transaction.
-
#retrieve_transaction_with_http_info(location_id, transaction_id, opts = {}) ⇒ Array<(RetrieveTransactionResponse, Fixnum, Hash)>
RetrieveTransaction Retrieves details for a single transaction.
-
#void_transaction(location_id, transaction_id, opts = {}) ⇒ VoidTransactionResponse
VoidTransaction Cancels a transaction that was created with the [Charge](#endpoint-charge) endpoint with a ‘delay_capture` value of `true`.
-
#void_transaction_with_http_info(location_id, transaction_id, opts = {}) ⇒ Array<(VoidTransactionResponse, Fixnum, Hash)>
VoidTransaction Cancels a transaction that was created with the [Charge](#endpoint-charge) endpoint with a `delay_capture` value of `true`.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ TransactionsApi
Returns a new instance of TransactionsApi.
16 17 18 |
# File 'lib/square_connect/api/transactions_api.rb', line 16 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
14 15 16 |
# File 'lib/square_connect/api/transactions_api.rb', line 14 def api_client @api_client end |
Instance Method Details
#capture_transaction(location_id, transaction_id, opts = {}) ⇒ CaptureTransactionResponse
CaptureTransaction Captures a transaction that was created with the [Charge](#endpoint-charge) endpoint with a ‘delay_capture` value of `true`. See [Delayed capture transactions](/payments/transactions/overview#delayed-capture) for more information.
26 27 28 29 |
# File 'lib/square_connect/api/transactions_api.rb', line 26 def capture_transaction(location_id, transaction_id, opts = {}) data, _status_code, _headers = capture_transaction_with_http_info(location_id, transaction_id, opts) return data end |
#capture_transaction_with_http_info(location_id, transaction_id, opts = {}) ⇒ Array<(CaptureTransactionResponse, Fixnum, Hash)>
CaptureTransaction Captures a transaction that was created with the [Charge](#endpoint-charge) endpoint with a `delay_capture` value of `true`. See [Delayed capture transactions](/payments/transactions/overview#delayed-capture) for more information.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/square_connect/api/transactions_api.rb', line 37 def capture_transaction_with_http_info(location_id, transaction_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: TransactionsApi.capture_transaction ..." end # verify the required parameter 'location_id' is set fail ArgumentError, "Missing the required parameter 'location_id' when calling TransactionsApi.capture_transaction" if location_id.nil? # verify the required parameter 'transaction_id' is set fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.capture_transaction" if transaction_id.nil? # resource path local_var_path = "/v2/locations/{location_id}/transactions/{transaction_id}/capture".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s).sub('{' + 'transaction_id' + '}', transaction_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'CaptureTransactionResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#capture_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#charge(location_id, body, opts = {}) ⇒ ChargeResponse
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) In order for an eCommerce payment to potentially qualify for [Square chargeback protection](squareup.com/help/article/5394), you must provide values for the following parameters in your request: - ‘buyer_email_address` - At least one of `billing_address` or `shipping_address` 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](#endpoint-retrievetransaction). See the ‘processing_fee_money` field of each [Tender included](#type-tender) in the transaction.
85 86 87 88 |
# File 'lib/square_connect/api/transactions_api.rb', line 85 def charge(location_id, body, opts = {}) data, _status_code, _headers = charge_with_http_info(location_id, body, opts) return data end |
#charge_with_http_info(location_id, body, opts = {}) ⇒ Array<(ChargeResponse, Fixnum, Hash)>
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) In order for an eCommerce payment to potentially qualify for [Square chargeback protection](squareup.com/help/article/5394), you must provide values for the following parameters in your request: - `buyer_email_address` - At least one of `billing_address` or `shipping_address` 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](#endpoint-retrievetransaction). See the `processing_fee_money` field of each [Tender included](#type-tender) in the transaction.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/square_connect/api/transactions_api.rb', line 96 def charge_with_http_info(location_id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: TransactionsApi.charge ..." end # verify the required parameter 'location_id' is set fail ArgumentError, "Missing the required parameter 'location_id' when calling TransactionsApi.charge" if location_id.nil? # verify the required parameter 'body' is set fail ArgumentError, "Missing the required parameter 'body' when calling TransactionsApi.charge" if body.nil? # resource path local_var_path = "/v2/locations/{location_id}/transactions".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ChargeResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#charge\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#create_refund(location_id, transaction_id, body, opts = {}) ⇒ CreateRefundResponse
CreateRefund Initiates a refund for a previously charged tender. You must issue a refund within 120 days of the associated payment. See [this article](squareup.com/help/us/en/article/5060) 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).
145 146 147 148 |
# File 'lib/square_connect/api/transactions_api.rb', line 145 def create_refund(location_id, transaction_id, body, opts = {}) data, _status_code, _headers = create_refund_with_http_info(location_id, transaction_id, body, opts) return data end |
#create_refund_with_http_info(location_id, transaction_id, body, opts = {}) ⇒ Array<(CreateRefundResponse, Fixnum, Hash)>
CreateRefund Initiates a refund for a previously charged tender. You must issue a refund within 120 days of the associated payment. See [this article](squareup.com/help/us/en/article/5060) 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).
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/square_connect/api/transactions_api.rb', line 157 def create_refund_with_http_info(location_id, transaction_id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: TransactionsApi.create_refund ..." end # verify the required parameter 'location_id' is set fail ArgumentError, "Missing the required parameter 'location_id' when calling TransactionsApi.create_refund" if location_id.nil? # verify the required parameter 'transaction_id' is set fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.create_refund" if transaction_id.nil? # verify the required parameter 'body' is set fail ArgumentError, "Missing the required parameter 'body' when calling TransactionsApi.create_refund" if body.nil? # resource path local_var_path = "/v2/locations/{location_id}/transactions/{transaction_id}/refund".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s).sub('{' + 'transaction_id' + '}', transaction_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'CreateRefundResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#create_refund\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#list_refunds(location_id, opts = {}) ⇒ ListRefundsResponse
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](#paginatingresults): 50
210 211 212 213 |
# File 'lib/square_connect/api/transactions_api.rb', line 210 def list_refunds(location_id, opts = {}) data, _status_code, _headers = list_refunds_with_http_info(location_id, opts) return data end |
#list_refunds_with_http_info(location_id, opts = {}) ⇒ Array<(ListRefundsResponse, Fixnum, Hash)>
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](#paginatingresults): 50
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/square_connect/api/transactions_api.rb', line 224 def list_refunds_with_http_info(location_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: TransactionsApi.list_refunds ..." end # verify the required parameter 'location_id' is set fail ArgumentError, "Missing the required parameter 'location_id' when calling TransactionsApi.list_refunds" if location_id.nil? if opts[:'sort_order'] && !['DESC', 'ASC'].include?(opts[:'sort_order']) fail ArgumentError, 'invalid value for "sort_order", must be one of DESC, ASC' end # resource path local_var_path = "/v2/locations/{location_id}/refunds".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s) # query parameters query_params = {} query_params[:'begin_time'] = opts[:'begin_time'] if !opts[:'begin_time'].nil? query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil? query_params[:'sort_order'] = opts[:'sort_order'] if !opts[:'sort_order'].nil? query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ListRefundsResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#list_refunds\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#list_transactions(location_id, opts = {}) ⇒ ListTransactionsResponse
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](#paginatingresults): 50
280 281 282 283 |
# File 'lib/square_connect/api/transactions_api.rb', line 280 def list_transactions(location_id, opts = {}) data, _status_code, _headers = list_transactions_with_http_info(location_id, opts) return data end |
#list_transactions_with_http_info(location_id, opts = {}) ⇒ Array<(ListTransactionsResponse, Fixnum, Hash)>
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](#paginatingresults): 50
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/square_connect/api/transactions_api.rb', line 294 def list_transactions_with_http_info(location_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: TransactionsApi.list_transactions ..." end # verify the required parameter 'location_id' is set fail ArgumentError, "Missing the required parameter 'location_id' when calling TransactionsApi.list_transactions" if location_id.nil? if opts[:'sort_order'] && !['DESC', 'ASC'].include?(opts[:'sort_order']) fail ArgumentError, 'invalid value for "sort_order", must be one of DESC, ASC' end # resource path local_var_path = "/v2/locations/{location_id}/transactions".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s) # query parameters query_params = {} query_params[:'begin_time'] = opts[:'begin_time'] if !opts[:'begin_time'].nil? query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil? query_params[:'sort_order'] = opts[:'sort_order'] if !opts[:'sort_order'].nil? query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ListTransactionsResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#list_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#retrieve_transaction(location_id, transaction_id, opts = {}) ⇒ RetrieveTransactionResponse
RetrieveTransaction Retrieves details for a single transaction.
347 348 349 350 |
# File 'lib/square_connect/api/transactions_api.rb', line 347 def retrieve_transaction(location_id, transaction_id, opts = {}) data, _status_code, _headers = retrieve_transaction_with_http_info(location_id, transaction_id, opts) return data end |
#retrieve_transaction_with_http_info(location_id, transaction_id, opts = {}) ⇒ Array<(RetrieveTransactionResponse, Fixnum, Hash)>
RetrieveTransaction Retrieves details for a single transaction.
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/square_connect/api/transactions_api.rb', line 358 def retrieve_transaction_with_http_info(location_id, transaction_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: TransactionsApi.retrieve_transaction ..." end # verify the required parameter 'location_id' is set fail ArgumentError, "Missing the required parameter 'location_id' when calling TransactionsApi.retrieve_transaction" if location_id.nil? # verify the required parameter 'transaction_id' is set fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.retrieve_transaction" if transaction_id.nil? # resource path local_var_path = "/v2/locations/{location_id}/transactions/{transaction_id}".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s).sub('{' + 'transaction_id' + '}', transaction_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'RetrieveTransactionResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#retrieve_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#void_transaction(location_id, transaction_id, opts = {}) ⇒ VoidTransactionResponse
VoidTransaction Cancels a transaction that was created with the [Charge](#endpoint-charge) endpoint with a ‘delay_capture` value of `true`. See [Delayed capture transactions](/payments/transactions/overview#delayed-capture) for more information.
406 407 408 409 |
# File 'lib/square_connect/api/transactions_api.rb', line 406 def void_transaction(location_id, transaction_id, opts = {}) data, _status_code, _headers = void_transaction_with_http_info(location_id, transaction_id, opts) return data end |
#void_transaction_with_http_info(location_id, transaction_id, opts = {}) ⇒ Array<(VoidTransactionResponse, Fixnum, Hash)>
VoidTransaction Cancels a transaction that was created with the [Charge](#endpoint-charge) endpoint with a `delay_capture` value of `true`. See [Delayed capture transactions](/payments/transactions/overview#delayed-capture) for more information.
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
# File 'lib/square_connect/api/transactions_api.rb', line 417 def void_transaction_with_http_info(location_id, transaction_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: TransactionsApi.void_transaction ..." end # verify the required parameter 'location_id' is set fail ArgumentError, "Missing the required parameter 'location_id' when calling TransactionsApi.void_transaction" if location_id.nil? # verify the required parameter 'transaction_id' is set fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.void_transaction" if transaction_id.nil? # resource path local_var_path = "/v2/locations/{location_id}/transactions/{transaction_id}/void".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s).sub('{' + 'transaction_id' + '}', transaction_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'VoidTransactionResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#void_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |