payabli 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.fern/metadata.json +5 -5
  3. data/README.md +4 -1
  4. data/lib/payabli/client.rb +38 -4
  5. data/lib/payabli/customer/client.rb +1 -1
  6. data/lib/payabli/funding/client.rb +49 -0
  7. data/lib/payabli/funding/types/deposit_funds_request.rb +19 -0
  8. data/lib/payabli/internal/http/raw_client.rb +28 -5
  9. data/lib/payabli/internal/oauth_provider.rb +67 -0
  10. data/lib/payabli/money_in/client.rb +79 -35
  11. data/lib/payabli/money_out/client.rb +63 -3
  12. data/lib/payabli/money_out/types/renew_v_card_request.rb +13 -0
  13. data/lib/payabli/payment_link/client.rb +7 -0
  14. data/lib/payabli/payment_link/types/pay_link_data_invoice.rb +1 -1
  15. data/lib/payabli/token/client.rb +51 -0
  16. data/lib/payabli/token/types/create_server_side_token_request.rb +17 -0
  17. data/lib/payabli/types/add_device_response.rb +4 -0
  18. data/lib/payabli/types/add_method_response.rb +4 -0
  19. data/lib/payabli/types/add_response_response.rb +4 -0
  20. data/lib/payabli/types/auth_capture_payout_response_data.rb +2 -0
  21. data/lib/payabli/types/authorize_payment_method.rb +4 -0
  22. data/lib/payabli/types/bill_pay_out_data.rb +15 -9
  23. data/lib/payabli/types/cancel_payout_response_data.rb +27 -0
  24. data/lib/payabli/types/capture_all_out_response_response_data_item.rb +2 -0
  25. data/lib/payabli/types/contacts_response.rb +3 -3
  26. data/lib/payabli/types/deposit_funds_response.rb +16 -0
  27. data/lib/payabli/types/get_method_response_response_data_customers_item.rb +42 -0
  28. data/lib/payabli/types/get_pay_link_from_id_response.rb +4 -0
  29. data/lib/payabli/types/method_element.rb +4 -0
  30. data/lib/payabli/types/methods_list.rb +6 -0
  31. data/lib/payabli/types/modify_approval_bill_response.rb +4 -0
  32. data/lib/payabli/types/notification_log_detail.rb +24 -0
  33. data/lib/payabli/types/payabli_access_token_response.rb +17 -0
  34. data/lib/payabli/types/payabli_api_response_0000.rb +1 -1
  35. data/lib/payabli/types/query_payout_transaction_records_item.rb +54 -34
  36. data/lib/payabli/types/query_payout_transaction_records_item_payment_data.rb +16 -16
  37. data/lib/payabli/types/query_payout_transaction_summary.rb +17 -17
  38. data/lib/payabli/types/query_response_settlements_records_item.rb +2 -0
  39. data/lib/payabli/types/query_transaction_events.rb +2 -2
  40. data/lib/payabli/types/refund_v_2_request.rb +21 -0
  41. data/lib/payabli/types/remove_device_response.rb +4 -0
  42. data/lib/payabli/types/renew_v_card_response.rb +13 -0
  43. data/lib/payabli/types/renew_v_card_response_data.rb +25 -0
  44. data/lib/payabli/types/set_approved_bill_response.rb +4 -0
  45. data/lib/payabli/types/settlement_split_funding_detail.rb +23 -0
  46. data/lib/payabli/types/stat_basic_extended_query_record.rb +8 -0
  47. data/lib/payabli/types/token_error_response.rb +13 -0
  48. data/lib/payabli/types/tokenize_ach.rb +0 -2
  49. data/lib/payabli/types/tokenize_card.rb +2 -0
  50. data/lib/payabli/types/transfer_out_record.rb +4 -0
  51. data/lib/payabli/types/vendor_call_status_completed.rb +20 -0
  52. data/lib/payabli/types/vendor_call_status_extracted_data.rb +12 -0
  53. data/lib/payabli/types/vendor_call_status_failed.rb +18 -0
  54. data/lib/payabli/types/vendor_call_status_response.rb +18 -0
  55. data/lib/payabli/types/vendor_call_status_scheduled.rb +14 -0
  56. data/lib/payabli/types/vendor_data.rb +1 -1
  57. data/lib/payabli/types/vendor_query_record.rb +45 -41
  58. data/lib/payabli/types/vendor_schedule_call_response.rb +20 -0
  59. data/lib/payabli/types/vendor_schedule_call_response_data.rb +16 -0
  60. data/lib/payabli/types/vendoridtrans.rb +23 -0
  61. data/lib/payabli/vendor/client.rb +79 -0
  62. data/lib/payabli/vendor/types/schedule_enrichment_call_request.rb +27 -0
  63. data/lib/payabli/version.rb +1 -1
  64. data/lib/payabli.rb +36 -13
  65. data/reference.md +675 -163
  66. data/wiremock/docker-compose.test.yml +1 -1
  67. data/wiremock/wiremock-mappings.json +258 -93
  68. metadata +25 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36bd2543107fba665cc922c2aabf537bfc21fa08bfc1ad4c508cb46f06273a20
4
- data.tar.gz: 96c5e675eced6a18eb20b5da9c4cc1b56b7bae4c8e27632f750e3da5efd8a69d
3
+ metadata.gz: 030ce6ece0ebf9ee1b7db55aabee60f4f77ddd0e755004597504f6c831bb39f7
4
+ data.tar.gz: f475de7c086a0699ac89a0b009ce87e30ff5ea16973a11dc6ad19395724a0350
5
5
  SHA512:
6
- metadata.gz: bcb5d0a819b41497c6ce92340c29d65adbc72ef70aff938f6aa433f81cf1890b78a1a295f8a4f98a142fbe911653e126189a7a73262ea1be96b14b3c4447b7aa
7
- data.tar.gz: 07fc43e8305fd4d5dddf461a25580bec52088648505ce45f8bbada721a6a7782d525fe68fdf818d1e65bc9d188ed9a4ea02cbde78fca8f1c2ae1a944d3678111
6
+ metadata.gz: 6ae52fe15e466ead4098f19b312144d8a907adcc736d40d2102cd7435dbc1fbca2bbf75aae42642997f706a89ece45b7773b47a37d5b5f49ca888fe14c19b8e5
7
+ data.tar.gz: 25304386f26b6bbb6f03b5628d270fc0538aa5149f23f637b32c73e7a153cda1b15750995d68b59205543da1d5aebba3d8665a57c04aa69101d7fc6170eea7a7
data/.fern/metadata.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
- "cliVersion": "5.7.9",
2
+ "cliVersion": "5.56.0",
3
3
  "generatorName": "fernapi/fern-ruby-sdk",
4
- "generatorVersion": "1.12.7",
4
+ "generatorVersion": "1.15.2",
5
5
  "generatorConfig": {
6
6
  "enableWireTests": true,
7
7
  "rubocopVariableNumberStyle": "snake_case"
8
8
  },
9
- "originGitCommit": "21b1f70a2e9bfc3b23ab1d28054848d68be85fdc",
9
+ "originGitCommit": "fbf628bcea22b886022a9bd709dca9daaf0bd3ca",
10
10
  "originGitCommitIsDirty": true,
11
11
  "invokedBy": "ci",
12
- "requestedVersion": "3.0.1",
12
+ "requestedVersion": "3.0.3",
13
13
  "ciProvider": "github",
14
- "sdkVersion": "3.0.1"
14
+ "sdkVersion": "3.0.3"
15
15
  }
data/README.md CHANGED
@@ -71,7 +71,10 @@ Instantiate and use the client with the following:
71
71
  ```ruby
72
72
  require "payabli"
73
73
 
74
- client = Payabli::Client.new(api_key: "<value>")
74
+ client = Payabli::Client.new(
75
+ client_id: "<clientId>",
76
+ client_secret: "<clientSecret>"
77
+ )
75
78
 
76
79
  client.money_in.getpaidv_2(
77
80
  customer_data: {
@@ -2,18 +2,42 @@
2
2
 
3
3
  module Payabli
4
4
  class Client
5
- # @param api_key [String]
6
5
  # @param base_url [String, nil]
6
+ # @param client_id [String, nil]
7
+ # @param client_secret [String, nil]
8
+ # @param api_key [String, nil]
9
+ # @param max_retries [Integer]
7
10
  #
8
11
  # @return [void]
9
- def initialize(api_key:, base_url: nil)
12
+ def initialize(base_url: nil, client_id: ENV.fetch("OAUTH_CLIENT_ID", nil), client_secret: ENV.fetch("OAUTH_CLIENT_SECRET", nil), api_key: nil, max_retries: 2)
13
+ if !client_id.to_s.empty? && !client_secret.to_s.empty?
14
+ # Create an unauthenticated client for the auth endpoint
15
+ auth_raw_client = Payabli::Internal::Http::RawClient.new(
16
+ base_url: base_url || Payabli::Environment::SANDBOX,
17
+ headers: {
18
+ "X-Fern-Language" => "Ruby"
19
+ }
20
+ )
21
+
22
+ # Create the auth client for token retrieval
23
+ auth_client = Payabli::Token::Client.new(client: auth_raw_client)
24
+
25
+ # Create the OAuth provider with the auth client and credentials
26
+ @auth_provider = Payabli::Internal::OAuthProvider.new(
27
+ auth_client: auth_client,
28
+ options: { base_url: base_url, client_id: client_id, client_secret: client_secret }
29
+ )
30
+ end
31
+
10
32
  @raw_client = Payabli::Internal::Http::RawClient.new(
11
33
  base_url: base_url || Payabli::Environment::SANDBOX,
12
34
  headers: {
13
- "User-Agent" => "payabli/3.0.1",
35
+ "User-Agent" => "payabli/3.0.3",
14
36
  "X-Fern-Language" => "Ruby",
15
37
  requestToken: api_key.to_s
16
- }
38
+ },
39
+ auth_provider: @auth_provider,
40
+ max_retries: max_retries
17
41
  )
18
42
  end
19
43
 
@@ -37,6 +61,11 @@ module Payabli
37
61
  @money_in ||= Payabli::MoneyIn::Client.new(client: @raw_client)
38
62
  end
39
63
 
64
+ # @return [Payabli::Token::Client]
65
+ def token
66
+ @token ||= Payabli::Token::Client.new(client: @raw_client)
67
+ end
68
+
40
69
  # @return [Payabli::Subscription::Client]
41
70
  def subscription
42
71
  @subscription ||= Payabli::Subscription::Client.new(client: @raw_client)
@@ -157,6 +186,11 @@ module Payabli
157
186
  @money_out ||= Payabli::MoneyOut::Client.new(client: @raw_client)
158
187
  end
159
188
 
189
+ # @return [Payabli::Funding::Client]
190
+ def funding
191
+ @funding ||= Payabli::Funding::Client.new(client: @raw_client)
192
+ end
193
+
160
194
  # @return [Payabli::Wallet::Client]
161
195
  def wallet
162
196
  @wallet ||= Payabli::Wallet::Client.new(client: @raw_client)
@@ -11,7 +11,7 @@ module Payabli
11
11
  end
12
12
 
13
13
  # Creates a customer in an entrypoint. An identifier is required to create customer records. Change your
14
- # identifier settings in Settings > Custom Fields in PartnerHub.
14
+ # identifier settings in Settings > Custom Fields in the Payabli Portal.
15
15
  # If you don't include an identifier, the record is rejected.
16
16
  #
17
17
  # @param request_options [Hash]
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Payabli
4
+ module Funding
5
+ class Client
6
+ # @param client [Payabli::Internal::Http::RawClient]
7
+ #
8
+ # @return [void]
9
+ def initialize(client:)
10
+ @client = client
11
+ end
12
+
13
+ # Deposits funds into a paypoint's available payout balance. Deposited funds enter a pending state and aren't
14
+ # available for instant payouts until confirmed through FBO reconciliation.
15
+ #
16
+ # @param request_options [Hash]
17
+ # @param params [Payabli::Funding::Types::DepositFundsRequest]
18
+ # @option request_options [String] :base_url
19
+ # @option request_options [Hash{String => Object}] :additional_headers
20
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
21
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
22
+ # @option request_options [Integer] :timeout_in_seconds
23
+ #
24
+ # @return [Payabli::Types::DepositFundsResponse]
25
+ def deposit_funds(request_options: {}, **params)
26
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
27
+ request = Payabli::Internal::JSON::Request.new(
28
+ base_url: request_options[:base_url],
29
+ method: "POST",
30
+ path: "Funding/depositFunds",
31
+ body: Payabli::Funding::Types::DepositFundsRequest.new(params).to_h,
32
+ request_options: request_options
33
+ )
34
+ begin
35
+ response = @client.send(request)
36
+ rescue Net::HTTPRequestTimeout
37
+ raise Payabli::Errors::TimeoutError
38
+ end
39
+ code = response.code.to_i
40
+ if code.between?(200, 299)
41
+ Payabli::Types::DepositFundsResponse.load(response.body)
42
+ else
43
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
44
+ raise error_class.new(response.body, code: code)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Payabli
4
+ module Funding
5
+ module Types
6
+ class DepositFundsRequest < Internal::Types::Model
7
+ field :amount, -> { Integer }, optional: false, nullable: false
8
+
9
+ field :entrypoint, -> { String }, optional: false, nullable: false
10
+
11
+ field :account_id, -> { String }, optional: false, nullable: false, api_name: "accountId"
12
+
13
+ field :paypoint_id, -> { Integer }, optional: true, nullable: false, api_name: "paypointId"
14
+
15
+ field :same_day_ach, -> { Internal::Types::Boolean }, optional: true, nullable: false, api_name: "sameDayAch"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -21,10 +21,14 @@ module Payabli
21
21
  # @param max_retries [Integer] The number of times to retry a failed request, defaults to 2.
22
22
  # @param timeout [Float] The timeout for the request, defaults to 60.0 seconds.
23
23
  # @param headers [Hash] The headers for the request.
24
- def initialize(base_url:, max_retries: 2, timeout: 60.0, headers: {})
24
+ # @param auth_provider [Object, nil] An optional auth provider responding to
25
+ # `auth_headers`. When present its headers are resolved on every request so
26
+ # token-based schemes (e.g. OAuth) can refresh an expired token mid-session.
27
+ def initialize(base_url:, max_retries: 2, timeout: 60.0, headers: {}, auth_provider: nil)
25
28
  @base_url = base_url
26
29
  @max_retries = max_retries
27
30
  @timeout = timeout
31
+ @auth_provider = auth_provider
28
32
  @default_headers = {
29
33
  "X-Fern-Language": "Ruby",
30
34
  "X-Fern-SDK-Name": "payabli",
@@ -36,6 +40,9 @@ module Payabli
36
40
  # @return [HTTP::Response] The HTTP response.
37
41
  def send(request)
38
42
  url = build_url(request)
43
+ # Resolve auth headers once per request (not per retry) so token-based
44
+ # providers refresh at most once here; static providers are cheap.
45
+ auth_headers = resolve_auth_headers
39
46
  attempt = 0
40
47
  response = nil
41
48
 
@@ -43,8 +50,9 @@ module Payabli
43
50
  http_request = build_http_request(
44
51
  url:,
45
52
  method: request.method,
46
- headers: request.encode_headers(protected_keys: @default_headers.keys),
47
- body: request.encode_body
53
+ headers: request.encode_headers(protected_keys: @default_headers.keys + auth_headers.keys),
54
+ body: request.encode_body,
55
+ auth_headers: auth_headers
48
56
  )
49
57
 
50
58
  conn = connect(url)
@@ -157,12 +165,27 @@ module Payabli
157
165
  "HTTP is only allowed for localhost. Use HTTPS or pass a localhost URL."
158
166
  end
159
167
 
168
+ # Resolves the auth headers to send with the next request. Delegates to the
169
+ # configured auth provider (if any) on every call so that token-based
170
+ # providers (e.g. OAuth client-credentials) can refresh an expired token
171
+ # before the request is sent. Returns an empty hash when no provider is set,
172
+ # which keeps the api-key / basic / bearer / no-auth paths unchanged.
173
+ # @return [Hash] The auth headers for the current request.
174
+ def resolve_auth_headers
175
+ return {} if @auth_provider.nil?
176
+
177
+ @auth_provider.auth_headers
178
+ end
179
+
160
180
  # @param url [URI::Generic] The url to the resource.
161
181
  # @param method [String] The HTTP method to use.
162
182
  # @param headers [Hash] The headers for the request.
163
183
  # @param body [String, nil] The body for the request.
184
+ # @param auth_headers [Hash] The auth headers resolved for this request. These
185
+ # take precedence over the static default headers but not over per-request
186
+ # headers, mirroring the previous baked-header precedence.
164
187
  # @return [HTTP::Request] The HTTP request.
165
- def build_http_request(url:, method:, headers: {}, body: nil)
188
+ def build_http_request(url:, method:, headers: {}, body: nil, auth_headers: {})
166
189
  request = Net::HTTPGenericRequest.new(
167
190
  method,
168
191
  !body.nil?,
@@ -170,7 +193,7 @@ module Payabli
170
193
  url
171
194
  )
172
195
 
173
- request_headers = @default_headers.merge(headers)
196
+ request_headers = @default_headers.merge(auth_headers).merge(headers)
174
197
  request_headers.each { |name, value| request[name] = value }
175
198
  request.body = body if body
176
199
 
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Payabli
4
+ module Internal
5
+ class OAuthProvider
6
+ BUFFER_IN_SECONDS = 120 # 2 minutes
7
+
8
+ # @param auth_client [untyped]
9
+ # @param options [Hash[String, untyped]]
10
+ #
11
+ # @return [void]
12
+ def initialize(auth_client:, options:)
13
+ @auth_client = auth_client
14
+ @options = options
15
+ @access_token = nil
16
+ @expires_at = nil
17
+ end
18
+
19
+ # Returns a cached access token, refreshing if necessary.
20
+ # Refreshes the token if it's nil, or if we're within the buffer period before expiration.
21
+ #
22
+ # @return [String]
23
+ def token
24
+ return refresh if @access_token.nil? || token_needs_refresh?
25
+
26
+ @access_token
27
+ end
28
+
29
+ # Returns the authentication headers to be included in requests.
30
+ #
31
+ # @return [Hash[String, String]]
32
+ def auth_headers
33
+ access_token = token
34
+ {
35
+ Authorization: "Bearer #{access_token}"
36
+ }
37
+ end
38
+
39
+ # Checks if the token needs to be refreshed.
40
+ # Returns true if the token will expire within the buffer period.
41
+ #
42
+ # @return [Boolean]
43
+ private def token_needs_refresh?
44
+ return true if @expires_at.nil?
45
+
46
+ Time.now >= (@expires_at - BUFFER_IN_SECONDS)
47
+ end
48
+
49
+ # Refreshes the access token by calling the token endpoint.
50
+ #
51
+ # @return [String]
52
+ private def refresh
53
+ request_params = {
54
+ client_id: @options[:client_id],
55
+ client_secret: @options[:client_secret]
56
+ }
57
+
58
+ token_response = @auth_client.create_server_side_token(**request_params)
59
+
60
+ @access_token = token_response.access_token
61
+ @expires_at = Time.now + token_response.expires_in
62
+
63
+ @access_token
64
+ end
65
+ end
66
+ end
67
+ end
@@ -10,14 +10,19 @@ module Payabli
10
10
  @client = client
11
11
  end
12
12
 
13
+ # <Warning>
14
+ # This endpoint is deprecated. New integrations should use the [Authorize
15
+ # endpoint](/developers/api-reference/moneyinV2/authorize-a-transaction), then capture, void, or refund the
16
+ # resulting transaction with the corresponding endpoints. Transactions created with this legacy endpoint must be
17
+ # managed with the legacy lifecycle endpoints — they aren't interchangeable with the current ones.
18
+ # </Warning>
19
+ #
20
+ #
13
21
  # Authorize a card transaction. This returns an authorization code and reserves funds for the merchant. Authorized
14
22
  # transactions aren't flagged for settlement until
15
23
  # [captured](/developers/api-reference/moneyin/capture-an-authorized-transaction).
24
+ #
16
25
  # Only card transactions can be authorized. This endpoint can't be used for ACH transactions.
17
- # <Tip>
18
- # Consider migrating to the [v2 Authorize endpoint](/developers/api-reference/moneyinV2/authorize-a-transaction)
19
- # to take advantage of unified response codes and improved response consistency.
20
- # </Tip>
21
26
  #
22
27
  # @param request_options [Hash]
23
28
  # @param params [Payabli::Types::TransRequestBody]
@@ -64,8 +69,9 @@ module Payabli
64
69
  end
65
70
 
66
71
  # <Warning>
67
- # This endpoint is deprecated and will be sunset on November 24, 2025. Migrate to [POST
68
- # `/capture/{transId}`](/developers/api-reference/moneyin/capture-an-authorized-transaction)`.
72
+ # This endpoint is deprecated. Use [POST
73
+ # `/capture/{transId}`](/developers/api-reference/moneyin/capture-an-authorized-transaction) instead, which
74
+ # supports partial captures and service fee adjustments.
69
75
  # </Warning>
70
76
  #
71
77
  # Capture an [authorized
@@ -105,6 +111,14 @@ module Payabli
105
111
  end
106
112
  end
107
113
 
114
+ # <Warning>
115
+ # This endpoint is deprecated. Use it only to capture transactions originally authorized with the legacy
116
+ # [Authorize endpoint](/developers/api-reference/moneyin/authorize-a-transaction). New integrations should use the
117
+ # [Capture endpoint](/developers/api-reference/moneyinV2/capture-an-authorized-transaction), which only works on
118
+ # transactions authorized with the current [Authorize
119
+ # endpoint](/developers/api-reference/moneyinV2/authorize-a-transaction).
120
+ # </Warning>
121
+ #
108
122
  # Capture an [authorized transaction](/developers/api-reference/moneyin/authorize-a-transaction) to complete the
109
123
  # transaction and move funds from the customer to merchant account.
110
124
  #
@@ -112,12 +126,6 @@ module Payabli
112
126
  # [Capture an authorized transaction](/developers/developer-guides/pay-in-auth-and-capture) for more information
113
127
  # about this endpoint.
114
128
  #
115
- # <Tip>
116
- # Consider migrating to the [v2 Capture
117
- # endpoint](/developers/api-reference/moneyinV2/capture-an-authorized-transaction) to take advantage of unified
118
- # response codes and improved response consistency.
119
- # </Tip>
120
- #
121
129
  # @param request_options [Hash]
122
130
  # @param params [Payabli::Types::CaptureRequest]
123
131
  # @option request_options [String] :base_url
@@ -237,13 +245,14 @@ module Payabli
237
245
  end
238
246
  end
239
247
 
240
- # Make a single transaction. This method authorizes and captures a payment in one step.
248
+ # <Warning>
249
+ # This endpoint is deprecated. New integrations should use the [Make a transaction
250
+ # endpoint](/developers/api-reference/moneyinV2/make-a-transaction) and manage the resulting transaction with the
251
+ # corresponding void or refund endpoints. Transactions created with this legacy endpoint must be managed with the
252
+ # legacy lifecycle endpoints — they aren't interchangeable with the current ones.
253
+ # </Warning>
241
254
  #
242
- # <Tip>
243
- # Consider migrating to the [v2 Make a transaction
244
- # endpoint](/developers/api-reference/moneyinV2/make-a-transaction) to take advantage of unified response codes
245
- # and improved response consistency.
246
- # </Tip>
255
+ # Make a single transaction. This method authorizes and captures a payment in one step.
247
256
  #
248
257
  # @param request_options [Hash]
249
258
  # @param params [Payabli::Types::TransRequestBody]
@@ -295,11 +304,20 @@ module Payabli
295
304
  end
296
305
  end
297
306
 
307
+ # <Warning>
308
+ # This endpoint is deprecated and only works on transactions created with the legacy endpoints. There's no
309
+ # equivalent in the current endpoints. For transactions created with [Make a
310
+ # transaction](/developers/api-reference/moneyinV2/make-a-transaction) or
311
+ # [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction), check the transaction's settlement
312
+ # status and call [Void](/developers/api-reference/moneyinV2/void-a-transaction) or
313
+ # [Refund](/developers/api-reference/moneyinV2/refund-a-settled-transaction) based on the result.
314
+ # </Warning>
315
+ #
298
316
  # A reversal either refunds or voids a transaction independent of the transaction's settlement status. Send a
299
317
  # reversal request for a transaction, and Payabli automatically determines whether it's a refund or void. You
300
318
  # don't need to know whether the transaction is settled or not. This endpoint only works on transactions made with
301
- # the v1 API. For v2 transactions, check the transaction's settlement status and call v2 void or v2 refund based
302
- # on the result.
319
+ # the legacy endpoints. For transactions made with the current endpoints, check the transaction's settlement
320
+ # status and call void or refund based on the result.
303
321
  #
304
322
  # @param request_options [Hash]
305
323
  # @param params [Hash]
@@ -334,14 +352,17 @@ module Payabli
334
352
  end
335
353
  end
336
354
 
355
+ # <Warning>
356
+ # This endpoint is deprecated. Use it only to refund transactions originally created with the legacy endpoints.
357
+ # New integrations should use the [Refund
358
+ # endpoint](/developers/api-reference/moneyinV2/refund-a-settled-transaction), which only works on transactions
359
+ # created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction) or
360
+ # [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction).
361
+ # </Warning>
362
+ #
337
363
  # Refund a transaction that has settled and send money back to the account holder. If a transaction hasn't been
338
364
  # settled, void it instead.
339
365
  #
340
- # <Tip>
341
- # Consider migrating to the [v2 Refund endpoint](/developers/api-reference/moneyinV2/refund-a-settled-transaction)
342
- # to take advantage of unified response codes and improved response consistency.
343
- # </Tip>
344
- #
345
366
  # @param request_options [Hash]
346
367
  # @param params [Hash]
347
368
  # @option request_options [String] :base_url
@@ -375,6 +396,15 @@ module Payabli
375
396
  end
376
397
  end
377
398
 
399
+ # <Warning>
400
+ # This endpoint is deprecated. Use it only to refund transactions originally created with the legacy endpoints. To
401
+ # refund a split-funded transaction created with [Make a
402
+ # transaction](/developers/api-reference/moneyinV2/make-a-transaction) or
403
+ # [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction), use the [Refund
404
+ # endpoint](/developers/api-reference/moneyinV2/refund-a-settled-transaction) with split instructions in the
405
+ # request body.
406
+ # </Warning>
407
+ #
378
408
  # Refunds a settled transaction with split instructions.
379
409
  #
380
410
  # @param request_options [Hash]
@@ -536,14 +566,16 @@ module Payabli
536
566
  end
537
567
  end
538
568
 
569
+ # <Warning>
570
+ # This endpoint is deprecated. Use it only to void transactions originally created with the legacy endpoints. New
571
+ # integrations should use the [Void endpoint](/developers/api-reference/moneyinV2/void-a-transaction), which only
572
+ # works on transactions created with [Make a transaction](/developers/api-reference/moneyinV2/make-a-transaction)
573
+ # or [Authorize](/developers/api-reference/moneyinV2/authorize-a-transaction).
574
+ # </Warning>
575
+ #
539
576
  # Cancel a transaction that hasn't been settled yet. Voiding non-captured authorizations prevents future captures.
540
577
  # If a transaction has been settled, refund it instead.
541
578
  #
542
- # <Tip>
543
- # Consider migrating to the [v2 Void endpoint](/developers/api-reference/moneyinV2/void-a-transaction) to take
544
- # advantage of unified response codes and improved response consistency.
545
- # </Tip>
546
- #
547
579
  # @param request_options [Hash]
548
580
  # @param params [Hash]
549
581
  # @option request_options [String] :base_url
@@ -719,13 +751,18 @@ module Payabli
719
751
 
720
752
  # Give a full refund for a transaction that has settled and send money back to the account holder. To perform a
721
753
  # partial refund, see [Partially refund a
722
- # transaction](developers/api-reference/moneyinV2/partial-refund-a-settled-transaction).
754
+ # transaction](/developers/api-reference/moneyinV2/partial-refund-a-settled-transaction).
723
755
  #
724
756
  # This is the v2 version of the refund endpoint, and returns the unified response format. See [Pay In unified
725
757
  # response codes reference](/guides/pay-in-unified-response-codes-reference) for more information.
726
758
  #
759
+ # <Note>
760
+ # To refund a split-funded transaction, include split instructions in the request body. Omit the body for a
761
+ # standard refund.
762
+ # </Note>
763
+ #
727
764
  # @param request_options [Hash]
728
- # @param params [Hash]
765
+ # @param params [Payabli::Types::RefundV2Request]
729
766
  # @option request_options [String] :base_url
730
767
  # @option request_options [Hash{String => Object}] :additional_headers
731
768
  # @option request_options [Hash{String => Object}] :additional_query_parameters
@@ -740,6 +777,7 @@ module Payabli
740
777
  base_url: request_options[:base_url],
741
778
  method: "POST",
742
779
  path: "v2/MoneyIn/refund/#{URI.encode_uri_component(params[:trans_id].to_s)}",
780
+ body: Payabli::Types::RefundV2Request.new(params).to_h,
743
781
  request_options: request_options
744
782
  )
745
783
  begin
@@ -756,14 +794,19 @@ module Payabli
756
794
  end
757
795
  end
758
796
 
759
- # Refund a transaction that has settled and send money back to the account holder. If `amount` is omitted or set
760
- # to 0, performs a full refund. When a non-zero `amount` is provided, this endpoint performs a partial refund.
797
+ # Refund a transaction that has settled and send money back to the account holder. If `amount` is set to 0,
798
+ # performs a full refund. When a non-zero `amount` is provided, this endpoint performs a partial refund.
761
799
  #
762
800
  # This is the v2 version of the refund endpoint, and returns the unified response format. See [Pay In unified
763
801
  # response codes reference](/guides/pay-in-unified-response-codes-reference) for more information.
764
802
  #
803
+ # <Note>
804
+ # To refund a split-funded transaction, include split instructions in the request body. Omit the body for a
805
+ # standard refund.
806
+ # </Note>
807
+ #
765
808
  # @param request_options [Hash]
766
- # @param params [Hash]
809
+ # @param params [Payabli::Types::RefundV2Request]
767
810
  # @option request_options [String] :base_url
768
811
  # @option request_options [Hash{String => Object}] :additional_headers
769
812
  # @option request_options [Hash{String => Object}] :additional_query_parameters
@@ -779,6 +822,7 @@ module Payabli
779
822
  base_url: request_options[:base_url],
780
823
  method: "POST",
781
824
  path: "v2/MoneyIn/refund/#{URI.encode_uri_component(params[:trans_id].to_s)}/#{URI.encode_uri_component(params[:amount].to_s)}",
825
+ body: Payabli::Types::RefundV2Request.new(params).to_h,
782
826
  request_options: request_options
783
827
  )
784
828
  begin
@@ -18,8 +18,17 @@ module Payabli
18
18
  # When `autoCapture` is `true`, Payabli captures the transaction asynchronously after authorization. The response
19
19
  # confirms only that the transaction was authorized; it doesn't confirm that capture succeeded. To confirm
20
20
  # capture, listen for the
21
- # [`payout_transaction_approvedcaptured`](/developers/webhooks/payout-transaction-approved-captured) webhook
22
- # event.
21
+ # [`payout_transaction_approvedcaptured`](/developers/api-reference/webhooks-overview/payout-transaction-approved-captured)
22
+ # webhook event.
23
+ #
24
+ # If a velocity fraud alert is triggered, the endpoint returns a `202` response with `responseCode` `9051`, and
25
+ # the authorization is held for risk review rather than rejected. If a risk policy blocks the transaction, the
26
+ # endpoint returns a `422` response with `responseCode` `9005`, a terminal rejection.
27
+ #
28
+ # For check payouts, Payabli validates the remit (mailing) address at authorization. If the address fails
29
+ # deliverability validation, the endpoint returns a `422` response and doesn't charge the paypoint. Correct the
30
+ # address and re-authorize. Other payout rails (ACH, RTP, virtual card, wire, and managed payables) aren't
31
+ # affected.
23
32
  #
24
33
  # @param request_options [Hash]
25
34
  # @param params [Payabli::MoneyOut::Types::RequestOutAuthorize]
@@ -214,7 +223,11 @@ module Payabli
214
223
  end
215
224
 
216
225
  # Captures a single authorized payout transaction by ID. If the transaction was authorized with `autoCapture` set
217
- # to `true`, you don't need to call this endpoint to capture the transaction for processing.
226
+ # to `true`, you don't need to call this endpoint to capture the transaction for processing.
227
+ #
228
+ # If a velocity fraud alert is triggered, the endpoint returns a `202` response with `responseCode` `9051`, and
229
+ # the capture is held for risk review rather than rejected. If a risk policy blocks the transaction, the endpoint
230
+ # returns a `422` response with `responseCode` `9005`, a terminal rejection.
218
231
  #
219
232
  # @param request_options [Hash]
220
233
  # @param params [Hash]
@@ -321,6 +334,53 @@ module Payabli
321
334
  end
322
335
  end
323
336
 
337
+ # Renews an expired or expiring virtual card by extending its expiration date to a future month.
338
+ #
339
+ # The card must be a virtual card that hasn't been fully used. The new expiration date must be in `MM-YYYY` or
340
+ # `MM/YYYY` format and no more than 2 years and 363 days in the future. The card expires on the last day of the
341
+ # month you specify.
342
+ #
343
+ # On success, `referenceId` holds the renewed card's token (the card processor may issue a new token). The
344
+ # response reuses the standard payout result object, so the payment-transaction fields it carries don't apply to
345
+ # renewal and always return `null`.
346
+ #
347
+ # @param request_options [Hash]
348
+ # @param params [Payabli::MoneyOut::Types::RenewVCardRequest]
349
+ # @option request_options [String] :base_url
350
+ # @option request_options [Hash{String => Object}] :additional_headers
351
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
352
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
353
+ # @option request_options [Integer] :timeout_in_seconds
354
+ # @option params [String] :card_token
355
+ #
356
+ # @return [Payabli::Types::RenewVCardResponse]
357
+ def renew_v_card(request_options: {}, **params)
358
+ params = Payabli::Internal::Types::Utils.normalize_keys(params)
359
+ request_data = Payabli::MoneyOut::Types::RenewVCardRequest.new(params).to_h
360
+ non_body_param_names = %w[cardToken]
361
+ body = request_data.except(*non_body_param_names)
362
+
363
+ request = Payabli::Internal::JSON::Request.new(
364
+ base_url: request_options[:base_url],
365
+ method: "PUT",
366
+ path: "MoneyOutCard/vcard/#{URI.encode_uri_component(params[:card_token].to_s)}/renew",
367
+ body: body,
368
+ request_options: request_options
369
+ )
370
+ begin
371
+ response = @client.send(request)
372
+ rescue Net::HTTPRequestTimeout
373
+ raise Payabli::Errors::TimeoutError
374
+ end
375
+ code = response.code.to_i
376
+ if code.between?(200, 299)
377
+ Payabli::Types::RenewVCardResponse.load(response.body)
378
+ else
379
+ error_class = Payabli::Errors::ResponseError.subclass_for_code(code)
380
+ raise error_class.new(response.body, code: code)
381
+ end
382
+ end
383
+
324
384
  # Sends a virtual card link via email to the vendor associated with the `transId`.
325
385
  #
326
386
  # @param request_options [Hash]
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Payabli
4
+ module MoneyOut
5
+ module Types
6
+ class RenewVCardRequest < Internal::Types::Model
7
+ field :card_token, -> { String }, optional: false, nullable: false, api_name: "cardToken"
8
+
9
+ field :expiration_date, -> { String }, optional: false, nullable: false, api_name: "expirationDate"
10
+ end
11
+ end
12
+ end
13
+ end