Skip to content

Commit

Permalink
Plan page fetches plans from BillaBear
Browse files Browse the repository at this point in the history
  • Loading branch information
that-guy-iain committed Jun 4, 2024
1 parent d27b119 commit 7d2d8da
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ UPLOAD_ACCESS_URL=
PAYMENT_PROVIDER=stripe

TRANSACTION_CLOUD_API_KEY=
TRANSACTION_CLOUD_API_KEY_PASSWORD=
TRANSACTION_CLOUD_API_KEY_PASSWORD=

BILLABEAR_API_KEY=
BILLABEAR_API_URL=
4 changes: 4 additions & 0 deletions config/packages/parthenon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ parthenon:
enabled: true
billing:
enabled: true
billabear:
enabled: true
api_key: '%env(resolve:BILLABEAR_API_KEY)%'
api_url: '%env(resolve:BILLABEAR_API_URL)%'
plan_management: config
payments:
provider: stripe
Expand Down
3 changes: 1 addition & 2 deletions src/Parthenon/Billing/BillaBear/BillaBearPlanManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

namespace App\Parthenon\Billing\BillaBear;
namespace Parthenon\Billing\BillaBear;

use BillaBear\Model\Feature;
use BillaBear\Model\Limit;
use BillaBear\Model\Price;
use BillaBear\Model\SubscriptionPlan;
use Doctrine\Common\Collections\Collection;
use Parthenon\Billing\BillaBear\SdkFactory;
use Parthenon\Billing\Exception\NoPlanFoundException;
use Parthenon\Billing\Plan\LimitedUserInterface;
use Parthenon\Billing\Plan\Plan;
Expand Down
3 changes: 3 additions & 0 deletions src/Parthenon/Billing/Controller/PlanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public function listAction(
}

foreach ($plans as $plan) {
if (!$plan->isPublic()) {
continue;
}
$output[$plan->getName()] = [
'name' => $plan->getName(),
'limits' => $plan->getLimits(),
Expand Down
6 changes: 4 additions & 2 deletions src/Parthenon/DependencyInjection/Modules/Billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use Parthenon\Billing\Athena\CustomerTeamSection;
use Parthenon\Billing\Athena\CustomerUserSection;
use Parthenon\Billing\BillaBear\BillaBearPlanManager;
use Parthenon\Billing\CustomerProviderInterface;
use Parthenon\Billing\Plan\CachedPlanManager;
use Parthenon\Billing\Plan\PlanManager;
Expand Down Expand Up @@ -128,8 +129,9 @@ public function handleConfiguration(array $config, ContainerBuilder $container):
}

if (isset($billingConfig['billabear']) && $billingConfig['billabear']['enabled']) {
$loader->load('services/billing/athena_plans.xml');
$container->setAlias(PlanManagerInterface::class, CachedPlanManager::class);
$loader->load('services/billing/billabear.xml');
$container->setAlias(PlanManagerInterface::class, BillaBearPlanManager::class);
$this->handleBillaBearConfig($billingConfig['billabear'], $container);
} elseif ('athena' === strtolower($billingConfig['plan_management'])) {
$loader->load('services/billing/athena_plans.xml');
$container->setAlias(PlanManagerInterface::class, CachedPlanManager::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<argument type="service" id="Parthenon\Billing\BillaBear\SdkFactory" />
</service>

<service id="Parthenon\Billing\Plan\BillaBearPlanManager" class="Parthenon\Billing\Plan\BillaBearPlanManager">
<service id="Parthenon\Billing\BillaBear\BillaBearPlanManager" class="Parthenon\Billing\BillaBear\BillaBearPlanManager">
<argument type="service" id="Parthenon\Billing\BillaBear\SdkFactory" />
</service>

Expand Down

0 comments on commit 7d2d8da

Please sign in to comment.