예제 #1
0
파일: pdt.py 프로젝트: alexissmirnov/donomo
    def test_pdt_signals(self):
        self.successful_pdt_fired = False
        self.failed_pdt_fired = False

        def successful_pdt(sender, **kwargs):
            self.successful_pdt_fired = True

        pdt_successful.connect(successful_pdt)

        def failed_pdt(sender, **kwargs):
            self.failed_pdt_fired = True

        pdt_failed.connect(failed_pdt)

        self.assertEqual(len(PayPalPDT.objects.all()), 0)
        paypal_response = self.client.get(reverse('paypal-pdt'),
                                          self.get_params)
        self.assertContains(paypal_response,
                            'Transaction complete',
                            status_code=200)
        self.assertEqual(len(PayPalPDT.objects.all()), 1)
        self.assertTrue(self.successful_pdt_fired)
        self.assertFalse(self.failed_pdt_fired)
        pdt_obj = PayPalPDT.objects.all()[0]
        self.assertEqual(pdt_obj.flag, False)
예제 #2
0
 def test_pdt_signals(self):
     self.successful_pdt_fired = False        
     self.failed_pdt_fired = False
     
     def successful_pdt(sender, **kwargs):
         self.successful_pdt_fired = True
     pdt_successful.connect(successful_pdt)
         
     def failed_pdt(sender, **kwargs):
         self.failed_pdt_fired = True 
     pdt_failed.connect(failed_pdt)
     
     self.assertEqual(len(PayPalPDT.objects.all()), 0)        
     paypal_response = self.client.get("/pdt/", self.get_params)
     self.assertContains(paypal_response, 'Transaction complete', status_code=200)        
     self.assertEqual(len(PayPalPDT.objects.all()), 1)
     self.assertTrue(self.successful_pdt_fired)
     self.assertFalse(self.failed_pdt_fired)        
     pdt_obj = PayPalPDT.objects.all()[0]
     self.assertEqual(pdt_obj.flag, False)
예제 #3
0
파일: listeners.py 프로젝트: potar/lfs
    ipn_obj = sender    
    if ipn_obj:        
        order = None
        if ipn_obj.payment_status == ST_PP_COMPLETED:
            order = mark_payment(ipn_obj, PAYMENT_FLAGGED)
        else:
            order = mark_payment(ipn_obj, PAYMENT_FAILED)    
        if order is not None:
            transaction, created = PayPalOrderTransaction.objects.get_or_create(order=order)
            transaction.ipn.add(ipn_obj)
            transaction.save()
        else:
            logging.warning("unsuccessful ipn payment, no order found for uuid %s"%ipn_obj.custom)
    else:
        logging.warning("unsuccessful ipn payment signal with no ipn object")

def successful_pdt(sender, **kwargs):    
    logging.info("successful pdt payment")
    pdt_obj = sender    
    order = mark_payment(pdt_obj, True)
    
def unsuccesful_pdt(sender, **kwargs):
    logging.info("unsuccessful pdt payment")
    pdt_obj = sender
    order = mark_payment(pdt_obj, False)    
    
payment_was_successful.connect(successful_payment, dispatch_uid="Order.ipn_successful")
payment_was_flagged.connect(unsuccessful_payment, dispatch_uid="Order.ipn_unsuccessful")
pdt_successful.connect(successful_pdt, dispatch_uid="Order.pdt_successful")
pdt_failed.connect(unsuccesful_pdt, dispatch_uid="Order.pdt_unsuccessful")