Skip to content

Commit 695f968

Browse files
authored
AppBridge : Add the host param to the billing redirect url (#1244)
1 parent 31ff8ea commit 695f968

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
laravel: '9.0'
3838
include:
3939
- php: '8.0'
40-
laravel: '9.0'
40+
laravel: '9.39.0'
4141
analysis: true
4242
coverage: 'xdebug'
4343
normalize: true

src/Traits/BillingController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function process(
8080
if (!$request->has('charge_id')) {
8181
return Redirect::route(Util::getShopifyConfig('route_names.home'), [
8282
'shop' => $shop->getDomain()->toNative(),
83+
'host' => base64_encode($shop->getDomain()->toNative().'/admin'),
8384
]);
8485
}
8586
// Activate the plan and save
@@ -92,6 +93,8 @@ public function process(
9293
// Go to homepage of app
9394
return Redirect::route(Util::getShopifyConfig('route_names.home'), [
9495
'shop' => $shop->getDomain()->toNative(),
96+
'host' => base64_encode($shop->getDomain()->toNative().'/admin'),
97+
'billing' => $result ? 'success' : 'failure',
9598
])->with(
9699
$result ? 'success' : 'failure',
97100
'billing'

tests/Traits/BillingControllerTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Osiset\ShopifyApp\Test\Traits;
44

55
use Illuminate\Auth\AuthManager;
6+
use Illuminate\Support\Str;
67
use Osiset\ShopifyApp\Exceptions\MissingShopDomainException;
78
use Osiset\ShopifyApp\Storage\Models\Charge;
89
use Osiset\ShopifyApp\Storage\Models\Plan;
@@ -78,8 +79,11 @@ public function testShopAcceptsBilling(): void
7879
// Refresh the model
7980
$shop->refresh();
8081

82+
$hostValue = urlencode(base64_encode($shop->getDomain()->toNative().'/admin'));
8183
// Assert we've redirected and shop has been updated
8284
$response->assertRedirect();
85+
$this->assertTrue(Str::contains($response->headers->get('Location'), '&host='.$hostValue));
86+
$this->assertTrue(Str::contains($response->headers->get('Location'), '&billing=success'));
8387
$this->assertNotNull($shop->plan);
8488
}
8589

@@ -148,7 +152,8 @@ public function testReturnToSettingScreenNoPlan(): void
148152
['shop' => $shop->name]
149153
);
150154
//Confirm we get sent back to the homepage of the app
151-
$response->assertRedirect('https://example-app.com?shop='.$shop->name);
155+
$hostValue = urlencode(base64_encode($shop->getDomain()->toNative().'/admin'));
156+
$response->assertRedirect('https://example-app.com?shop='.$shop->name.'&host='.$hostValue);
152157
}
153158

154159
public function testUsageChargeSuccessWithShopParam(): void

0 commit comments

Comments
 (0)