dotfiles/bin/payme
2023-07-26 19:36:38 +02:00

51 lines
940 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
name="" # Your name
iban="" # Your International Bank Account Number, without separators
bic="" # The Bank Identification Code of your bank
currency="EUR"
if [ -z "$name" ] || [ -z "$iban" ] || [ -z "$bic" ]; then
echo "Fill in your account information in $(realpath "$0")"
exit 1
fi
if test $# -lt 2; then
echo "Usage: $0 <amount> <message>" >&2
exit 1
fi
amount="$1"
shift 1
message="$@"
echo "$(tput bold)Beneficiary$(tput sgr0) $name"
echo "$(tput bold)Account$(tput sgr0) $iban (BIC: $bic)"
echo "$(tput bold)Amount$(tput sgr0) $amount $currency"
echo "$(tput bold)Message$(tput sgr0) $message"
if ! [[ $amount =~ [0-9]+(\.[0-9]+)? ]]; then
echo "Incorrect 'amount' format, (only) provide a decimal number like '1.5'" >&2
exit 1
fi
rm -f /tmp/qr.png
qrencode -s 10 -o /tmp/qr.png <<EOF
BCD
001
1
SCT
$bic
$name
$iban
$currency$amount
CHAR
$message
EOF
nsxiv /tmp/qr.png