def make_test_purchase(payment={}, **kwargs): purchaseargs = { "first_name": 'Mister', "last_name": 'Tester', "orderno" : "test%03i" % random.randrange(1,100), "email" : "*****@*****.**", "phone" : "555-555-1234", "ship_street1" : "123 Test St.", "ship_city" : "Testington", "ship_state" : "TX", "ship_postal_code" : "55555", "ship_country" : "US", "bill_street1" : "123 Test St.", "bill_city" : "Testington", "bill_state" : "TX", "bill_postal_code" : "55555", "bill_country" : "US", "tax" : Decimal("0"), "shipping" : Decimal("0"), } purchaseargs.update(kwargs) purchase = Purchase(**purchaseargs) purchase.recalc() purchase.save() if payment: for f in ('card_type', 'expire_month', 'expire_year', 'card_number', 'ccv'): assert(f in payment) p = Payment(purchase = purchase, amount = purchase.total) p.save() c = CreditCardDetail( payment=p, credit_type=payment['card_type'], expire_month=payment['expire_month'], expire_year=payment['expire_year'], ) if 'card_holder' in payment: c.card_holder = payment['card_holder'] c.storeCC(payment['card_number']) c.ccv = payment['ccv'] c.save() return purchase