Skip to content

Getting Started

Get started with RAKUFUN SDK and complete the integration in just a few minutes.

Quick Installation

Include the SDK in your HTML page:

html
<script src="https://sdk.rakufun.com/rakufun-universal.min.js"></script>

Basic Usage

Step 1: Handle Purchase Action

javascript
async function buyWithRakufun() {
  try {
    await rakufun.quickBuy({
      title: "iPhone 15 Pro Max",
      price: "189800",
      url: "https://example.com/iphone-15-pro-max"
    });
  } catch (error) {
    console.error('Purchase failed:', error);
  }
}

Step 2: Add to Your Website

html
<!DOCTYPE html>
<html>
<head>
    <title>My E-commerce Site</title>
</head>
<body>
    <div class="product">
        <h1>iPhone 15 Pro Max</h1>
        <p class="price">¥189,800</p>
        <button onclick="buyWithRakufun()">
            🛒 Buy with RAKUFUN
        </button>
    </div>

    <script src="https://sdk.rakufun.com/rakufun-universal.min.js"></script>
    <script>
        async function buyWithRakufun() {
            await rakufun.quickBuy({
                title: "iPhone 15 Pro Max 256GB Natural Titanium",
                price: "189800",
                url: window.location.href
            });
        }
    </script>
</body>
</html>

Complete Example

A complete example using all fields:

javascript
async function completeExample() {
    try {
        await rakufun.quickBuy({
            // Required fields
            url: window.location.href,
            title: "Nintendo Switch OLED",
            price: "37980",
            
            // Optional fields
            description: "Latest 7-inch OLED display Switch",
            images: ["https://example.com/switch-oled.jpg"],
            brand: "Nintendo",
            condition: "New",
            minQuantity: "1",
            maxStock: "30",
            shippingInfo: "0",
            deliveryTime: "1-3 days",
            precautions: "Includes 1-year manufacturer warranty",
            productParameters: "Display: 7-inch OLED, Storage: 64GB"
        });
    } catch (error) {
        console.error('Purchase failed:', error);
    }
}

Error Handling

The SDK provides comprehensive error handling:

javascript
async function buyWithRakufun() {
    try {
        await rakufun.quickBuy({
            title: "Product Title",
            price: "12300",
            url: window.location.href
        });
    } catch (error) {
        // Handle errors
        switch (error.code) {
            case 'VALIDATION_ERROR':
                alert('Product information is incomplete, please check');
                break;
            case 'NETWORK_ERROR':
                alert('Network connection failed, please retry');
                break;
            default:
                alert('Purchase failed, please try again later');
        }
    }
}

Field Reference (14 Fields)

javascript
// Basic Information (5 fields)
url: "https://...",                    // Product page URL (auto-captured or manually set)
title: "Product Title",               // Product name
price: "19800",                       // Product price (numeric string)
description: "Product Description",   // Detailed description
images: ["img1.jpg", "img2.jpg"],     // Product image array

// Product Attributes (5 fields)
condition: "New",                     // Product condition (New / Used / Display, etc.)
brand: "Brand Name",                  // Brand name
minQuantity: "1",                     // Minimum order quantity
maxStock: "100",                      // Maximum stock quantity
shippingInfo: "500",                  // Shipping information

// Logistics Information (2 fields)
deliveryTime: "3-5 days",             // Estimated delivery time
precautions: "Precaution notes",      // Precautions/additional notes

// Specifications (1 field)
productParameters: "Specifications",  // Product parameters (spec sheet, etc.)

// System Information (1 field)
timestamp: "2024-11-06T..."           // Capture timestamp (auto-generated)

Next Steps

You've successfully run the RAKUFUN SDK. You can continue to:

Need Help?

Support email: [email protected]

Released under the MIT License