def create_order(user, plan_pricing, ip_address, organization, renew=False): order = Order(user=user, plan=plan_pricing.plan, pricing=plan_pricing.pricing, created=user.date_joined, amount=plan_pricing.price, tax=app_settings.TAX, currency=app_settings.CURRENCY) order.full_clean() order.save() payment = Payment(organization=organization, order=order, currency=order.currency, total=order.total(), tax=order.tax_total(), customer_ip_address=ip_address, is_renewal=renew) payment.full_clean() payment.save() return payment