Esempio n. 1
0
def handle_notify(request):
    """ Handles the actual success notification from Paytrail """

    # Get parameters
    order_number = request.GET.get('ORDER_NUMBER', '')
    timestamp = request.GET.get('TIMESTAMP', '')
    paid = request.GET.get('PAID', '')
    method = request.GET.get('METHOD', '')
    authcode = request.GET.get('RETURN_AUTHCODE', '')
    secret = settings.VMAKSUT_SECRET

    # Validate & handle
    if paytrail.validate_success(order_number, timestamp, paid, method, authcode, secret):
        # Get transaction
        ta = get_object_or_404(StoreTransaction, pk=int(order_number))
        if ta.is_paid:
            logger.warning('Somebody is trying to pay an already paid transaction (%s).', ta.id)
            return HttpResponse("")

        # Use common functions to handle the payment
        # If handling the payment fails, cause 404.
        # This will tell paytrail to try notifying again later.
        if not ta_common.handle_payment(ta):
            raise Http404
    else:
        logger.warning("Error while attempting to validate paytrail notification!")
        raise Http404

    # Just respond with something
    return HttpResponse("")
Esempio n. 2
0
def handle_success(request):
    """ Handles the success user redirect from Paytrail """
    
    # Get parameters
    order_number = request.GET.get('ORDER_NUMBER', '')
    timestamp = request.GET.get('TIMESTAMP', '')
    paid = request.GET.get('PAID', '')
    method = request.GET.get('METHOD', '')
    authcode = request.GET.get('RETURN_AUTHCODE', '')
    secret = settings.VMAKSUT_SECRET

    # Validate, and mark transaction as pending
    if paytrail.validate_success(order_number, timestamp, paid, method, authcode, secret):
        ta = get_object_or_404(StoreTransaction, pk=int(order_number))
        ta_common.handle_pending(ta)
    
    return render_to_response('store/success.html')
Esempio n. 3
0
def handle_success(request):
    """ Handles the success user redirect from Paytrail """
    
    # Get parameters
    order_number = request.GET.get('ORDER_NUMBER', '')
    timestamp = request.GET.get('TIMESTAMP', '')
    paid = request.GET.get('PAID', '')
    method = request.GET.get('METHOD', '')
    authcode = request.GET.get('RETURN_AUTHCODE', '')
    secret = settings.VMAKSUT_SECRET

    # Validate, and mark transaction as pending
    if paytrail.validate_success(order_number, timestamp, paid, method, authcode, secret):
        ta = get_object_or_404(StoreTransaction, pk=int(order_number))
        ta_common.handle_pending(ta)
        return HttpResponseRedirect(reverse('store:pm:paytrail-success'))

    return render(request, 'store/success.html')