Skip to content

Commit

Permalink
Merge pull request #114 from mdwiltfong/mdwiltfong/issue106
Browse files Browse the repository at this point in the history
Mdwiltfong/issue106
  • Loading branch information
mdwiltfong authored Apr 18, 2022
2 parents c5b0f20 + eefc8ff commit 1cc941c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
14 changes: 9 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def handle_quote():
payment_method_types=["bancontact", "card", "ideal"],
stripe_account=session["account_id"]
)

session["setupIntent_id"]=setupIntent["id"]

session["client_secret"]=setupIntent['client_secret']
except Exception as e:
Expand All @@ -220,11 +220,15 @@ def checkout():
session["quote_id"],
stripe_account=session["account_id"]
)
stripe.Invoice.finalize_invoice(
quoteResp["invoice"],
auto_advance=True,
setup_intent=stripe.SetupIntent.retrieve(session["setupIntent_id"],stripe_account=session["account_id"])

stripe.Customer.modify(
session["student_id"],
invoice_settings={
"default_payment_method":setup_intent.payment_method
},
stripe_account=session["account_id"]
)
)
return redirect("/")

@app.route("/teacher/<account_id>/profile",methods=["GET","POST"])
Expand Down
30 changes: 7 additions & 23 deletions static/checkout.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
let stripe, clientSecret, elements, cardElement;
const DOMAIN = window.location.href;
window.addEventListener("DOMContentLoaded", () => {
getConfig().then(() => {
const appearance = {
iconStyle: "solid",
style: {
base: {
iconColor: "#fff",
color: "#fff",
fontWeight: 400,
fontFamily: "Helvetica Neue, Helvetica, Arial, sans-serif",
fontSize: "16px",
fontSmoothing: "antialiased",

"::placeholder": {
color: "#BFAEF6",
},
":-webkit-autofill": {
color: "white",
},
},
invalid: {
iconColor: "#FFC7EE",
color: "#FFC7EE",
},
theme: "stripe",
variables: {
colorText: "#cdd0f8",
colorDanger: "#16db93",
},
};

Expand All @@ -47,7 +31,7 @@ const setMessage = (message) => {
const messageDiv = document.querySelector("#messages");
if (message.error) {
messageDiv.className += " w-25 alert alert-danger";
messageDiv.innerHTML += message.error.message;
messageDiv.innerHTML += message.error.type;
} else {
messageDiv.className = "w-25 alert alert-success";
messageDiv.innerHTML += message;
Expand All @@ -61,7 +45,7 @@ form.addEventListener("submit", async (e) => {
.confirmSetup({
elements,
confirmParams: {
return_url: "/checkout_successful",
return_url: new URL("/checkout_successful", DOMAIN).toString(),
},
})
.then((result) => {
Expand Down
7 changes: 5 additions & 2 deletions templates/invoice_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ <h1 class="display-1 text-center">Send a Quote</h1>
</div>

{% endfor %}
<button type="submit" class="btn btn-success btn-lg">Submit</button>
<a href="/teacher/{{teacher.account_id}}/profile" class="btn btn-danger btn-lg">Cancel</a>
<div class="mt-3">
<button type="submit" class="btn btn-success btn-lg">Submit</button>
<a href="/teacher/{{teacher.account_id}}/profile" class="btn btn-danger btn-lg">Cancel</a>

</div>
</form>
</div>
</div>
Expand Down
15 changes: 12 additions & 3 deletions templates/teacher_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,18 @@ <h6>Send another <a href="/teacher/invoice">quote</a></h6>
</div>
</li>
{% else %}
<li class="list-group-item">{{student.name}} ({{student.email}}) <div
class="badge alert-primary d-inline">Enrollment:
{{student.subscription_status}}</div>
<li class="list-group-item">
{{student.name}} ({{student.email}})
{% if student.subscription_status == 'active' %}
<div class="badge alert-primary d-inline">
Enrollment:{{student.subscription_status}}
</div>
{% else %}
<div class="badge alert-danger d-inline">
Enrollment:{{student.subscription_status}}
</div>
{% endif %}

</li>

{% endif %}
Expand Down
Binary file modified tmp.pdf
Binary file not shown.

0 comments on commit 1cc941c

Please sign in to comment.