def view_invoice(invoice_identifier):
    invoice = InvoicingManager.get_invoice_by_identifier(invoice_identifier)
    if not invoice:
        abort(404)
    if invoice.status == 'completed':
        return redirect(
            url_for('event_invoicing.view_invoice_after_payment',
                    invoice_identifier=invoice_identifier))

    pay_by_stripe = False
    pay_by_paypal = False

    stripe_publishable_key = "No Key Set"

    if StripePaymentsManager.get_credentials():
        pay_by_stripe = True
        stripe_publishable_key = StripePaymentsManager.get_credentials(
        )['PUBLISHABLE_KEY']

    if PayPalPaymentsManager.get_credentials():
        pay_by_paypal = True

    return render_template(
        'gentelella/guest/invoicing/invoice_pre_payment.html',
        invoice=invoice,
        event=invoice.event,
        countries=list(pycountry.countries),
        pay_by_stripe=pay_by_stripe,
        pay_by_paypal=pay_by_paypal,
        stripe_publishable_key=stripe_publishable_key)
def view_invoice(invoice_identifier):
    invoice = InvoicingManager.get_invoice_by_identifier(invoice_identifier)
    if not invoice:
        abort(404)
    if invoice.status == 'completed':
        return redirect(
            url_for('event_invoicing.view_invoice_after_payment', invoice_identifier=invoice_identifier))

    pay_by_stripe = False
    pay_by_paypal = False

    stripe_publishable_key = "No Key Set"

    if StripePaymentsManager.get_credentials():
        pay_by_stripe = True
        stripe_publishable_key = StripePaymentsManager.get_credentials()['PUBLISHABLE_KEY']

    if PayPalPaymentsManager.get_credentials():
        pay_by_paypal = True

    return render_template('gentelella/guest/invoicing/invoice_pre_payment.html', invoice=invoice, event=invoice.event,
                           countries=list(pycountry.countries),
                           pay_by_stripe=pay_by_stripe,
                           pay_by_paypal=pay_by_paypal,
                           stripe_publishable_key=stripe_publishable_key)
Ejemplo n.º 3
0
    def charge_stripe_invoice_payment(form):
        invoice = InvoicingManager.get_invoice_by_identifier(form['identifier'])
        invoice.stripe_token = form['stripe_token_id']
        save_to_db(invoice)

        charge = StripePaymentsManager.capture_payment(invoice, credentials=StripePaymentsManager.get_credentials())
        if charge:
            invoice.paid_via = 'stripe'
            invoice.payment_mode = charge.source.object
            invoice.brand = charge.source.brand
            invoice.exp_month = charge.source.exp_month
            invoice.exp_year = charge.source.exp_year
            invoice.last4 = charge.source.last4
            invoice.transaction_id = charge.id
            invoice.status = 'completed'
            invoice.completed_at = datetime.utcnow()
            save_to_db(invoice)

            return True, invoice
        else:
            return False, 'Error'
Ejemplo n.º 4
0
    def charge_stripe_invoice_payment(form):
        invoice = InvoicingManager.get_invoice_by_identifier(
            form['identifier'])
        invoice.stripe_token = form['stripe_token_id']
        save_to_db(invoice)

        charge = StripePaymentsManager.capture_payment(
            invoice, credentials=StripePaymentsManager.get_credentials())
        if charge:
            invoice.paid_via = 'stripe'
            invoice.payment_mode = charge.source.object
            invoice.brand = charge.source.brand
            invoice.exp_month = charge.source.exp_month
            invoice.exp_year = charge.source.exp_year
            invoice.last4 = charge.source.last4
            invoice.transaction_id = charge.id
            invoice.status = 'completed'
            invoice.completed_at = datetime.utcnow()
            save_to_db(invoice)

            return True, invoice
        else:
            return False, 'Error'