Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.fype.dev/llms.txt

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

Fype SDKs

Fype provides official SDKs for Node.js and Python to make integration seamless.

Node.js SDK

Installation

npm install @fype/nodejs-sdk

Initialization

import { Fype } from '@fype/nodejs-sdk';

const fype = new Fype({
  apiKey: 'fype_test_...',
});

Usage

// Create a payment
const payment = await fype.payments.create({
  amount: 1000,
  currency: 'INR',
  customer_email: 'jane@example.com',
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel',
});

console.log(payment.checkout_url);

// Process a refund
const refund = await fype.refunds.create({
  payment_id: payment.id,
  amount: 500,
});

Python SDK

Installation

pip install fype-python-sdk

Initialization

from fype import Fype

fype = Fype(api_key="fype_test_...")

Usage

# Create a payment
payment = fype.payments.create(
    amount=1000,
    currency="INR",
    customer_email="jane@example.com",
    success_url="https://example.com/success",
    cancel_url="https://example.com/cancel"
)

print(payment['checkout_url'])

# Verify webhook signature
# Returns True if valid, raises SignatureVerificationError if invalid
is_valid = fype.webhooks.verify_signature(
    raw_payload=request.body(),
    signature_header=request.headers.get('X-Fype-Signature'),
    secret="whsec_..."
)

Best Practices

  • Timeout Management: Our SDKs have built-in timeout handling. We recommend a 15-second timeout for payment creation.
  • Error Handling: Always wrap your SDK calls in try/catch (Node.js) or try/except (Python) blocks to handle FypeAuthenticationError, FypeInvalidRequestError, etc.
  • Async/Await: Both SDKs are built to be non-blocking. Use async/await patterns for the best performance.
  • Signature Verification: Note that the Node.js verifySignature method returns true on success but throws a FypeSignatureVerificationError on mismatch. The Python version returns True or raises SignatureVerificationError.