예제 #1
0
    def _create_confirmed_order(self, order, transaction_id):
        """
        Create an order from the current cart but does not mark it as payed.
        Instead mark the order as CONFIRMED only, as somebody manually has to
        check bank account statements and mark the payments.
        """
        OrderPayment.objects.create(order=order, amount=Decimal(0),
            transaction_id=transaction_id, payment_method=self.backend_name)

        # Confirm the current order
        order.status = Order.CONFIRMED
        order.save()

        # empty the related cart
        try:
            cart = Cart.objects.get(pk=order.cart_pk)
            cart.empty()
        except Cart.DoesNotExist:
            pass
        confirmed.send(sender=self, order=order)
예제 #2
0
    def _create_confirmed_order(self, order, transaction_id):
        """
        Create an order from the current cart but does not mark it as payed.
        Instead mark the order as CONFIRMED only, as somebody manually has to
        check bank account statements and mark the payments.
        """
        OrderPayment.objects.create(order=order, amount=Decimal(0),
            transaction_id=transaction_id, payment_method=self.backend_name)

        # Confirm the current order
        order.status = Order.CONFIRMED
        order.save()

        # empty the related cart
        try:
            cart = Cart.objects.get(pk=order.cart_pk)
            cart.empty()
        except Cart.DoesNotExist:
            pass
        confirmed.send(sender=self, order=order)
예제 #3
0
    def handle_order_notifications(self, data):

        order_id = data.get(PayerXMLDocument.ORDER_ID_URL_PARAMETER_NAME,
                            data.get('payer_merchant_reference_id', None))
        payment_method = data.get('payer_payment_type', 'unknown')
        transaction_id = data.get('payer_payment_id', data.get('payread_payment_id', None))
        callback_type = data.get('payer_callback_type', '').lower()
        # testmode = bool(data.get('payer_testmode', 'false') == 'true')
        # added_fee = data.get('payer_added_fee', 0)

        if order_id is not None:

            order = Order.objects.get(pk=order_id)

            if callback_type == 'auth':

                # Payment approved, update order status, empty cart
                order.status = Order.CONFIRMED
                order.save()

                try:
                    cart = Cart.objects.get(pk=order.cart_pk)
                    cart.empty()
                except Cart.DoesNotExist:
                    pass

                confirmed.send(sender=self, order=order)

            elif callback_type == 'settle':

                # Payment completed, update order status, add payment
                order.status = Order.COMPLETED

                self.shop.confirm_payment(order, self.shop.get_order_total(order), transaction_id,
                                          u"Payer %s (%s)" % (unicode(self.backend_name).lower(), payment_method,))

                completed.send(sender=self, order=order)
예제 #4
0
 def test_should_send_email_to_owners(self):
     owners = (('John', '*****@*****.**'), ('Mary', '*****@*****.**'))
     with SettingsOverride(SN_OWNERS=owners):
         confirmed.send(sender=self, order=self.order)
         self.assertEqual(len(mail.outbox[0].to), 2)
예제 #5
0
 def test_should_have_from_address_from_settings(self):
     from_email = '*****@*****.**'
     with SettingsOverride(SN_FROM_EMAIL=from_email):
         confirmed.send(sender=self, order=self.order)
         self.assertEqual(mail.outbox[0].from_email, from_email)
예제 #6
0
 def test_should_send_email_on_confirmed_signal(self):
     confirmed.send(sender=self, order=self.order)
     self.assertEqual(len(mail.outbox), 2)
예제 #7
0
 def test_has_body_from_template(self):
     confirmed.send(sender=self, order=self.order)
     self.assertTrue(
         self.was_template_rendered(
             'shop_simplenotifications/payment_instructions_body.txt'))
예제 #8
0
 def test_should_send_email_to_customer(self):
     confirmed.send(sender=self, order=self.order)
     self.assertEqual(mail.outbox[1].to, [
         '*****@*****.**',
     ])
예제 #9
0
 def test_has_subject_from_template(self):
     confirmed.send(sender=self, order=self.order)
     self.assertTrue(
         self.was_template_rendered(
             'shop_simplenotifications/confirmed_subject.txt'))
 def test_should_send_email_to_owners(self):
     owners = (('John', '*****@*****.**'), ('Mary', '*****@*****.**'))
     with SettingsOverride(SN_OWNERS=owners):
         confirmed.send(sender=self, order=self.order)
         self.assertEqual(len(mail.outbox[0].to), 2)
 def test_should_have_from_address_from_settings(self):
     from_email = '*****@*****.**'
     with SettingsOverride(SN_FROM_EMAIL=from_email):
         confirmed.send(sender=self, order=self.order)
         self.assertEqual(mail.outbox[0].from_email, from_email)
 def test_should_send_email_on_confirmed_signal(self):
     confirmed.send(sender=self, order=self.order)
     self.assertEqual(len(mail.outbox), 2)
 def test_has_body_from_template(self):
     confirmed.send(sender=self, order=self.order)
     self.assertTrue(self.was_template_rendered(
         'shop_simplenotifications/payment_instructions_body.txt'))
 def test_should_send_email_to_customer(self):
     confirmed.send(sender=self, order=self.order)
     self.assertEqual(mail.outbox[1].to, ['*****@*****.**', ])
 def test_has_subject_from_template(self):
     confirmed.send(sender=self, order=self.order)
     self.assertTrue(self.was_template_rendered(
         'shop_simplenotifications/confirmed_subject.txt'))