예제 #1
0
def start(request, template='buysafe/start.html'):
    keyword_args = {}
    for k in request.POST:
        keyword_args[k] = request.POST[k]

    context = {}

    info = call_handler(
        'BUYSAFE_FORM_VALUES_GENERATOR',
        default_order_info_handler,
        request=request, context=context, **keyword_args
    )

    forms = []
    payment_methods = PaymentMethod.enabled.all()
    for method in payment_methods:
        form_model = PAYMENT_SEND_FORMS[method.payment_type]
        info['store_name'] = method.store_id
        form = form_model(
            store_password=method.password, initial=info
        )
        form.fill_checksum()
        form.submit_button_title = method.name
        forms.append(form)

    context['forms'] = forms
    return call_handler_and_render(
        'BUYSAFE_START_HANDLER', None,
        request=request, template=template, context=context,
        forms=forms, payment_methods=payment_methods
    )
예제 #2
0
def fail(request, payment_type, template='buysafe/fail.html'):
    context = {}
    payment_type = int(payment_type)
    form = get_payment_form(payment_type, request.POST)
    if form is None:
        return call_handler_and_render(
            'BUYSAFE_FAIL_INVALID_HANDLER',
            make_response_handler(HttpResponseBadRequest),
            request=request, context=context, form=form
        )
    context['data'] = form.cleaned_data
    send_type = form.cleaned_data['send_type']
    if send_type == SunTechReceiveForm.SEND_TYPE.BACKGROUND:
        return call_handler_and_render(
            'BUYSAFE_FAIL_BACKGROUND_HANDLER',
            make_response_handler(HttpResponse),
            request=request, context=context, form=form
        )
    return call_handler_and_render(
        'BUYSAFE_FAIL_RENDER_HANDLER', None,
        request=request, template=template, context=context, form=form
    )
예제 #3
0
def check(request, payment_type):
    context = {}
    payment_type = int(payment_type)
    form = get_payment_form(payment_type, request.POST)
    if form is None:
        return call_handler_and_render(
            'BUYSAFE_CHECK_INVALID_HANDLER',
            make_response_handler(HttpResponseBadRequest),
            request=request, context=context, form=form
        )
    send_type = form.cleaned_data['send_type']
    if send_type == SunTechReceiveForm.SEND_TYPE.BACKGROUND:
        return call_handler_and_render(
            'BUYSAFE_CHECK_HANDLER',
            make_response_handler(HttpResponse, '0000'),
            request=request, context=context, form=form
        )
        return HttpResponse('0000')
    return call_handler_and_render(
        'BUYSAFE_CHECK_INVALID_HANDLER',
        make_response_handler(HttpResponseBadRequest),
        request=request, context=context, form=form
    )