Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Paypal Adaptive API support for Django
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A trivial example for now:


    from buzzcar.accounting.views import view_that_asks_for_money
    from django.conf.urls.defaults import patterns, url, include
    urlpatterns = patterns('',
        url(r'^payment/$', view_that_asks_for_money, name="payment"),
        url(r'^paypal/', include('paypaladaptive.urls')),

    from django.contrib.auth.decorators import login_required
    from django.http import HttpResponseServerError, HttpResponseRedirect
    from django.shortcuts import render_to_response
    from django.template.context import RequestContext
    from django.views.decorators.http import require_GET
    from money.Money import Money
    from paypaladaptive import settings, forms
    from paypaladaptive.models import Payment
    import logging
    logger = logging.getLogger(__name__)
    def view_that_asks_for_money(request):
        payment = Payment(amount=Money('5.00'), purchaser=request.user)
        if not payment.process(request):
            # TODO: unable to process payment
            logger.error('Payment returned error during processing: %s' % payment.status_detail)
            return HttpResponseServerError("Unexpected error")
        if not settings.USE_EMBEDDED:
            return HttpResponseRedirect(payment.next_url())
        form = forms.PayPalAdaptiveEmbeddedForm(payment.pay_key)
        context = RequestContext(request)
        template_vars = {"form": form}
        return render_to_response("payment.html", template_vars, context)

templates/payment.html (not showing inheritance):

    <h1>Show me the money!</h1>
    <!-- writes out the form tag automatically -->
    {{ form.render }}
Something went wrong with that request. Please try again.