Example #1
0
    def test_no_payment_method_change(self, mock_fetch_status,
                                      mock_transaction):
        self.assertEquals(PaymentLogEntry.objects.count(), 1)

        # Mock the status check with docdata
        mock_fetch_status.return_value = self.create_status_response(
            'AUTHORIZED')

        order = OrderFactory.create()
        order_payment = OrderPaymentFactory.create(
            order=order, payment_method='docdataCreditcard')
        docdata_payment = DocdataPaymentFactory.create(
            order_payment=order_payment,
            default_pm='mastercard',
            payment_cluster_id='1234',
            total_gross_amount=100)
        DocdataTransactionFactory.create(payment=docdata_payment,
                                         payment_method='VISA')
        c = Client()
        merchant_order_id = "{0}-1".format(order_payment.id)
        resp = c.get(reverse('docdata-payment-status-update',
                             kwargs={'merchant_order_id': merchant_order_id}))

        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.content, 'success')

        # Reload the order payment
        order_payment = OrderPayment.objects.get(id=order_payment.id)
        self.assertEqual(order_payment.payment_method, 'docdataCreditcard')
Example #2
0
    def test_no_payment_method_change(self, mock_fetch_status,
                                      mock_transaction):
        self.assertEquals(PaymentLogEntry.objects.count(), 1)

        # Mock the status check with docdata
        mock_fetch_status.return_value = self.create_status_response(
            'AUTHORIZED')

        order = OrderFactory.create()
        order_payment = OrderPaymentFactory.create(
            order=order, payment_method='docdataCreditcard')
        docdata_payment = DocdataPaymentFactory.create(
            order_payment=order_payment,
            default_pm='mastercard',
            payment_cluster_id='1234',
            total_gross_amount=100)
        DocdataTransactionFactory.create(payment=docdata_payment,
                                         payment_method='VISA')
        c = Client()
        merchant_order_id = "{0}-1".format(order_payment.id)
        resp = c.get(
            reverse('docdata-payment-status-update',
                    kwargs={'merchant_order_id': merchant_order_id}))

        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.content, 'success')

        # Reload the order payment
        order_payment = OrderPayment.objects.get(id=order_payment.id)
        self.assertEqual(order_payment.payment_method, 'docdataCreditcard')
Example #3
0
    def test_unknown_payment_method_change(self, mock_fetch_status,
                                           mock_transaction):
        self.skipTest('Skipping test until we update it.')

        # Two payment log entries already exist: 2x 'a new payment status "started" '
        self.assertEquals(PaymentLogEntry.objects.count(), 2)

        # Mock the status check with docdata
        mock_fetch_status.return_value = self.create_status_response(
            'AUTHORIZED')

        order = OrderFactory.create()
        # Ensure that we use an existing payment_method or the adapter throws an exception
        order_payment = OrderPaymentFactory.create(order=order,
                                                   payment_method='docdataPaypal')
        docdata_payment = DocdataPaymentFactory.create(
            order_payment=order_payment,
            default_pm='paypal',
            payment_cluster_id='1236',
            total_gross_amount=100)

        DocdataTransactionFactory.create(payment=docdata_payment,
                                         payment_method='BLABLABLA')
        c = Client()
        merchant_order_id = "{0}-1".format(order_payment.id)
        resp = c.get(reverse('docdata-payment-status-update',
                             kwargs={'merchant_order_id': merchant_order_id}))
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.content, 'success')

        # Reload the order payment
        order_payment = OrderPayment.objects.get(id=order_payment.id)
        self.assertEqual(order_payment.payment_method, 'docdataPaypal')

        # Check that all is logged correctly
        self.assertEquals(
            PaymentLogEntry.objects.filter(payment=docdata_payment).count(), 5)
        log = PaymentLogEntry.objects.all()[0]
        self.assertEqual(log.message,
                         "{0} - Payment method '{1}' not found for payment "
                         "with id {2} and order payment with id {3}.".format(
                             docdata_payment,
                             'BLABLABLA',
                             docdata_payment.id,
                             docdata_payment.order_payment.id))
        self.assertEqual(log.payment.id, docdata_payment.id)
        self.assertEqual(log.level, 'WARNING')
Example #4
0
    def test_unknown_payment_method_change(self, mock_fetch_status,
                                           mock_transaction):
        self.skipTest('Skipping test until we update it.')

        # Two payment log entries already exist: 2x 'a new payment status "started" '
        self.assertEquals(PaymentLogEntry.objects.count(), 2)

        # Mock the status check with docdata
        mock_fetch_status.return_value = self.create_status_response(
            'AUTHORIZED')

        order = OrderFactory.create()
        # Ensure that we use an existing payment_method or the adapter throws an exception
        order_payment = OrderPaymentFactory.create(
            order=order, payment_method='docdataPaypal')
        docdata_payment = DocdataPaymentFactory.create(
            order_payment=order_payment,
            default_pm='paypal',
            payment_cluster_id='1236',
            total_gross_amount=100)

        DocdataTransactionFactory.create(payment=docdata_payment,
                                         payment_method='BLABLABLA')
        c = Client()
        merchant_order_id = "{0}-1".format(order_payment.id)
        resp = c.get(
            reverse('docdata-payment-status-update',
                    kwargs={'merchant_order_id': merchant_order_id}))
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.content, 'success')

        # Reload the order payment
        order_payment = OrderPayment.objects.get(id=order_payment.id)
        self.assertEqual(order_payment.payment_method, 'docdataPaypal')

        # Check that all is logged correctly
        self.assertEquals(
            PaymentLogEntry.objects.filter(payment=docdata_payment).count(), 5)
        log = PaymentLogEntry.objects.all()[0]
        self.assertEqual(
            log.message, "{0} - Payment method '{1}' not found for payment "
            "with id {2} and order payment with id {3}.".format(
                docdata_payment, 'BLABLABLA', docdata_payment.id,
                docdata_payment.order_payment.id))
        self.assertEqual(log.payment.id, docdata_payment.id)
        self.assertEqual(log.level, 'WARNING')