Exemplo n.º 1
0
 def test_client_does_not_exist(self):
     print('test_client_does_not_exist')
     current_date = timezone.now().strftime(self.time_format)
     service_id = getattr(settings, 'PAY_SERV_ID')
     r = allpay(
         rf.get(
             self.pay_url, {
                 'ACT':
                 1,
                 'PAY_ACCOUNT':
                 'not_existing_acc',
                 'SERVICE_ID':
                 service_id,
                 'PAY_ID':
                 '840ab457-e7d1-4494-8197-9570da035170',
                 'TRADE_POINT':
                 'term1',
                 'SIGN':
                 _make_sign(1, 'not_existing_acc', service_id,
                            '840ab457-e7d1-4494-8197-9570da035170')
             }))
     r = r.content.decode('utf-8')
     self.assertXMLEqual(
         r, ''.join(("<pay-response>", "<status_code>-40</status_code>",
                     "<time_stamp>%s</time_stamp>" % escape(current_date),
                     "</pay-response>")))
Exemplo n.º 2
0
 def user_pay_view(self):
     print('test_user_pay_view')
     current_date = timezone.now().strftime(self.time_format)
     service_id = getattr(settings, 'PAY_SERV_ID')
     r = allpay(
         rf.get(
             self.pay_url, {
                 'ACT':
                 1,
                 'PAY_ACCOUNT':
                 'pay_account1',
                 'SERVICE_ID':
                 service_id,
                 'PAY_ID':
                 '840ab457-e7d1-4494-8197-9570da035170',
                 'TRADE_POINT':
                 'term1',
                 'SIGN':
                 _make_sign(1, 'pay_account1', service_id,
                            '840ab457-e7d1-4494-8197-9570da035170')
             }))
     r = r.content.decode('utf-8')
     o = ''.join(
         ("<pay-response>", "<balance>-13.12</balance>",
          "<name>Test Name</name>", "<account>pay_account1</account>",
          "<service_id>%s</service_id>" % escape(service_id),
          "<min_amount>10.0</min_amount>", "<max_amount>5000</max_amount>",
          "<status_code>21</status_code>", "<time_stamp>%s</time_stamp>" %
          escape(current_date), "</pay-response>"))
     self.assertXMLEqual(r, o)
Exemplo n.º 3
0
 def user_pay_check(self):
     print('test_user_pay_check')
     current_date = timezone.now().strftime(self.time_format)
     service_id = getattr(settings, 'PAY_SERV_ID')
     r = allpay(
         rf.get(
             self.pay_url, {
                 'ACT':
                 7,
                 'SERVICE_ID':
                 service_id,
                 'PAY_ID':
                 '840ab457-e7d1-4494-8197-9570da035170',
                 'SIGN':
                 _make_sign(7, '', service_id,
                            '840ab457-e7d1-4494-8197-9570da035170')
             }))
     r = r.content.decode('utf-8')
     xml = ''.join(
         ("<pay-response>", "<status_code>11</status_code>",
          "<time_stamp>%s</time_stamp>" % escape(current_date),
          "<transaction>",
          "<pay_id>840ab457-e7d1-4494-8197-9570da035170</pay_id>",
          "<service_id>%s</service_id>" % escape(service_id),
          "<amount>18.21</amount>", "<status>111</status>",
          "<time_stamp>%s</time_stamp>" % escape(self.test_pay_time),
          "</transaction>"
          "</pay-response>"))
     self.assertXMLEqual(r, xml)
Exemplo n.º 4
0
 def user_pay_pay(self):
     print('test_user_pay_pay')
     current_date = timezone.now().strftime(self.time_format)
     service_id = getattr(settings, 'PAY_SERV_ID')
     r = allpay(
         rf.get(
             self.pay_url, {
                 'ACT':
                 4,
                 'PAY_ACCOUNT':
                 'pay_account1',
                 'PAY_AMOUNT':
                 18.21,
                 'RECEIPT_NUM':
                 2126235,
                 'SERVICE_ID':
                 service_id,
                 'PAY_ID':
                 '840ab457-e7d1-4494-8197-9570da035170',
                 'TRADE_POINT':
                 'term1',
                 'SIGN':
                 _make_sign(4, 'pay_account1', service_id,
                            '840ab457-e7d1-4494-8197-9570da035170')
             }))
     r = r.content.decode('utf-8')
     xml = ''.join(
         ("<pay-response>",
          "<pay_id>840ab457-e7d1-4494-8197-9570da035170</pay_id>",
          "<service_id>%s</service_id>" % escape(service_id),
          "<amount>18.21</amount>", "<status_code>22</status_code>",
          "<time_stamp>%s</time_stamp>" % escape(current_date),
          "</pay-response>"))
     self.test_pay_time = current_date
     self.assertXMLEqual(r, xml)
Exemplo n.º 5
0
 def non_existing_pay(self):
     print('non_existing_pay')
     current_date = timezone.now().strftime(self.time_format)
     uuid = '9f154e93-d800-419a-92f7-da33529138be'
     service_id = getattr(settings, 'PAY_SERV_ID')
     r = allpay(
         rf.get(
             self.pay_url, {
                 'ACT': 7,
                 'SERVICE_ID': service_id,
                 'PAY_ID': uuid,
                 'SIGN': _make_sign(7, '', service_id, uuid)
             }))
     r = r.content.decode('utf-8')
     xml = ''.join(("<pay-response>", "<status_code>-10</status_code>",
                    "<time_stamp>%s</time_stamp>" % escape(current_date),
                    "</pay-response>"))
     self.assertXMLEqual(r, xml)
Exemplo n.º 6
0
 def try_pay_double(self):
     print('try_pay_double')
     service_id = getattr(settings, 'PAY_SERV_ID')
     r = allpay(
         rf.get(
             self.pay_url, {
                 'ACT':
                 4,
                 'PAY_ACCOUNT':
                 'pay_account1',
                 'SERVICE_ID':
                 service_id,
                 'PAY_ID':
                 '840ab457-e7d1-4494-8197-9570da035170',
                 'TRADE_POINT':
                 'term1',
                 'SIGN':
                 _make_sign(4, 'pay_account1', service_id,
                            '840ab457-e7d1-4494-8197-9570da035170')
             }))
     r = r.content.decode('utf-8')
     r = parse(r)
     status_code = int(r['pay-response']['status_code'])
     self.assertEqual(status_code, -100)
Exemplo n.º 7
0
 def check_ballance(self):
     print('check_ballance')
     service_id = getattr(settings, 'PAY_SERV_ID')
     r = allpay(
         rf.get(
             self.pay_url, {
                 'ACT':
                 1,
                 'PAY_ACCOUNT':
                 'pay_account1',
                 'SERVICE_ID':
                 service_id,
                 'PAY_ID':
                 '840ab457-e7d1-4494-8197-9570da035170',
                 'TRADE_POINT':
                 'term1',
                 'SIGN':
                 _make_sign(1, 'pay_account1', service_id,
                            '840ab457-e7d1-4494-8197-9570da035170')
             }))
     r = r.content.decode('utf-8')
     r = parse(r)
     bl = float(r['pay-response']['balance'])
     self.assertEqual(bl, 5.09)