2019-02-04 11:45:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
CWD="$(dirname $0)"
|
2019-07-11 09:12:14 +00:00
|
|
|
DAMSEL="${CWD}/../damsel"
|
2019-02-04 11:45:55 +00:00
|
|
|
SCRIPTNAME="$(basename $0)"
|
|
|
|
|
|
|
|
source "${CWD}/lib/logging"
|
|
|
|
|
|
|
|
function usage {
|
|
|
|
echo -e "Given ID of an invoice and a payment start payment refund."
|
|
|
|
echo
|
|
|
|
echo -e "Usage: $(em ${SCRIPTNAME} invoice_id payment_id amount currency)"
|
|
|
|
echo -e " $(em invoice_id) Invoice ID (string)."
|
|
|
|
echo -e " $(em payment_id) Payment ID (string), $(em 1) by default."
|
|
|
|
echo -e " $(em amount) Amount (number)."
|
|
|
|
echo -e " $(em currency) Currency code (string)."
|
|
|
|
echo
|
|
|
|
echo -e "More information:"
|
2022-05-27 15:46:58 +00:00
|
|
|
echo -e " https://github.com/valitydev/damsel/blob/master/proto/payment_processing.thrift"
|
2019-02-04 11:45:55 +00:00
|
|
|
exit 127
|
|
|
|
}
|
|
|
|
|
|
|
|
INVOICE="${1}"
|
|
|
|
PAYMENT="${2}"
|
|
|
|
AMOUNT="${3}"
|
|
|
|
CURCODE="${4}"
|
|
|
|
|
|
|
|
[ -z "${INVOICE}" -o -z "${PAYMENT}" -o -z "${AMOUNT}" -o -z "${CURCODE}" ] && usage
|
|
|
|
|
|
|
|
PARAMS=$(jq -nc "{cash:{amount:${AMOUNT}, currency:{symbolic_code:\"${CURCODE}\"}}}")
|
|
|
|
|
|
|
|
[ -f woorlrc ] && source woorlrc
|
|
|
|
|
2019-07-16 16:08:28 +00:00
|
|
|
"${WOORL[@]:-woorl}" \
|
2019-07-11 09:12:14 +00:00
|
|
|
-s "${DAMSEL}/proto/payment_processing.thrift" \
|
|
|
|
"http://${HELLGATE:-hellgate}:8022/v1/processing/invoicing" \
|
2022-05-27 15:46:58 +00:00
|
|
|
Invoicing RefundPayment "\"${INVOICE}\"" "\"${PAYMENT}\"" "${PARAMS}"
|