Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
AppBridge : Add the host param to the billing redirect url (#1244)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyon147 authored Nov 10, 2022
1 parent 31ff8ea commit 695f968
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
laravel: '9.0'
include:
- php: '8.0'
laravel: '9.0'
laravel: '9.39.0'
analysis: true
coverage: 'xdebug'
normalize: true
Expand Down
3 changes: 3 additions & 0 deletions src/Traits/BillingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function process(
if (!$request->has('charge_id')) {
return Redirect::route(Util::getShopifyConfig('route_names.home'), [
'shop' => $shop->getDomain()->toNative(),
'host' => base64_encode($shop->getDomain()->toNative().'/admin'),
]);
}
// Activate the plan and save
Expand All @@ -92,6 +93,8 @@ public function process(
// Go to homepage of app
return Redirect::route(Util::getShopifyConfig('route_names.home'), [
'shop' => $shop->getDomain()->toNative(),
'host' => base64_encode($shop->getDomain()->toNative().'/admin'),
'billing' => $result ? 'success' : 'failure',
])->with(
$result ? 'success' : 'failure',
'billing'
Expand Down
7 changes: 6 additions & 1 deletion tests/Traits/BillingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Osiset\ShopifyApp\Test\Traits;

use Illuminate\Auth\AuthManager;
use Illuminate\Support\Str;
use Osiset\ShopifyApp\Exceptions\MissingShopDomainException;
use Osiset\ShopifyApp\Storage\Models\Charge;
use Osiset\ShopifyApp\Storage\Models\Plan;
Expand Down Expand Up @@ -78,8 +79,11 @@ public function testShopAcceptsBilling(): void
// Refresh the model
$shop->refresh();

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

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

public function testUsageChargeSuccessWithShopParam(): void
Expand Down

0 comments on commit 695f968

Please sign in to comment.