예제 #1
0
    def validate(self):
        """
    * Validate all set refund details\n
    * @return boolean
    * @raises IPC_Exception
        """
        try:
            self._getCnf().validate()
        except Exception as ex:
            raise IPC_Exception(f'Invalid Config details: {ex}')

        if self.getAmount() == None or not Helper.isValidAmount(
                self.getAmount()):
            raise IPC_Exception('Invalid Amount')

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

        if self.getTrnref() == None or not Helper.isValidTrnRef(
                self.getTrnref()):
            raise IPC_Exception('Invalid TrnRef')

        if self.getOrderID() == None or not Helper.isValidOrderId(
                self.getOrderID()):
            raise IPC_Exception('Invalid OrderId')

        if self.getOutputFormat() == None or not Helper.isValidOutputFormat(
                self.getOutputFormat()):
            raise IPC_Exception('Invalid Output format')

        return True
예제 #2
0
    def add(self, itemName, quantity, price, type=ITEM_TYPE_ARTICLE):
        """
    * @param string itemName Item name
    * @param int quantity Items quantity
    * @param float price Single item price
    * @param string type\n
    * @return Cart
    * @raises IPC_Exception
        """
        if not bool(itemName):
            raise IPC_Exception('Invalid cart item name')

        if not bool(quantity) or not Helper.isValidCartQuantity(quantity):
            raise IPC_Exception('Invalid cart item quantity')

        if not bool(price) or not Helper.isValidAmount(price):
            raise IPC_Exception('Invalid cart item price')

        item = {
            'name': itemName,
            'quantity': quantity,
            'price': price,
        }

        if type == self.ITEM_TYPE_DELIVERY:
            item['delivery'] = 1
        elif type == self.ITEM_TYPE_DISCOUNT:
            item['price'] = num = -1 * abs(item['price'])

        self.__cart += item

        return self
    def validate(self):
        """
    * Validate all set purchase details\n
    * @return boolean
    * @raises IPC_Exception
        """
        try:
            self._getCnf().validate()
        except Exception as ex:
            raise IPC_Exception(f'Invalid Config details: {ex}')

        if not Helper.versionCheck(self._getCnf().getVersion(), '1.4'):
            raise IPC_Exception(
                'IPCVersion ' + self._getCnf().getVersion() +
                ' does not support IPCAuthorizationCapture method. Please use 1.4 or above.'
            )

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

        if self.getAmount() == None or not Helper.isValidAmount(
                self.getAmount()):
            raise IPC_Exception('Empty or invalid amount')

        return True
    def validate(self):
        """
    * Validate all set purchase details\n
    * @return boolean
    * @raises IPC_Exception
        """
        try:
            self._getCnf().validate()
        except Exception as ex:
            raise IPC_Exception(f'Invalid Config details: {ex}')

        if not Helper.versionCheck(self._getCnf().getVersion(), '1.4'):
            raise IPC_Exception(
                'IPCVersion ' + self._getCnf().getVersion() +
                ' does not support IPCIAPreAuthorization method. Please use 1.4 or above.'
            )

        if self.getItemName() == None or not isinstance(
                self.getItemName(), str):
            raise IPC_Exception('Empty or invalid item name.')

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

        if self.getAmount() == None or not Helper.isValidAmount(
                self.getAmount()):
            raise IPC_Exception('Empty or invalid amount')

        if self.getCard() == None:
            raise IPC_Exception('Missing card details')

        if self.getCard().getCardToken() != None:
            raise IPC_Exception(
                'IPCIAPreAuthorization does not support card token.')

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

        return True
예제 #5
0
    def validate(self):
        """
    * Validate all set PreAuthorization details\n
    * @return boolean
    * @raises IPC_Exception
        """
        if not Helper.versionCheck(self._getCnf().getVersion(), '1.4'):
            raise IPC_Exception(
                'IPCVersion ' + self._getCnf().getVersion() +
                ' does not support IPCPreAuthorization method. Please use 1.4 or above.'
            )

        if self.getItemName() == None or not isinstance(
                self.getItemName(), str):
            raise IPC_Exception('Empty or invalid item name.')

        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.getAmount() == None or not Helper.isValidAmount(
                self.getAmount()):
            raise IPC_Exception('Empty or invalid amount')

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

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

        return True