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)
def charge_paypal_invoice_payment(invoice): payment_details = PayPalPaymentsManager \ .get_approved_payment_details(invoice, credentials=PayPalPaymentsManager.get_credentials()) if 'PAYERID' in payment_details: capture_result = PayPalPaymentsManager \ .capture_payment(invoice, payment_details['PAYERID'], credentials=PayPalPaymentsManager.get_credentials()) if capture_result['ACK'] == 'Success': invoice.paid_via = 'paypal' invoice.status = 'completed' invoice.transaction_id = capture_result['PAYMENTINFO_0_TRANSACTIONID'] invoice.completed_at = datetime.utcnow() save_to_db(invoice) return True, invoice else: return False, capture_result['L_SHORTMESSAGE0'] else: return False, 'Payer ID missing. Payment flow tampered.'
def charge_paypal_invoice_payment(invoice): payment_details = PayPalPaymentsManager\ .get_approved_payment_details(invoice, credentials=PayPalPaymentsManager.get_credentials()) if 'PAYERID' in payment_details: capture_result = PayPalPaymentsManager\ .capture_payment(invoice, payment_details['PAYERID'], credentials=PayPalPaymentsManager.get_credentials()) if capture_result['ACK'] == 'Success': invoice.paid_via = 'paypal' invoice.status = 'completed' invoice.transaction_id = capture_result[ 'PAYMENTINFO_0_TRANSACTIONID'] invoice.completed_at = datetime.utcnow() save_to_db(invoice) return True, invoice else: return False, capture_result['L_SHORTMESSAGE0'] else: return False, 'Payer ID missing. Payment flow tampered.'