Updated charge close to working
This commit is contained in:
@@ -3,6 +3,7 @@ from app.payment import payment
|
||||
from app import db
|
||||
from app.classes.customer import Customer_Customer
|
||||
from app.classes.cards import Card_Card, Card_Card_schema
|
||||
from app.classes.transactions import Transaction
|
||||
|
||||
|
||||
|
||||
@@ -233,4 +234,46 @@ def update_user_card(card_id):
|
||||
db.session.add(get_card)
|
||||
db.session.commit()
|
||||
|
||||
return jsonify({"ok": True}), 200
|
||||
return jsonify({"ok": True}), 200
|
||||
|
||||
|
||||
@payment.route("/transactions/authorize/<int:page>", methods=["GET"])
|
||||
def get_authorize_transactions(page):
|
||||
"""
|
||||
Gets transactions with transaction_type = 0 (charge), for the authorize page
|
||||
"""
|
||||
try:
|
||||
per_page = 50
|
||||
offset = (page - 1) * per_page
|
||||
|
||||
query = (
|
||||
db.session
|
||||
.query(Transaction, Customer_Customer)
|
||||
.join(Customer_Customer, Transaction.customer_id == Customer_Customer.id)
|
||||
.order_by(Transaction.created_at.desc())
|
||||
.offset(offset)
|
||||
.limit(per_page)
|
||||
)
|
||||
|
||||
results = query.all()
|
||||
|
||||
transactions_data = []
|
||||
for transaction, customer in results:
|
||||
transactions_data.append({
|
||||
"id": transaction.id,
|
||||
"preauthorize_amount": transaction.preauthorize_amount,
|
||||
"charge_amount": transaction.charge_amount,
|
||||
"transaction_type": transaction.transaction_type,
|
||||
"status": transaction.status,
|
||||
"customer_name": f"{customer.customer_first_name} {customer.customer_last_name}",
|
||||
"created_at": transaction.created_at.isoformat(),
|
||||
"auth_net_transaction_id": transaction.auth_net_transaction_id,
|
||||
"rejection_reason": transaction.rejection_reason,
|
||||
"delivery_id": transaction.delivery_id,
|
||||
"service_id": transaction.service_id,
|
||||
})
|
||||
|
||||
return jsonify(transactions_data), 200
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e)}), 500
|
||||
|
||||
Reference in New Issue
Block a user