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

# payment-guide

> How to pay for your Scriptonia blueprint with Solana or Dodo (card/UPI). 

## Payment Methods (Solana, Dodo)

### Solana

Pay with **SOL**  from a Solana wallet. The app uses **Reown AppKit** with a Solana adapter; **Phantom** and other Solana wallets are supported.

**Details**

| Aspect        | Details                                                                                                      |
| :------------ | :----------------------------------------------------------------------------------------------------------- |
| **You need**  | A Solana wallet (e.g. Phantom) with enough **SOL** (for the transfer and fees)                               |
| **Network**   | `devnet` for testing; `mainnet` for production. Wallet and app must use the same network.                    |
| **Recipient** | `TREASURY_WALLET` (from `/api/payment/config`).                                                              |
| **Flow**      | Connect wallet (header) → Payment page → choose **Solana** → approve transaction → redirect to **Execution** |

### Dodo (Card / UPI)

Pay with **Visa, Mastercard, UPI, or other cards** via **Dodo Payments**. You are redirected to Dodo’s hosted checkout and back to Scriptonia.

**Details**

| Aspect       | Details                                                                                                                                |
| :----------- | :------------------------------------------------------------------------------------------------------------------------------------- |
| **You need** | A card or UPI accepted by Dodo. No wallet required.                                                                                    |
| **Amount**   | Set in Dodo (often aligned with `UNIFIED_PRICE_USD`, e.g. \~\$4 USD).                                                                  |
| **Flow**     | Choose **Card** → **Pay with Card** → Dodo Checkout → complete payment → redirect to `/payment/success` → verification → **Execution** |

**Platform mapping**

* Selected platform (Website, Web Application, Android, iOS) maps to a Dodo product
* Product and price are defined in the Dodo dashboard

***

## Setting Up Phantom Wallet

Phantom is one of the supported Solana wallets. You connect via the **wallet button in the header** (Reown AppKit).

***

### 1. Install Phantom

* **Browser:** [https://phantom.app](https://phantom.app) → Chrome, Brave, Edge, Firefox
* **Mobile:** App Store or Google Play

***

### 2. Create or import a wallet

* **New:** Create wallet and back up seed phrase
* **Import:** Enter existing seed phrase

***

### 3. Get SOL

* **Devnet:** Use a devnet faucet; switch Phantom to **Devnet**
* **Mainnet:** Buy SOL and withdraw to Phantom;
* Keep SOL for **transaction fees**

***

### 4. Connect on Scriptonia

* Use the **wallet button in the header**
* Choose **Phantom** (or another Solana wallet)
* Approve connection
* Wallet state appears in header

**Note**

* Payment page does **not** connect the wallet
* You must connect via the **header** before paying

***

## Payment Process

***

### Solana

1. **Idea → Intent → Platform**
2. Open **Payment page** (`/payment?sessionId=...&platform=...`)
3. Ensure wallet is connected via **header**
4. Select **Solana**
5. Click **Pay**
6. Sign transaction in wallet
7. On confirmation → redirected to **Execution**

***

### Dodo (Card)

1. **Idea → Intent → Platform**
2. Open **Payment page**
3. Select **Card**
4. Click **Pay with Card**
5. Complete checkout on Dodo
6. Redirect to `/payment/success?sessionId=...&platform=...`
7. App verifies payment via `/api/dodo/confirm-payment`
8. Redirect to **Execution**

***

### After payment

* **Solana**
  * `/api/payment` called
  * Workflow updated with `transactionSig`
  * `paymentMethod: 'solana'`
* **Dodo**
  * `/api/dodo/confirm-payment` (and webhook)
  * Workflow updated with `dodoPaymentId`
  * `paymentMethod: 'dodo'`

Both lead to **Execution**.

***

## Troubleshooting Payments

***

### Solana

| Issue                            | What to check                                     |
| :------------------------------- | :------------------------------------------------ |
| Insufficient funds               | Enough **SOL** + fees                             |
| Use header wallet button         | Connect wallet via header first                   |
| RPC error / timeout              | Check RPC or `HELIUS_RPC_URL`                     |
| Wrong network                    | Wallet and app network must match                 |
| Wallet not signing               | Unlock Phantom; reconnect                         |
| Invalid agent address            | `TREASURY_WALLET` missing or wrong                |
| Tx succeeded but workflow failed | Contact support with `sessionId` and tx signature |

***

### Dodo

| Issue                        | What to check                                     |
| :--------------------------- | :------------------------------------------------ |
| Failed to create checkout    | Check `DODO_API_KEY` and product                  |
| Redirect fails               | Browser blockers or URL issues                    |
| Stuck on “Verifying Payment” | Check `/api/dodo/confirm-payment` and URL params  |
| Verification failed          | Contact support with `sessionId` and `payment_id` |
| Paid but Execution blocked   | Workflow not updated; contact support             |

***

### General

| Issue                       | What to check                                |
| :-------------------------- | :------------------------------------------- |
| No Active Session           | Start from Home → Idea → Intent → Platform   |
| Workflow context not found  | Session lost; restart or contact support     |
| Payment ok, Execution fails | Retry with same `sessionId`; contact support |
