Exemplo n.º 1
0
 def test_encodeSignedData_whenNoOrder(self):
     data = dict(self.data)
     data['BadData'] = "value"
     with self.assertRaises(ValueError):
         encodeSignedData(
             self.merchantkey,
             **data
             )
Exemplo n.º 2
0
 def test_encodeSignedData_whenNoOrder(self):
     data = dict(self.data)
     del data['Ds_Merchant_Order']
     with self.assertRaises(KeyError):
         encodeSignedData(
             self.merchantkey,
             **data
             )
Exemplo n.º 3
0
    def test_sendingPost_production(self):

        data = dict(
            Ds_Merchant_Amount = "10000",
            Ds_Merchant_ConsumerLanguage = "003",
            Ds_Merchant_Currency = "978",
            Ds_Merchant_MerchantCode = config.redsys['merchantcode'],
            Ds_Merchant_MerchantData = "COBRAMENT QUOTA SOCI",
            Ds_Merchant_MerchantName = "SOM ENERGIA, SCCL",
            Ds_Merchant_MerchantURL = "https://testing.somenergia.coop:5001/pagament/notificacio",
            Ds_Merchant_Order = "201671121375",
            Ds_Merchant_ProductDescription = "Alta de soci SOMENERGIA",
            Ds_Merchant_SumTotal = "10000",
            Ds_Merchant_Terminal = "1",
            Ds_Merchant_Titular = "SOM ENERGIA, SCCL",
            Ds_Merchant_TransactionType = "0",
            Ds_Merchant_UrlKO = "https://www.somenergia.coop/es/pago-cancelado",
            Ds_Merchant_UrlOK = "https://www.somenergia.coop/es/pago-realizado",
            )
        import requests
        r = requests.post('https://sis.redsys.es/sis/realizarPago',
            data = encodeSignedData(
#                'sq7HjrUOBfKmC576ILgskD5srU870gJ7', # Clave para tests
                config.redsys['merchantkey'],
                **data
                )
            )
        self.assertEqual(r.status_code, 200)
        self.assertNotIn('RSisException', r.text)
        self.assertFalse(re.match('SIS[0-9]', r.text))
Exemplo n.º 4
0
    def test_sendingPost_testingFails_invalidUser(self):

        data = dict(
            Ds_Merchant_Amount = "10000",
            Ds_Merchant_ConsumerLanguage = "003",
            Ds_Merchant_Currency = "978",
            Ds_Merchant_MerchantCode = "999999999", # bad user
            Ds_Merchant_MerchantData = "COBRAMENT QUOTA SOCI",
            Ds_Merchant_MerchantName = "SOM ENERGIA, SCCL",
            Ds_Merchant_MerchantURL = "https://testing.somenergia.coop:5001/pagament/notificacio",
            Ds_Merchant_Order = "20167db2f375",
            Ds_Merchant_ProductDescription = "Alta de soci SOMENERGIA",
            Ds_Merchant_SumTotal = "10000",
            Ds_Merchant_Terminal = "1",
            Ds_Merchant_Titular = "SOM ENERGIA, SCCL",
            Ds_Merchant_TransactionType = "0",
            Ds_Merchant_UrlKO = "https://www.somenergia.coop/es/pago-cancelado",
            Ds_Merchant_UrlOK = "https://www.somenergia.coop/es/pago-realizado",
            )
        import requests
        r = requests.post('https://sis-t.redsys.es:25443/sis/realizarPago',
            data = encodeSignedData(
                'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
                **data
                )
            )

        self.assertEqual(r.status_code, 200)
        self.assertIn('RSisException', r.text)
        self.assertIn('<!--SIS0026:-->', r.text)
Exemplo n.º 5
0
 def test_encodeSignedData_whenAllOk(self):
     result = encodeSignedData(
         self.merchantkey,
         **self.data
         )
     self.assertEqual(result, dict(
         Ds_SignatureVersion = 'HMAC_SHA256_V1',
         Ds_Signature = self.signature,
         Ds_MerchantParameters =  self.encodedPayload,
         ))
Exemplo n.º 6
0
 def test_encodeSignedData_whenValueTooLong(self):
     data = dict(self.data)
     data['Ds_Merchant_ProductDescription'] = "M"+"0123456789"*300
     result = encodeSignedData(
             self.merchantkey,
             **data
             )
     reverted = json.loads(base64.b64decode(result['Ds_MerchantParameters']))
     revertedDescription = reverted['Ds_Merchant_ProductDescription']
     self.assertTrue(revertedDescription.startswith("M01234"))
     self.assertEqual(len(revertedDescription), 125)