Beispiel #1
0
    def _assert_transaction_parameters_retry(self, response_success,
                                             failure_log_message):
        self.processor.retry_attempts = 2
        logger_name = 'ecommerce.extensions.payment.processors.paypal'

        with LogCapture(logger_name) as paypal_logger:
            self._assert_transaction_parameters()
            self.assert_processor_response_recorded(self.processor.NAME,
                                                    self.PAYMENT_ID,
                                                    response_success,
                                                    basket=self.basket)

            last_request_body = json.loads(httpretty.last_request().body)
            expected = urljoin(
                self.site.siteconfiguration.build_ecommerce_url(),
                reverse('paypal_execute'))
            self.assertEqual(last_request_body['redirect_urls']['return_url'],
                             expected)
            paypal_logger.check((
                logger_name,
                'WARNING',
                failure_log_message,
            ), (logger_name, 'INFO',
                'Successfully created PayPal payment [{}] for basket [{}].'.
                format(self.PAYMENT_ID, self.basket.id)))
Beispiel #2
0
    def _assert_transaction_parameters_retry(self, response_success, failure_log_message):
        self.processor.retry_attempts = 2
        logger_name = 'ecommerce.extensions.payment.processors.paypal'

        with LogCapture(logger_name) as paypal_logger:
            self._assert_transaction_parameters()
            self.assert_processor_response_recorded(
                self.processor.NAME,
                self.PAYMENT_ID,
                response_success,
                basket=self.basket
            )

            last_request_body = json.loads(httpretty.last_request().body)
            expected = urljoin(self.site.siteconfiguration.build_ecommerce_url(), reverse('paypal_execute'))
            self.assertEqual(last_request_body['redirect_urls']['return_url'], expected)
            paypal_logger.check(
                (
                    logger_name,
                    'WARNING',
                    failure_log_message,
                ),
                (
                    logger_name,
                    'INFO',
                    'Successfully created PayPal payment [{}] for basket [{}].'.format(self.PAYMENT_ID, self.basket.id)
                )
            )
Beispiel #3
0
    def test_get_transaction_parameters(self):
        """Verify the processor returns the appropriate parameters required to complete a transaction."""
        self.mock_oauth2_response()
        response = self.mock_payment_creation_response(self.basket)

        self._assert_transaction_parameters()
        self.assert_processor_response_recorded(self.processor.NAME, self.PAYMENT_ID, response, basket=self.basket)

        last_request_body = json.loads(httpretty.last_request().body)
        expected = urljoin(self.site.siteconfiguration.build_ecommerce_url(), reverse('paypal_execute'))
        self.assertEqual(last_request_body['redirect_urls']['return_url'], expected)
Beispiel #4
0
    def test_get_transaction_parameters(self):
        """Verify the processor returns the appropriate parameters required to complete a transaction."""
        self.mock_oauth2_response()
        response = self.mock_payment_creation_response(self.basket)

        self._assert_transaction_parameters()
        self.assert_processor_response_recorded(self.processor.NAME, self.PAYMENT_ID, response, basket=self.basket)

        last_request_body = json.loads(httpretty.last_request().body)
        expected = urljoin(self.site.siteconfiguration.build_ecommerce_url(), reverse('paypal_execute'))
        self.assertEqual(last_request_body['redirect_urls']['return_url'], expected)