def testAuthorize(request): p = PaymentManager() if 'campaign' in request.GET.keys(): campaign_id = request.GET['campaign'] else: campaign_id = None if 'amount' in request.GET.keys(): amount = float(request.GET['amount']) else: return HttpResponse("Error, no amount in request") # Note, set this to 1-5 different receivers with absolute amounts for each receiver_list = [{'email': TEST_RECEIVERS[0], 'amount':20.00}, {'email': TEST_RECEIVERS[1], 'amount':10.00}] if campaign_id: campaign = Campaign.objects.get(id=int(campaign_id)) t, url = p.authorize('USD', TARGET_TYPE_CAMPAIGN, amount, campaign=campaign, return_url=None, list=None, user=None) else: t, url = p.authorize('USD', TARGET_TYPE_NONE, amount, campaign=None, return_url=None, list=None, user=None) if url: logger.info("testAuthorize: " + url) return HttpResponseRedirect(url) else: response = t.error logger.info("testAuthorize: Error " + str(t.error)) return HttpResponse(response)
def test_authorize(self): print "RUNNING TEST: test_authorize" p = PaymentManager() # Note, set this to 1-5 different receivers with absolute amounts for each t, url = p.authorize(t) self.validateRedirect(t, url) loginSandbox(self.selenium) paySandbox(self, self.selenium, url, authorize=True) # stick in a getStatus to update statuses in the absence of IPNs p.checkStatus() t = Transaction.objects.get(id=t.id) self.assertEqual(t.status, IPN_PREAPPROVAL_STATUS_ACTIVE)