Browse Source

bug fix: stripe should take in proper values

control 3 years ago
parent
commit
dacca27fcd
5 changed files with 9 additions and 4 deletions
  1. 3 1
      app/dashboards.py
  2. BIN
      app/database.db
  3. 4 1
      app/dispatch.py
  4. 1 1
      app/templates/charge.html
  5. 1 1
      app/templates/checkout.html

+ 3 - 1
app/dashboards.py

@@ -56,9 +56,12 @@ def profile():
 
 
     # Wallet Top Up Form
+    ##:
     if form3.validate_on_submit():
         amount = form3.amount.data
         raw_amount = int(amount*100) # converting to cents int for Stripe
+        # save to db
+        dispatch.save_tx(current_user.id, raw_amount)
 
         if amount: # Send to stripe checkout
             # render a checkout page for Stripe
@@ -220,7 +223,6 @@ def detail():
 @login_required
 def charge():
     # Stripe charge POST request method
-
     # Amount in cents
     dbc_stripe = Stripe.query.filter_by(user_id = current_user.id).order_by(Stripe.id.desc()).first()
     raw_amount = dbc_stripe.raw_amount

BIN
app/database.db


+ 4 - 1
app/dispatch.py

@@ -214,13 +214,16 @@ def init_wallet(user_id):
         db.session.add(dbc_ntable)
         db.session.commit()
 
-def top_up(user_id, raw_amount):
+def save_tx(user_id, raw_amount):
     # add to Stripe top up transaction table
     dbc_ntable = Stripe(
         user_id = user_id,
         raw_amount = raw_amount,
         )
     db.session.add(dbc_ntable)
+    db.session.commit()
+
+def top_up(user_id, raw_amount):
     # Append to user Wallet amount
     dbc_wallet = Wallet.query.filter_by(user_id = user_id).first()
     dbc_wallet.amount += raw_amount # converted to dollars float in db

+ 1 - 1
app/templates/charge.html

@@ -2,6 +2,6 @@
 
 {% block content %}
 
-<h2>Thanks, you'r ready to bid!</h2>
+<h2>Thanks, you're ready to bid! Good luck!</h2>
 
 {% endblock %}

+ 1 - 1
app/templates/checkout.html

@@ -15,7 +15,7 @@
     <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
           data-key="{{ key }}"
           data-description="artFi Exchange Deposit"
-          data-amount="{{ raw_amount }}"
+          data-amount="{{ ramount }}"
           data-locale="auto">
     </script>
 </form>