Class: Payabli::MoneyIn::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/payabli/money_in/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/payabli/money_in/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#authorize(request_options: {}, **params) ⇒ Payabli::Types::AuthResponse

This endpoint is deprecated. New integrations should use the [Authorize endpoint](/developers/api-reference/moneyinV2/authorize-a-transaction), then capture, void, or refund the resulting transaction with the corresponding endpoints. Transactions created with this legacy endpoint must be managed with the legacy lifecycle endpoints — they aren't interchangeable with the current ones.

Authorize a card transaction. This returns an authorization code and reserves funds for the merchant. Authorized transactions aren't flagged for settlement until captured.

Only card transactions can be authorized. This endpoint can't be used for ACH transactions.

Examples:

client.money_in.authorize(
  payment_details: {
    total_amount: 1.1
  },
  payment_method: {
    cardexp: "cardexp",
    cardnumber: "cardnumber",
    method_: "card"
  }
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :force_customer_creation (Boolean, nil)
  • :idempotency_key (String, nil)

Returns:



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
# File 'lib/payabli/money_in/client.rb', line 50

def authorize(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[force_customer_creation]
  query_params = {}
  query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)
  params = params.except(*query_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/authorize",
    headers: headers,
    query: query_params,
    body: Payabli::Types::TransRequestBody.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::AuthResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#authorizev_2(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Authorize a card transaction. This returns an authorization code and reserves funds for the merchant. Authorized transactions aren't flagged for settlement until captured. This is the v2 version of the api/MoneyIn/authorize endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

Note: Only card transactions can be authorized. This endpoint can't be used for ACH transactions.

Examples:

client.money_in.authorizev_2(
  customer_data: {
    customer_id: 4440
  },
  entry_point: "8cfec329267",
  ipaddress: "255.255.255.255",
  payment_details: {
    service_fee: 0,
    total_amount: 100
  },
  payment_method: {
    cardcvv: "999",
    cardexp: "02/27",
    card_holder: "John Cassian",
    cardnumber: "4111111111111111",
    cardzip: "12345",
    initiator: "payor",
    method_: "card"
  }
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :force_customer_creation (Boolean, nil)
  • :idempotency_key (String, nil)

Returns:



852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
# File 'lib/payabli/money_in/client.rb', line 852

def authorizev_2(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[force_customer_creation]
  query_params = {}
  query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)
  params = params.except(*query_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/authorize",
    headers: headers,
    query: query_params,
    body: Payabli::Types::TransRequestBody.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#capture(request_options: {}, **params) ⇒ Payabli::Types::CaptureResponse

This endpoint is deprecated. Use [POST `/capture/transId`](/developers/api-reference/moneyin/capture-an-authorized-transaction) instead, which supports partial captures and service fee adjustments.
Capture an [authorized

transaction](/developers/api-reference/moneyin/authorize-a-transaction) to complete the transaction and move funds from the customer to merchant account.

Examples:

client.money_in.capture(
  trans_id: "transId",
  amount: 1.1
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :amount (Integer)

Returns:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/payabli/money_in/client.rb', line 111

def capture(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/capture/#{URI.encode_uri_component(params[:trans_id].to_s)}/#{URI.encode_uri_component(params[:amount].to_s)}",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::CaptureResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#capture_auth(request_options: {}, **params) ⇒ Payabli::Types::CaptureResponse

This endpoint is deprecated. Use it only to capture transactions originally authorized with the legacy [Authorize endpoint](/developers/api-reference/moneyin/authorize-a-transaction). New integrations should use the [Capture endpoint](/developers/api-reference/moneyinV2/capture-an-authorized-transaction), which only works on transactions authorized with the current [Authorize endpoint](/developers/api-reference/moneyinV2/authorize-a-transaction).

Capture an authorized transaction to complete the transaction and move funds from the customer to merchant account.

You can use this endpoint to capture both full and partial amounts of the original authorized transaction. See Capture an authorized transaction for more information about this endpoint.

Examples:

client.money_in.capture_auth(
  trans_id: "transId",
  payment_details: {
    total_amount: 1.1
  }
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



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
# File 'lib/payabli/money_in/client.rb', line 168

def capture_auth(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[trans_id]
  body_params = params.except(*path_param_names)

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/capture/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    headers: headers,
    body: Payabli::Types::CaptureRequest.new(body_params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::CaptureResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#capturev_2(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Capture an authorized transaction to complete the transaction and move funds from the customer to merchant account. This is the v2 version of the api/MoneyIn/capture/{transId} endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

Examples:

client.money_in.capturev_2(
  trans_id: "10-7d9cd67d-2d5d-4cd7-a1b7-72b8b201ec13",
  payment_details: {
    total_amount: 105,
    service_fee: 5
  }
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
# File 'lib/payabli/money_in/client.rb', line 910

def capturev_2(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[trans_id]
  body_params = params.except(*path_param_names)

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/capture/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    headers: headers,
    body: Payabli::Types::CaptureRequest.new(body_params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#credit(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse0

Make a temporary microdeposit in a customer account to verify the customer's ownership and access to the target account. Reverse the microdeposit with reverseCredit. Payabli doesn't automatically make microdeposits when you add a bank account, you must manually make the requests.

This feature must be enabled by Payabli on a per-merchant basis. Contact support for help.

Examples:

client.money_in.credit(
  idempotency_key: "6B29FC40-CA47-1067-B31D-00DD010662DA",
  customer_data: {
    billing_address_1: "5127 Linkwood ave",
    customer_number: "C-90010"
  },
  entrypoint: "8cfec329267",
  payment_details: {
    service_fee: 0,
    total_amount: 1
  },
  payment_method: {
    ach_account: "88354454",
    ach_account_type: "Checking",
    ach_holder: "John Smith",
    ach_routing: "021000021",
    method_: "ach"
  }
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :force_customer_creation (Boolean, nil)
  • :idempotency_key (String, nil)

Returns:



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
# File 'lib/payabli/money_in/client.rb', line 234

def credit(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request_data = Payabli::MoneyIn::Types::RequestCredit.new(params).to_h
  non_body_param_names = %w[forceCustomerCreation idempotencyKey]
  body = request_data.except(*non_body_param_names)

  query_params = {}
  query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/makecredit",
    headers: headers,
    query: query_params,
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::PayabliApiResponse0.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#details(request_options: {}, **params) ⇒ Payabli::Types::TransactionQueryRecordsCustomer

Retrieve a processed transaction's details.

Examples:

client.money_in.details(trans_id: "45-as456777hhhhhhhhhh77777777-324")

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/payabli/money_in/client.rb', line 285

def details(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/details/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::TransactionQueryRecordsCustomer.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#getpaid(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseGetPaid

This endpoint is deprecated. New integrations should use the [Make a transaction endpoint](/developers/api-reference/moneyinV2/make-a-transaction) and manage the resulting transaction with the corresponding void or refund endpoints. Transactions created with this legacy endpoint must be managed with the legacy lifecycle endpoints — they aren't interchangeable with the current ones.

Make a single transaction. This method authorizes and captures a payment in one step.

Examples:

client.money_in.getpaid(
  payment_details: {
    total_amount: 1.1
  },
  payment_method: {
    cardexp: "cardexp",
    cardnumber: "cardnumber",
    method_: "card"
  }
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :ach_validation (Boolean, nil)
  • :force_customer_creation (Boolean, nil)
  • :include_details (Boolean, nil)
  • :idempotency_key (String, nil)
  • :validation_code (String, nil)

Returns:



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
# File 'lib/payabli/money_in/client.rb', line 344

def getpaid(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[ach_validation force_customer_creation include_details]
  query_params = {}
  query_params["achValidation"] = params[:ach_validation] if params.key?(:ach_validation)
  query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)
  query_params["includeDetails"] = params[:include_details] if params.key?(:include_details)
  params = params.except(*query_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]
  headers["validationCode"] = params[:validation_code] if params[:validation_code]

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/getpaid",
    headers: headers,
    query: query_params,
    body: Payabli::Types::TransRequestBody.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::PayabliApiResponseGetPaid.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#getpaidv_2(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Make a single transaction. This method authorizes and captures a payment in one step. This is the v2 version of the api/MoneyIn/getpaid endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

Examples:

client.money_in.getpaidv_2(
  customer_data: {
    customer_id: 4440
  },
  entry_point: "8cfec329267",
  ipaddress: "255.255.255.255",
  payment_details: {
    service_fee: 0,
    total_amount: 100
  },
  payment_method: {
    cardcvv: "999",
    cardexp: "02/27",
    card_holder: "John Cassian",
    cardnumber: "4111111111111111",
    cardzip: "12345",
    initiator: "payor",
    method_: "card"
  }
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :ach_validation (Boolean, nil)
  • :force_customer_creation (Boolean, nil)
  • :idempotency_key (String, nil)
  • :validation_code (String, nil)

Returns:



776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
# File 'lib/payabli/money_in/client.rb', line 776

def getpaidv_2(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[ach_validation force_customer_creation]
  query_params = {}
  query_params["achValidation"] = params[:ach_validation] if params.key?(:ach_validation)
  query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation)
  params = params.except(*query_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]
  headers["validationCode"] = params[:validation_code] if params[:validation_code]

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/getpaid",
    headers: headers,
    query: query_params,
    body: Payabli::Types::TransRequestBody.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#refund(request_options: {}, **params) ⇒ Payabli::Types::RefundResponse

This endpoint is deprecated. Use it only to refund transactions originally created with the legacy endpoints. New integrations should use the [Refund endpoint](/developers/api-reference/moneyinV2/refund-a-settled-transaction), which only works on transactions created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction) or [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction).

Refund a transaction that has settled and send money back to the account holder. If a transaction hasn't been settled, void it instead.

Examples:

client.money_in.refund(
  trans_id: "transId",
  amount: 1.1
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :amount (Integer)

Returns:



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/payabli/money_in/client.rb', line 465

def refund(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/refund/#{URI.encode_uri_component(params[:trans_id].to_s)}/#{URI.encode_uri_component(params[:amount].to_s)}",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::RefundResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#refund_with_instructions(request_options: {}, **params) ⇒ Payabli::Types::RefundWithInstructionsResponse

This endpoint is deprecated. Use it only to refund transactions originally created with the legacy endpoints. To refund a split-funded transaction created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction) or [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction), use the [Refund endpoint](/developers/api-reference/moneyinV2/refund-a-settled-transaction) with split instructions in the request body.

Refunds a settled transaction with split instructions.

Examples:

client.money_in.refund_with_instructions(trans_id: "transId")

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :idempotency_key (String, nil)

Returns:



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
# File 'lib/payabli/money_in/client.rb', line 514

def refund_with_instructions(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request_data = Payabli::MoneyIn::Types::RequestRefund.new(params).to_h
  non_body_param_names = %w[transId idempotencyKey]
  body = request_data.except(*non_body_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/refund/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    headers: headers,
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::RefundWithInstructionsResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#refundv_2(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Give a full refund for a transaction that has settled and send money back to the account holder. To perform a partial refund, see Partially refund a transaction.

This is the v2 version of the refund endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

To refund a split-funded transaction, include split instructions in the request body. Omit the body for a standard refund.

Examples:

client.money_in.refundv_2(
  trans_id: "10-3ffa27df-b171-44e0-b251-e95fbfc7a723",
  amount: 100,
  order_description: "Materials deposit",
  refund_details: {
    split_refunding: [{
      origination_entry_point: "495147f647",
      account_id: "187-342",
      description: "Refunding undelivered materials",
      amount: 60
    }, {
      origination_entry_point: "8cfec329267",
      account_id: "187-343",
      description: "Refunding deposit for undelivered materials",
      amount: 40
    }]
  },
  source: "api"
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
# File 'lib/payabli/money_in/client.rb', line 981

def refundv_2(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[trans_id]
  body_params = params.except(*path_param_names)

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/refund/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    headers: headers,
    body: body_params.empty? ? nil : Payabli::Types::RefundV2Request.new(body_params).to_h,
    omit_content_type_without_body: true,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#refundv_2_amount(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Refund a transaction that has settled and send money back to the account holder. If amount is set to 0, performs a full refund. When a non-zero amount is provided, this endpoint performs a partial refund.

This is the v2 version of the refund endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

For a standard refund, whether full (`amount` set to 0) or partial, send no request body. Include a request body only to refund a split-funded transaction, with split instructions in `refundDetails`.

Examples:

client.money_in.refundv_2_amount(
  trans_id: "10-3ffa27df-b171-44e0-b251-e95fbfc7a723",
  amount: 70,
  order_description: "Materials deposit",
  refund_details: {
    split_refunding: [{
      origination_entry_point: "495147f647",
      account_id: "187-342",
      description: "Refunding undelivered materials",
      amount: 40
    }, {
      origination_entry_point: "8cfec329267",
      account_id: "187-343",
      description: "Refunding deposit for undelivered materials",
      amount: 30
    }]
  },
  source: "api"
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :amount (Integer)

Returns:



1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
# File 'lib/payabli/money_in/client.rb', line 1053

def refundv_2_amount(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[trans_id amount]
  body_params = params.except(*path_param_names)

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/refund/#{URI.encode_uri_component(params[:trans_id].to_s)}/#{URI.encode_uri_component(params[:amount].to_s)}",
    headers: headers,
    body: body_params.empty? ? nil : Payabli::Types::RefundV2Request.new(body_params).to_h,
    omit_content_type_without_body: true,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#reverse(request_options: {}, **params) ⇒ Payabli::Types::ReverseResponse

This endpoint is deprecated and only works on transactions created with the legacy endpoints. There's no equivalent in the current endpoints. For transactions created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction) or [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction), check the transaction's settlement status and call [Void](/developers/api-reference/moneyinV2/void-a-transaction) or [Refund](/developers/api-reference/moneyinV2/refund-a-settled-transaction) based on the result.

A reversal either refunds or voids a transaction independent of the transaction's settlement status. Send a reversal request for a transaction, and Payabli automatically determines whether it's a refund or void. You don't need to know whether the transaction is settled or not. This endpoint only works on transactions made with the legacy endpoints. For transactions made with the current endpoints, check the transaction's settlement status and call void or refund based on the result.

Examples:

client.money_in.reverse(
  trans_id: "transId",
  amount: 1.1
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :amount (Integer)

Returns:



413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# File 'lib/payabli/money_in/client.rb', line 413

def reverse(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/reverse/#{URI.encode_uri_component(params[:trans_id].to_s)}/#{URI.encode_uri_component(params[:amount].to_s)}",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::ReverseResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#reverse_credit(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse

Reverse microdeposits that are used to verify customer account ownership and access. The transId value is returned in the success response for the original credit transaction made with api/MoneyIn/makecredit.

Examples:

client.money_in.reverse_credit(trans_id: "45-as456777hhhhhhhhhh77777777-324")

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/payabli/money_in/client.rb', line 562

def reverse_credit(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/reverseCredit/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::PayabliApiResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#send_receipt_2_trans(request_options: {}, **params) ⇒ Payabli::Types::ReceiptResponse

Send a payment receipt for a transaction.

Examples:

client.money_in.send_receipt_2_trans(
  trans_id: "45-as456777hhhhhhhhhh77777777-324",
  email: "[email protected]"
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)
  • :email (String, nil)

Returns:



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
# File 'lib/payabli/money_in/client.rb', line 605

def send_receipt_2_trans(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["email"] = params[:email] if params.key?(:email)

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/sendreceipt/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    headers: headers,
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::ReceiptResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#validate(request_options: {}, **params) ⇒ Payabli::Types::ValidateResponse

Validates a card number without running a transaction or authorizing a charge.

Examples:

client.money_in.validate(
  idempotency_key: "6B29FC40-CA47-1067-B31D-00DD010662DA",
  entry_point: "8cfec329267",
  payment_method: {
    method_: "card",
    cardnumber: "4360000001000005",
    cardexp: "12/29",
    cardzip: "14602-8328",
    card_holder: "Dianne Becker-Smith"
  }
)

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :idempotency_key (String, nil)

Returns:



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
# File 'lib/payabli/money_in/client.rb', line 658

def validate(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  request_data = Payabli::MoneyIn::Types::RequestPaymentValidate.new(params).to_h
  non_body_param_names = %w[idempotencyKey]
  body = request_data.except(*non_body_param_names)

  headers = {}
  headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key]

  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers)
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "MoneyIn/validate",
    headers: headers,
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::ValidateResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#void(request_options: {}, **params) ⇒ Payabli::Types::VoidResponse

This endpoint is deprecated. Use it only to void transactions originally created with the legacy endpoints. New integrations should use the [Void endpoint](/developers/api-reference/moneyinV2/void-a-transaction), which only works on transactions created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction) or [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction).

Cancel a transaction that hasn't been settled yet. Voiding non-captured authorizations prevents future captures. If a transaction has been settled, refund it instead.

Examples:

client.money_in.void(trans_id: "transId")

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
# File 'lib/payabli/money_in/client.rb', line 713

def void(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "MoneyIn/void/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::VoidResponse.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#voidv_2(request_options: {}, **params) ⇒ Payabli::Types::V2TransactionResponseWrapper

Cancel a transaction that hasn't been settled yet. Voiding non-captured authorizations prevents future captures. This is the v2 version of the api/MoneyIn/void/{transId} endpoint, and returns the unified response format. See Pay In unified response codes reference for more information.

Examples:

client.money_in.voidv_2(trans_id: "10-3ffa27df-b171-44e0-b251-e95fbfc7a723")

Parameters:

  • (defaults to: {})

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :trans_id (String)

Returns:



1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
# File 'lib/payabli/money_in/client.rb', line 1100

def voidv_2(request_options: {}, **params)
  params = Payabli::Internal::Types::Utils.normalize_keys(params)
  headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }])
  request = Payabli::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v2/MoneyIn/void/#{URI.encode_uri_component(params[:trans_id].to_s)}",
    headers: headers,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Payabli::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Payabli::Types::V2TransactionResponseWrapper.load(response.body)
  else
    error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end