Ejemplo n.º 1
0
    def checkout(self):
        self.build_params()
        headers = {
            'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
        }
        response = requests.post(self.transaction_url,
                                 self.params,
                                 headers=headers)

        if response.status_code == 200:
            root = xmltodict.parse(response.text)
            transaction = root['transaction']
            data = {
                'transaction': transaction,
                'status_code': response.status_code,
                'success': True,
                'date': parse(transaction['date']),
                'code': transaction['code'],
            }
            checkout_realizado_com_sucesso.send(sender=self, data=data)
        else:
            data = {
                'status_code': response.status_code,
                'message': response.text,
                'success': False,
                'date': timezone.now()
            }
            checkout_realizado_com_erro.send(sender=self, data=data)

        checkout_realizado.send(sender=self, data=data)

        return data
Ejemplo n.º 2
0
    def checkout(self):
        self.build_params()
        headers = {
            "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
        }
        response = requests.post(self.transaction_url,
                                 self.params,
                                 headers=headers)

        if response.status_code == 200:
            root = xmltodict.parse(response.text)
            transaction = root["transaction"]
            data = {
                "transaction": transaction,
                "status_code": response.status_code,
                "success": True,
                "date": parse(transaction["date"]),
                "code": transaction["code"],
            }
            checkout_realizado_com_sucesso.send(sender=self, data=data)
        else:
            data = {
                "status_code": response.status_code,
                "message": response.text,
                "success": False,
                "date": timezone.now(),
            }
            checkout_realizado_com_erro.send(sender=self, data=data)

        checkout_realizado.send(sender=self, data=data)

        logger.debug("operation=transparent_api_checkout, "
                     "data={!r}".format(data))
        return data
Ejemplo n.º 3
0
    def checkout(self):
        self.build_params()
        headers = {
            'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
        }
        response = requests.post(
            self.checkout_url, self.params, headers=headers
        )

        data = {}

        if response.status_code == 200:
            root = xmltodict.parse(response.text)
            data = {
                'code': root['checkout']['code'],
                'status_code': response.status_code,
                'date': parse(root['checkout']['date']),
                'redirect_url': '{}?code={}'.format(
                    self.redirect_url, root['checkout']['code']
                ),
                'success': True
            }
            checkout_realizado_com_sucesso.send(
                sender=self, data=data
            )
        else:
            data = {
                'status_code': response.status_code,
                'message': response.text,
                'success': False,
                'date': timezone.now()
            }
            checkout_realizado_com_erro.send(
                sender=self, data=data
            )

        checkout_realizado.send(
            sender=self, data=data
        )

        logger.debug('operation=api_checkout, data={!r}'.format(data))
        return data
Ejemplo n.º 4
0
    def checkout(self):
        self.build_params()
        headers = {
            'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
        }
        response = requests.post(
            self.checkout_url, self.params, headers=headers
        )

        data = {}

        if response.status_code == 200:
            root = xmltodict.parse(response.text)
            data = {
                'code': root['checkout']['code'],
                'status_code': response.status_code,
                'date': parse(root['checkout']['date']),
                'redirect_url': '{0}?code={1}'.format(
                    self.redirect_url, root['checkout']['code']
                ),
                'success': True
            }
            checkout_realizado_com_sucesso.send(
                sender=self, data=data
            )
        else:
            data = {
                'status_code': response.status_code,
                'message': response.text,
                'success': False,
                'date': datetime.now()
            }
            checkout_realizado_com_erro.send(
                sender=self, data=data
            )

        checkout_realizado.send(
            sender=self, data=data
        )

        return data