Page MenuHomePhorge

D1600.1775180361.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D1600.1775180361.diff

diff --git a/src/app/Providers/Payment/Stripe.php b/src/app/Providers/Payment/Stripe.php
--- a/src/app/Providers/Payment/Stripe.php
+++ b/src/app/Providers/Payment/Stripe.php
@@ -70,8 +70,8 @@
$request = [
'customer' => $customer_id,
- 'cancel_url' => \url('/wallet'), // required
- 'success_url' => \url('/wallet'), // required
+ 'cancel_url' => Utils::serviceUrl('/wallet'), // required
+ 'success_url' => Utils::serviceUrl('/wallet'), // required
'payment_method_types' => ['card'], // required
'locale' => 'en',
'mode' => 'setup',
@@ -181,8 +181,8 @@
$request = [
'customer' => $customer_id,
- 'cancel_url' => \url('/wallet'), // required
- 'success_url' => \url('/wallet'), // required
+ 'cancel_url' => Utils::serviceUrl('/wallet'), // required
+ 'success_url' => Utils::serviceUrl('/wallet'), // required
'payment_method_types' => ['card'], // required
'locale' => 'en',
'line_items' => [
diff --git a/src/app/Utils.php b/src/app/Utils.php
--- a/src/app/Utils.php
+++ b/src/app/Utils.php
@@ -116,20 +116,13 @@
*/
public static function serviceUrl(string $route): string
{
- return trim(\config('app.public_url'), '/') . '/' . ltrim($route, '/');
+ $url = \config('app.public_url');
- // TODO: Investigate why it does not work
-
- $url = \secure_url($route);
-
- $app_url = trim(\config('app.url'), '/');
- $pub_url = trim(\config('app.public_url'), '/');
-
- if ($pub_url != $app_url) {
- $url = str_replace($app_url, $pub_url, $url);
+ if (!$url) {
+ $url = \config('app.url');
}
- return $url;
+ return rtrim(trim($url, '/') . '/' . ltrim($route, '/'), '/');
}
/**
diff --git a/src/tests/Unit/UtilsTest.php b/src/tests/Unit/UtilsTest.php
--- a/src/tests/Unit/UtilsTest.php
+++ b/src/tests/Unit/UtilsTest.php
@@ -9,10 +9,8 @@
{
/**
* Test for Utils::powerSet()
- *
- * @return void
*/
- public function testPowerSet()
+ public function testPowerSet(): void
{
$set = [];
@@ -55,11 +53,36 @@
}
/**
+ * Test for Utils::serviceUrl()
+ */
+ public function testServiceUrl(): void
+ {
+ $public_href = 'https://public.url/cockpit';
+ $local_href = 'https://local.url/cockpit';
+
+ \config([
+ 'app.url' => $local_href,
+ 'app.public_url' => '',
+ ]);
+
+ $this->assertSame($local_href, Utils::serviceUrl(''));
+ $this->assertSame($local_href . '/unknown', Utils::serviceUrl('unknown'));
+ $this->assertSame($local_href . '/unknown', Utils::serviceUrl('/unknown'));
+
+ \config([
+ 'app.url' => $local_href,
+ 'app.public_url' => $public_href,
+ ]);
+
+ $this->assertSame($public_href, Utils::serviceUrl(''));
+ $this->assertSame($public_href . '/unknown', Utils::serviceUrl('unknown'));
+ $this->assertSame($public_href . '/unknown', Utils::serviceUrl('/unknown'));
+ }
+
+ /**
* Test for Utils::uuidInt()
- *
- * @return void
*/
- public function testUuidInt()
+ public function testUuidInt(): void
{
$result = Utils::uuidInt();
@@ -69,10 +92,8 @@
/**
* Test for Utils::uuidStr()
- *
- * @return void
*/
- public function testUuidStr()
+ public function testUuidStr(): void
{
$result = Utils::uuidStr();

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 3, 1:39 AM (3 d, 16 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18734679
Default Alt Text
D1600.1775180361.diff (3 KB)

Event Timeline