Documentation

Learn how to confirm Pi orders, manage credits, and build with our APIs

Getting Started

Welcome to Flux! Our platform helps merchants automate Pi order confirmations by monitoring blockchain activity. Here's how it works:

1

Connect Your Wallet

Register your Pi wallet to receive direct payments from customers.

2

Purchase Credits

Buy credits to power order confirmations. Each credit confirms one Pi order.

3

Add Order Button

Integrate our confirmation button using SDKs or plugins.

Important: Flux never holds or processes Pi. All payments go directly from customer wallets to your wallet. We confirm blockchain activity and notify you.

Understanding Credits

Credits power Flux's order confirmation service:

How Credits Work

  • Each credit confirms one order on the Pi blockchain
  • When a customer pays, one credit is used to verify the transaction
  • Credits never expire - they remain valid until used
  • Purchase credits in bulk for volume discounts

Credit Usage Example

// Check your credit balance
const credits = await flux.credits.getBalance();
console.log(`Credits remaining: ${credits.available}`);

// Monitor credit usage
flux.on('credit.used', (event) => {
    console.log(`Credit used for order ${event.orderId}`);
    console.log(`Credits remaining: ${event.creditsRemaining}`);
});

Order Confirmation Flow

How Flux confirms orders through blockchain monitoring:

  1. Customer clicks your order button
  2. Customer pays directly to your wallet address
  3. Flux confirms the transaction on the blockchain (uses 1 credit)
  4. You receive instant order confirmation
  5. Order details appear in your dashboard

Code Example

// Create an order button
const button = await flux.buttons.create({
    amount: 10.0,
    merchantWallet: 'YOUR_PI_WALLET',  // Payments go directly here
    onOrderConfirmed: (transaction) => {
        console.log('Order confirmed!', transaction.amount);
        console.log('Transaction ID:', transaction.id);
        // Credit used for confirmation
        console.log('Credits remaining:', transaction.creditsRemaining);
    }
});

Authentication

All API requests require authentication. You can generate API keys from your Flux Developer Dashboard.

API Keys

Authentication is performed via HTTP Bearer Authentication. Include your API key in the Authorization header:

GET /v1/payments HTTP/1.1
Host: api.flux.io
Authorization: Bearer your_api_key_here
Content-Type: application/json

Security Note

Always keep your API keys secure. Never share them in client-side code or publicly accessible repositories. Your API keys carry many privileges, so be sure to keep them secure!

API Key Types

Flux provides two types of API keys:

Key Type Environment Purpose
sk_live_... Production For processing real Pi transactions. Use only in your production environment.
sk_test_... Sandbox For testing. Creates test payments that don't move real Pi. Use for development and testing.

Authentication Code Samples

JavaScript
Python
PHP
// Using fetch API with authentication header
const fetchPayments = async () => {
  try {
    const response = await fetch('https://api.flux.io/v1/payments', {
      method: 'GET',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      }
    });
    
    const data = await response.json();
    
    console.log('Payments:', data);
    return data;
  } catch (error) {
    console.error('Error fetching payments:', error);
  }
};
fetchPayments();
console.error('Error fetching payments:', error); } };

Error Handling

The Flux API uses conventional HTTP response codes to indicate the success or failure of API requests. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the provided information (e.g., a required parameter was missing), and codes in the 5xx range indicate an error with Flux's servers.

HTTP Status Codes

Status Code Description
200 - OK Everything worked as expected.
201 - Created A new resource was successfully created.
400 - Bad Request The request was unacceptable, often due to missing or invalid parameters.
401 - Unauthorized No valid API key provided or the key doesn't have the required permissions.
404 - Not Found The requested resource doesn't exist.
429 - Too Many Requests Rate limit exceeded.
500, 502, 503, 504 - Server Errors Something went wrong on Flux's servers.

Error Response Format

When an error occurs, Flux returns a JSON object with error details:

{
  "error": {
    "code": "invalid_request",
    "message": "The provided API key is invalid",
    "docs_url": "https://docs.flux.io/errors#invalid_request",
    "param": null,
    "request_id": "req_7PtEBi4JMVb2Ef"
  }
}

Error Types

Flux API errors generally fall into the following categories:

Error Code Description
authentication_error Failed to authenticate with the API.
invalid_request The request parameters were invalid.
resource_not_found The requested resource does not exist.
rate_limit_exceeded Too many requests hit the API too quickly.
api_error An error occurred on Flux's server.

Handling Errors

JavaScript
Python
try {
  const payment = await flux.payments.create({
    amount: 10.0,
    currency: 'PI',
    description: 'Premium subscription'
  });
  // Handle successful payment
} catch (error) {
  if (error.type === 'authentication_error') {
    console.error('Authentication failed:', error.message);
    // Handle authentication error
  } else if (error.type === 'invalid_request') {
    console.error('Invalid request:', error.message);
    // Handle invalid parameters
  } else if (error.type === 'rate_limit_exceeded') {
    console.error('Rate limit exceeded. Try again later.');
    // Implement backoff strategy
  } else {
    console.error('Unexpected error:', error.message);
    // Handle other errors
  }
}

Order Confirmation API

Monitor Pi blockchain activity for order confirmations

Confirm an Order

Endpoint: POST /order/confirm

Request


{
  "amount": 10.0,
  "currency": "PI",
  "description": "Premium subscription",
  "merchant_wallet": "GD5YHQWSTDLU4I2TVSTTLVKXI3RDEOYMPC66EYS32JBPBTKWT4X2EWBW"
}
                

Response


{
  "order_id": "ord_8f7sd6f876dsf",
  "amount": 10.0,
  "status": "pending_confirmation",
  "created_at": "2025-05-27T22:45:13Z"
}
                

Verified Reviews API

Collect and display blockchain-verified customer feedback

Request a Review

Endpoint: POST /request

Request


{
  "order_id": "order_12345",
  "product_name": "Premium Subscription"
}
                

SDKs & Libraries

Official SDKs for Flux's order confirmation services:

JavaScript/Node.js

Our official Node.js SDK for server-side and client-side applications.

npm install flux-pi-sdk
View on GitHub

Python

Python SDK for server-side applications.

pip install flux-pi-sdk
View on GitHub

PHP

PHP SDK for server-side applications.

composer require flux/flux-pi-sdk
View on GitHub

Ruby

Ruby SDK for server-side applications and Rails integration.

gem install flux-pi-sdk
View on GitHub

Go

Go SDK for integrating Pi Network payments in Go applications.

go get github.com/flux/flux-pi-sdk
View on GitHub

Sandbox Environment

The Flux Sandbox environment allows you to test your integration without processing real Pi transactions.

Sandbox API Keys

You can generate sandbox API keys from your Flux Developer Dashboard. These keys will only work with the sandbox API endpoints.

Testing Payments

In the sandbox environment, you can simulate successful payments using the following test Pi wallet:


# Test Pi Wallet Address for Sandbox
public_key: GD5YHQWSTDLU4I2TVSTTLVKXI3RDEOYMPC66EYS32JBPBTKWT4X2EWBW