sales.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:Tktr 作者: Intuity 项目源码 文件源码
def single_payment_view(self):
        payments = self.request.root.payments
        # Get payment if possible
        if not self.request.matchdict["ref_code"] in self.request.root.payments:
            return HTTPFound(location=self.request.route_path("admin_payments"))
        payment = payments[self.request.matchdict["ref_code"]]
        if "action" in self.request.GET:
            if self.request.GET["action"] == "recalculate":
                if payment.method == "stripe":
                    payment.processing = int(payment.item_total * self.stripe_percentage)
                    payment.total = int(payment.item_total * (1 + self.stripe_percentage))
                else:
                    payment.processing = 0
                    payment.total = payment.item_total
                self.request.session.flash("Recalculated the payment total.", "info")
            elif self.request.GET["action"] == "emailconfirm":
                PurchaseConfirmationEmail(self.request).compose_and_send(payment.ref_code)
                self.request.session.flash("A payment confirmation has been sent via email.", "info")
            elif self.request.GET["action"] == "sendtickets":
                emailer = GenericEmail(self.request)
                emailer.compose_and_send(
                    "Event Tickets",
                    """Please find the tickets you purchased in payment %s attached as a PDF to this email. Please download and print-out the tickets and bring them with you to the event.""" % (payment.ref_code),
                    payment.owner.__name__,
                    pdf_attachment=TicketDownload(self.request).payment_tickets_pdf(payment)
                )
                self.request.session.flash("The tickets in this payment have been sent via email.", "info")

        return {
            "payment": payment,
        }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号