{{-- How far one registered product is from being sold through BCP. "Registered here" and "sold through here" are not the same thing. A product can have its routes, its token and its plans in BCP and still not be asking BCP anything, because its own code was never changed to. So this lists what it takes a step at a time, and the step only the product can take is read off the token itself: when it was last used. It shows whether each setting is in place. It never shows the setting: a token and a webhook secret are credentials, and a status page is no place to print them. --}}
@php $name = $integration->name(); //The address as its documentation writes it: {workspaceId}, {hospitalId}. $placeholder = '{'.$integration->accountNoun().'Id}'; $left = collect($steps)->where('state', 'todo'); $sold = $left->isEmpty(); $chips = [ 'done' => ['label' => 'Done', 'tone' => 'border-emerald-200 bg-emerald-50 text-emerald-700'], 'todo' => ['label' => 'To do', 'tone' => 'border-amber-200 bg-amber-50 text-amber-700'], 'off' => ['label' => 'Off', 'tone' => 'border-slate-700 bg-slate-800 text-slate-400'], ]; @endphp

{{ $sold ? $name.' is sold through BCP' : $name.' is not sold through BCP yet' }}

@if ($sold) It has a plan on sale, holds a token, and is asking BCP what each {{ $integration->accountNoun() }} may do. @else {{ $left->count() }} {{ Str::plural('step', $left->count()) }} left, marked “To do” below. A step marked “Off” is one {{ $name }} can do without. @endif

What it takes

Read from the plans, the tokens and the settings each time this page is opened.

    @foreach ($steps as $step)
  1. {{ $step['label'] }} {{ $step['detail'] }} {{ $chips[$step['state']]['label'] }}
  2. @endforeach

How the two systems talk

{{ $name }} asks BCP
GET /api/v1/{{ $integration->key }}/entitlements/{{ $placeholder }} One token for every {{ $integration->accountNoun() }}, and for nothing else: it is answered only for plans under {{ $product->name }}, at up to {{ number_format($integration->rateLimitPerMinute()) }} requests a minute.
BCP tells {{ $name }}
A signed POST (header {{ $integration->signatureHeader() }}) saying which {{ $integration->accountNoun() }} changed, never what it changed to, so there is one description of what a {{ $integration->accountNoun() }} may do and never a second that could disagree with it.
@if ($tokens->isNotEmpty())
    @foreach ($tokens as $token)
  • {{ $token->name }} {{ $token->hasScope($integration->billingScope()) ? 'Reads and opens purchases' : 'Reads only' }} · {{ $token->last_used_at ? 'last used '.$token->last_used_at->diffForHumans() : 'never used' }}
  • @endforeach
@endif

What a plan can grant

The switches and ceilings {{ $name }} understands. A plan sets them under Plans.

Features
@forelse ($integration->featureKeys() as $key) {{ $key }} @empty None. Nothing in {{ $name }} is switched on or off by a plan. @endforelse
Limits
@forelse ($integration->limitKeys() as $key) {{ $key }} @empty None. A plan of {{ $name }} grants a period of use and nothing else. @endforelse

BCP owns {{ $name }}'s plans, prices, trials, invoices and payments. {{ $name }} owns everything else about itself.