Skip to the content.

Django Payments

Django Payments is a wrapper around many payment methods for django…

How to use

Configure your settings as follows:

#settings.py
def amount_generator_example(request: HttpRequest, *caller_view_args, **caller_view_kwargs):
    return request.session.get("cart_object", {}).get("total", 0)
def access_token_generator_example(request: HttpRequest, *caller_view_args, **caller_view_kwargs):
    return caller_view_kwargs.get("user").get("access_token", "access_token$sandbox$youraccesstoken")

INSTALLED_PLUGINS = {
    PLUGIN_NAME: {
        "version": "1.0.0",
        "agreement": "Agreement from settings",
        "amount": amount_generator_example, # Also could be a lambda
        "access_token": access_token_generator_example, # Also could be a lambda
        "context": {
            "urls_kwargs": {
                "var_identifier": lambda context: {
                    "url_var_for_reverser": "any data you want"
                }
            }
        }
    }
}

In the template use as follows you can include django form as using next parameters ‘paypal_buttons.html’ with total=”0.20” auth_token=”access_token” context_id=”same_that_in_your_settings”.