Skip to main content

Create Checkout Session

Create a checkout session to start the subscription flow.
curl -X POST https://api.eventop.xyz/checkout/create \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "planId": "premium-monthly",
    "customerEmail": "user@example.com",
    "customerId": "user_123",
    "successUrl": "https://yourdomain.com/success",
    "cancelUrl": "https://yourdomain.com/pricing",
    "metadata": {
      "userId": "123",
      "source": "pricing_page"
    }
  }'

Request Body

planId
string
required
The ID of the subscription plan to subscribe to
customerEmail
string
required
Customer’s email address
customerId
string
Your internal customer/user ID (for tracking)
successUrl
string
required
URL to redirect to after successful subscription
cancelUrl
string
URL to redirect to if user cancels (defaults to successUrl)
metadata
object
Additional data to attach to the session (max 50 keys)

Response

{
  "sessionId": "session_abc123...",
  "url": "https://checkout.eventop.xyz/session_abc123...",
  "expiresAt": "2024-12-09T11:00:00Z"
}
sessionId
string
Unique identifier for the checkout session
url
string
Checkout page URL to redirect the user to
expiresAt
string
ISO 8601 timestamp when the session expires (30 minutes from creation)

Get Checkout Session

Retrieve details of a checkout session.
curl https://api.eventop.xyz/checkout/session_abc123 \
  -H "Authorization: Bearer sk_live_..."

Response

{
  "sessionId": "session_abc123...",
  "status": "completed",
  "merchant": {
    "walletAddress": "7xKXtg2...",
    "companyName": "YourCompany",
    "logoUrl": "https://..."
  },
  "plan": {
    "planId": "premium-monthly",
    "planName": "Premium Plan",
    "feeAmount": "9990000",
    "paymentInterval": "2592000",
    "description": "Premium features"
  },
  "customerEmail": "user@example.com",
  "customerId": "user_123",
  "successUrl": "https://yourdomain.com/success",
  "cancelUrl": "https://yourdomain.com/pricing",
  "metadata": {
    "userId": "123",
    "source": "pricing_page"
  },
  "subscriptionPda": "ABC123...",
  "expiresAt": "2024-12-09T11:00:00Z",
  "completedAt": "2024-12-09T10:45:23Z"
}

Complete Checkout Session

Mark a checkout session as completed (called by our mobile app).
curl -X POST https://api.eventop.xyz/checkout/session_abc123/complete \
  -H "Content-Type: application/json" \
  -d '{
    "subscriptionPda": "ABC123...",
    "userWallet": "7xKXtg2...",
    "signature": "5j7Km..."
  }'

Request Body

subscriptionPda
string
required
The on-chain subscription PDA address
userWallet
string
required
User’s Solana wallet address
signature
string
required
Transaction signature from Solana

Response

{
  "sessionId": "session_abc123...",
  "status": "completed",
  "subscriptionPda": "ABC123...",
  "successUrl": "https://yourdomain.com/success?session_id=session_abc123"
}

Cancel Checkout Session

Cancel a pending checkout session.
curl -X POST https://api.eventop.xyz/checkout/session_abc123/cancel \
  -H "Authorization: Bearer sk_live_..."

Response

{
  "sessionId": "session_abc123...",
  "status": "cancelled",
  "cancelUrl": "https://yourdomain.com/pricing"
}

Session Status

StatusDescription
pendingSession created, awaiting user action
completedUser successfully subscribed
expiredSession expired (30 min TTL)
cancelledSession was cancelled

Best Practices

Success and cancel URLs must use HTTPS in production.
The session ID is automatically appended as a query parameter: ?session_id=...Use this to verify the subscription was completed.
Sessions expire after 30 minutes. Show an error and let users retry.
Store any data you need to correlate the subscription with your system:
    {
      "metadata": {
        "userId": "123",
        "accountId": "acc_456",
        "campaign": "summer-2024",
        "referrer": "twitter"
      }
    }