[bin] Add payme script
This commit is contained in:
parent
35b6c40c35
commit
6d5e61209c
1 changed files with 51 additions and 0 deletions
51
bin/payme
Executable file
51
bin/payme
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/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
|
Loading…
Reference in a new issue