Yes, using public key encryption is a secure form of payment.
Public key cryptography or public key encryption system means the method of encryption may be known but the method of decryption is not.
The word "public" in this system meant that anyone can use such key to encrypt their own message, but there is a second key which is private, and is only known to the recipient. In this case, the customer uses the coffee shops' public key to encrypt his information (including his credit card info).
This system remains secure given the condition that a potential attacker only knows the public key.