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

# Issue Your First Card

> Create a card for an approved customer, fund it, and decrypt the card details so they can start spending.

This quickstart takes an approved customer from card creation to a funded,
spendable card: create the card, fund it based on your management model, and
decrypt the card details for the cardholder.

## Before you begin

Complete the [shared setup steps](/docs/quickstarts): get your API keys,
configure webhooks, and get your customer through compliance approval. You'll
also need to know your [program type and management model](/docs/first-steps),
since it determines how you fund the card.

<Steps>
  <Step title="Issue a Card">
    Create a virtual or physical card for the approved user by calling the [Create a Card](/reference/cards/create-a-card-for-a-user) endpoint.

    * **Virtual cards** are available immediately but require client-side decryption to display the PAN
    * **Physical cards** require a shipping address and activation after delivery

    See [Issuing Cards](/docs/issuing-cards) for configuration options and spending limits.
    See [Push Provisioning](/docs/push-provisioning) steps to allow users to add their card to Apple Wallet or Google Wallet directly from your app.

    <CodeGroup>
      ```ts Virtual theme={null}
      const card = await client.users.createCard(userId, {
        type: 'virtual',
      });
      ```

      ```ts Physical theme={null}
      const card = await client.users.createCard(userId, {
        type: 'physical',
        shipping: {
          line1: '123 Main St',
          city: 'San Francisco',
          region: 'CA',
          postalCode: '94105',
          country: 'United States',
          countryCode: 'US',
          phoneNumber: '+14155551234', // required
          method: 'standard',         // 'standard' | 'express' for US; 'international' for non-US
        },
      });
      ```
    </CodeGroup>
  </Step>

  <Step title="Fund the Card">
    How you fund the card depends on your management model:

    <Tabs>
      <Tab title="Rain-Managed">
        1. Retrieve the user's smart contract address via [Get Contract Info](/reference/contracts/get-smart-contract-information-for-a-user)
        2. Send supported tokens (for example, USDC) directly to the contract on-chain
        3. The credit limit updates automatically once the deposit is confirmed

        See [Rain-Managed Programs](/docs/rain-managed-programs) for detailed instructions and code examples.
        See [Supported Chains & Tokens](/docs/supported-chains-and-tokens) for the full list of supported networks.

        <CodeGroup>
          ```ts retrieveContractAddress.ts theme={null}
          const contracts = await client.users.retrieveContracts(userId);
          const contract = contracts[0];

          if (!contract.depositAddress) {
            throw new Error('Deposit address not yet available for this contract');
          }

          // Send supported tokens (for example, USDC) to this address on the specified chain
          console.log(`Deposit to: ${contract.depositAddress}`);
          console.log(`Chain ID: ${contract.chainId}`);
          // contract.tokens lists accepted ERC-20 tokens and their on-chain addresses
          ```
        </CodeGroup>
      </Tab>

      <Tab title="Partner-Managed">
        Add collateral to your account through the Dashboard by clicking **Add tokens**. You can fund via wallet or Safe.

        See [Partner-Managed Programs](/docs/partner-managed-programs) for payment options and balance management.
      </Tab>
    </Tabs>
  </Step>

  <Step title="Decrypt and Use the Card">
    For virtual cards, decrypt the card PAN on the client side so the cardholder can start spending. Rain uses RSA-OAEP encryption for card data.

    See [Viewing Encrypted Card Details](/docs/viewing-encrypted-card-details) for the decryption implementation guide.

    <CodeGroup>
      ```ts decryptCardSecrets.ts theme={null}
      import crypto from 'crypto';

      // RAIN_PUBLIC_KEY: environment-specific PEM key from /docs/resource-sessionid-keys
      const RAIN_PUBLIC_KEY = process.env['RAIN_PUBLIC_KEY'];

      // 1. Generate a random session key
      const sessionKey = crypto.randomBytes(32);

      // 2. Encrypt it with Rain's RSA public key (OAEP padding)
      const encryptedSessionId = crypto.publicEncrypt(
        { key: RAIN_PUBLIC_KEY, padding: crypto.constants.RSA_PKCS1_OAEP_PADDING },
        sessionKey,
      ).toString('base64');

      // 3. Fetch the encrypted card secrets
      //    Note: the param is `SessionId` (capital S, capital I)
      const secrets = await client.cards.retrieveSecrets(card.id, {
        SessionId: encryptedSessionId,
      });

      // secrets.encryptedPan → { data: string, iv: string }
      // secrets.encryptedCvc → { data: string, iv: string }
      // Decrypt both fields with sessionKey using AES
      ```
    </CodeGroup>
  </Step>
</Steps>

## What's next

<Columns cols={3}>
  <Card title="Testing in Sandbox" icon="flask" href="/docs/simulating-transactions/overview">
    Simulate transactions and test your integration before going live.
  </Card>

  <Card title="Transaction Lifecycle" icon="arrows-spin" href="/docs/transaction-lifecycle">
    Understand how transactions flow from authorization to settlement.
  </Card>

  <Card title="Managing Transactions" icon="credit-card" href="/docs/viewing-transactions">
    View, authorize, and manage cardholder transactions.
  </Card>
</Columns>
