From 13fed7e14bb160ff920d4d821f47545128755609 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 8 Apr 2025 11:19:39 +0300 Subject: [PATCH 1/2] Adds `scripts/hellgate/cancel-chargeback.sh` script --- scripts/hellgate/cancel-chargeback.sh | 57 +++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 scripts/hellgate/cancel-chargeback.sh diff --git a/scripts/hellgate/cancel-chargeback.sh b/scripts/hellgate/cancel-chargeback.sh new file mode 100755 index 0000000..4f97a52 --- /dev/null +++ b/scripts/hellgate/cancel-chargeback.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +set -e + +CWD="$(dirname $0)" +DAMSEL="${CWD}/../../damsel" + +[ -f woorlrc ] && source woorlrc + +SCRIPTNAME=$(basename $0) + +source "${CWD}/../lib/logging" + +usage () { + echo -e "Given ID of an invoice fetch a number of events emitted by this invoice." + echo + echo -e "Usage: $(em ${SCRIPTNAME} invoice_id payment_id chargeback_id)" + echo -e " $(em invoice_id) Invoice ID (string)." + echo -e " $(em payment_id) Payment ID (string)." + echo -e " $(em chargeback_id) Chargeback ID (string)." + echo -e " -h, --help Show this help message." + echo + echo -e "More information:" + echo -e " https://github.com/valitydev/damsel/blob/ecf49770668a5985e0cb2989220318d205e14c37/proto/payment_processing.thrift#L1318-L1335" + echo -e " https://github.com/valitydev/damsel/blob/ecf49770668a5985e0cb2989220318d205e14c37/proto/payment_processing.thrift#L1340-L1352" + exit 127 +} + +reopen_chargeback() { + "${WOORL[@]:-woorl}" \ + -s "${DAMSEL}/proto/payment_processing.thrift" \ + "http://${HELLGATE:-hellgate}:8022/v1/processing/invoicing" \ + Invoicing ReopenChargeback "$1" "$2" "$3" "{}" +} + +cancel_chargeback() { + "${WOORL[@]:-woorl}" \ + -s "${DAMSEL}/proto/payment_processing.thrift" \ + "http://${HELLGATE:-hellgate}:8022/v1/processing/invoicing" \ + Invoicing CancelChargeback "$1" "$2" "$3" "{}" +} + +case "$1" in + ""|"-h"|"--help" ) + usage + ;; + * ) + INVOICE_ID="\"$1\"" + PAYMENT_ID="\"$2\"" + CHARGEBACK_ID="\"$3\"" + reopen_chargeback "$INVOICE_ID" "$PAYMENT_ID" "$CHARGEBACK_ID" + echo -n "Chargeback $CHARGEBACK_ID $(info reopened)." + cancel_chargeback "$INVOICE_ID" "$PAYMENT_ID" "$CHARGEBACK_ID" + echo -n "Chargeback $CHARGEBACK_ID $(info canceled)." + echo -n "$(info Done.)" + ;; +esac From c08930172ba486f9aa54fc276df1c66e974e82b5 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 8 Apr 2025 11:30:27 +0300 Subject: [PATCH 2/2] Fixes logging --- scripts/hellgate/cancel-chargeback.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/hellgate/cancel-chargeback.sh b/scripts/hellgate/cancel-chargeback.sh index 4f97a52..62599e3 100755 --- a/scripts/hellgate/cancel-chargeback.sh +++ b/scripts/hellgate/cancel-chargeback.sh @@ -27,6 +27,7 @@ usage () { } reopen_chargeback() { + echo -e "$(info Reopenning)..." "${WOORL[@]:-woorl}" \ -s "${DAMSEL}/proto/payment_processing.thrift" \ "http://${HELLGATE:-hellgate}:8022/v1/processing/invoicing" \ @@ -34,6 +35,7 @@ reopen_chargeback() { } cancel_chargeback() { + echo -e "$(info Cancelling)..." "${WOORL[@]:-woorl}" \ -s "${DAMSEL}/proto/payment_processing.thrift" \ "http://${HELLGATE:-hellgate}:8022/v1/processing/invoicing" \ @@ -49,9 +51,9 @@ case "$1" in PAYMENT_ID="\"$2\"" CHARGEBACK_ID="\"$3\"" reopen_chargeback "$INVOICE_ID" "$PAYMENT_ID" "$CHARGEBACK_ID" - echo -n "Chargeback $CHARGEBACK_ID $(info reopened)." + echo -e "Chargeback $(em reopened)." cancel_chargeback "$INVOICE_ID" "$PAYMENT_ID" "$CHARGEBACK_ID" - echo -n "Chargeback $CHARGEBACK_ID $(info canceled)." - echo -n "$(info Done.)" + echo -e "Chargeback $(em canceled)." + echo -e "$(info Done)." ;; esac