Module: NOWPayments::API::Payouts

Included in:
Client
Defined in:
lib/nowpayments/api/payouts.rb

Overview

Payout and mass payout endpoints (requires JWT auth)

Instance Method Summary collapse

Instance Method Details

#balanceHash

Get account balance GET /v1/balance

Returns:

  • (Hash)

    Balance information with available and pending amounts per currency



10
11
12
# File 'lib/nowpayments/api/payouts.rb', line 10

def balance
  get("balance").body
end

#create_payout(withdrawals:, payout_description: nil, ipn_callback_url: nil) ⇒ Hash

Create payout POST /v1/payout Note: This endpoint requires JWT authentication

Parameters:

  • withdrawals (Array<Hash>)

    Array of withdrawal objects Each withdrawal should have:

    • address (String, required): Crypto address

    • currency (String, required): Currency code

    • amount (Numeric, required): Amount to send

    • ipn_callback_url (String, optional): Individual callback URL

    • extra_id (String, optional): Payment extra ID (memo/tag)

    • fiat_amount (Numeric, optional): Fiat equivalent amount

    • fiat_currency (String, optional): Fiat currency code

    • unique_external_id (String, optional): External reference ID

    • payout_description (String, optional): Individual description

  • payout_description (String, nil) (defaults to: nil)

    Description for entire batch

  • ipn_callback_url (String, nil) (defaults to: nil)

    Callback URL for entire batch

Returns:

  • (Hash)

    Payout result



47
48
49
50
51
52
53
# File 'lib/nowpayments/api/payouts.rb', line 47

def create_payout(withdrawals:, payout_description: nil, ipn_callback_url: nil)
  params = { withdrawals: withdrawals }
  params[:payout_description] = payout_description if payout_description
  params[:ipn_callback_url] = ipn_callback_url if ipn_callback_url

  post("payout", body: params).body
end

#list_payouts(limit: 10, offset: 0) ⇒ Hash

List payouts with pagination GET /v1/payout

Parameters:

  • limit (Integer) (defaults to: 10)

    Results per page

  • offset (Integer) (defaults to: 0)

    Offset for pagination

Returns:

  • (Hash)

    List of payouts



79
80
81
82
83
84
# File 'lib/nowpayments/api/payouts.rb', line 79

def list_payouts(limit: 10, offset: 0)
  get("payout", params: {
        limit: limit,
        offset: offset
      }).body
end

#min_payout_amount(currency:) ⇒ Hash

Get minimum payout amount GET /v1/payout/min-amount

Parameters:

  • currency (String)

    Currency code

Returns:

  • (Hash)

    Minimum payout amount for currency



90
91
92
# File 'lib/nowpayments/api/payouts.rb', line 90

def min_payout_amount(currency:)
  get("payout/min-amount", params: { currency: currency }).body
end

#payout_fee(currency:, amount:) ⇒ Hash

Get payout fee estimate GET /v1/payout/fee

Parameters:

  • currency (String)

    Currency code

  • amount (Numeric)

    Payout amount

Returns:

  • (Hash)

    Fee estimate



99
100
101
102
103
104
# File 'lib/nowpayments/api/payouts.rb', line 99

def payout_fee(currency:, amount:)
  get("payout/fee", params: {
        currency: currency,
        amount: amount
      }).body
end

#payout_status(payout_id) ⇒ Hash

Get payout status GET /v1/payout/:payout_id

Parameters:

  • payout_id (String, Integer)

    Payout ID

Returns:

  • (Hash)

    Payout status and details



70
71
72
# File 'lib/nowpayments/api/payouts.rb', line 70

def payout_status(payout_id)
  get("payout/#{payout_id}").body
end

#validate_payout_address(address:, currency:, extra_id: nil) ⇒ Hash

Validate payout address POST /v1/payout/validate-address

Parameters:

  • address (String)

    Payout address to validate

  • currency (String)

    Currency code

  • extra_id (String, nil) (defaults to: nil)

    Optional memo/tag/destination tag

Returns:

  • (Hash)

    Validation result



20
21
22
23
24
25
26
27
28
# File 'lib/nowpayments/api/payouts.rb', line 20

def validate_payout_address(address:, currency:, extra_id: nil)
  params = {
    address: address,
    currency: currency
  }
  params[:extra_id] = extra_id if extra_id

  post("payout/validate-address", body: params).body
end

#verify_payout(batch_withdrawal_id:, verification_code:) ⇒ Hash

Verify payout with 2FA code POST /v1/payout/:batch_withdrawal_id/verify

Parameters:

  • batch_withdrawal_id (String, Integer)

    Batch withdrawal ID from create_payout

  • verification_code (String)

    2FA code from Google Auth app or email

Returns:

  • (Hash)

    Verification result



60
61
62
63
64
# File 'lib/nowpayments/api/payouts.rb', line 60

def verify_payout(batch_withdrawal_id:, verification_code:)
  post("payout/#{batch_withdrawal_id}/verify", body: {
         verification_code: verification_code
       }).body
end