Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.fluveo.com/llms.txt

Use this file to discover all available pages before exploring further.

All API requests made with test mode keys (sk_test_...) operate in a sandboxed environment. No real payments are processed, and test data is completely isolated from live data.

Test payment methods

Use these payment method IDs in test mode to simulate different outcomes:
Payment MethodBehavior
pm_card_visaSimulates a successful Visa payment
pm_card_declinedSimulates a card decline (generic_decline)
pm_card_insufficient_fundsSimulates a decline due to insufficient funds
pm_card_expiredSimulates a decline due to an expired card
pm_card_3ds_requiredSimulates a payment that requires 3D Secure authentication
For tokenization flows, use the test card number 4242 4242 4242 4242 with any future expiration date and any 3-digit CVC.

Simulating a successful payment

# Create a PaymentIntent with a test payment method
curl -X POST https://api.leanrails.com/v1/payment_intents \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "amount": 2000,
    "currency": "usd",
    "payment_method": "pm_card_visa"
  }'

# Confirm the payment
curl -X POST https://api.leanrails.com/v1/payment_intents/pi_xxx/confirm \
  -u "sk_test_xxx:" \
  -H "Idempotency-Key: $(uuidgen)"

Simulating a declined payment

curl -X POST https://api.leanrails.com/v1/payment_intents \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "amount": 2000,
    "currency": "usd",
    "payment_method": "pm_card_declined"
  }'
The response includes the decline reason:
{
  "error": {
    "type": "payment_error",
    "code": "card_declined",
    "decline_code": "generic_decline",
    "message": "Your card was declined."
  }
}

Simulating other failure scenarios

# Insufficient funds
curl -X POST https://api.leanrails.com/v1/payment_intents \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "amount": 2000,
    "currency": "usd",
    "payment_method": "pm_card_insufficient_funds"
  }'

# Expired card
curl -X POST https://api.leanrails.com/v1/payment_intents \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "amount": 2000,
    "currency": "usd",
    "payment_method": "pm_card_expired"
  }'

# 3D Secure required
curl -X POST https://api.leanrails.com/v1/payment_intents \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "amount": 2000,
    "currency": "usd",
    "payment_method": "pm_card_3ds_required"
  }'

Testing webhooks

Webhook events in test mode are delivered to your configured endpoints with livemode: false in the payload. You can verify your webhook handler processes test events correctly without affecting live data.
{
  "id": "evt_test_abc123",
  "object": "event",
  "type": "payment_intent.succeeded",
  "livemode": false,
  "data": {
    "object": {
      "id": "pi_test_xyz",
      "object": "payment_intent",
      "amount": 2000,
      "currency": "usd",
      "status": "succeeded",
      "livemode": false
    }
  }
}

Commerce test scenarios

Test mode fully supports all commerce operations. Use these scenarios to validate your integration:

Create a product and price

# Create a product
curl -X POST https://api.leanrails.com/v1/products \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "name": "Test T-Shirt",
    "description": "A test product for integration testing"
  }'

# Create a price for the product
curl -X POST https://api.leanrails.com/v1/prices \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "product_id": "prod_test_abc123",
    "unit_amount": 2500,
    "currency": "usd"
  }'

Create and fulfill an order

# Create an order
curl -X POST https://api.leanrails.com/v1/orders \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "line_items": [
      {
        "price_id": "price_test_abc123",
        "quantity": 2
      }
    ],
    "customer_id": "cus_test_xyz"
  }'

# Create a fulfillment
curl -X POST https://api.leanrails.com/v1/fulfillments \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "order_id": "order_test_abc123",
    "tracking_number": "1Z999AA10123456784",
    "carrier": "ups"
  }'

Test inventory adjustments

curl -X POST https://api.leanrails.com/v1/inventory/adjust \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "inventory_item_id": "invitem_test_abc123",
    "location_id": "loc_test_xyz",
    "adjustment": 50
  }'

Go-live checklist

1

Verify error handling

Test with pm_card_declined, pm_card_insufficient_funds, and pm_card_expired to confirm your integration handles decline codes gracefully.
2

Test the full payment flow

Create, confirm, and refund a PaymentIntent using pm_card_visa in test mode.
3

Test the commerce flow

Create products, prices, orders, and fulfillments. Verify inventory adjustments and webhook events fire correctly.
4

Configure live webhooks

Set up webhook endpoints for your production URL and subscribe to the events you need.
5

Switch to live keys

Replace sk_test_... with your sk_live_... key and start processing real payments.