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

# Link Generator

> Use the Stash Pay Link Generator in Stash Studio to quickly generate, test, and debug checkout links using the Server SDK integration without writing code.

The Stash Pay Link Generator is a testing and development tool in Stash Studio that enables you to quickly generate, test, and debug checkout links using the Server SDK integration method.

**Key Benefits:**

* **Rapid Testing**: Generate checkout links without writing code
* **Visual Preview**: See how checkouts appear in-game with iOS mobile preview
* **Configuration Management**: Save and reuse common test scenarios
* **Team Collaboration**: Export and share configurations with teammates
* **Multi-Environment**: Automatically detects test vs production environments

## Accessing the Link Generator

Navigate to **Stash Studio** → **Stash Pay** → **Link Generator**.

> [!NOTE]
>
> The Link Generator automatically detects your environment (test or production) and uses the appropriate API base URL. Test environment uses `https://test-api.stash.gg`, while production uses `https://api.stash.gg`.

## Quick Start

**1. Select a configuration**

Select a saved configuration from the left panel, or click **New** to create a fresh configuration.

**2. Fill in the form**

Enter your checkout details in the form on the right panel. The form is organized into sections:

1. **Configuration Name** (required) - Name your test configuration
2. **Base URL** - Auto-detected based on environment, can be overridden
3. **API Key** - Select an API key from the dropdown (fetched from Studio settings)
4. **User** (accordion, expanded by default):
   * User ID (required)
   * Email (optional)
   * Display Name (optional)
   * Profile Image URL (optional)
   * Platform (iOS, Android, or Undefined)
5. **Item** (accordion, expanded by default):
   * Item ID (required)
   * Item Name (required)
   * Price (required)
   * Quantity (required, defaults to 1)
   * Image URL (required)
   * Description (optional)
6. **Advanced** (accordion, collapsed by default):
   * Currency (optional, defaults to USD)
   * Transaction ID (optional, with "Generate ID" button)
   * Region Code (optional)

**3. Generate the checkout link**

Click **Generate** to create a checkout link. The CURL command appears in the center panel, and the checkout preview displays in the iOS mobile frame.

**4. Test and save**

Review the checkout in the preview, copy the CURL command if needed, and save your configuration for future use.

## Integration Type

The Link Generator supports **Server SDK** integration only. This is the recommended and most common integration method for Stash Pay, where your backend creates checkout links server-to-server.

> [!NOTE]
>
> **Why Server SDK only?** The Link Generator focuses on Server SDK because it's the standard integration method. Server SDK provides secure, server-side checkout link generation using API keys, which keeps credentials private and is suitable for production use. For other integration methods, you'll need to test using your own code or API tools.

**Configuration includes:**

* API Key (fetched from Studio settings)
* Base URL (auto-detected: test or prod)
* Item details (ID, name, price, quantity, image)
* User information (ID, email, platform)
* Currency and region settings

**Endpoint:** `/sdk/server/checkout_links/generate_quick_pay_url`

## Interface Overview

The interface is split into three main areas:

### Right Panel: Configuration Management

* **Save/Delete buttons** - Manage the current configuration
* **Form fields** - Enter checkout details (items, pricing, user info)
* **Generate button** - Execute the API request

### Center Panel: CURL Command

* View the generated CURL command with syntax highlighting
* Show/hide API keys for security
* Copy command to clipboard
* Fullscreen mode for long commands

### Center Panel: Checkout Preview

* iOS mobile frame showing the live checkout
* Scale controls (60%, 80%, 100%)
* Copy checkout URL
* Open in new tab
* Fullscreen mode

## Configuration Management

### Save Configurations

Save your test scenarios for easy reuse:

1. Fill in the form with your test data
2. Click **Save** (or **Save As** for new configurations)
3. Enter a descriptive name for your configuration
4. Configurations save automatically to browser localStorage

> [!NOTE]
>
> Configurations are stored locally in your browser and organized by shop. They persist across page refreshes and browser restarts.

### Load Saved Configurations

Click any saved configuration card in the left panel to load it. Form fields populate instantly, and previous results clear to avoid confusion.

### New Configuration

Click the **New** button to start fresh. The form resets to default values, and the base URL auto-detects based on your environment.

### Export & Import

Share configurations with your team using JSON export/import:

**Export:**

1. Click the download icon in the header tabs
2. Downloads as `stash-pay-link-configs-{shopHandle}.json`
3. Contains all saved configurations for the current shop

**Import:**

1. Click the upload icon in the header tabs
2. Select a JSON file from your file system
3. Configurations merge with existing (duplicates skipped)
4. Success toast confirms import

## Checkout Preview

The checkout preview displays your generated checkout in an iOS mobile frame, allowing you to see exactly how it will appear to players.

### Preview Features

* **iOS Mobile Frame**: Authentic iOS device borders and styling (393px width × 852px height)
* **Scale Controls**: Adjust preview size (60%, 80%, 100%) to fit your screen
* **Copy URL**: Copy the checkout URL to clipboard
* **Open in New Tab**: Launch checkout in a full browser for testing payments
* **Fullscreen**: Maximize preview for detailed inspection

### Preview Actions

* **Copy URL** - Copy checkout URL to clipboard
* **Open in New Tab** - Launch checkout in browser
* **Fullscreen** - Maximize preview for detailed inspection

> [!NOTE]
>
> Some merchant services don't allow iframes for security reasons. If the preview doesn't load, use "Open in New Tab" to test the full checkout flow.

## CURL Command Display

The CURL command panel shows the exact API request you can use to generate the checkout link:

* **Syntax-highlighted** curl command
* **Show/Hide API key** toggle for security
* **Copy to clipboard** with toast notification
* **Fixed height** (160px) with scrolling
* **Fullscreen mode** for long commands

> [!NOTE]
>
> You can copy the CURL command and use it in a terminal or Postman for automated testing.

## Error Handling

The Link Generator provides clear feedback for different scenarios:

* **Success**: Green indicator, displays preview
* **Error**: Red indicator, shows error details in separate panel
* **Network issues**: Clear error messages with retry guidance

**Common Issues:**

* **Missing required fields** → Review form validation
* **Invalid JSON in request** → Check CURL command
* **Network errors** → Verify API endpoint accessibility
* **Invalid API key** → Verify API key in Studio settings

## Best Practices

### Configuration Naming

Use descriptive names for saved configurations:

* ✅ "1000 gems purchase - iOS user"
* ✅ "VIP subscription - monthly"
* ✅ "Special offer - new users"
* ❌ "Test 1", "Config 2"

### Environment Testing

**Test Environment:**

* Hostname: `localhost` or `studio-test.stash.gg`
* API Base: `https://test-api.stash.gg`
* Use test API keys
* Safe for experimentation

**Production Environment:**

* Hostname: `studio.stash.gg`
* API Base: `https://api.stash.gg`
* Use production API keys with caution
* Validate thoroughly before shipping

> [!WARNING]
>
> Always verify you're using the correct environment (test vs production) before processing transactions. Check your API endpoints and Stash Studio configuration to confirm which environment you're using.

### Team Workflows

**Before Shipping:**

1. Create test configurations for edge cases
2. Export and share with QA team
3. Everyone tests same scenarios
4. Document any issues found
5. Re-test after fixes

**For Debugging:**

1. Reproduce issue with specific configuration
2. Export configuration
3. Attach to bug report
4. Engineering can import and debug locally

## Troubleshooting

### Preview Not Loading

**Check:**

* API key is valid and not expired
* Base URL matches your environment
* Item details are complete and valid
* User information is properly formatted

**Common Issues:**

* Missing required fields → Review form validation
* Invalid JSON in request → Check CURL command
* Network errors → Verify API endpoint accessibility

### Import Failures

**Reasons:**

* Invalid JSON format in file
* File corrupted or incomplete
* Version mismatch (export from different feature version)

**Solutions:**

* Validate JSON with a linter
* Re-export from source
* Check file wasn't truncated during transfer

### CURL Command Not Working

**Verify:**

* API key is correct (toggle show to verify)
* Shell escaping is intact (single quotes handled)
* URL encoding is correct
* Headers are properly formatted

## Technical Details

### Supported Platforms

* **iOS** - Full support with native preview
* **Android** - Supported (preview uses iOS styling)
* **Web** - Not applicable (mobile-only checkout)

### API Endpoint

**Server SDK:**

* Endpoint: `/sdk/server/checkout_links/generate_quick_pay_url`
* Method: POST
* Auth: API Key (x-stash-api-key header)

### Data Storage

**Storage:**

* Configurations stored in browser localStorage
* Scoped per shop: `stash-pay-configs-${shopId}`
* Survives page refreshes and browser restarts
* Last used configuration remembered

**Security:**

* API key secrets never stored (only IDs)
* Secrets fetched at runtime from Studio
* Masked display by default in CURL commands


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.