コード例 #1
0
ファイル: views.py プロジェクト: tydonk/pretix
def success(request, *args, **kwargs):
    pid = request.GET.get('paymentId')
    token = request.GET.get('token')
    payer = request.GET.get('PayerID')
    request.session['payment_paypal_token'] = token
    request.session['payment_paypal_payer'] = payer

    if request.session.get('payment_paypal_order'):
        order = Order.objects.get(pk=request.session.get('payment_paypal_order'))
    else:
        order = None

    if pid == request.session.get('payment_paypal_id', None):
        if order:
            prov = Paypal(request.event)
            resp = prov.payment_perform(request, order)
            if resp:
                return resp
    else:
        messages.error(request, _('Invalid response from PayPal received.'))
        logger.error('Session did not contain payment_paypal_id')
        return redirect(eventreverse(request.event, 'presale:event.checkout', kwargs={'step': 'payment'}))

    if order:
        return redirect(eventreverse(request.event, 'presale:event.order', kwargs={
            'order': order.code,
            'secret': order.secret
        }) + ('?paid=yes' if order.status == Order.STATUS_PAID else ''))
    else:
        return redirect(eventreverse(request.event, 'presale:event.checkout', kwargs={'step': 'confirm'}))
コード例 #2
0
ファイル: views.py プロジェクト: woakes070048/pretix
def success(request, organizer=None, event=None):
    pid = request.GET.get('paymentId')
    token = request.GET.get('token')
    payer = request.GET.get('PayerID')
    if pid == request.session.get('payment_paypal_id', None):
        request.session['payment_paypal_token'] = token
        request.session['payment_paypal_payer'] = payer
        try:
            event = Event.objects.get(
                id=request.session['payment_paypal_event'])
            if request.session.get('payment_paypal_order'):
                prov = Paypal(event)
                order = Order.objects.get(
                    pk=request.session.get('payment_paypal_order'))
                resp = prov.payment_perform(request, order)
                return redirect(resp or eventreverse(event,
                                                     'presale:event.order',
                                                     kwargs={
                                                         'order': order.code,
                                                         'secret': order.secret
                                                     }) + '?paid=yes')
            return redirect(
                eventreverse(event,
                             'presale:event.checkout',
                             kwargs={'step': 'confirm'}))
        except Event.DoesNotExist:
            pass  # TODO: Handle this
    else:
        pass  # TODO: Handle this
コード例 #3
0
ファイル: views.py プロジェクト: JRodDynamite/pretix
def success(request, organizer=None, event=None):
    pid = request.GET.get('paymentId')
    token = request.GET.get('token')
    payer = request.GET.get('PayerID')
    if pid == request.session.get('payment_paypal_id', None):
        request.session['payment_paypal_token'] = token
        request.session['payment_paypal_payer'] = payer
        try:
            event = Event.objects.get(id=request.session['payment_paypal_event'])
            if request.session.get('payment_paypal_order'):
                prov = Paypal(event)
                order = Order.objects.get(pk=request.session.get('payment_paypal_order'))
                resp = prov.payment_perform(request, order)
                return redirect(resp or eventreverse(event, 'presale:event.order', kwargs={
                    'order': order.code,
                    'secret': order.secret
                }) + '?paid=yes')
            return redirect(eventreverse(event, 'presale:event.checkout', kwargs={'step': 'confirm'}))
        except Event.DoesNotExist:
            pass  # TODO: Handle this
    else:
        pass  # TODO: Handle this