示例#1
0
def stripe_payment_refunded(payment: StripePayment):
    if payment.state == "refunded":
        logger.info("Payment is already refunded, ignoring")
        return

    logger.info("Setting payment %s to refunded", payment.id)

    # Payment is already locked by the caller of stripe_update_payment
    with db.session.no_autoflush:
        for purchase in payment.purchases:
            purchase.refund_purchase()

    payment.state = "refunded"
    db.session.commit()

    if not app.config.get("TICKETS_NOTICE_EMAIL"):
        app.logger.warning("No tickets notice email configured, not sending")
        return

    msg = Message(
        "An EMF payment has been refunded",
        sender=app.config.get("TICKETS_EMAIL"),
        recipients=[app.config.get("TICKETS_NOTICE_EMAIL")[1]],
    )
    msg.body = render_template("emails/notice-payment-refunded.txt",
                               payment=payment)
    mail.send(msg)
示例#2
0
文件: stripe.py 项目: dpslwk/Website
def stripe_payment_refunded(payment: StripePayment):
    # Email user
    msg = Message(
        "You have received a refund from EMF",
        sender=app.config.get("TICKETS_EMAIL"),
        recipients=[payment.user.email],
    )
    msg.body = render_template("emails/stripe-refund-sent.txt",
                               user=payment.user,
                               payment=payment)
    mail.send(msg)

    if payment.state == "refunded":
        logger.info("Payment is already refunded, ignoring")
        return

    logger.info("Setting payment %s to refunded", payment.id)

    # Payment is already locked by the caller of stripe_update_payment
    with db.session.no_autoflush:
        for purchase in payment.purchases:
            purchase.refund_purchase()

    payment.state = "refunded"
    db.session.commit()

    ticket_admin_email(
        "Unexpected Stripe refund received",
        "emails/notice-payment-refunded.txt",
        payment=payment,
    )
示例#3
0
def stripe_payment_refunded(payment: StripePayment):
    if payment.state in ("refunded", "refunding"):
        logger.info(
            f"Payment {payment.id} is {payment.state}, ignoring refund webhook"
        )
        return

    logger.info("Setting payment %s to refunded", payment.id)

    # Payment is already locked by the caller of stripe_update_payment
    with db.session.no_autoflush:
        for purchase in payment.purchases:
            purchase.refund_purchase()

    payment.state = "refunded"
    db.session.commit()

    ticket_admin_email(
        "Unexpected Stripe refund received",
        "emails/notice-payment-refunded.txt",
        payment=payment,
    )