Skip to main content

getPrimaryPurchase

SolvaPay SDK v1.0.0


SolvaPay SDK / react/src / getPrimaryPurchase

Function: getPrimaryPurchase()

getPrimaryPurchase(purchases): PurchaseInfo | null

Defined in: packages/react/src/utils/purchases.ts:78

Get the primary purchase to display

Prioritization:

  1. Active purchases (most recent by startDate)
  2. null if no valid purchases

Note: Backend keeps purchases as 'active' until expiration, so we only need to check for active purchases. Cancelled purchases are still active until their endDate.

Parameters

purchases

PurchaseInfo[]

Returns

PurchaseInfo | null