def try_payment_identifier(self, text) -> None:
        '''set payment identifier only if valid, else exception'''
        pi = PaymentIdentifier(self.send_tab.wallet, text)
        if not pi.is_valid():
            raise InvalidPaymentIdentifier('Invalid payment identifier')
        self.set_payment_identifier(text)
set payment identifier only if valid, else exception
electrum/gui/qt/paytoedit.py