Removes test transaction UI button
Removes the test transaction button from the admin UI. The test transaction endpoint is still available in the API for development and debugging purposes.
This commit is contained in:
parent
9c2a1f7d4a
commit
e7b6d261f7
2 changed files with 64 additions and 71 deletions
|
|
@ -356,16 +356,6 @@
|
|||
<q-tooltip>Process specific transaction by ID (bypasses dispense checks)</q-tooltip>
|
||||
Manual TX
|
||||
</q-btn>
|
||||
<q-btn
|
||||
v-if="lamassuConfig && lamassuConfig.source_wallet_id"
|
||||
size="sm"
|
||||
color="warning"
|
||||
@click="testTransaction"
|
||||
:loading="runningTestTransaction"
|
||||
class="q-ml-sm"
|
||||
>
|
||||
Test Transaction
|
||||
</q-btn>
|
||||
</div>
|
||||
</q-card-section>
|
||||
</q-expansion-item>
|
||||
|
|
|
|||
125
views_api.py
125
views_api.py
|
|
@ -300,67 +300,70 @@ async def api_process_specific_transaction(
|
|||
)
|
||||
|
||||
|
||||
@satmachineadmin_api_router.post("/api/v1/dca/test-transaction")
|
||||
async def api_test_transaction(
|
||||
user: User = Depends(check_super_user),
|
||||
crypto_atoms: int = 103,
|
||||
commission_percentage: float = 0.03,
|
||||
discount: float = 0.0,
|
||||
) -> dict:
|
||||
"""Test transaction processing with simulated Lamassu transaction data"""
|
||||
try:
|
||||
from .transaction_processor import transaction_processor
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
|
||||
# Create a mock transaction that mimics Lamassu database structure
|
||||
mock_transaction = {
|
||||
"transaction_id": str(uuid.uuid4())[:8], # Short ID for testing
|
||||
"crypto_amount": crypto_atoms, # Total sats including commission
|
||||
"fiat_amount": 100, # Mock fiat amount (100 centavos = 1 GTQ)
|
||||
"commission_percentage": commission_percentage, # Already as decimal
|
||||
"discount": discount,
|
||||
"transaction_time": datetime.now(timezone.utc),
|
||||
"crypto_code": "BTC",
|
||||
"fiat_code": "GTQ",
|
||||
"device_id": "test_device",
|
||||
"status": "confirmed",
|
||||
}
|
||||
|
||||
# Process the mock transaction through the complete DCA flow
|
||||
await transaction_processor.process_transaction(mock_transaction)
|
||||
|
||||
# Calculate commission for response
|
||||
if commission_percentage > 0:
|
||||
effective_commission = commission_percentage * (100 - discount) / 100
|
||||
base_crypto_atoms = int(crypto_atoms / (1 + effective_commission))
|
||||
commission_amount_sats = crypto_atoms - base_crypto_atoms
|
||||
else:
|
||||
base_crypto_atoms = crypto_atoms
|
||||
commission_amount_sats = 0
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"message": "Test transaction processed successfully",
|
||||
"transaction_details": {
|
||||
"transaction_id": mock_transaction["transaction_id"],
|
||||
"total_amount_sats": crypto_atoms,
|
||||
"base_amount_sats": base_crypto_atoms,
|
||||
"commission_amount_sats": commission_amount_sats,
|
||||
"commission_percentage": commission_percentage
|
||||
* 100, # Show as percentage
|
||||
"effective_commission": effective_commission * 100
|
||||
if commission_percentage > 0
|
||||
else 0,
|
||||
"discount": discount,
|
||||
},
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||
detail=f"Error processing test transaction: {str(e)}",
|
||||
)
|
||||
# COMMENTED OUT FOR PRODUCTION - Test transaction endpoint disabled
|
||||
# Uncomment only for development/debugging purposes
|
||||
#
|
||||
# @satmachineadmin_api_router.post("/api/v1/dca/test-transaction")
|
||||
# async def api_test_transaction(
|
||||
# user: User = Depends(check_super_user),
|
||||
# crypto_atoms: int = 103,
|
||||
# commission_percentage: float = 0.03,
|
||||
# discount: float = 0.0,
|
||||
# ) -> dict:
|
||||
# """Test transaction processing with simulated Lamassu transaction data"""
|
||||
# try:
|
||||
# from .transaction_processor import transaction_processor
|
||||
# import uuid
|
||||
# from datetime import datetime, timezone
|
||||
#
|
||||
# # Create a mock transaction that mimics Lamassu database structure
|
||||
# mock_transaction = {
|
||||
# "transaction_id": str(uuid.uuid4())[:8], # Short ID for testing
|
||||
# "crypto_amount": crypto_atoms, # Total sats including commission
|
||||
# "fiat_amount": 100, # Mock fiat amount (100 centavos = 1 GTQ)
|
||||
# "commission_percentage": commission_percentage, # Already as decimal
|
||||
# "discount": discount,
|
||||
# "transaction_time": datetime.now(timezone.utc),
|
||||
# "crypto_code": "BTC",
|
||||
# "fiat_code": "GTQ",
|
||||
# "device_id": "test_device",
|
||||
# "status": "confirmed",
|
||||
# }
|
||||
#
|
||||
# # Process the mock transaction through the complete DCA flow
|
||||
# await transaction_processor.process_transaction(mock_transaction)
|
||||
#
|
||||
# # Calculate commission for response
|
||||
# if commission_percentage > 0:
|
||||
# effective_commission = commission_percentage * (100 - discount) / 100
|
||||
# base_crypto_atoms = int(crypto_atoms / (1 + effective_commission))
|
||||
# commission_amount_sats = crypto_atoms - base_crypto_atoms
|
||||
# else:
|
||||
# base_crypto_atoms = crypto_atoms
|
||||
# commission_amount_sats = 0
|
||||
#
|
||||
# return {
|
||||
# "success": True,
|
||||
# "message": "Test transaction processed successfully",
|
||||
# "transaction_details": {
|
||||
# "transaction_id": mock_transaction["transaction_id"],
|
||||
# "total_amount_sats": crypto_atoms,
|
||||
# "base_amount_sats": base_crypto_atoms,
|
||||
# "commission_amount_sats": commission_amount_sats,
|
||||
# "commission_percentage": commission_percentage
|
||||
# * 100, # Show as percentage
|
||||
# "effective_commission": effective_commission * 100
|
||||
# if commission_percentage > 0
|
||||
# else 0,
|
||||
# "discount": discount,
|
||||
# },
|
||||
# }
|
||||
#
|
||||
# except Exception as e:
|
||||
# raise HTTPException(
|
||||
# status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||
# detail=f"Error processing test transaction: {str(e)}",
|
||||
# )
|
||||
|
||||
|
||||
# Lamassu Transaction Endpoints
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue