summaryrefslogtreecommitdiff
path: root/integrationtests/test-refund.sh
blob: 40dc65f57a80f47107d94f4e1ce279a75aa59868 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
# Script to check that the wallet can handle refund URIs and actually process the refund

source "common.sh"
normal_start_and_wait "refund"

echo "Withdraw TESTKUDOS"
taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle testing withdraw -e "$EXCHANGE_URL" -b "$BANK_URL" -a "TESTKUDOS:10" >>"$LOG" 2>>"$LOG"
echo -n "Balance after withdrawal: "
taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
REFUND_URI=$(taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle testing gen-refund-uri \
    -m "$MERCHANT_URL" -k sandbox \
    -s "first refund" -a "TESTKUDOS:8" -r "TESTKUDOS:2" 2>>"$LOG" | grep -E -m 1 -o "taler://refund.*insecure=1")
echo -n "Balance after payment: "
taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
echo "Handling refund: $REFUND_URI"
taler-wallet-cli --wallet-db="$WALLET_DB" --no-throttle handle-uri "$REFUND_URI" 2>"$LOG"
taler-wallet-cli --wallet-db="$WALLET_DB" run-until-done 2>>"$LOG" >>"$LOG"
echo -n "Balance after first refund: "
taler-wallet-cli --wallet-db="$WALLET_DB" balance 2>>"$LOG"
# TODO how to test second refund for same purchase?

echo "SUCCESS"
exit 0