Exemple #1
0
    def verify(self, item_check_callable=None, test=True):
        """
        Verifies an IPN.
        Checks for obvious signs of weirdness in the payment and flags appropriately.
        
        You can provide a function `item_check_callabe` that takes a PayPalIPN instance
        and returns (True, None) if the item is valid. Returns (False, "reason") if
        the item isn't valid. This function should check that `mc_gross`, `mc_currency`
        `item_name` and `item_number` are all correct.

        """
        from paypal.standard.helpers import duplicate_txn_id
        
        if self._postback(test):

            if self.is_transaction():
                if self.payment_status != "Completed":
                    self.set_flag("Invalid payment_status.")
                if duplicate_txn_id(self):
                    self.set_flag("Duplicate transaction ID.")
                if self.receiver_email != settings.PAYPAL_RECEIVER_EMAIL:
                    self.set_flag("Invalid receiver_email.")
                if callable(item_check_callable):
                    flag, reason = item_check_callable(self)
                    if flag:
                        self.set_flag(reason)                 

            else:
                # ### To-Do: Need to run a different series of checks on recurring payments.
                pass
    
        if self.flag:
            payment_was_flagged.send(sender=self)
        else:
            if self.is_subscription_cancellation():
                subscription_was_cancelled.send(sender=self)
            elif self.is_subscription_signup():
                subscription_was_signed_up.send(sender=self)
            elif self.is_subscription_end_of_term():
                subscription_was_eot.send(sender=self)
            elif self.is_subscription_modified():
                subscription_was_modified.send(sender=self)
            else:
                payment_was_successful.send(sender=self)
Exemple #2
0
 def verify_secret(self, form_instance, secret):
     """
     Verifies an IPN payment over SSL using EWP. 
     
     """
     from paypal.standard.helpers import check_secret
     if not check_secret(form_instance, secret):
         self.set_flag("Invalid secret.")
     
     if self.flag:
         payment_was_flagged.send(sender=self)
     else:
         if self.is_subscription_cancellation():
             subscription_was_cancelled.send(sender=self)
         elif self.is_subscription_signup():
             subscription_was_signed_up.send(sender=self)
         elif self.is_subscription_end_of_term():
             subscription_was_eot.send(sender=self)
         elif self.is_subscription_modified():
             subscription_was_modified.send(sender=self)
         else:
             payment_was_successful.send(sender=self)