Add kredits API with wallet balance endpoint
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
5
app/controllers/api/base_controller.rb
Normal file
5
app/controllers/api/base_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Api::BaseController < ApplicationController
|
||||
|
||||
layout false
|
||||
|
||||
end
|
||||
12
app/controllers/api/kredits_controller.rb
Normal file
12
app/controllers/api/kredits_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Api::KreditsController < Api::BaseController
|
||||
|
||||
def onchain_btc_balance
|
||||
btcpay = BtcPay.new
|
||||
balance = btcpay.onchain_wallet_balance
|
||||
render json: balance
|
||||
rescue
|
||||
render json: { error: 'Failed to fetch wallet balance' },
|
||||
status: 500
|
||||
end
|
||||
|
||||
end
|
||||
@@ -9,12 +9,12 @@ class BtcPay
|
||||
end
|
||||
|
||||
def onchain_wallet_balance
|
||||
wallet_info = get "stores/#{@store_id}/payment-methods/onchain/BTC/wallet"
|
||||
res = get "stores/#{@store_id}/payment-methods/onchain/BTC/wallet"
|
||||
|
||||
{
|
||||
balance: wallet_info["balance"].to_f,
|
||||
unconfirmed_balance: wallet_info["unconfirmedBalance"].to_f,
|
||||
confirmed_balance: wallet_info["confirmedBalance"].to_f
|
||||
balance: res["balance"].to_f,
|
||||
unconfirmed_balance: res["unconfirmedBalance"].to_f,
|
||||
confirmed_balance: res["confirmedBalance"].to_f
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user