chargeCents($net); } /** * The fee as the extra, non-recurring line of a checkout session — or null * when the operator has set none. * * `$currency` is the recurring Price's own, not the catalogue default: Stripe * requires every line of one session to share a currency, and reading two * sources for it is how a checkout ends up refused for a mismatch nobody can * see from either page. * * @return array{amount_cents: int, label: string, currency: string}|null */ public static function checkoutLine(string $currency, TaxTreatment $treatment): ?array { $charged = self::chargedCents($treatment); if ($charged === 0) { return null; } return [ 'amount_cents' => $charged, // What the customer reads on Stripe's page and on Stripe's receipt. // The same words the price sheet uses, because meeting a different // name for the same charge at the till is exactly the moment somebody // abandons a checkout. 'label' => __('checkout.setup_fee_line'), 'currency' => strtoupper($currency), ]; } }