Ejemplo n.º 1
0
def order_singlescreen(request):
	# approach 3: single screen (ask for everything)
	order = UnawareOrder()
	payment_form = PaymentMethodForm(data=request.POST or None)
	formset = ItemFormSet(instance=order, data=request.POST or None)
	if request.method == 'POST':
		if formset.is_valid() and payment_form.is_valid():
			order.save()
			formset.save()
			payment = order.payments.create(amount=order.total, currency=order.currency)
			payment_form.save(payment)
			return HttpResponseRedirect(
					reverse('mamona-confirm-payment', kwargs={'payment_id': payment.id}))
	return direct_to_template(
		request,
		'sales/order_singlescreen.html',
		{'order': order, 'formset': formset, 'payment_form': payment_form}
		)
Ejemplo n.º 2
0
def order_multiitem(request):
    # approach 2: an order with no payment method (Mamona will ask)
    order = UnawareOrder()
    if request.method == 'POST':
        formset = ItemFormSet(instance=order, data=request.POST)
        if formset.is_valid():
            order.save()
            formset.save()
            payment = order.payments.create(amount=order.total,
                                            currency=order.currency)
            return HttpResponseRedirect(
                reverse('mamona-process-payment',
                        kwargs={'payment_id': payment.id}))
    else:
        formset = ItemFormSet(instance=order)
    return direct_to_template(request, 'sales/order_multiitem.html', {
        'order': order,
        'formset': formset
    })
Ejemplo n.º 3
0
def order_multiitem(request):
	# approach 2: an order with no payment method (Mamona will ask)
	order = UnawareOrder()
	if request.method == 'POST':
		formset = ItemFormSet(instance=order, data=request.POST)
		if formset.is_valid():
			order.save()
			formset.save()
			payment = order.payments.create(amount=order.total, currency=order.currency)
			return HttpResponseRedirect(
					reverse('mamona-process-payment', kwargs={'payment_id': payment.id})
					)
	else:
		formset = ItemFormSet(instance=order)
	return direct_to_template(
		request,
		'sales/order_multiitem.html',
		{'order': order, 'formset': formset}
		)
Ejemplo n.º 4
0
def order_singlescreen(request):
    # approach 3: single screen (ask for everything)
    order = UnawareOrder()
    payment_form = PaymentMethodForm(data=request.POST or None)
    formset = ItemFormSet(instance=order, data=request.POST or None)
    if request.method == 'POST':
        if formset.is_valid() and payment_form.is_valid():
            order.save()
            formset.save()
            payment = order.payments.create(amount=order.total,
                                            currency=order.currency)
            payment_form.save(payment)
            return HttpResponseRedirect(
                reverse('mamona-confirm-payment',
                        kwargs={'payment_id': payment.id}))
    return direct_to_template(request, 'sales/order_singlescreen.html', {
        'order': order,
        'formset': formset,
        'payment_form': payment_form
    })