示例#1
0
 def test_pay__wrong_md5(self):
     self.assertTrue(pay(command=COMMAND_TYPE.PAY,
                         external_md5=None,
                         v1=self.user_email, v2=None, v3=None,
                         id=self.xsolla_id, sum=self.payment_sum, test=False, date=None, request_url='bla-bla.test.com'),
                         (PAY_RESULT.WRONG_MD5, None))
     self.assertTrue(pay(command=COMMAND_TYPE.PAY,
                         external_md5='weadadsasdasd',
                         v1=self.user_email, v2=None, v3=None,
                         id=self.xsolla_id, sum=self.payment_sum, test=False, date=None, request_url='bla-bla.test.com'),
                         (PAY_RESULT.WRONG_MD5, None))
示例#2
0
    def test_test_is_1(self):
        self.assertEqual(InvoicePrototype._db_count(), 0)
        with mock.patch('the_tale.finances.bank.logic.get_account_id', mock.Mock(return_value=1234)):
            result, invoice_id = pay(command=COMMAND_TYPE.PAY,
                                     external_md5=self.pay_md5,
                                     v1=self.user_email, v2=None, v3=None,
                                     id=self.xsolla_id, sum=self.payment_sum, test='1', date=None, request_url='bla-bla.test.com')

        self.assertTrue(result.is_SUCCESS)
        self.assertEqual(InvoicePrototype._db_count(), 1)
        self.assertTrue(InvoicePrototype._db_get_object(0).test)
示例#3
0
文件: views.py 项目: angru/the-tale
    def command(self,
                command=None,
                md5=None,
                v1=None,
                v2=None,
                v3=None,
                id=None,
                sum=None,
                test=None,
                date=None):
        try:
            self.log(command)

            if self.user_ip not in xsolla_settings.ALLOWED_IPS:
                return self.create_answer(COMMON_RESULT.DISALLOWED_IP)

            try:
                command = COMMAND_TYPE(command)
            except:
                return self.create_answer(COMMON_RESULT.WRONG_COMMAND)

            if command.is_CHECK:
                return self.create_check_answer(
                    xsolla_logic.check_user(command=command,
                                            external_md5=md5,
                                            v1=v1,
                                            v2=v2,
                                            v3=v3))
            elif command.is_PAY:
                pay_result, internal_id = xsolla_logic.pay(
                    command=command,
                    external_md5=md5,
                    v1=v1,
                    v2=v2,
                    v3=v3,
                    id=id,
                    sum=sum,
                    test=test,
                    date=date,
                    request_url=self.request.build_absolute_uri())
                return self.create_pay_answer(pay_result,
                                              xsolla_id=id,
                                              internal_id=internal_id,
                                              sum=sum)

            elif command.is_CANCEL:
                return self.create_cancel_answer()
        except:
            logger.error('XSOLLA command exception',
                         exc_info=sys.exc_info(),
                         extra={})
            return self.create_answer(COMMON_RESULT.UNKNOWN_ERROR)
示例#4
0
 def test_pay__no_sum(self):
     self.assertTrue(
         pay(command=COMMAND_TYPE.PAY,
             external_md5=self.pay_md5,
             v1=self.user_email,
             v2=None,
             v3=None,
             id=self.xsolla_id,
             sum=None,
             test=False,
             date=None,
             request_url=u'bla-bla.test.com'),
         (PAY_RESULT.NOT_SPECIFIED_SUM, None))
示例#5
0
 def test_pay__no_v1(self):
     self.assertTrue(
         pay(command=COMMAND_TYPE.PAY,
             external_md5=self.pay_md5,
             v1=None,
             v2=None,
             v3=None,
             id=self.xsolla_id,
             sum=self.payment_sum,
             test=False,
             date=None,
             request_url='bla-bla.test.com'),
         (PAY_RESULT.NOT_SPECIFIED_V1, None))
示例#6
0
 def test_pay__wrong_md5(self):
     self.assertTrue(
         pay(command=COMMAND_TYPE.PAY,
             external_md5=None,
             v1=self.user_email,
             v2=None,
             v3=None,
             id=self.xsolla_id,
             sum=self.payment_sum,
             test=False,
             date=None,
             request_url=u'bla-bla.test.com'), (PAY_RESULT.WRONG_MD5, None))
     self.assertTrue(
         pay(command=COMMAND_TYPE.PAY,
             external_md5='weadadsasdasd',
             v1=self.user_email,
             v2=None,
             v3=None,
             id=self.xsolla_id,
             sum=self.payment_sum,
             test=False,
             date=None,
             request_url=u'bla-bla.test.com'), (PAY_RESULT.WRONG_MD5, None))
示例#7
0
    def test_test_is_1(self):
        self.assertEqual(InvoicePrototype._db_count(), 0)
        with mock.patch('the_tale.finances.bank.logic.get_account_id',
                        mock.Mock(return_value=1234)):
            result, invoice_id = pay(command=COMMAND_TYPE.PAY,
                                     external_md5=self.pay_md5,
                                     v1=self.user_email,
                                     v2=None,
                                     v3=None,
                                     id=self.xsolla_id,
                                     sum=self.payment_sum,
                                     test='1',
                                     date=None,
                                     request_url=u'bla-bla.test.com')

        self.assertTrue(result.is_SUCCESS)
        self.assertEqual(InvoicePrototype._db_count(), 1)
        self.assertTrue(InvoicePrototype._db_get_object(0).test)
示例#8
0
文件: views.py 项目: Alkalit/the-tale
    def command(self,
                command=None, md5=None,
                v1=None, v2=None, v3=None,
                id=None, sum=None, test=None, date=None):
        try:
            self.log(command)

            if self.user_ip not in xsolla_settings.ALLOWED_IPS:
                return self.create_answer(COMMON_RESULT.DISALLOWED_IP)

            try:
                command = COMMAND_TYPE(command)
            except:
                return self.create_answer(COMMON_RESULT.WRONG_COMMAND)


            if command.is_CHECK:
                return self.create_check_answer(xsolla_logic.check_user(command=command,
                                                                        external_md5=md5,
                                                                        v1=v1,
                                                                        v2=v2,
                                                                        v3=v3))
            elif command.is_PAY:
                pay_result, internal_id = xsolla_logic.pay(command=command,
                                                           external_md5=md5,
                                                           v1=v1,
                                                           v2=v2,
                                                           v3=v3,
                                                           id=id,
                                                           sum=sum,
                                                           test=test,
                                                           date=date,
                                                           request_url=self.request.build_absolute_uri())
                return self.create_pay_answer(pay_result, xsolla_id=id, internal_id=internal_id, sum=sum)

            elif command.is_CANCEL:
                return self.create_cancel_answer()
        except:
            logger.error('XSOLLA command exception',
                         exc_info=sys.exc_info(),
                         extra={} )
            return self.create_answer(COMMON_RESULT.UNKNOWN_ERROR)
示例#9
0
 def test_pay__no_sum(self):
     self.assertTrue(pay(command=COMMAND_TYPE.PAY,
                         external_md5=self.pay_md5,
                         v1=self.user_email, v2=None, v3=None,
                         id=self.xsolla_id, sum=None, test=False, date=None, request_url='bla-bla.test.com'),
                         (PAY_RESULT.NOT_SPECIFIED_SUM, None))
示例#10
0
 def test_pay__no_v1(self):
     self.assertTrue(pay(command=COMMAND_TYPE.PAY,
                         external_md5=self.pay_md5,
                         v1=None, v2=None, v3=None,
                         id=self.xsolla_id, sum=self.payment_sum, test=False, date=None, request_url=u'bla-bla.test.com'),
                         (PAY_RESULT.NOT_SPECIFIED_V1, None))