From 9860bfa0bacf28cc874c5422bfcbb5a0445b3b3d Mon Sep 17 00:00:00 2001 From: Eddy Jaga Date: Fri, 12 Dec 2025 17:19:06 +1100 Subject: [PATCH] fix webhook url --- Gemfile.lock | 2 +- changelog.md | 12 ++++++++++++ lib/zai_payment.rb | 2 +- lib/zai_payment/client.rb | 2 +- lib/zai_payment/config.rb | 13 +++++++++++++ lib/zai_payment/version.rb | 2 +- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 78eca19..f80b114 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - zai_payment (2.8.4) + zai_payment (2.8.5) base64 (~> 0.3.0) faraday (~> 2.0) openssl (~> 3.3) diff --git a/changelog.md b/changelog.md index 1b9fd12..133cf41 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,17 @@ ## [Released] +## [2.8.5] - 2025-12-12 + +### Fixed +- **Webhook Environment-Based Base URL**: Fixed webhook base URL to dynamically switch based on environment 🔧 + - Added `Config#webhook_base_endpoint` method to determine correct endpoint per environment + - Production environment: webhooks use `core_base` (`https://au-0000.api.assemblypay.com`) + - Prelive environment: webhooks use `va_base` (`https://sandbox.au-0000.api.assemblypay.com`) + - Webhook client now automatically uses correct base URL when switching environments + - Improves on v2.8.4 which hardcoded to `core_base` for all environments + +**Full Changelog**: https://github.com/Sentia/zai-payment/compare/v2.8.4...v2.8.5 + ## [2.8.4] - 2025-12-12 ### Fixed diff --git a/lib/zai_payment.rb b/lib/zai_payment.rb index abae6ba..d2fd483 100644 --- a/lib/zai_payment.rb +++ b/lib/zai_payment.rb @@ -46,7 +46,7 @@ def token_type = auth.token_type # --- Resource accessors --- # @return [ZaiPayment::Resources::Webhook] webhook resource instance def webhooks - @webhooks ||= Resources::Webhook.new(client: Client.new(base_endpoint: :core_base)) + @webhooks ||= Resources::Webhook.new(client: Client.new(base_endpoint: config.webhook_base_endpoint)) end # @return [ZaiPayment::Resources::User] user resource instance diff --git a/lib/zai_payment/client.rb b/lib/zai_payment/client.rb index 93eec79..6ba5c44 100644 --- a/lib/zai_payment/client.rb +++ b/lib/zai_payment/client.rb @@ -107,7 +107,7 @@ def set_timeout_option(faraday, option, value) def base_url # Use specified base_endpoint or default to va_base # Users API uses core_base endpoint - # Webhooks API uses va_base endpoint + # Webhooks API uses core_base (production) or va_base (prelive) if base_endpoint config.endpoints[base_endpoint] else diff --git a/lib/zai_payment/config.rb b/lib/zai_payment/config.rb index 7a1bbe1..6efad42 100644 --- a/lib/zai_payment/config.rb +++ b/lib/zai_payment/config.rb @@ -39,5 +39,18 @@ def endpoints raise "Unknown environment: #{environment}" end end + + # Returns the appropriate webhook base endpoint based on environment + # Production uses core_base, prelive uses va_base + def webhook_base_endpoint + case environment.to_sym + when :production + :core_base + when :prelive + :va_base + else + raise "Unknown environment: #{environment}" + end + end end end diff --git a/lib/zai_payment/version.rb b/lib/zai_payment/version.rb index caf06e0..52611f7 100644 --- a/lib/zai_payment/version.rb +++ b/lib/zai_payment/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module ZaiPayment - VERSION = '2.8.4' + VERSION = '2.8.5' end