### Quick Start: Create Product and Checkout with BagelPay Python SDK Source: https://bagelpay.gitbook.io/docs/documentation/sdks/python-sdk A Python example demonstrating the quick start workflow: initializing the BagelPay client, creating a sample product, and obtaining a product URL for checkout. ```python import random from bagelpay import BagelPayClient, CheckoutRequest, CreateProductRequest # 1. Create account at [BagelPay Dashboard](https://dashboard.bagelpay.io) # 2. Go to "Developer Settings" → "API Keys" # 3. Generate new API key for your environment # 3. Save your test and live keys securely # 1. Initialize the client client = BagelPayClient( api_key="your-api-key-here" ) # 2. Create a sample product product = client.create_product(CreateProductRequest( name="Product_name", description="Description_of_product", price=29.99 currency="USD", billing_type="subscription", tax_inclusive=False, tax_category="digital_products", recurring_interval="daily", trial_days=1 )) # 3. Get payment URL print(f"Product URL: {product.product_url}") # 4. Complete the checkout session # For testing payments, you could use the test card '4242 4242 4242 4242' with any expiration and CVV. ``` -------------------------------- ### Quick Start: Create Product with BagelPay SDK Source: https://bagelpay.gitbook.io/docs/documentation/sdks/typescripts-sdk A 30-second quick demo demonstrating how to initialize the BagelPay client and create a new product with subscription details. This example highlights basic SDK usage for product management. ```typescript import { BagelPayClient } from 'bagelpay'; async function main() { // Initialize the client const client = new BagelPayClient({ apiKey: 'your-api-key' }); try { // Create a product const product = await client.createProduct({ name: `Premium Subscription ${Date.now()}`, description: 'Monthly premium subscription with unique identifier', price: 29.99, currency: 'USD', billingType: 'subscription', taxInclusive: false, taxCategory: 'digital_products', recurringInterval: 'monthly', trialDays: 7 }); console.log('✅ Product url:', product.productUrl); } catch (error) { console.error('❌ Error:', error); } } // Run the main function main().catch(console.error); ``` -------------------------------- ### Install BagelPay Golang SDK Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Installs the BagelPay Golang SDK using the `go get` command. This is the initial step to integrate BagelPay's payment functionalities into your Go application. ```shell go get github.com/bagelpay/bagelpay-sdk-go ``` -------------------------------- ### Run Basic Usage Example with BagelPay Go SDK Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Instructions on how to run a basic usage example for the BagelPay Go SDK. This typically involves navigating to the example directory and executing the Go program. ```sh cd examples/basic_usage go run main.go ``` -------------------------------- ### Install BagelPay Python SDK Source: https://bagelpay.gitbook.io/docs/documentation/sdks/python-sdk Instructions to install the BagelPay Python SDK using pip or Poetry. It also covers installation from source for development purposes. ```sh # Install latest stable version pip install bagelpay # Upgrade to latest version pip install --upgrade bagelpay ``` ```sh # Add to your project poetry add bagelpay ``` ```sh # Clone the repository git clone https://github.com/bagelpay/bagelpay-sdk-python.git # Create virtual environment python3 -m venv venv source venv/bin/activate # Linux/Mac # or venv\Scripts\activate # Windows # Install SDK in development mode pip install -e . # Verify installation python -c "import bagelpay; print('Installation successful!')" ``` -------------------------------- ### Start Local Server with ngrok Tunnel (JavaScript) Source: https://bagelpay.gitbook.io/docs/documentation/developers-and-api-usage/webhooks/verify-webhook-requests Starts a local HTTP server on a specified port and creates a public URL using ngrok to expose the local server. Requires the 'ngrok' npm package. The function connects to ngrok using an authentication token and logs the public URL. It then starts the express application to listen for incoming requests. ```javascript // Start server with ngrok tunnel async function startServer() { const listeningPort = 8000; try { // Set your ngrok auth token await ngrok.authtoken('your_ngrok_key'); const publicUrl = await ngrok.connect({ addr: listeningPort, proto: 'http', subdomain: 'stunning-crane-direct' // Optional: use your reserved subdomain }); console.log(`ngrok Public URL: ${publicUrl}`); app.listen(listeningPort, '0.0.0.0', () => { console.log(`Server running on port ${listeningPort}`); }); } catch (error) { console.error('Failed to start server:', error); } } if (require.main === module) { startServer(); } ``` -------------------------------- ### Install BagelPay Typescript SDK Source: https://bagelpay.gitbook.io/docs/documentation/sdks/typescripts-sdk Install the BagelPay Typescript SDK using npm. This is the primary method for integrating the SDK into your project. ```sh npm install bagelpay ``` -------------------------------- ### Verify BagelPay Python SDK Installation Source: https://bagelpay.gitbook.io/docs/documentation/sdks/python-sdk A Python script to verify the successful installation of the BagelPay SDK by importing it and checking its version and available modules. It also attempts to initialize the client. ```python import bagelpay from bagelpay import BagelPayClient print(f"BagelPay SDK Version: {bagelpay.__version__}") print(f"Available modules: {dir(bagelpay)}") # Test basic functionality try: client = BagelPayClient(api_key="test") print("✅ SDK imported successfully") except Exception as e: print(f"❌ Import failed: {e}") ``` -------------------------------- ### Quick Start: Create Product with Golang SDK Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Demonstrates how to initialize the BagelPay client and create a new product with specified details like name, price, currency, and billing type. This snippet is useful for quickly testing product creation. ```go package main import ( "context" "fmt" "log" "time" "github.com/bagelpay/bagelpay-sdk-go/src/bagelpay" ) func main() { // Initialize the client client := bagelpay.NewClient(bagelpay.ClientConfig{ APIKey: "your-api-key", TestMode: true, }) ctx := context.Background() // Create a product product, err := client.CreateProduct(ctx, bagelpay.CreateProductRequest{ Name: fmt.Sprintf("Premium Subscription %d", time.Now().Unix()), Description: "Monthly premium subscription with unique identifier", Price: 29.99, Currency: "USD", BillingType: "subscription", TaxInclusive: false, TaxCategory: "digital_products", RecurringInterval: "monthly", TrialDays: 7, }) if err != nil { log.Fatalf("Failed to create product: %v", err) } fmt.Printf("✅ Product URL: %s\n", *product.ProductURL) } ``` -------------------------------- ### Configure ngrok for Localhost Tunneling Source: https://bagelpay.gitbook.io/docs/documentation/template-and-framework/shipany This command starts an ngrok tunnel to expose your local server running on port 3000 to the internet. This is essential for receiving payment notifications from BagelPay in your local environment. Ensure ngrok is installed and authenticated. ```sh ngrok http http://localhost:3000 ``` -------------------------------- ### Switch to Live Mode: Recreate Product (Screenshot) Source: https://bagelpay.gitbook.io/docs/documentation/developers-and-api-usage/developer-integration-guide This visual guide illustrates the process of recreating a product in BagelPay's Live Mode. It emphasizes copying the product configuration from Test Mode to ensure consistency when transitioning to live transactions. ```image https://2715164374-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVrvPnQUpsDkMiL1jMEXt%2Fuploads%2FxfPIiT7Ql06ExtyhYjGJ%2Fimage.png?alt=media&token=cf9c6f58-916c-4a95-a3e9-47c977c880fe ``` -------------------------------- ### Initialize BagelPay Python Client with Options Source: https://bagelpay.gitbook.io/docs/documentation/sdks/python-sdk Python code examples demonstrating different ways to initialize the BagelPay client, including direct parameter passing, using a configuration dictionary, and utilizing a context manager for automatic resource management. ```python from bagelpay import BagelPayClient import os # Method 1: Direct parameters client = BagelPayClient( base_url="https://test.bagelpay.io", api_key="your-api-key", timeout=30, # Request timeout in seconds ) # Method 2: Configuration dictionary config = { "base_url": "https://test.bagelpay.io", "api_key": os.getenv("BAGELPAY_API_KEY"), "timeout": 30 } client = BagelPayClient(**config) # Method 4: Context manager (recommended for production) with BagelPayClient(api_key="your-api-key") as client: # Automatically handles connection cleanup response = client.list_products() print(f"Found {response.total} products") ``` -------------------------------- ### Product Management with Golang SDK Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Provides Go code examples for creating, listing, retrieving, updating, archiving, and unarchiving products using the BagelPay SDK. It covers different product types and configurations. ```go // Create Product product, err := client.CreateProduct(ctx, bagelpay.CreateProductRequest{ Name: "Premium Plan", Description: "Monthly premium subscription", Price: 29.99, Currency: "USD", BillingType: "subscription", // or "single_payment" TaxInclusive: false, TaxCategory: "digital_products", RecurringInterval: "monthly", // daily, weekly, monthly, 3months, 6months TrialDays: 7, }) // List Products products, err := client.ListProducts(ctx, pageNum, pageSize) // Get Product product, err := client.GetProduct(ctx, productID) // Update Product product, err := client.UpdateProduct(ctx, bagelpay.UpdateProductRequest{ ProductID: "prod_123456789", Name: "Updated Premium Plan", Description: "Updated description", Price: 39.99, Currency: "USD", BillingType: "subscription", TaxInclusive: true, TaxCategory: "digital_services", RecurringInterval: "monthly", TrialDays: 14, }) // Archive/Unarchive Product // Archive product product, err := client.ArchiveProduct(ctx, productID) // Unarchive product product, err := client.UnarchiveProduct(ctx, productID) ``` -------------------------------- ### BagelPay Checkout URL Example Source: https://bagelpay.gitbook.io/docs/documentation/developers-and-api-usage/developer-integration-guide This snippet shows an example of a checkout URL generated by the BagelPay API. This URL is used to redirect users to the payment page to complete their transaction. ```url https://test.bagelpay.io/checkout/prod_1961350758759763969/ch_1961373726999154689 ``` -------------------------------- ### List All Products via API (curl) Source: https://bagelpay.gitbook.io/docs/documentation/developers-and-api-usage/developer-integration-guide Demonstrates how to list all available products using the BagelPay API via a curl command. This requires authentication with an API key. ```Shell curl --request GET \ --url https://api.bagelpay.io/v1/products \ --header "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Configure BagelPay Go SDK Client for Production Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Shows how to initialize the BagelPay Go SDK client for production use. This involves providing a live API key and setting `TestMode` to `false`. ```go client := bagelpay.NewClient(bagelpay.ClientConfig{ APIKey: "bagel_live_your_live_key", TestMode: false, }) ``` -------------------------------- ### BagelPay Checkout Session Response Example (JSON) Source: https://bagelpay.gitbook.io/docs/documentation/developers-and-api-usage/developer-integration-guide This is an example of a successful JSON response from the BagelPay API after creating a checkout session. It includes details about the checkout object, its status, and importantly, the `checkout_url` that directs users to the payment page. ```json { "msg": "Operation successful", "code": 200, "data": { "object": "checkout", "units": 1, "metadata": { "key_1": "value_1", "key_2": "value_1", "key_N": "value_N" }, "status": "pending", "mode": "test", "payment_id": "ch_1961373726999154689", "product_id": "prod_1961350758759763969", "request_id": null, "success_url": "https://test.bagelpay.io/success?aggregateId=XXXX", "checkout_url": "https://test.bagelpay.io/checkout/prod_1961350758759763969/ch_1961373726999154689", "created_at": "2025-08-29T10:21:51.773+00:00", "updated_at": "2025-08-29T10:21:51.773+00:00", "expires_on": "2025-08-29T11:21:51.773+00:00" } } ``` -------------------------------- ### Client Initialization Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Demonstrates how to initialize the BagelPay client with various configuration options, including API key, test mode, timeout, and custom base URL. ```APIDOC ## Client Initialization ### Description Initialize the BagelPay client with your API key and optional configurations such as test mode, timeout, and custom base URL. ### Method `bagelpay.NewClient(config bagelpay.ClientConfig)` ### Parameters #### Request Body - **APIKey** (string) - Required - Your BagelPay API key. - **TestMode** (bool) - Optional - Set to true for test mode (default is true). - **Timeout** (time.Duration) - Optional - Sets the client timeout (default is 30 seconds). - **BaseURL** (string) - Optional - Allows specifying a custom base URL for the API. - **HTTPClient** (*http.Client) - Optional - Allows providing a custom HTTP client. ### Request Example ```go client := bagelpay.NewClient(bagelpay.ClientConfig{ APIKey: "your-api-key", TestMode: true, Timeout: 30 * time.Second, BaseURL: "custom-url", HTTPClient: &http.Client{}, }) ``` ``` -------------------------------- ### Initialize BagelPay Client with Golang Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Shows various ways to initialize the BagelPay client, including specifying API key, test mode, timeout, custom base URL, and HTTP client. It also presents convenience constructors for test, live, and default modes. ```go client := bagelpay.NewClient(bagelpay.ClientConfig{ APIKey: "your-api-key", // Your BagelPay API key TestMode: true, // Default: true Timeout: 30 * time.Second, // Default: 30 seconds BaseURL: "custom-url", // Optional custom base URL HTTPClient: &http.Client{}, // Optional custom HTTP client }) // Test mode client (recommended for development) testClient := bagelpay.NewTestClient("your-test-api-key") // Live mode client (for production) liveClient := bagelpay.NewLiveClient("your-live-api-key") // Default client (test mode) defaultClient := bagelpay.NewDefaultClient("your-api-key") ``` -------------------------------- ### Get Subscription Detail - OpenAPI Specification Source: https://bagelpay.gitbook.io/docs/apireference/api-document/subscription This OpenAPI 3.1.0 specification defines the GET /api/subscriptions/{subscription_id} endpoint. It requires a subscription ID and an 'x-api-key' header for authentication. The response includes detailed information about the subscription status, customer, product, billing cycle, and more. ```json {"openapi":"3.1.0","info":{"title":"BagelPay-SDK","version":"1.0.0"},"tags":[{"name":"Subscription"}],"servers":[{"url":"https://test.bagelpay.io","description":"Development env"}],"security":[],"paths":{"/api/subscriptions/{subscription_id}":{"get":{"summary":"Get Subscription Detail","deprecated":false,"description":"","tags":["Subscription"],"parameters":[{"name":"subscription_id","in":"path","description":"","required":true,"schema":{"type":"string"}},{"name":"x-api-key","in":"header","description":"","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"msg":{"type":"string"},"code":{"type":"integer"},"data":{"type":"object","properties":{"status":{"type":"string"},"remark":{"type":["string","null"]},"customer":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"}},"required":["id","email"]},"mode":{"type":"string"},"last4":{"type":"string"},"subscription_id":{"type":"string"},"product_id":{"type":"string"},"store_id":{"type":"string"},"billing_period_start":{"type":["string","null"]},"billing_period_end":{"type":["string","null"]},"cancel_at":{"type":["string","null"]},"trial_start":{"type":["string","null"]},"trial_end":{"type":["string","null"]},"units":{"type":"integer"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"product_name":{"type":"string"},"payment_method":{"type":"string"},"next_billing_amount":{"type":"integer"},"recurring_interval":{"type":"string"}},"required":["status","remark","customer","mode","last4","subscription_id","product_id","store_id","billing_period_start","billing_period_end","cancel_at","trial_start","trial_end","units","created_at","updated_at","product_name","payment_method","next_billing_amount","recurring_interval"]}},"required":["msg","code","data"]}}},"headers":{}}}}}}} ``` -------------------------------- ### Get Product Detail API Specification (JSON) Source: https://bagelpay.gitbook.io/docs/apireference/api-document/products This snippet details the GET /api/products/{product_id} endpoint. It allows retrieval of specific product information using its ID. Requires an 'x-api-key' header for authentication. The response includes product details such as name, price, currency, and billing information. ```json {"openapi":"3.1.0","info":{"title":"BagelPay-SDK","version":"1.0.0"},"tags":[{"name":"Products"}],"servers":[{"url":"https://test.bagelpay.io","description":"Development env"}],"security":[],"paths":{"/api/products/{product_id}":{"get":{"summary":"Get Product Detail","deprecated":false,"description":"","tags":["Products"],"parameters":[{"name":"product_id","in":"path","description":"","required":true,"schema":{"type":"string"}},{"name":"x-api-key","in":"header","description":"","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"msg":{"type":"string"},"code":{"type":"integer"},"data":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"price":{"type":"number"},"currency":{"type":"string"},"object":{"type":"string"},"mode":{"type":"string"},"product_id":{"type":"string"},"store_id":{"type":"string"},"product_url":{"type":"string"},"billing_type":{"type":"string"},"billing_period":{"type":"string"},"tax_category":{"type":"string"},"tax_inclusive":{"type":"boolean"},"is_archive":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"trial_days":{"type":"integer"},"recurring_interval":{"type":"string"}},"required":["name","description","price","currency","object","mode","product_id","store_id","product_url","billing_type","billing_period","tax_category","tax_inclusive","is_archive","created_at","updated_at","trial_days","recurring_interval"]}},"required":["msg","code","data"]}}},"headers":{}}}}}}} ``` -------------------------------- ### GET /api/products/list Source: https://bagelpay.gitbook.io/docs/apireference/api-document/products Retrieves a list of all products available in the store. ```APIDOC ## GET /api/products/list ### Description Retrieves a list of all products available in the store, with options for pagination. ### Method GET ### Endpoint /api/products/list ### Parameters #### Path Parameters None #### Query Parameters - **pageNum** (integer) - Optional - The page number (minimum: 1) - **pageSize** (integer) - Optional - The number of items per page (minimum: 1) #### Request Body None ### Request Example ```bash GET /api/products/list?pageNum=1&pageSize=10 ``` ### Response #### Success Response (200) - **total** (integer) - Total number of products - **items** (array) - List of products - **name** (string) - **description** (string) - **price** (number) - **currency** (string) - **object** (string) - **mode** (string) - **remark** (string|null) - **product_id** (string) - **store_id** (string) - **product_url** (string) - **billing_type** (string) - **billing_period** (string) - **tax_category** (string) - **tax_inclusive** (boolean) - **is_archive** (boolean) - **created_at** (string) - **updated_at** (string) - **trial_days** (integer) - **recurring_interval** (string|null) - **code** (integer) - Response code - **msg** (string) - Response message #### Response Example ```json { "total": 5, "items": [ { "name": "Basic Plan", "description": "Basic features access", "price": 9.99, "currency": "USD", "object": "product", "mode": "subscription", "remark": null, "product_id": "prod_abcde", "store_id": "store_12345", "product_url": "https://test.bagelpay.io/p/prod_abcde", "billing_type": "subscription", "billing_period": "month", "tax_category": "saas_services", "tax_inclusive": false, "is_archive": false, "created_at": "2023-10-26T09:00:00Z", "updated_at": "2023-10-26T09:00:00Z", "trial_days": 7, "recurring_interval": "monthly" } ], "code": 200, "msg": "Products listed successfully." } ``` ``` -------------------------------- ### Configure BagelPay Go SDK Client for Test Mode Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Demonstrates how to initialize the BagelPay Go SDK client for test mode. This is essential for development and testing environments, using a specific test API key. ```go client := bagelpay.NewClient(bagelpay.ClientConfig{ APIKey: "bagel_test_your_test_key", TestMode: true, }) ``` -------------------------------- ### Get Store Info - OpenAPI Specification Source: https://bagelpay.gitbook.io/docs/apireference/api-document/account This OpenAPI 3.1.0 specification describes the GET /api/store/info endpoint for retrieving store details. It includes details on request headers, response structure, and possible data fields such as store ID, name, balances, and status. The endpoint requires an 'x-api-key' header for authentication. ```json { "openapi": "3.1.0", "info": { "title": "BagelPay-SDK", "version": "1.0.0" }, "tags": [ { "name": "Account" } ], "servers": [ { "url": "https://live.bagelpay.io", "description": "Public env" } ], "security": [], "paths": { "/api/store/info": { "get": { "summary": "StoreInfo", "deprecated": false, "description": "", "tags": [ "Account" ], "parameters": [ { "name": "x-api-key", "in": "header", "description": "", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" }, "code": { "type": "integer" }, "data": { "type": "object", "properties": { "mode": { "type": "string", "enum": [ "test", "live" ] }, "object": { "type": "string", "default": "storeInfo" }, "store_id": { "type": "string" }, "store_name": { "type": "string" }, "created_at": { "type": "string" }, "available_balance": { "type": "integer" }, "onhold_balance": { "type": "number" }, "email": { "type": "string" }, "status": { "type": "string", "enum": [ "UNDER_REVIEW", "ACTIVE", "BANNED", "DISABLED", "PENDING_VERIFICATION" ] } }, "required": [ "mode", "object", "store_id", "store_name", "created_at", "available_balance", "onhold_balance", "email", "status" ] } }, "required": [ "msg", "code", "data" ] } } } } }, "headers": {} } } } } ``` -------------------------------- ### GET /subscriptions Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Retrieves a list of all active subscriptions, with support for pagination. ```APIDOC ## GET /subscriptions ### Description Retrieves a list of all customer subscriptions managed by BagelPay. Supports pagination for efficient data retrieval. ### Method `GET` ### Endpoint `/subscriptions` ### Parameters #### Query Parameters - **pageNum** (integer) - Optional - The page number for pagination. - **pageSize** (integer) - Optional - The number of subscriptions to return per page. ### Response #### Success Response (200 OK) - A list of subscription objects. #### Response Example ```json [ { "SubscriptionID": "sub_xxxxxxxxxxxx", "CustomerID": "cust_xxxxxxxxxxxx", "ProductID": "prod_xxxxxxxxxxxx", "Status": "active", "CreatedAt": "2023-10-25T09:00:00Z" }, { "SubscriptionID": "sub_yyyyyyyyyyyy", "CustomerID": "cust_yyyyyyyyyyyy", "ProductID": "prod_yyyyyyyyyyyy", "Status": "canceled", "CreatedAt": "2023-10-24T08:00:00Z" } ] ``` ``` -------------------------------- ### Get Product Detail via API (curl) Source: https://bagelpay.gitbook.io/docs/documentation/developers-and-api-usage/developer-integration-guide Shows how to retrieve detailed information for a specific product using the BagelPay API with a curl command. Requires the product ID and an API key for authentication. ```Shell curl --request GET \ --url https://api.bagelpay.io/v1/products/PRODUCT_ID \ --header "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### GET /api/transactions/list Source: https://bagelpay.gitbook.io/docs/apireference/api-document/transactions Lists all transactions with optional pagination and filtering. ```APIDOC ## GET /api/transactions/list ### Description Lists all transactions with optional pagination and filtering. ### Method GET ### Endpoint /api/transactions/list ### Parameters #### Query Parameters - **pageNum** (integer) - Optional - The page number for pagination, defaults to 1. - **pageSize** (integer) - Optional - The number of items per page, defaults to 1. #### Header Parameters - **x-api-key** (string) - Required - Your API key for authentication. ### Response #### Success Response (200) - **total** (integer) - The total number of transactions. - **items** (array) - A list of transaction objects. - **amount** (number) - The transaction amount. - **currency** (string) - The currency of the transaction. - **type** (string) - The type of transaction. - **customer** (object) - Information about the customer. - **id** (string|null) - The customer's ID. - **email** (string|null) - The customer's email. - **remark** (string|null) - Any remarks for the transaction. - **mode** (string) - The transaction mode. - **fees** (number) - The transaction fees. - **tax** (number) - The transaction tax. - **net** (number) - The net amount of the transaction. - **object** (string) - The object type. - **transaction_id** (string) - The unique transaction ID. - **order_id** (string) - The associated order ID. - **amount_paid** (number) - The amount paid. - **discount_amount** (number) - The discount amount. - **tax_amount** (number) - The tax amount. - **tax_country** (string) - The tax country. - **refunded_amount** (number) - The refunded amount. - **created_at** (string|null) - The timestamp when the transaction was created. - **updated_at** (string|null) - The timestamp when the transaction was last updated. - **code** (integer) - The response code. - **msg** (string) - The response message. #### Response Example ```json { "total": 100, "items": [ { "amount": 100.50, "currency": "USD", "type": "payment", "customer": { "id": "cus_123", "email": "customer@example.com" }, "remark": "Order #456", "mode": "live", "fees": 0.50, "tax": 1.00, "net": 99.00, "object": "transaction", "transaction_id": "txn_abc", "order_id": "order_456", "amount_paid": 100.50, "discount_amount": 0.00, "tax_amount": 1.00, "tax_country": "US", "refunded_amount": 0.00, "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ], "code": 0, "msg": "Success" } ``` ``` -------------------------------- ### Manage Products with BagelPay API (Python) Source: https://bagelpay.gitbook.io/docs/documentation/sdks/python-sdk Provides examples for interacting with products via the BagelPay client. This includes fetching product details, archiving and unarchiving products, listing all products with pagination, and filtering products by status, billing type, and price. Requires an initialized BagelPay client. ```python # Get product details product = client.get_product("prod_123456") print(f"Product: {product.name}") print(f"Status: {'Active' if not product.is_archive else 'Archived'}") # Archive product (stop selling but keep records) archived_product = client.archive_product("prod_123456") print(f"Product archived: {archived_product.is_archive}") # Unarchive product unarchived_product = client.unarchive_product("prod_123456") print(f"Product restored: {not unarchived_product.is_archive}") # Bulk product operations all_products = [] page_num = 1 while True: products = client.list_products(pageNum=page_num, pageSize=100) all_products.extend(products.items) if len(products.items) < 100: break page_num += 1 print(f"Total products loaded: {len(all_products)}") # Filter products by criteria active_products = [p for p in all_products if not p.is_archive] subscription_products = [p for p in all_products if p.billing_type == "subscription"] expensive_products = [p for p in all_products if p.price > 100] print(f"Active products: {len(active_products)}") print(f"Subscription products: {len(subscription_products)}") print(f"Premium products (>$100): {len(expensive_products)}") ``` -------------------------------- ### GET /transactions Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Retrieves a list of all transactions, supporting pagination for efficient querying. ```APIDOC ## GET /transactions ### Description Fetches a list of all transactions processed through BagelPay. Pagination is supported to manage large datasets. ### Method `GET` ### Endpoint `/transactions` ### Parameters #### Query Parameters - **pageNum** (integer) - Optional - The page number for pagination. - **pageSize** (integer) - Optional - The number of transactions to return per page. ### Response #### Success Response (200 OK) - A list of transaction objects. #### Response Example ```json [ { "TransactionID": "txn_xxxxxxxxxxxx", "Amount": 29.99, "Currency": "USD", "Status": "succeeded", "CreatedAt": "2023-10-26T12:00:00Z" }, { "TransactionID": "txn_yyyyyyyyyyyy", "Amount": 9.99, "Currency": "USD", "Status": "pending", "CreatedAt": "2023-10-26T11:00:00Z" } ] ``` ``` -------------------------------- ### Subscription Management with Golang SDK Source: https://bagelpay.gitbook.io/docs/documentation/sdks/golang-sdk Provides Go code examples for listing, retrieving, and canceling subscriptions using the BagelPay SDK. These functions enable management of recurring payments for customers. ```go // List Subscriptions subscriptions, err := client.ListSubscriptions(ctx, pageNum, pageSize) // Get Subscription subscription, err := client.GetSubscription(ctx, subscriptionID) // Cancel Subscription subscription, err := client.CancelSubscription(ctx, subscriptionID) ```