def validate(self, paymentParametersRequired):
        """
    * Validate all set customer details\n
    * @param string paymentParametersRequired\n
    * @return bool
    * @raises IPC_Exception
        """
        if paymentParametersRequired == Purchase.Purchase.PURCHASE_TYPE_FULL:

            if self.getFirstName() == None:
                raise IPC_Exception('Invalid First name')

            if self.getLastName() == None:
                raise IPC_Exception('Invalid Last name')

            if self.getEmail() == None or not Helper.isValidEmail(
                    self.getEmail()):
                raise IPC_Exception('Invalid Email')

        return True
Exemple #2
0
    def validate(self):
        """
    * Validate all set purchase details\n
    * @return boolean
    * @raises IPC_Exception
        """
        if self.getUrlCancel() == None or not Helper.isValidURL(
                self.getUrlCancel()):
            raise IPC_Exception('Invalid Cancel URL')

        if self.getUrlNotify() == None or not Helper.isValidURL(
                self.getUrlNotify()):
            raise IPC_Exception('Invalid Notify URL')

        if self.getUrlOk() == None or not Helper.isValidURL(self.getUrlOk()):
            raise IPC_Exception('Invalid Success URL')

        if self.getCurrency() == None:
            raise IPC_Exception('Invalid currency')

        if self.getEmail() == None and self.getPhone() == None:
            raise IPC_Exception('Must provide customer email either phone')

        if self.getEmail() != None and not Helper.isValidEmail(
                self.getEmail()):
            raise IPC_Exception('Invalid Email')

        try:
            self._getCnf().validate()
        except Exception as ex:
            raise IPC_Exception(f'Invalid Config details: {ex}')

        if self.getCart() == None:
            raise IPC_Exception('Missing Cart details')

        try:
            self.getCart().validate()
        except Exception as ex:
            raise IPC_Exception(f'Invalid Cart details: {ex}')

        return True