Add premium My Case MVP
This commit is contained in:
@@ -10,7 +10,7 @@ declare(strict_types=1);
|
||||
* STRIPE_PUBLISHABLE_KEY pk_live_... or pk_test_...
|
||||
* STRIPE_WEBHOOK_SECRET whsec_...
|
||||
* STRIPE_PRICE_TOPUP_S / _M / _L
|
||||
* STRIPE_PRICE_LIGHT / _PRO / _PRO_PLUS
|
||||
* STRIPE_PRICE_PLUS_NOK / STRIPE_PRICE_PRO_NOK
|
||||
*/
|
||||
final class StripeClient
|
||||
{
|
||||
@@ -55,9 +55,8 @@ final class StripeClient
|
||||
'topup_s' => self::config('STRIPE_PRICE_TOPUP_S'),
|
||||
'topup_m' => self::config('STRIPE_PRICE_TOPUP_M'),
|
||||
'topup_l' => self::config('STRIPE_PRICE_TOPUP_L'),
|
||||
'light' => self::config('STRIPE_PRICE_LIGHT'),
|
||||
'pro' => self::config('STRIPE_PRICE_PRO'),
|
||||
'pro_plus' => self::config('STRIPE_PRICE_PRO_PLUS'),
|
||||
'plus' => self::config('STRIPE_PRICE_PLUS_NOK'),
|
||||
'pro' => self::config('STRIPE_PRICE_PRO_NOK'),
|
||||
];
|
||||
}
|
||||
$id = $map[$sku] ?? '';
|
||||
@@ -78,12 +77,16 @@ final class StripeClient
|
||||
};
|
||||
}
|
||||
|
||||
/** Map a Stripe price ID back to the internal subscription tier (light/pro/pro_plus). */
|
||||
/** Map a Stripe price ID back to the internal subscription tier (plus/pro). */
|
||||
public static function tierForPrice(string $priceId): ?string
|
||||
{
|
||||
foreach (['light', 'pro', 'pro_plus'] as $tier) {
|
||||
if (self::config('STRIPE_PRICE_' . strtoupper($tier)) === $priceId) {
|
||||
return $tier;
|
||||
$map = [
|
||||
'plus' => self::config('STRIPE_PRICE_PLUS_NOK'),
|
||||
'pro' => self::config('STRIPE_PRICE_PRO_NOK'),
|
||||
];
|
||||
foreach ($map as $tier => $configuredPriceId) {
|
||||
if ($configuredPriceId !== '' && hash_equals($configuredPriceId, $priceId)) {
|
||||
return (string)$tier;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -173,7 +176,7 @@ final class StripeClient
|
||||
$method = strtoupper($method);
|
||||
$headers = [
|
||||
'Authorization: Bearer ' . $this->secretKey,
|
||||
'Stripe-Version: 2024-10-28.acacia',
|
||||
'Stripe-Version: 2026-02-25.clover',
|
||||
];
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
Reference in New Issue
Block a user