def get_transaction_data(): # Get POST data try: data = json.loads(request.data) except JSONDecodeError: return abort(403) if 'api_secret' not in data or config_file['API_SECRET'] != data[ 'api_secret']: return abort(403) # Initilialize webpay configure_webpay() # ACK the transaction try: response = Transaction.commit(token=data['token']) except TransactionCommitError: # On error, return the status of the token try: response = Transaction.status(token=data['token']) except TransactionStatusError as e: # Invalid token return {"response_code": -1, "reason": e.message} return json.dumps(response, default=lambda x: x.__dict__)
def status(cls, token: str, options: Options = None) -> TransactionStatusResponse: return T.status(token, cls.build_options(options))