> ## Documentation Index
> Fetch the complete documentation index at: https://memberpulseptyltd.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# UJ-M-003: Choose and Purchase Membership Plan

> Member selects a membership plan and completes payment to become a paid member

## Journey Overview

| Attribute      | Value                                                 |
| -------------- | ----------------------------------------------------- |
| **Journey ID** | UJ-M-003                                              |
| **Actor**      | Registered member without active membership           |
| **Goal**       | Purchase a membership plan to access member benefits  |
| **Trigger**    | User clicks "Upgrade" or visits membership plans page |
| **Outcome**    | User has active paid membership with full access      |

## Preconditions

* User has completed registration
* User profile is complete (or minimum required)
* User does not have an active membership (or upgrading)
* At least one membership plan is published

## Journey Flow

```mermaid theme={null}
flowchart TD
    A[Member views plans] --> B[Compare plan features]
    B --> C[Select plan]
    C --> D{Plan has pricing tiers?}
    D -->|Yes| E[Select pricing tier]
    D -->|No| F[Review selection]
    E --> F
    F --> G{Promo code?}
    G -->|Yes| H[Apply promo code]
    G -->|No| I[Proceed to checkout]
    H --> I
    I --> J[Enter payment details]
    J --> K[Stripe processes payment]
    K --> L{Payment successful?}
    L -->|Yes| M[Membership activated]
    L -->|No| N[Show error, retry]
    N --> J
    M --> O[Confirmation + Invoice]
    O --> P[Access member benefits]
```

## Detailed Steps

<Steps>
  <Step title="Browse Membership Plans">
    Member navigates to Membership Plans page.

    **Displayed Information per Plan:**

    * Plan name and description
    * Price (monthly/annual options)
    * Feature list with checkmarks
    * "Most Popular" or "Best Value" badges
    * "Current Plan" indicator if applicable

    **Sorting/Filtering:**

    * Plans ordered by price (low to high) or featured
    * Category filter if multiple plan types exist
  </Step>

  <Step title="Compare Plans">
    Member reviews plan comparison table:

    | Feature          | Basic    | Professional | Enterprise      |
    | ---------------- | -------- | ------------ | --------------- |
    | Member directory | ✅        | ✅            | ✅               |
    | Event discounts  | 10%      | 20%          | 30%             |
    | Course access    | Limited  | Full         | Full + Priority |
    | CPD tracking     | ✅        | ✅            | ✅               |
    | Resource library | Basic    | Full         | Full + Archives |
    | Support          | Standard | Priority     | Dedicated       |
    | Price/month      | \$19     | \$49         | \$99            |
  </Step>

  <Step title="Select Plan">
    Member clicks "Select" or "Choose Plan" button.

    **If plan has pricing tiers:**

    * Monthly billing option
    * Annual billing (with discount, e.g., "Save 20%")
    * Multi-year options if available

    **If upgrading:**

    * Shows prorated amount
    * Explains billing change
  </Step>

  <Step title="Apply Promo Code (Optional)">
    Member enters promotional code:

    **Promo Code Types:**

    * Percentage discount (e.g., 25% off)
    * Fixed amount discount (e.g., \$50 off)
    * Free trial extension
    * First month/year free

    **Validation:**

    * Code exists and is active
    * Code applies to selected plan
    * Code not already used by member
    * Code within usage limits

    **Display:**

    * Original price shown struck through
    * Discount amount displayed
    * New total calculated
  </Step>

  <Step title="Review Order">
    Order summary displayed:

    ```
    ┌─────────────────────────────────────┐
    │ Order Summary                       │
    ├─────────────────────────────────────┤
    │ Professional Plan (Annual)    $588  │
    │ Promo: WELCOME25             -$147  │
    ├─────────────────────────────────────┤
    │ Subtotal                      $441  │
    │ GST (10%)                      $44  │
    ├─────────────────────────────────────┤
    │ Total                         $485  │
    │ Billed annually                     │
    │ Next billing: Dec 22, 2026          │
    └─────────────────────────────────────┘
    ```
  </Step>

  <Step title="Enter Payment Details">
    Stripe Elements embedded payment form:

    **Payment Methods:**

    * Credit/Debit Card (Visa, Mastercard, Amex)
    * Digital Wallets (Apple Pay, Google Pay)
    * Bank Transfer (if enabled)

    **Card Form Fields:**

    * Card number
    * Expiry date
    * CVC
    * Cardholder name
    * Billing address (if required)

    **Saved Cards:**

    * If returning customer, show saved payment methods
    * Option to add new card
  </Step>

  <Step title="Process Payment">
    Member clicks "Complete Purchase":

    1. Frontend validates card details
    2. Stripe creates PaymentIntent
    3. 3D Secure authentication if required
    4. Payment processed
    5. Webhook received by backend
    6. Membership record created/updated
  </Step>

  <Step title="Confirmation">
    On successful payment:

    * Success message displayed
    * Membership activated immediately
    * Confirmation email sent with:
      * Invoice/receipt
      * Membership details
      * Welcome information
      * Getting started guide
    * Redirected to dashboard or welcome page
  </Step>
</Steps>

## Payment Failure Handling

| Failure Reason     | User Message                                       | Recovery Action      |
| ------------------ | -------------------------------------------------- | -------------------- |
| Card declined      | "Your card was declined. Please try another card." | Enter different card |
| Insufficient funds | "Payment failed. Please check your card balance."  | Use different card   |
| Card expired       | "This card has expired. Please use a valid card."  | Update card details  |
| 3D Secure failed   | "Authentication failed. Please try again."         | Retry authentication |
| Network error      | "Connection error. Please try again."              | Retry payment        |
| Fraud detected     | "Unable to process payment. Contact support."      | Contact support      |

## Subscription Management

After purchase, member can:

* View active subscription in profile
* See next billing date
* Update payment method
* Download invoices
* Cancel/downgrade (with confirmation)

## Group/Corporate Membership

If member is part of a corporate plan:

* Plan may be pre-assigned
* Payment handled by organization
* Member sees "Sponsored by \[Company]"
* No payment required from individual

## Related Entities

* [`Membership Plan`](/entities/core/membership-plan)
* [`Membership Pricing`](/entities/core/membership-pricing)
* [`User Membership`](/entities/core/user-membership)
* [`Payment Transaction`](/entities/integration/payment-transaction)
* [`Unearned Revenue`](/entities/integration/unearned-revenue)

## Related Journeys

* [UJ-M-004](/member/journeys/renew-membership)
* [UJ-M-005](/member/journeys/failed-payment-recovery)
* [UJ-M-031](/member/journeys/view-invoices)

## Acceptance Criteria

### Frontend

* [ ] Plan comparison page with feature matrix
* [ ] Pricing toggle (monthly/annual)
* [ ] Promo code input with validation
* [ ] Order summary with real-time calculation
* [ ] Stripe Elements payment form integration
* [ ] Saved payment methods display
* [ ] 3D Secure modal handling
* [ ] Loading states during payment processing
* [ ] Success confirmation page
* [ ] Error handling with clear messages

### Backend

* [ ] `GET /api/membership-plans` - List available plans
* [ ] `GET /api/membership-plans/{id}` - Plan details
* [ ] `POST /api/membership/subscribe` - Create subscription
* [ ] `POST /api/promo-codes/validate` - Validate promo code
* [ ] `POST /api/payments/create-intent` - Create Stripe PaymentIntent
* [ ] Webhook handler for `payment_intent.succeeded`
* [ ] Webhook handler for `customer.subscription.created`

### Permissions

* [ ] Any authenticated user can view plans
* [ ] Only members without active subscription can purchase

### Business Rules

* [ ] Promo codes validated against plan and usage limits
* [ ] Tax calculated based on member location
* [ ] Annual plans show monthly equivalent price
* [ ] Upgrading prorates remaining value
* [ ] Membership active immediately on payment success

### Error Handling

* [ ] Payment failures logged with Stripe error codes
* [ ] Failed payments trigger support notification
* [ ] Partial failures (payment ok, membership creation failed) handled gracefully
