ThetaGuidesQuickstartAPI reference

Quickstart

You need a test secret key (it starts with sk_test_) from your operator.

Install

pnpm add @theta/node

Take a test payment

import { Theta } from '@theta/node';

const theta = new Theta(process.env.THETA_SECRET_KEY!, { baseUrl: process.env.THETA_API_BASE_URL });

// 1. Create the payment. Amounts are in the smallest unit: 5000 means USD 50.00.
const intent = await theta.paymentIntents.create({
  amount: 5_000,
  currency: 'usd',
  payment_method: 'pm_card_approved', // a test payment method; real ones come from the payment element
});

// 2. Charge it.
const paid = await theta.paymentIntents.confirm(intent.id);
console.log(paid.status); // "succeeded"

Test payment methods

Every call can be repeated safely: the SDK sends an idempotency key, so a retry after a lost response cannot charge twice.