Choose Your Service

Expert guidance and support for your business implementation needs

Premium Consulting Service
Premium Consulting Service
$50/session
24/7 Priority Support
Custom Implementation
Personal Account Manager
Training Sessions
Performance Analytics

Secure payment processing • Instant access

Business Payment Implementation Guide

One Item Variable Price

Follow this guide to implement secure payment processing with cryptographic signature validation.

Secure Payment Implementation
Enterprise-grade payment processing with cryptographic signature validation

1. Environment Configuration

Configure your environment variables in .env.local

NEXT_PUBLIC_ORBITA_APP_URL=https://testnet.orbita.zone
NEXT_PUBLIC_ORBITA_SHOP_URL=https://shop.orbita.zone
ORBITA_SERVICE_PRIVATE_KEY=<your_service_private_key>

2. Signature Generation

Create a signature utility in lib/signature-utils.ts

import { sha256 } from "@cosmjs/crypto";
import { fromHex } from "@cosmjs/encoding";
import { Secp256k1 } from "@cosmjs/crypto";

export async function createSignature(message: string, privateKey: string): Promise<string> {
  const messageBytes = new TextEncoder().encode(message);
  const messageHash = await sha256(messageBytes);
  const privKeyBytes = fromHex(privateKey);
  const signatureObj = await Secp256k1.createSignature(messageHash, privKeyBytes);
  const signatureFixed = signatureObj.toFixedLength();
  return Buffer.from(signatureFixed).toString("base64");
}

3. Payment Processing

Implement the payment handler in lib/payment-utils.ts

// Single item payment handler
export async function handleOneItemBusinessCheckout(
  paymentId: string,    // Unique identifier for this payment
  price: string,        // Price as string (e.g., "50")
  priceCurrency: string, // Currency code (e.g., "USD")
  successURL: string    // URL to redirect after successful payment
) {
  try {
    // Create cryptographic signature for security
    // Format: "paymentId|price+currency"
    const signatureMessage = `${paymentId}|${price}${priceCurrency}`;
    const signature = await getSignature(signatureMessage, "service");

    // Redirect to payment page with all required parameters
    window.open(
      `${ORBITA_APP_URL}/pay?payment_id=${paymentId}&price=${price}${priceCurrency}&return_url=${
        encodeURIComponent(successURL)
      }&signature=${encodeURIComponent(signature)}`
    );
  } catch (error) {
    console.error("Signature creation error:", error);
    throw error;
  }
}

4. Usage Example

Implement the payment handler in your component

const handlePurchase = async () => {
  setLoading(true);
  try {
    await handleOneItemBusinessCheckout(
      process.env.NEXT_PUBLIC_ORBITA_SERVICE_PAYMENT_ID!, // Payment ID
      "50",      // Price
      "USD",     // Currency
      `${ORBITA_SHOP_URL}/success`  // Success URL
    );
  } catch (error) {
    console.error("Purchase error:", error);
  } finally {
    setLoading(false);
  }
};