File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -421,6 +421,28 @@ public static function getApiUrl() {
421
421
return self ::$ config ['ApiUrl ' ];
422
422
}
423
423
424
+ /**
425
+ * Returns the appropriate URL for the host that should load the embedded app.
426
+ *
427
+ * @param string $host The host value received from Shopify
428
+ *
429
+ * @return string
430
+ */
431
+ public static function getEmbeddedAppUrl ($ host )
432
+ {
433
+ if (empty ($ host )) {
434
+ throw new SdkException ("Host value cannot be empty " );
435
+ }
436
+
437
+ $ decodedHost = base64_decode ($ host , true );
438
+ if (!$ decodedHost ) {
439
+ throw new SdkException ("Host was not a valid base64 string " );
440
+ }
441
+
442
+ $ apiKey = self ::$ config ['ApiKey ' ];
443
+ return "https:// $ decodedHost/apps/ $ apiKey " ;
444
+ }
445
+
424
446
/**
425
447
* Maintain maximum 2 calls per second to the API
426
448
*
You can’t perform that action at this time.
0 commit comments