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 charge_stripe_order_payment(form): order = TicketingManager.get_and_set_expiry(form['identifier']) order.stripe_token = form['stripe_token_id'] save_to_db(order) charge = StripePaymentsManager.capture_payment(order) if charge: order.paid_via = 'stripe' order.payment_mode = charge.source.object order.brand = charge.source.brand order.exp_month = charge.source.exp_month order.exp_year = charge.source.exp_year order.last4 = charge.source.last4 order.transaction_id = charge.id order.status = 'completed' order.completed_at = datetime.utcnow() save_to_db(order) invoice_id = order.get_invoice_number() order_url = url_for('ticketing.view_order_after_payment', order_identifier=order.identifier, _external=True) trigger_after_purchase_notifications(order.user.email, order.event_id, order.event, invoice_id, order_url) send_email_for_after_purchase(order.user.email, invoice_id, order_url, order.event.name, order.event.organizer_name) send_notif_for_after_purchase(order.user, invoice_id, order_url) return True, order else: return False, 'Error'
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'
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'