Class: Komoju::PaymentsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/komoju-sdk/api/payments_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ PaymentsApi

Returns a new instance of PaymentsApi.



19
20
21
# File 'lib/komoju-sdk/api/payments_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/komoju-sdk/api/payments_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#cancel_payment(id, opts = {}) ⇒ Payment

Payment: Cancel Cancels a payment. The given payment must have a state of ‘pending` or `authorized` in order to be canceled.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



27
28
29
30
# File 'lib/komoju-sdk/api/payments_api.rb', line 27

def cancel_payment(id, opts = {})
  data, _status_code, _headers = cancel_payment_with_http_info(id, opts)
  data
end

#cancel_payment_with_http_info(id, opts = {}) ⇒ Array<(Payment, Integer, Hash)>

Payment: Cancel Cancels a payment. The given payment must have a state of &#x60;pending&#x60; or &#x60;authorized&#x60; in order to be canceled.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Payment, Integer, Hash)>)

    Payment data, response status code and response headers



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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/komoju-sdk/api/payments_api.rb', line 37

def cancel_payment_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.cancel_payment ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.cancel_payment"
  end
  if @api_client.config.client_side_validation && id.to_s.length > 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.cancel_payment, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && id.to_s.length < 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.cancel_payment, the character length must be great than or equal to 25.'
  end

  # resource path
  local_var_path = '/payments/{id}/cancel'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Payment'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key']

  new_options = opts.merge(
    :operation => :"PaymentsApi.cancel_payment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#cancel_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#capture_payment(id, capture_payment_request, opts = {}) ⇒ Payment

Payment: Capture Captures a payment. Only works when the payment was created with ‘capture` set to false, or via a session with `capture` set to `"manual"`.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • capture_payment_request (CapturePaymentRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



99
100
101
102
# File 'lib/komoju-sdk/api/payments_api.rb', line 99

def capture_payment(id, capture_payment_request, opts = {})
  data, _status_code, _headers = capture_payment_with_http_info(id, capture_payment_request, opts)
  data
end

#capture_payment_with_http_info(id, capture_payment_request, opts = {}) ⇒ Array<(Payment, Integer, Hash)>

Payment: Capture Captures a payment. Only works when the payment was created with &#x60;capture&#x60; set to false, or via a session with &#x60;capture&#x60; set to &#x60;&quot;manual&quot;&#x60;.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • capture_payment_request (CapturePaymentRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Payment, Integer, Hash)>)

    Payment data, response status code and response headers



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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/komoju-sdk/api/payments_api.rb', line 110

def capture_payment_with_http_info(id, capture_payment_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.capture_payment ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.capture_payment"
  end
  if @api_client.config.client_side_validation && id.to_s.length > 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.capture_payment, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && id.to_s.length < 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.capture_payment, the character length must be great than or equal to 25.'
  end

  # verify the required parameter 'capture_payment_request' is set
  if @api_client.config.client_side_validation && capture_payment_request.nil?
    fail ArgumentError, "Missing the required parameter 'capture_payment_request' when calling PaymentsApi.capture_payment"
  end
  # resource path
  local_var_path = '/payments/{id}/capture'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(capture_payment_request)

  # return_type
  return_type = opts[:debug_return_type] || 'Payment'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key']

  new_options = opts.merge(
    :operation => :"PaymentsApi.capture_payment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#capture_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_payment(create_payment_request, opts = {}) ⇒ Payment

Payment: Create Creates a payment for a given ‘amount` and `currency`. There are two ways to create payment: - For one-time payment, you can pass `payment_details` with payment method type and additional attributes. - For recurring payment, you can pass customer’s ID via ‘customer` attribute. Customer’s saved payment method will be used for the payment. Note that either ‘payment_details` or `customer` is required for the payment. However, both of them should not be given at the same time.

Parameters:

  • create_payment_request (CreatePaymentRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



180
181
182
183
# File 'lib/komoju-sdk/api/payments_api.rb', line 180

def create_payment(create_payment_request, opts = {})
  data, _status_code, _headers = create_payment_with_http_info(create_payment_request, opts)
  data
end

#create_payment_with_http_info(create_payment_request, opts = {}) ⇒ Array<(Payment, Integer, Hash)>

Payment: Create Creates a payment for a given &#x60;amount&#x60; and &#x60;currency&#x60;. There are two ways to create payment: - For one-time payment, you can pass &#x60;payment_details&#x60; with payment method type and additional attributes. - For recurring payment, you can pass customer&#39;s ID via &#x60;customer&#x60; attribute. Customer&#39;s saved payment method will be used for the payment. Note that either &#x60;payment_details&#x60; or &#x60;customer&#x60; is required for the payment. However, both of them should not be given at the same time.

Parameters:

  • create_payment_request (CreatePaymentRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Payment, Integer, Hash)>)

    Payment data, response status code and response headers



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/komoju-sdk/api/payments_api.rb', line 190

def create_payment_with_http_info(create_payment_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.create_payment ...'
  end
  # verify the required parameter 'create_payment_request' is set
  if @api_client.config.client_side_validation && create_payment_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_payment_request' when calling PaymentsApi.create_payment"
  end
  # resource path
  local_var_path = '/payments'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_payment_request)

  # return_type
  return_type = opts[:debug_return_type] || 'Payment'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key']

  new_options = opts.merge(
    :operation => :"PaymentsApi.create_payment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#create_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_refund_request(id, create_refund_request_request, opts = {}) ⇒ nil

Payment: Refund Request A "Refund Request" requests that a payment be refunded manually. This can be used for payment methods that do not support refunds, such as konbini. To support non-refundable payment methods, a bank account must be specified so that we know where to send the funds. Since it is a manual process, the refund will be carried out at a later date, and there’s a possibility of it being rejected.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • create_refund_request_request (CreateRefundRequestRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


249
250
251
252
# File 'lib/komoju-sdk/api/payments_api.rb', line 249

def create_refund_request(id, create_refund_request_request, opts = {})
  create_refund_request_with_http_info(id, create_refund_request_request, opts)
  nil
end

#create_refund_request_with_http_info(id, create_refund_request_request, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Payment: Refund Request A &quot;Refund Request&quot; requests that a payment be refunded manually. This can be used for payment methods that do not support refunds, such as konbini. To support non-refundable payment methods, a bank account must be specified so that we know where to send the funds. Since it is a manual process, the refund will be carried out at a later date, and there&#39;s a possibility of it being rejected.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • create_refund_request_request (CreateRefundRequestRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
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
# File 'lib/komoju-sdk/api/payments_api.rb', line 260

def create_refund_request_with_http_info(id, create_refund_request_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.create_refund_request ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.create_refund_request"
  end
  if @api_client.config.client_side_validation && id.to_s.length > 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.create_refund_request, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && id.to_s.length < 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.create_refund_request, the character length must be great than or equal to 25.'
  end

  # verify the required parameter 'create_refund_request_request' is set
  if @api_client.config.client_side_validation && create_refund_request_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_refund_request_request' when calling PaymentsApi.create_refund_request"
  end
  # resource path
  local_var_path = '/payments/{id}/refund_request'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_refund_request_request)

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key']

  new_options = opts.merge(
    :operation => :"PaymentsApi.create_refund_request",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#create_refund_request\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#finalize_payment(id, finalize_payment_request, opts = {}) ⇒ Payment

Payment: Finalize Finalizes a payment. Finalizes an EMV contact transaction by confirming the chip card’s final decision (TC for approved, AAC for declined). Use this after authorization to submit the terminal’s transaction outcome and determine whether the payment is captured or cancelled.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • finalize_payment_request (FinalizePaymentRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



331
332
333
334
# File 'lib/komoju-sdk/api/payments_api.rb', line 331

def finalize_payment(id, finalize_payment_request, opts = {})
  data, _status_code, _headers = finalize_payment_with_http_info(id, finalize_payment_request, opts)
  data
end

#finalize_payment_with_http_info(id, finalize_payment_request, opts = {}) ⇒ Array<(Payment, Integer, Hash)>

Payment: Finalize Finalizes a payment. Finalizes an EMV contact transaction by confirming the chip card&#39;s final decision (TC for approved, AAC for declined). Use this after authorization to submit the terminal&#39;s transaction outcome and determine whether the payment is captured or cancelled.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • finalize_payment_request (FinalizePaymentRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Payment, Integer, Hash)>)

    Payment data, response status code and response headers



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
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
399
400
401
402
403
404
405
# File 'lib/komoju-sdk/api/payments_api.rb', line 342

def finalize_payment_with_http_info(id, finalize_payment_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.finalize_payment ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.finalize_payment"
  end
  if @api_client.config.client_side_validation && id.to_s.length > 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.finalize_payment, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && id.to_s.length < 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.finalize_payment, the character length must be great than or equal to 25.'
  end

  # verify the required parameter 'finalize_payment_request' is set
  if @api_client.config.client_side_validation && finalize_payment_request.nil?
    fail ArgumentError, "Missing the required parameter 'finalize_payment_request' when calling PaymentsApi.finalize_payment"
  end
  # resource path
  local_var_path = '/payments/{id}/finalize'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(finalize_payment_request)

  # return_type
  return_type = opts[:debug_return_type] || 'Payment'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key']

  new_options = opts.merge(
    :operation => :"PaymentsApi.finalize_payment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#finalize_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_payment_methods(opts = {}) ⇒ Array<AvailablePaymentMethod>

Payment Method: List Lists available payment methods.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



411
412
413
414
# File 'lib/komoju-sdk/api/payments_api.rb', line 411

def list_payment_methods(opts = {})
  data, _status_code, _headers = list_payment_methods_with_http_info(opts)
  data
end

#list_payment_methods_with_http_info(opts = {}) ⇒ Array<(Array<AvailablePaymentMethod>, Integer, Hash)>

Payment Method: List Lists available payment methods.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Array<AvailablePaymentMethod>, Integer, Hash)>)

    Array<AvailablePaymentMethod> data, response status code and response headers



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
458
459
460
461
462
# File 'lib/komoju-sdk/api/payments_api.rb', line 420

def list_payment_methods_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.list_payment_methods ...'
  end
  # resource path
  local_var_path = '/payment_methods'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Array<AvailablePaymentMethod>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key']

  new_options = opts.merge(
    :operation => :"PaymentsApi.list_payment_methods",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#list_payment_methods\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_payments(opts = {}) ⇒ PaymentList

Payment: List Retrieves a paginated list of payments. Pagination can be configured with ‘page` and `per_page` parameters. Payments can be filtered by `currency`, `external_order_num`, and `status`. A time range can be specified with `start_time`, and `end_time`.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :start_time (Time)

    Query for records created after this time.

  • :end_time (Time)

    Query for records created before this time.

  • :per_page (Integer)

    How many objects per page.

  • :page (Integer)

    Page number to query for.

  • :merchant_id (String)
  • :currency (Currency)
  • :external_order_num (String)

    A unique ID from your application used to track this payment.

  • :status (String)

    The status of the payment. Can be a single status or comma-separated values.

Returns:



476
477
478
479
# File 'lib/komoju-sdk/api/payments_api.rb', line 476

def list_payments(opts = {})
  data, _status_code, _headers = list_payments_with_http_info(opts)
  data
end

#list_payments_with_http_info(opts = {}) ⇒ Array<(PaymentList, Integer, Hash)>

Payment: List Retrieves a paginated list of payments. Pagination can be configured with &#x60;page&#x60; and &#x60;per_page&#x60; parameters. Payments can be filtered by &#x60;currency&#x60;, &#x60;external_order_num&#x60;, and &#x60;status&#x60;. A time range can be specified with &#x60;start_time&#x60;, and &#x60;end_time&#x60;.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :start_time (Time)

    Query for records created after this time.

  • :end_time (Time)

    Query for records created before this time.

  • :per_page (Integer)

    How many objects per page.

  • :page (Integer)

    Page number to query for.

  • :merchant_id (String)
  • :currency (Currency)
  • :external_order_num (String)

    A unique ID from your application used to track this payment.

  • :status (String)

    The status of the payment. Can be a single status or comma-separated values.

Returns:

  • (Array<(PaymentList, Integer, Hash)>)

    PaymentList data, response status code and response headers



493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'lib/komoju-sdk/api/payments_api.rb', line 493

def list_payments_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.list_payments ...'
  end
  if @api_client.config.client_side_validation && !opts[:'merchant_id'].nil? && opts[:'merchant_id'].to_s.length > 25
    fail ArgumentError, 'invalid value for "opts[:"merchant_id"]" when calling PaymentsApi.list_payments, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && !opts[:'merchant_id'].nil? && opts[:'merchant_id'].to_s.length < 25
    fail ArgumentError, 'invalid value for "opts[:"merchant_id"]" when calling PaymentsApi.list_payments, the character length must be great than or equal to 25.'
  end

  pattern = Regexp.new(/^(pending|authorized|captured|expired|cancelled|refunded)(,(pending|authorized|captured|expired|cancelled|refunded))*$/)
  if @api_client.config.client_side_validation && !opts[:'status'].nil? && opts[:'status'] !~ pattern
    fail ArgumentError, "invalid value for 'opts[:\"status\"]' when calling PaymentsApi.list_payments, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/payments'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = opts[:'start_time'] if !opts[:'start_time'].nil?
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'merchant_id'] = opts[:'merchant_id'] if !opts[:'merchant_id'].nil?
  query_params[:'currency'] = opts[:'currency'] if !opts[:'currency'].nil?
  query_params[:'external_order_num'] = opts[:'external_order_num'] if !opts[:'external_order_num'].nil?
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'PaymentList'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key']

  new_options = opts.merge(
    :operation => :"PaymentsApi.list_payments",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#list_payments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#refund_payment(id, refund_payment_request, opts = {}) ⇒ Payment

Payment: Refund Refunds an arbitrary amount of money from an existing payment. If no amount is specified, the whole payment is refunded.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • refund_payment_request (RefundPaymentRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



564
565
566
567
# File 'lib/komoju-sdk/api/payments_api.rb', line 564

def refund_payment(id, refund_payment_request, opts = {})
  data, _status_code, _headers = refund_payment_with_http_info(id, refund_payment_request, opts)
  data
end

#refund_payment_with_http_info(id, refund_payment_request, opts = {}) ⇒ Array<(Payment, Integer, Hash)>

Payment: Refund Refunds an arbitrary amount of money from an existing payment. If no amount is specified, the whole payment is refunded.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • refund_payment_request (RefundPaymentRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Payment, Integer, Hash)>)

    Payment data, response status code and response headers



575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/komoju-sdk/api/payments_api.rb', line 575

def refund_payment_with_http_info(id, refund_payment_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.refund_payment ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.refund_payment"
  end
  if @api_client.config.client_side_validation && id.to_s.length > 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.refund_payment, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && id.to_s.length < 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.refund_payment, the character length must be great than or equal to 25.'
  end

  # verify the required parameter 'refund_payment_request' is set
  if @api_client.config.client_side_validation && refund_payment_request.nil?
    fail ArgumentError, "Missing the required parameter 'refund_payment_request' when calling PaymentsApi.refund_payment"
  end
  # resource path
  local_var_path = '/payments/{id}/refund'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(refund_payment_request)

  # return_type
  return_type = opts[:debug_return_type] || 'Payment'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key']

  new_options = opts.merge(
    :operation => :"PaymentsApi.refund_payment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#refund_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#show_payment(id, opts = {}) ⇒ Payment

Payment: Show Retrieves a single payment object by its ‘id`.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



645
646
647
648
# File 'lib/komoju-sdk/api/payments_api.rb', line 645

def show_payment(id, opts = {})
  data, _status_code, _headers = show_payment_with_http_info(id, opts)
  data
end

#show_payment_with_http_info(id, opts = {}) ⇒ Array<(Payment, Integer, Hash)>

Payment: Show Retrieves a single payment object by its &#x60;id&#x60;.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Payment, Integer, Hash)>)

    Payment data, response status code and response headers



655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
# File 'lib/komoju-sdk/api/payments_api.rb', line 655

def show_payment_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.show_payment ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.show_payment"
  end
  if @api_client.config.client_side_validation && id.to_s.length > 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.show_payment, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && id.to_s.length < 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.show_payment, the character length must be great than or equal to 25.'
  end

  # resource path
  local_var_path = '/payments/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Payment'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key']

  new_options = opts.merge(
    :operation => :"PaymentsApi.show_payment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#show_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_payment(id, update_payment_request, opts = {}) ⇒ Payment

Payment: Update Updates a payment. Only a payment’s ‘description` and `metadata` can be changed.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • update_payment_request (UpdatePaymentRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



717
718
719
720
# File 'lib/komoju-sdk/api/payments_api.rb', line 717

def update_payment(id, update_payment_request, opts = {})
  data, _status_code, _headers = update_payment_with_http_info(id, update_payment_request, opts)
  data
end

#update_payment_with_http_info(id, update_payment_request, opts = {}) ⇒ Array<(Payment, Integer, Hash)>

Payment: Update Updates a payment. Only a payment&#39;s &#x60;description&#x60; and &#x60;metadata&#x60; can be changed.

Parameters:

  • id (String)

    A unique identifier for the payment.

  • update_payment_request (UpdatePaymentRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Payment, Integer, Hash)>)

    Payment data, response status code and response headers



728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
# File 'lib/komoju-sdk/api/payments_api.rb', line 728

def update_payment_with_http_info(id, update_payment_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PaymentsApi.update_payment ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling PaymentsApi.update_payment"
  end
  if @api_client.config.client_side_validation && id.to_s.length > 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.update_payment, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && id.to_s.length < 25
    fail ArgumentError, 'invalid value for "id" when calling PaymentsApi.update_payment, the character length must be great than or equal to 25.'
  end

  # verify the required parameter 'update_payment_request' is set
  if @api_client.config.client_side_validation && update_payment_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_payment_request' when calling PaymentsApi.update_payment"
  end
  # resource path
  local_var_path = '/payments/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(update_payment_request)

  # return_type
  return_type = opts[:debug_return_type] || 'Payment'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key']

  new_options = opts.merge(
    :operation => :"PaymentsApi.update_payment",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PaymentsApi#update_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end