def test_pay(self): c = Client() acc = Account() acc.username = '******' acc.password = '******' acc.fullname = 'foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() TransactionType.objects.create(name=u'Сбербанк РФ', internal_name='payments.ru_sberbank') response = c.post(reverse('getpaid-rusberbank-pay'), u"""<?xml version="1.0" encoding="utf-8"?> <request> <params> <act>2</act> <agent_date>2009-04-15T11:22:33</agent_date> <pay_id>2345</pay_id> <pay_date>2009-04-15T11:00:12</pay_date> <account>010001</account> <pay_amount>10000</pay_amount> <client_name>Иванов</client_name> <month>03.2009</month> </params> <sign>853ee7471ac2eb774e850c727998e0cd</sign> </request>""", content_type='text/xml') print response.content xml = BeautifulSoup(response.content) self.assertEqual( Transaction.objects.filter( type__internal_name='payments.ru_sberbank', bill='2345').count(), 1)
def test_confirm(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() TransactionType.objects.create(name='EasyPay', internal_name = 'payments.easypay') response = c.post(reverse('getpaid-easypay-pay'), """<Request> <DateTime>yyyy-MM-ddTHH:mm:ss</DateTime> <Sign></Sign> <Payment> <ServiceId>1</ServiceId> <OrderId>1</OrderId> <Account>010001</Account> <Amount>10.11</Amount> </Payment> </Request>""", content_type='text/xml') print response.content bs = BeautifulSoup(response.content) response = c.post(reverse('getpaid-easypay-pay'), """<Request> <DateTime>yyyy-MM-ddTHH:mm:ss</DateTime> <Sign></Sign> <Confirm> <ServiceId>1</ServiceId> <PaymentId>%s</PaymentId> </Confirm> </Request>""" % bs.response.paymentid, content_type='text/xml') print 'TRANSACTION=', Transaction.objects.get(type__internal_name='payments.easypay', bill='1') print response.content
def test_check(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() c.login(username= '******', password= '******') TransactionType.objects.create(name=u'Единая касса', internal_name = 'payments.w1ru') response = c.post(reverse('getpaid-new-payment'), {"summ": "10.00", "backend": "payments.w1ru"}) from getpaid.models import Payment payment = Payment.objects.filter().order_by('-id')[0] print response.content d = {"WMI_MERCHANT_ID": PaymentProcessor.get_backend_setting('MERCHANT_ID',''), "WMI_PAYMENT_AMOUNT": '10.00', "WMI_CURRENCY_ID": '643', "WMI_TO_USER_ID": '123456789012', "WMI_PAYMENT_NO": payment.id, "WMI_ORDER_ID": '12345', "WMI_DESCRIPTION": 'descr', "WMI_SUCCESS_URL": 'http://ya.ru', "WMI_FAIL_URL": 'http://ya.ru', "WMI_EXPIRED_DATE": '2012-01-01T00:00:00', "WMI_CREATE_DATE": '2012-01-01T00:00:00', "WMI_UPDATE_DATE": '2012-01-01T00:00:00', "WMI_ORDER_STATE": 'Accepted', } d['WMI_SIGNATURE'] = PaymentProcessor.compute_sig(d) response = c.post(reverse('getpaid-w1ru-postback'), d) print response.content
def test_pay(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() TransactionType.objects.create(name=u'Сбербанк РФ', internal_name = 'payments.ru_sberbank') response = c.post(reverse('getpaid-rusberbank-pay'), u"""<?xml version="1.0" encoding="utf-8"?> <request> <params> <act>2</act> <agent_date>2009-04-15T11:22:33</agent_date> <pay_id>2345</pay_id> <pay_date>2009-04-15T11:00:12</pay_date> <account>010001</account> <pay_amount>10000</pay_amount> <client_name>Иванов</client_name> <month>03.2009</month> </params> <sign>853ee7471ac2eb774e850c727998e0cd</sign> </request>""", content_type='text/xml') print response.content xml = BeautifulSoup(response.content) self.assertEqual(Transaction.objects.filter(type__internal_name='payments.ru_sberbank', bill='2345').count(), 1)
def test_check(self): c = Client() acc = Account() acc.username = '******' acc.password = '******' acc.fullname = 'foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() c.login(username='******', password='******') TransactionType.objects.create(name=u'Единая касса', internal_name='payments.w1ru') response = c.post(reverse('getpaid-new-payment'), { "summ": "10.00", "backend": "payments.w1ru" }) from getpaid.models import Payment payment = Payment.objects.filter().order_by('-id')[0] print response.content d = { "WMI_MERCHANT_ID": PaymentProcessor.get_backend_setting('MERCHANT_ID', ''), "WMI_PAYMENT_AMOUNT": '10.00', "WMI_CURRENCY_ID": '643', "WMI_TO_USER_ID": '123456789012', "WMI_PAYMENT_NO": payment.id, "WMI_ORDER_ID": '12345', "WMI_DESCRIPTION": 'descr', "WMI_SUCCESS_URL": 'http://ya.ru', "WMI_FAIL_URL": 'http://ya.ru', "WMI_EXPIRED_DATE": '2012-01-01T00:00:00', "WMI_CREATE_DATE": '2012-01-01T00:00:00', "WMI_UPDATE_DATE": '2012-01-01T00:00:00', "WMI_ORDER_STATE": 'Accepted', } d['WMI_SIGNATURE'] = PaymentProcessor.compute_sig(d) response = c.post(reverse('getpaid-w1ru-postback'), d) print response.content
def test_pay(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() response = c.post(reverse('getpaid-easypay-pay'), "") print response.content
def test_check(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() response = c.get(reverse('getpaid-masterplat-pay'), {'duser': '******', 'dpass': '******', 'cid': '010001', 'uact': 'get_info'}) print response.content print 'check'
def test_pay(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() TransactionType.objects.create(name=u'SimpleTerminal', internal_name = 'payments.simpleterminal') response = c.get(reverse('getpaid-simpleterminal-pay'), {'uid': '010001', 'sum': '100', 'trans':1}) print 'pay' print response.content
def test_pay(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() TransactionType.objects.create(name=u'SimpleTerminal', internal_name = 'payments.paypro') response = c.get(reverse('getpaid-paypro-pay'), {'pay_id': '12345', 'check': '11111', 'account': '010001', 'date': '2013-08-13 10:55:45', 'pay_amount': '100', 'pay_amount_all': '101'}) print 'pay' print response.content
def test_pay(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() TransactionType.objects.create(name=u'Materplat', internal_name = 'payments.masterplat') response = c.get(reverse('getpaid-masterplat-pay'), {'duser': '******', 'dpass': '******', 'cid': '010001', 'uact': 'payment', 'Term':1, 'trans': 'aabbcc', 'sum':100}) print 'pay' print response.content
def test_check(self): c = Client() acc = Account() acc.username = '******' acc.password = '******' acc.fullname = 'foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() response = c.get(reverse('getpaid-masterplat-pay'), { 'duser': '******', 'dpass': '******', 'cid': '010001', 'uact': 'get_info' }) print response.content print 'check'
def test_check(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() response = c.post(reverse('getpaid-easypay-pay'), """<Request> <DateTime>yyyy-MM-ddTHH:mm:ss</DateTime> <Sign></Sign> <Check> <ServiceId>int</ServiceId> <Account>010001</Account> </Check> </Request>""", content_type='text/xml') print response.content
def test_pay(self): c = Client() acc = Account() acc.username = '******' acc.password = '******' acc.fullname = 'foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() TransactionType.objects.create(name=u'SimpleTerminal', internal_name='payments.simpleterminal') response = c.get(reverse('getpaid-simpleterminal-pay'), { 'uid': '010001', 'sum': '100', 'trans': 1 }) print 'pay' print response.content
def test_pay(self): c = Client() acc = Account() acc.username = '******' acc.password = '******' acc.fullname = 'foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() response = c.post(reverse('getpaid-platezhkaua-pay'), """<?xml version="1.0" encoding="UTF-8"?> <commandCall> <login>12345</login> <password>12345</password> <command>check</command> <transactionID>204</transactionID> <payElementID>1</payElementID> <account>010001</account> </commandCall>""", content_type='text/xml') print response.content
def test_pay(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() response = c.post(reverse('getpaid-platezhkaua-pay'), """<?xml version="1.0" encoding="UTF-8"?> <commandCall> <login>12345</login> <password>12345</password> <command>check</command> <transactionID>204</transactionID> <payElementID>1</payElementID> <account>010001</account> </commandCall>""", content_type='text/xml') print response.content
def test_pay(self): c = Client() acc = Account() acc.username = '******' acc.password = '******' acc.fullname = 'foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() TransactionType.objects.create(name=u'Materplat', internal_name='payments.masterplat') response = c.get( reverse('getpaid-masterplat-pay'), { 'duser': '******', 'dpass': '******', 'cid': '010001', 'uact': 'payment', 'Term': 1, 'trans': 'aabbcc', 'sum': 100 }) print 'pay' print response.content
def test_check(self): c = Client() acc = Account() acc.username = '******' acc.password = '******' acc.fullname = 'foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() response = c.post(reverse('getpaid-rusberbank-pay'), u"""<?xml version="1.0" encoding="utf-8"?> <request> <params> <act>1</act> <agent_date>2009-04-15T11:22:33</agent_date> <account>010001</account> <pay_amount>10000</pay_amount> <client_name>Иванов Иван Иванович</client_name> </params> <sign>853ee7471ac2eb774e850c727998e0cd</sign> </request>""", content_type='text/xml') print response.content
def test_check(self): c = Client() acc = Account() acc.username='******' acc.password='******' acc.fullname='foouser' acc.created = datetime.datetime.now() acc.contract = '010001' acc.save() response = c.post(reverse('getpaid-rusberbank-pay'), u"""<?xml version="1.0" encoding="utf-8"?> <request> <params> <act>1</act> <agent_date>2009-04-15T11:22:33</agent_date> <account>010001</account> <pay_amount>10000</pay_amount> <client_name>Иванов Иван Иванович</client_name> </params> <sign>853ee7471ac2eb774e850c727998e0cd</sign> </request>""", content_type='text/xml') print response.content
def create_user(username=None, password=None): user = Account() user.username = username if username else 'test' user.password = password if password else 'test' user.city='Minsk' user.region='' user.street='' user.house='' user.house_bulk = '' user.entrance = '' user.room='' user.ballance=566 user.nas= create_nas() user.vlan=1 user.allow_webcab=True user.allow_expresscards = True user.assign_dhcp_null = True user.assign_dhcp_block = True user.allow_vpn_null = True user.allow_vpn_block = True user.save() return user
def activate_card(login, pin): status_ok = 1 status_bad_userpassword = 2 status_card_was_activated =3 status_bad_card = 4 now = datetime.datetime.now() cur=connection.cursor() if login and pin: return_status = 0 card = Card.objects.filter(type=2, login=login, pin=pin, salecard__isnull=False, disabled=False) if not card: return status_bad_userpassword if len(card)>1: return status_bad_card card=card[0] if card.activated or card.start_date>now or card.end_date<now: return status_card_was_activated account = Account() account.username = login account.password = pin account.status = 1 account.created = now account.allow_webcab = True account.allow_expresscards = True account.save() subaccount = SubAccount() subaccount.account = account subaccount.username = login subaccount.password = pin subaccount.ipv4_vpn_pool = card.ippool subaccount.nas = card.nas subaccount.save() ac = AccountTarif() ac.account=account ac.tarif = card.tarif ac.datetime = now ac.save() transaction = Transaction() transaction.bill = _(u'Активация карты доступа') transaction.account=account transaction.accounttarif=ac transaction.type = TransactionType.objects.get(internal_name= 'ACCESS_CARD') transaction.approved = True transaction.tarif=card.tarif transaction.summ=card.nominal transaction.created=now transaction.save() card.activated = now card.activated_by = account card.save() return status_ok return
def create_user(username=None, password=None): user = Account() user.username = username if username else 'test' user.password = password if password else 'test' user.city = 'Minsk' user.region = '' user.street = '' user.house = '' user.house_bulk = '' user.entrance = '' user.room = '' user.ballance = 566 user.nas = create_nas() user.vlan = 1 user.allow_webcab = True user.allow_expresscards = True user.assign_dhcp_null = True user.assign_dhcp_block = True user.allow_vpn_null = True user.allow_vpn_block = True user.save() return user