from api import Tronscan from custom_decorators import singleton from utils.datetime import current_timestamp @singleton class Payment: def __init__(self, api_key): self.tronscan = Tronscan(api_key) def check_payment(self, quant, from_address, to_address, order_create_timestamp): result = self.tronscan.token_trc20_transfers(from_address=from_address, to_address=to_address, start_timestamp=order_create_timestamp, end_timestamp=int(current_timestamp() * 1000)) token_transfers = result['token_transfers'] token_transfer = token_transfers[-1] confirmed = token_transfer['confirmed'] correct_quant = quant == (token_transfer['quant'] / 6) confirmed = confirmed and correct_quant return confirmed