# Stripe Integration via LowCodeAPI

## Overview

Stripe is a comprehensive payment processing platform providing services for:

- **Payments** - Accept payments from customers
- **Customers** - Manage customer information
- **Subscriptions** - Create and manage recurring billing
- **Products & Prices** - Define products and pricing
- **Invoices** - Generate and manage invoices
- **Payment Intents** - Process one-time payments
- **Payment Methods** - Manage payment methods
- **Refunds** - Process refunds
- **Webhooks** - Handle event notifications

## Base Endpoint

```
https://api.lowcodeapi.com/stripe/
```

## Authentication

LowCodeAPI handles authentication automatically using API Key authentication. You only need to:

1. **Sign up** at [Stripe](https://stripe.com) to get your API Key
2. **Connect your account** in the LowCodeAPI dashboard
3. **Use your `api_token`** in all requests

The `api_token` is your LowCodeAPI authentication token. LowCodeAPI will automatically:
- Fetch your Stripe API key
- Apply it to each request as a Bearer token

**Auth Type**: Bearer Token (sk_live_ or sk_test_ prefix)

## API Categories

- **Payment Processing** - Online payments and billing

## Common Endpoints

### Category: Payment Intents

#### Create Payment Intent

**Method**: `POST` | **LowCodeAPI Path**: `/v1/payment_intents`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/payment_intents?api_token={api_token}
```

**Description**: Create a payment intent for one-time payment.

**Request Body**:
```json
{
  "amount": 2000,
  "currency": "usd",
  "customer": "cus_abc123",
  "payment_method_types": ["card"],
  "description": "Order payment",
  "metadata": {
    "order_id": "ord_123"
  }
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `amount` | integer | Yes | Payment amount in cents |
| `currency` | string | Yes | Three-letter ISO currency code |
| `customer` | string | No | Customer ID |
| `payment_method_types` | array | No | Payment method types (default: ["card"]) |
| `description` | string | No | Payment description |
| `metadata` | object | No | Custom key-value data |
| `receipt_email` | string | No | Email for receipt |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/payment_intents?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 9900,
    "currency": "usd",
    "payment_method_types": ["card"],
    "description": "Premium subscription"
  }'
```

**Official Documentation**: [Create Payment Intent](https://stripe.com/docs/api/payment_intents/create)

---

#### Retrieve Payment Intent

**Method**: `GET` | **LowCodeAPI Path**: `/v1/payment_intents/payment_intent_id`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/payment_intents/payment_intent_id?payment_intent_id={payment_intent_id}&api_token={api_token}
```

**Description**: Retrieve a payment intent by ID.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `payment_intent_id` | string | Yes | Payment Intent ID |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/stripe/v1/payment_intents/payment_intent_id?payment_intent_id=pi_abc123&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [Retrieve Payment Intent](https://stripe.com/docs/api/payment_intents/retrieve)

---

#### Confirm Payment Intent

**Method**: `POST` | **LowCodeAPI Path**: `/v1/payment_intents/payment_intent_id/confirm`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/payment_intents/payment_intent_id/confirm?payment_intent_id={payment_intent_id}&api_token={api_token}
```

**Description**: Confirm a payment intent.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `payment_intent_id` | string | Yes | Payment Intent ID |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/payment_intents/payment_intent_id/confirm?payment_intent_id=pi_abc123&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [Confirm Payment Intent](https://stripe.com/docs/api/payment_intents/confirm)

---

### Category: Customers

#### Create Customer

**Method**: `POST` | **LowCodeAPI Path**: `/v1/customers`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/customers?api_token={api_token}
```

**Description**: Create a new customer.

**Request Body**:
```json
{
  "name": "John Doe",
  "email": "[email protected]",
  "phone": "+15555555555",
  "description": "VIP Customer",
  "metadata": {
    "source": "website"
  }
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | string | No | Customer name |
| `email` | string | No | Customer email |
| `phone` | string | No | Customer phone |
| `description` | string | No | Customer description |
| `metadata` | object | No | Custom key-value data |
| `payment_method` | string | No | Default payment method ID |
| `address` | object | No | Customer address |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/customers?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Jane Smith",
    "email": "[email protected]",
    "description": "New customer from website"
  }'
```

**Official Documentation**: [Create Customer](https://stripe.com/docs/api/customers/create)

---

#### Retrieve Customer

**Method**: `GET` | **LowCodeAPI Path**: `/v1/customers/customer_id`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/customers/customer_id?customer_id={customer_id}&api_token={api_token}
```

**Description**: Retrieve a customer by ID.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `customer_id` | string | Yes | Customer ID |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/stripe/v1/customers/customer_id?customer_id=cus_abc123&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [Retrieve Customer](https://stripe.com/docs/api/customers/retrieve)

---

#### Update Customer

**Method**: `POST` | **LowCodeAPI Path**: `/v1/customers/customer_id`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/customers/customer_id?customer_id={customer_id}&api_token={api_token}
```

**Description**: Update a customer.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `customer_id` | string | Yes | Customer ID |

**Request Body**:
```json
{
  "name": "Updated Name",
  "email": "[email protected]",
  "metadata": {
    "updated": "true"
  }
}
```

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/customers/customer_id?customer_id=cus_abc123&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Jane Johnson",
    "email": "[email protected]"
  }'
```

**Official Documentation**: [Update Customer](https://stripe.com/docs/api/customers/update)

---

### Category: Products

#### Create Product

**Method**: `POST` | **LowCodeAPI Path**: `/v1/products`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/products?api_token={api_token}
```

**Description**: Create a product.

**Request Body**:
```json
{
  "name": "Premium Plan",
  "description": "Monthly premium subscription",
  "metadata": {
    "feature": "full_access"
  }
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | string | Yes | Product name |
| `description` | string | No | Product description |
| `metadata` | object | No | Custom key-value data |
| `active` | boolean | No | Product availability (default: true) |
| `images` | array | No | Product image URLs |
| `url` | string | No | Product URL |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/products?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Basic Subscription",
    "description": "Monthly basic plan with essential features"
  }'
```

**Official Documentation**: [Create Product](https://stripe.com/docs/api/products/create)

---

#### List Products

**Method**: `GET` | **LowCodeAPI Path**: `/v1/products`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/products?api_token={api_token}
```

**Description**: List all products.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `active` | boolean | No | Filter by active status |
| `limit` | integer | No | Maximum number of products (default: 10) |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/stripe/v1/products?api_token=YOUR_API_TOKEN&active=true&limit=100"
```

**Official Documentation**: [List Products](https://stripe.com/docs/api/products/list)

---

### Category: Prices

#### Create Price

**Method**: `POST` | **LowCodeAPI Path**: `/v1/prices`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/prices?api_token={api_token}
```

**Description**: Create a price for a product.

**Request Body**:
```json
{
  "product": "prod_abc123",
  "unit_amount": 1999,
  "currency": "usd",
  "recurring": {
    "interval": "month"
  }
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `product` | string | Yes | Product ID |
| `unit_amount` | integer | Yes | Price in cents |
| `currency` | string | Yes | Three-letter ISO currency code |
| `recurring` | object | No | Recurring billing configuration |
| `nickname` | string | No | Price nickname |
| `metadata` | object | No | Custom key-value data |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/prices?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "product": "prod_abc123",
    "unit_amount": 2999,
    "currency": "usd",
    "recurring": {"interval": "month"}
  }'
```

**Official Documentation**: [Create Price](https://stripe.com/docs/api/prices/create)

---

### Category: Subscriptions

#### Create Subscription

**Method**: `POST` | **LowCodeAPI Path**: `/v1/subscriptions`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/subscriptions?api_token={api_token}
```

**Description**: Create a subscription for a customer.

**Request Body**:
```json
{
  "customer": "cus_abc123",
  "items": [
    {
      "price": "price_abc123",
      "quantity": 1
    }
  ],
  "payment_behavior": "default_incomplete",
  "metadata": {
    "source": "website"
  }
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `customer` | string | Yes | Customer ID |
| `items` | array | Yes | Subscription items |
| `payment_behavior` | string | No | Payment behavior: default_incomplete, error_if_incomplete |
| `trial_period_days` | integer | No | Trial period in days |
| `metadata` | object | No | Custom key-value data |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/subscriptions?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": "cus_abc123",
    "items": [{"price": "price_abc123", "quantity": 1}],
    "trial_period_days": 14
  }'
```

**Official Documentation**: [Create Subscription](https://stripe.com/docs/api/subscriptions/create)

---

#### Retrieve Subscription

**Method**: `GET` | **LowCodeAPI Path**: `/v1/subscriptions/subscription_id`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/subscriptions/subscription_id?subscription_id={subscription_id}&api_token={api_token}
```

**Description**: Retrieve a subscription by ID.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `subscription_id` | string | Yes | Subscription ID |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/stripe/v1/subscriptions/subscription_id?subscription_id=sub_abc123&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [Retrieve Subscription](https://stripe.com/docs/api/subscriptions/retrieve)

---

#### Cancel Subscription

**Method**: `DELETE` | **LowCodeAPI Path**: `/v1/subscriptions/subscription_id`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/subscriptions/subscription_id?subscription_id={subscription_id}&api_token={api_token}
```

**Description**: Cancel a subscription.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `subscription_id` | string | Yes | Subscription ID |

**Example Request**:
```bash
curl -X DELETE "https://api.lowcodeapi.com/stripe/v1/subscriptions/subscription_id?subscription_id=sub_abc123&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [Cancel Subscription](https://stripe.com/docs/api/subscriptions/cancel)

---

### Category: Invoices

#### Create Invoice

**Method**: `POST` | **LowCodeAPI Path**: `/v1/invoices`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/invoices?api_token={api_token}
```

**Description**: Create an invoice for a customer.

**Request Body**:
```json
{
  "customer": "cus_abc123",
  "description": "Monthly services",
  "metadata": {
    "invoice_type": "recurring"
  }
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `customer` | string | Yes | Customer ID |
| `description` | string | No | Invoice description |
| `metadata` | object | No | Custom key-value data |
| `auto_advance` | boolean | No | Auto-finalize invoice |
| `collection_method` | string | No | Collection method: charge_automatically, send_invoice |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/invoices?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": "cus_abc123",
    "description": "Monthly consulting services"
  }'
```

**Official Documentation**: [Create Invoice](https://stripe.com/docs/api/invoices/create)

---

#### Retrieve Invoice

**Method**: `GET` | **LowCodeAPI Path**: `/v1/invoices/invoice_id`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/invoices/invoice_id?invoice_id={invoice_id}&api_token={api_token}
```

**Description**: Retrieve an invoice by ID.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `invoice_id` | string | Yes | Invoice ID |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/stripe/v1/invoices/invoice_id?invoice_id=in_abc123&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [Retrieve Invoice](https://stripe.com/docs/api/invoices/retrieve)

---

### Category: Refunds

#### Create Refund

**Method**: `POST` | **LowCodeAPI Path**: `/v1/refunds`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/refunds?api_token={api_token}
```

**Description**: Create a refund.

**Request Body**:
```json
{
  "payment_intent": "pi_abc123",
  "amount": 1000,
  "reason": "requested_by_customer",
  "metadata": {
    "order_id": "ord_123"
  }
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `payment_intent` | string | Yes | Payment Intent ID |
| `amount` | integer | No | Refund amount in cents |
| `reason` | string | No | Reason: duplicate, fraudulent, requested_by_customer |
| `metadata` | object | No | Custom key-value data |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/refunds?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "payment_intent": "pi_abc123",
    "amount": 5000,
    "reason": "requested_by_customer"
  }'
```

**Official Documentation**: [Create Refund](https://stripe.com/docs/api/refunds/create)

---

### Category: Payment Methods

#### Create Payment Method

**Method**: `POST` | **LowCodeAPI Path**: `/v1/payment_methods`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/payment_methods?api_token={api_token}
```

**Description**: Create a payment method.

**Request Body**:
```json
{
  "type": "card",
  "card": {
    "number": "4242424242424242",
    "exp_month": 12,
    "exp_year": 2025,
    "cvc": "123"
  },
  "billing_details": {
    "name": "John Doe",
    "email": "[email protected]"
  }
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `type` | string | Yes | Payment method type: card, us_bank_account |
| `card` | object | No | Card details |
| `billing_details` | object | No | Billing information |
| `metadata` | object | No | Custom key-value data |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/payment_methods?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "card",
    "card": {
      "number": "4242424242424242",
      "exp_month": 12,
      "exp_year": 2025,
      "cvc": "123"
    },
    "billing_details": {
      "name": "Jane Smith"
    }
  }'
```

**Official Documentation**: [Create Payment Method](https://stripe.com/docs/api/payment_methods/create)

---

#### Attach Payment Method

**Method**: `POST` | **LowCodeAPI Path**: `/v1/payment_methods/payment_method_id/attach`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/payment_methods/payment_method_id/attach?payment_method_id={payment_method_id}&api_token={api_token}
```

**Description**: Attach a payment method to a customer.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `payment_method_id` | string | Yes | Payment Method ID |

**Request Body**:
```json
{
  "customer": "cus_abc123"
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `customer` | string | Yes | Customer ID |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/stripe/v1/payment_methods/payment_method_id/attach?payment_method_id=pm_abc123&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"customer": "cus_abc123"}'
```

**Official Documentation**: [Attach Payment Method](https://stripe.com/docs/api/payment_methods/attach)

---

### Category: Webhooks

#### List Webhook Endpoints

**Method**: `GET` | **LowCodeAPI Path**: `/v1/webhook_endpoints`

**Full URL**:
```
https://api.lowcodeapi.com/stripe/v1/webhook_endpoints?api_token={api_token}
```

**Description**: List all webhook endpoints.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `limit` | integer | No | Maximum number of endpoints (default: 10) |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/stripe/v1/webhook_endpoints?api_token=YOUR_API_TOKEN&limit=100"
```

**Official Documentation**: [List Webhook Endpoints](https://stripe.com/docs/api/webhook_endpoints/list)

---

## Usage Examples

### Example 1: Process One-Time Payment

Create and confirm a payment:

```bash
# Step 1: Create a customer
# No ID needed - creates new customer
curl -X POST "https://api.lowcodeapi.com/stripe/v1/customers?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "[email protected]"
  }'

# Step 2: Create a payment intent
# No ID needed - creates payment intent
curl -X POST "https://api.lowcodeapi.com/stripe/v1/payment_intents?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 9900,
    "currency": "usd",
    "customer": "CUSTOMER_ID"
  }'

# Step 3: Confirm the payment intent
# Replace PAYMENT_INTENT_ID with actual ID
curl -X POST "https://api.lowcodeapi.com/stripe/v1/payment_intents/payment_intent_id/confirm?payment_intent_id=PAYMENT_INTENT_ID&api_token=YOUR_API_TOKEN"
```

### Example 2: Create Subscription Product

Set up a subscription product:

```bash
# Step 1: Create a product
# No ID needed - creates product
curl -X POST "https://api.lowcodeapi.com/stripe/v1/products?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pro Plan",
    "description": "Monthly pro subscription"
  }'

# Step 2: Create a price for the product
# Replace PRODUCT_ID with actual ID from Step 1
curl -X POST "https://api.lowcodeapi.com/stripe/v1/prices?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "product": "PRODUCT_ID",
    "unit_amount": 1999,
    "currency": "usd",
    "recurring": {"interval": "month"}
  }'

# Step 3: Create subscription for customer
# Replace PRICE_ID and CUSTOMER_ID
curl -X POST "https://api.lowcodeapi.com/stripe/v1/subscriptions?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": "CUSTOMER_ID",
    "items": [{"price": "PRICE_ID"}]
  }'
```

### Example 3: Process Refund

Issue a refund:

```bash
# Step 1: Create refund for payment intent
# No ID needed - creates refund
curl -X POST "https://api.lowcodeapi.com/stripe/v1/refunds?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "payment_intent": "PAYMENT_INTENT_ID",
    "amount": 5000,
    "reason": "requested_by_customer",
    "metadata": {"refund_reason": "Customer not satisfied"}
  }'
```

## Complete Endpoint Reference

For a complete list of all 200+ endpoints and their parameters, refer to:

- **OpenAPI Definition**: https://backend.lowcodeapi.com/stripe/definition
- **Official Stripe Documentation**: https://stripe.com/docs/api

## Rate Limits & Best Practices

- **Rate Limit**: Stripe uses dynamic rate limiting based on account and API endpoint
- **Best Practices**:
  - Use webhook events to handle asynchronous payment updates
  - Store Stripe IDs (customers, products, prices) in your database
  - Always use HTTPS for all API requests
  - Implement idempotency keys for safe retries
  - Use test mode (sk_test_ keys) during development
  - Set up proper webhook signature verification
  - Handle decline codes appropriately
  - Use metadata for tracking custom data

## Error Handling

All responses are wrapped in a `data` key:
```json
{
  "data": {
    // Actual response from Stripe
  }
}
```

Common error responses:
- **400**: Invalid request
- **401**: Invalid API key
- **402**: Payment failed (declined)
- **404**: Resource not found
- **429**: Rate limit exceeded
- **500**: Stripe server error