Skip to content

Commit

Permalink
fix(UX): Correct URL in shopify webhooks
Browse files Browse the repository at this point in the history
Users end up typing complete url with protocol but it doesn't work with
shopify SDK.

Fix: Strip protocol.
  • Loading branch information
ankush committed Dec 5, 2023
1 parent 4452fea commit 71d5a3f
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from frappe import _
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from frappe.utils import get_datetime
from pyactiveresource.connection import UnauthorizedAccess
from shopify.collection import PaginatedIterator
from shopify.resources import Location

Expand Down Expand Up @@ -41,6 +40,8 @@ def is_enabled(self) -> bool:
def validate(self):
ensure_old_connector_is_disabled()

if self.shopify_url:
self.shopify_url = self.shopify_url.replace("https://", "")
self._handle_webhooks()
self._validate_warehouse_links()
self._initalize_default_values()
Expand All @@ -54,10 +55,7 @@ def on_update(self):

def _handle_webhooks(self):
if self.is_enabled() and not self.webhooks:
try:
new_webhooks = connection.register_webhooks(self.shopify_url, self.get_password("password"))
except UnauthorizedAccess:
new_webhooks = []
new_webhooks = connection.register_webhooks(self.shopify_url, self.get_password("password"))

if not new_webhooks:
msg = _("Failed to register webhooks with Shopify.") + "<br>"
Expand Down

0 comments on commit 71d5a3f

Please sign in to comment.