• Home
  • Get started
  • Documentation
  • Source
  • License
  • About
reahl

reahl

Power tools for Python development

Gallery

  • Navigation
  • Form
  • Table
  • Chart
  • Payment
  • Other

PayPal Payment

An actual $1 donation is made to Reahl if you complete the process!
def create_paypal_button(self, view):
    cart = ShoppingCart.for_current_session()
    paypal_order = cart.get_paypal_order()

    if paypal_order.is_due_for_payment:
        div = Div(view)
        warning = 'An actual $1 donation is made to Reahl if you complete the process!'
        div.add_child(Alert(view, warning, 'danger'))

        is_paypal_sandbox = False
        credentials = PayPalClientCredentials(self.username,
                                              self.password,
                                              is_paypal_sandbox)

        buttons = PayPalButtonsPanel(view,
                                    'paypal_buttons',
                                    paypal_order,
                                    credentials,
                                    cart.paypal_currency_code)
        div.add_child(buttons)
        return div
    elif paypal_order.is_paid:
        form = Form(view, 'success_form')
        form.add_child(Alert(view, 'Thank you! Your order has been paid successfully', 'primary'))
        self.define_event_handler(cart.events.clear_event)
        form.add_child(Button(form, cart.events.clear_event, style='primary'))
        return form
    else:
        error_message = 'We could not complete your payment at PayPal (Order status: %s)' % paypal_order.status
        return Alert(view, error_message, 'danger')

Copyright © 2006-2023 Reahl Software Services (Pty) Ltd

Running on Reahl