Class: Payabli::MoneyOut::Client
- Inherits:
-
Object
- Object
- Payabli::MoneyOut::Client
- Defined in:
- lib/payabli/money_out/client.rb
Instance Method Summary collapse
-
#authorize_out(request_options: {}, **params) ⇒ Payabli::Types::AuthCapturePayoutResponse
Authorizes a transaction for payout.
-
#cancel_all_out(request_options: {}, **params) ⇒ Payabli::Types::CaptureAllOutResponse
Cancels an array of payout transactions.
-
#cancel_out_delete(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse0000
Cancel a payout transaction by ID.
-
#cancel_out_get(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse0000
Cancel a payout transaction by ID.
-
#capture_all_out(request_options: {}, **params) ⇒ Payabli::Types::CaptureAllOutResponse
Captures an array of authorized payout transactions for settlement.
-
#capture_out(request_options: {}, **params) ⇒ Payabli::Types::AuthCapturePayoutResponse
Captures a single authorized payout transaction by ID.
-
#get_check_image(request_options: {}, **params) ⇒ String
Retrieve the image of a check associated with a processed transaction.
- #initialize(client:) ⇒ void constructor
-
#payout_details(request_options: {}, **params) ⇒ Payabli::Types::BillDetailResponse
Returns details for a processed money out transaction.
-
#reissue_out(request_options: {}, **params) ⇒ Payabli::Types::ReissuePayoutResponse
Reissues a payout transaction with a new payment method.
-
#renew_v_card(request_options: {}, **params) ⇒ Payabli::Types::RenewVCardResponse
Renews an expired or expiring virtual card by extending its expiration date to a future month.
-
#send_v_card_link(request_options: {}, **params) ⇒ Payabli::Types::OperationResult
Sends a virtual card link via email to the vendor associated with the
transId. -
#update_check_payment_status(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse00Responsedatanonobject
Updates the status of a processed check payment transaction.
-
#v_card_get(request_options: {}, **params) ⇒ Payabli::Types::VCardGetResponse
Retrieves vCard details for a single card in an entrypoint.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/money_out/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#authorize_out(request_options: {}, **params) ⇒ Payabli::Types::AuthCapturePayoutResponse
Authorizes a transaction for payout.
If you don't pass autoCapture with a value of true, authorized transactions aren't flagged for settlement
until captured. Use the referenceId returned in the response to capture the transaction.
When autoCapture is true, Payabli captures the transaction asynchronously after authorization. The response
confirms only that the transaction was authorized; it doesn't confirm that capture succeeded. To confirm
capture, listen for the
payout_transaction_approvedcaptured
webhook event.
If a velocity fraud alert is triggered, the endpoint returns a 202 response with responseCode 9051, and
the authorization is held for risk review rather than rejected. If a risk policy blocks the transaction, the
endpoint returns a 422 response with responseCode 9005, a terminal rejection.
For check payouts, Payabli validates the remit (mailing) address at authorization. If the address fails
deliverability validation, the endpoint returns a 422 response and doesn't charge the paypoint. Correct the
address and re-authorize. Other payout rails (ACH, RTP, virtual card, wire, and managed payables) aren't
affected.
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 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/payabli/money_out/client.rb', line 66 def (request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request_data = Payabli::MoneyOut::Types::RequestOutAuthorize.new(params).to_h non_body_param_names = %w[allowDuplicatedBills doNotCreateBills forceVendorCreation idempotencyKey] body = request_data.except(*non_body_param_names) query_params = {} query_params["allowDuplicatedBills"] = params[:allow_duplicated_bills] if params.key?(:allow_duplicated_bills) query_params["doNotCreateBills"] = params[:do_not_create_bills] if params.key?(:do_not_create_bills) query_params["forceVendorCreation"] = params[:force_vendor_creation] if params.key?(:force_vendor_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: [:base_url], method: "POST", path: "MoneyOut/authorize", headers: headers, query: query_params, body: body, 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::AuthCapturePayoutResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#cancel_all_out(request_options: {}, **params) ⇒ Payabli::Types::CaptureAllOutResponse
Cancels an array of payout transactions.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/payabli/money_out/client.rb', line 118 def cancel_all_out(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: [:base_url], method: "POST", path: "MoneyOut/cancelAll", headers: headers, body: params, 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::CaptureAllOutResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#cancel_out_delete(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse0000
Cancel a payout transaction by ID.
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/payabli/money_out/client.rb', line 197 def cancel_out_delete(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: [:base_url], method: "DELETE", path: "MoneyOut/cancel/#{URI.encode_uri_component(params[:reference_id].to_s)}", headers: headers, 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::PayabliApiResponse0000.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#cancel_out_get(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse0000
Cancel a payout transaction by ID.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/payabli/money_out/client.rb', line 158 def cancel_out_get(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: [:base_url], method: "GET", path: "MoneyOut/cancel/#{URI.encode_uri_component(params[:reference_id].to_s)}", headers: headers, 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::PayabliApiResponse0000.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#capture_all_out(request_options: {}, **params) ⇒ Payabli::Types::CaptureAllOutResponse
Captures an array of authorized payout transactions for settlement. The maximum number of transactions that can be captured in a single request is 500.
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 |
# File 'lib/payabli/money_out/client.rb', line 237 def capture_all_out(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) 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: [:base_url], method: "POST", path: "MoneyOut/captureAll", headers: headers, body: params, 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::CaptureAllOutResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#capture_out(request_options: {}, **params) ⇒ Payabli::Types::AuthCapturePayoutResponse
Captures a single authorized payout transaction by ID. If the transaction was authorized with autoCapture set
to true, you don't need to call this endpoint to capture the transaction for processing.
If a velocity fraud alert is triggered, the endpoint returns a 202 response with responseCode 9051, and
the capture is held for risk review rather than rejected. If a risk policy blocks the transaction, the endpoint
returns a 422 response with responseCode 9005, a terminal rejection.
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 |
# File 'lib/payabli/money_out/client.rb', line 286 def capture_out(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) 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: [:base_url], method: "GET", path: "MoneyOut/capture/#{URI.encode_uri_component(params[:reference_id].to_s)}", headers: headers, 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::AuthCapturePayoutResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_check_image(request_options: {}, **params) ⇒ String
Retrieve the image of a check associated with a processed transaction. The check image is returned in the response body as a base64-encoded string. The check image is only available for payouts that have been processed.
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/payabli/money_out/client.rb', line 502 def get_check_image(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: [:base_url], method: "GET", path: "MoneyOut/checkimage/#{URI.encode_uri_component(params[:asset_name].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#payout_details(request_options: {}, **params) ⇒ Payabli::Types::BillDetailResponse
Returns details for a processed money out transaction.
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/payabli/money_out/client.rb', line 328 def payout_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: [:base_url], method: "GET", path: "MoneyOut/details/#{URI.encode_uri_component(params[:trans_id].to_s)}", headers: headers, 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::BillDetailResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#reissue_out(request_options: {}, **params) ⇒ Payabli::Types::ReissuePayoutResponse
Reissues a payout transaction with a new payment method. This creates a new transaction linked to the original and marks the original transaction as reissued.
The original transaction must be in Processing or Processed status. The payment method in the request body is used directly. The endpoint doesn't fall back to vendor-managed payment methods.
The new transaction goes through the standard authorize-and-capture flow automatically. Both the original and new transactions are linked through their event histories for audit purposes.
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
# File 'lib/payabli/money_out/client.rb', line 615 def reissue_out(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request_data = Payabli::MoneyOut::Types::ReissueOutRequest.new(params).to_h non_body_param_names = %w[transId idempotencyKey] body = request_data.except(*non_body_param_names) query_params = {} query_params["transId"] = params[:trans_id] if params.key?(:trans_id) 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: [:base_url], method: "POST", path: "MoneyOut/reissue", headers: headers, query: query_params, body: body, 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::ReissuePayoutResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#renew_v_card(request_options: {}, **params) ⇒ Payabli::Types::RenewVCardResponse
Renews an expired or expiring virtual card by extending its expiration date to a future month.
The card must be a virtual card that hasn't been fully used. The new expiration date must be in MM-YYYY or
MM/YYYY format and no more than 2 years and 363 days in the future. The card expires on the last day of the
month you specify.
On success, referenceId holds the renewed card's token (the card processor may issue a new token). The
response reuses the standard payout result object, so the payment-transaction fields it carries don't apply to
renewal and always return null.
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/payabli/money_out/client.rb', line 417 def renew_v_card(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request_data = Payabli::MoneyOut::Types::RenewVCardRequest.new(params).to_h non_body_param_names = %w[cardToken] body = request_data.except(*non_body_param_names) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "MoneyOutCard/vcard/#{URI.encode_uri_component(params[:card_token].to_s)}/renew", headers: headers, body: body, 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::RenewVCardResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#send_v_card_link(request_options: {}, **params) ⇒ Payabli::Types::OperationResult
Sends a virtual card link via email to the vendor associated with the transId.
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/payabli/money_out/client.rb', line 460 def send_v_card_link(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: [:base_url], method: "POST", path: "vcard/send-card-link", headers: headers, body: Payabli::MoneyOut::Types::SendVCardLinkRequest.new(params).to_h, 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::OperationResult.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_check_payment_status(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponse00Responsedatanonobject
Updates the status of a processed check payment transaction. This endpoint handles the status transition, updates related bills, creates audit events, and triggers notifications.
The transaction must meet all of the following criteria:
- Status: Must be in Processing or Processed status.
- Payment method: Must be a check payment method.
Allowed status values
| Value | Status | Description |
|---|---|---|
0 |
Cancelled/Voided | Cancels the check transaction. Reverts associated bills to their previous state |
(Approved or Active), creates "Cancelled" events, and sends a payout_transaction_voidedcancelled notification
if the notification is enabled. |
| 5 | Paid | Marks the check transaction as paid. Updates associated bills to "Paid" status, creates "Paid"
events, and sends a payout_transaction_paid notification if the notification is enabled. |
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
# File 'lib/payabli/money_out/client.rb', line 558 def update_check_payment_status(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: [:base_url], method: "PATCH", path: "MoneyOut/status/#{URI.encode_uri_component(params[:trans_id].to_s)}/#{URI.encode_uri_component(params[:check_payment_status].to_s)}", headers: headers, 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::PayabliApiResponse00Responsedatanonobject.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#v_card_get(request_options: {}, **params) ⇒ Payabli::Types::VCardGetResponse
Retrieves vCard details for a single card in an entrypoint.
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/payabli/money_out/client.rb', line 367 def v_card_get(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: [:base_url], method: "GET", path: "MoneyOut/vcard/#{URI.encode_uri_component(params[:card_token].to_s)}", headers: headers, 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::VCardGetResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |