You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.2 KiB
35 lines
1.2 KiB
import stripe
|
|
import json
|
|
from app import create_app, db
|
|
from models import *
|
|
from sqlalchemy import and_
|
|
api_key = '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'
|
|
stripe.api_key = api_key
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = create_app()
|
|
print(f"api_key: {api_key}")
|
|
|
|
|
|
with app.app_context():
|
|
to_check = {
|
|
"pay": db.session.query(Payments).filter(and_(Payments.Stripe_Charge_ID == None, Payments.Payment_Intent != None)).all(),
|
|
"singlepay": db.session.query(SinglePayments).filter(and_(SinglePayments.Stripe_Charge_ID == None, SinglePayments.Payment_Intent != None)).all(),
|
|
}
|
|
|
|
for key, value in to_check.items():
|
|
|
|
|
|
for pi in value:
|
|
print(f"PI: {pi.Payment_Intent}")
|
|
res = stripe.PaymentIntent.retrieve(
|
|
pi.Payment_Intent,
|
|
expand=['latest_charge.balance_transaction']
|
|
)
|
|
if res.get('latest_charge') and res.get('latest_charge').get('id').startswith('ch_'):
|
|
pi.Stripe_Charge_ID = res.get('latest_charge').get('id')
|
|
db.session.commit()
|