Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(docker): add webhook notifiers for installation tracking (#7653)
Shailesh-7143446c5e6048b
diff --git a/docker-compose.yml b/docker-compose.ymlindex cb39b23b13..ca8434cf05 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -8,6 +8,15 @@ networks:services:### Dependencies+ prestart-hook:+ image: curlimages/curl-base:latest+ container_name: prestart-hook+ entrypoint: ["/bin/sh", "-c", "apk add --no-cache bash && /bin/bash /prestart_hook.sh"]+ volumes:+ - ./scripts/prestart_hook.sh:/prestart_hook.sh+ networks:+ - router_net+pg:image: postgres:latestports:@@ -86,6 +95,18 @@ services:start_period: 5stimeout: 5s+ poststart-hook:+ image: curlimages/curl-base:latest+ container_name: poststart-hook+ depends_on:+ hyperswitch-server:+ condition: service_healthy # Ensures it only starts when `hyperswitch-server` is healthy+ entrypoint: ["/bin/sh", "-c", "apk add --no-cache bash jq && /bin/bash /poststart_hook.sh"]+ volumes:+ - ./scripts/poststart_hook.sh:/poststart_hook.sh+ networks:+ - router_net+hyperswitch-producer:image: docker.juspay.io/juspaydotin/hyperswitch-producer:standalonepull_policy: alwaysdiff --git a/scripts/poststart_hook.sh b/scripts/poststart_hook.shnew file mode 100755index 0000000000..dcd06aa02b--- /dev/null+++ b/scripts/poststart_hook.sh@@ -0,0 +1,65 @@+#! /usr/bin/env bash+set -euo pipefail++# Configuration+PLATFORM="docker-compose" # Change to "helm" or "cdk" as needed+VERSION="unknown"+STATUS=""+SERVER_BASE_URL="http://hyperswitch-server:8080"+HYPERSWITCH_HEALTH_URL="${SERVER_BASE_URL}/health"+HYPERSWITCH_DEEP_HEALTH_URL="${SERVER_BASE_URL}/health/ready"+WEBHOOK_URL="https://hyperswitch.gateway.scarf.sh/${PLATFORM}"++# Fetch health status+echo "Fetching app server health status..."+HEALTH_RESPONSE=$(curl --silent --fail "${HYPERSWITCH_HEALTH_URL}") || HEALTH_RESPONSE="connection_error"++if [[ "${HEALTH_RESPONSE}" == "connection_error" ]]; then+ STATUS="error"+ ERROR_MESSAGE="404 response"++ curl --get "${WEBHOOK_URL}" \+ --data-urlencode "version=${VERSION}" \+ --data-urlencode "status=${STATUS}" \+ --data-urlencode "error_message=${ERROR_MESSAGE}"++ echo "Webhook sent with connection error."+ exit 0+fi++# Fetch Hyperswitch version+VERSION=$(curl --silent --output /dev/null --request GET --write-out '%header{x-hyperswitch-version}' "${HYPERSWITCH_DEEP_HEALTH_URL}" | sed 's/-dirty$//')++echo "Fetching Hyperswitch health status..."+HEALTH_RESPONSE=$(curl --silent "${HYPERSWITCH_DEEP_HEALTH_URL}")++# Prepare curl command+CURL_COMMAND=("curl" "--get" "${WEBHOOK_URL}" "--data-urlencode" "version=${VERSION}")++# Check if the response contains an error+if [[ "$(echo "${HEALTH_RESPONSE}" | jq --raw-output '.error')" != 'null' ]]; then+ STATUS="error"+ ERROR_TYPE=$(echo "${HEALTH_RESPONSE}" | jq --raw-output '.error.type')+ ERROR_MESSAGE=$(echo "${HEALTH_RESPONSE}" | jq --raw-output '.error.message')+ ERROR_CODE=$(echo "${HEALTH_RESPONSE}" | jq --raw-output '.error.code')++ CURL_COMMAND+=(+ "--data-urlencode" "status=${STATUS}"+ "--data-urlencode" "error_type=${ERROR_TYPE}"+ "--data-urlencode" "error_message=${ERROR_MESSAGE}"+ "--data-urlencode" "error_code=${ERROR_CODE}"+ )+else+ STATUS="success"+ CURL_COMMAND+=("--data-urlencode" "status=${STATUS}")++ for key in $(echo "${HEALTH_RESPONSE}" | jq --raw-output 'keys_unsorted[]'); do+ value=$(echo "${HEALTH_RESPONSE}" | jq --raw-output --arg key "${key}" '.[$key]')+ CURL_COMMAND+=("--data-urlencode" "'${key}=${value}'")+ done+fi++# Send the webhook request+bash -c "${CURL_COMMAND[*]}"++echo "Webhook notification sent."diff --git a/scripts/prestart_hook.sh b/scripts/prestart_hook.shnew file mode 100755index 0000000000..c4eb16efd8--- /dev/null+++ b/scripts/prestart_hook.sh@@ -0,0 +1,14 @@+#! /usr/bin/env bash+set -euo pipefail++# Define the URL and parameters+PLATFORM="docker-compose"+WEBHOOK_URL="https://hyperswitch.gateway.scarf.sh/${PLATFORM}"+VERSION="unknown"+STATUS="initiated"++# Send the GET request+curl --get "${WEBHOOK_URL}" --data-urlencode "version=${VERSION}" --data-urlencode "status=${STATUS}"++# Print confirmation+echo "Request sent to ${WEBHOOK_URL} with version=${VERSION} and status=${STATUS}"