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
pm_card_approvedsucceedspm_card_declinedis declinedpm_card_requires_3dsasks for 3-D Securepm_ecocash_approvesends a wallet prompt that the customer approves
Every call can be repeated safely: the SDK sends an idempotency key, so a retry after a lost response cannot charge twice.