npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yakies/antom-nodejs-sdk

v1.4.13

Published

The global antom gateway SDK for Node.js TypeScript

Readme

Antom Node.js SDK

Language: Node.js  
Node.js version: 16.0+  
TypeScript: Supported  
Release: 1.4.10  
Copyright: Ant financial services group  

Installation

npm install @yakies/antom-nodejs-sdk

Quick Start

1. Basic Payment Example

import {
  DefaultAntomClient,
  AntomPayRequest,
  Amount,
  Order,
  PaymentMethod,
  SettlementStrategy,
  Env,
  ProductCodeType,
  TerminalType,
  ResultStatusType
} from '@yakies/antom-nodejs-sdk';

// Configuration
const GATEWAY_HOST = 'https://open-na.alipay.com';
const CLIENT_ID = 'your_client_id';
const MERCHANT_PRIVATE_KEY = 'your_private_key';
const ALIPAY_PUBLIC_KEY = 'alipay_public_key';

async function pay() {
  const client = new DefaultAntomClient(
    GATEWAY_HOST,
    CLIENT_ID,
    MERCHANT_PRIVATE_KEY,
    ALIPAY_PUBLIC_KEY
  );

  const request = new AntomPayRequest();

  // Set basic payment parameters
  request.setProductCode(ProductCodeType.CASHIER_PAYMENT);
  request.setPaymentRequestId('pay_test_' + Date.now());
  request.setPaymentRedirectUrl('https://www.yourRedirectUrl.com');
  request.setPaymentNotifyUrl('https://www.yourNotifyUrl.com');

  // Set payment method
  const paymentMethod = {
    paymentMethodType: 'ALIPAY_CN',
    paymentMethodId: 'payment_method_id'
  };
  request.setPaymentMethod(paymentMethod);

  // Set amount
  const amount: Amount = {
    currency: 'CNY',
    value: '10000'
  };
  request.setPaymentAmount(amount);

  // Set order
  const order: Order = {
    referenceOrderId: 'order_' + Date.now(),
    orderDescription: 'Test Product',
    orderAmount: amount,
    buyer: {
      buyerEmail: '[email protected]',
      referenceBuyerId: '12345679'
    },
    goods: [{
      goodsBrand: 'Test Brand',
      goodsName: 'Test Product'
    }],
    merchant: {
      merchantMcc: 'merchantMcc',
      referenceMerchantId: 'merchant_' + Date.now()
    }
  };
  request.setOrder(order);

  // Set settlement strategy
  const settlementStrategy: SettlementStrategy = {
    settlementCurrency: 'USD'
  };
  request.setSettlementStrategy(settlementStrategy);

  // Set environment
  const env: Env = {
    terminalType: TerminalType.WEB
  };
  request.setEnv(env);

  try {
    const response = await client.execute(request);
    const responseData = JSON.parse(response);
    
    if (responseData.result?.resultStatus !== ResultStatusType.F) {
      console.log('Payment created successfully:');
      console.log('Payment ID:', responseData.paymentId);
      console.log('Payment Create Time:', responseData.paymentCreateTime);
      console.log('Payment URL:', responseData.normalUrl);
    } else {
      console.log('Payment failed:', responseData.result?.resultMessage);
    }
  } catch (error) {
    console.error('Payment error:', error);
  }
}

pay();

2. Payment Consultation Example

import {
  DefaultAntomClient,
  AntomPayConsultRequest,
  Amount,
  Env,
  SettlementStrategy,
  ProductCodeType,
  TerminalType,
  OsType
} from 'antom-nodejs-sdk';

async function payConsult() {
  const client = new DefaultAntomClient(
    GATEWAY_HOST,
    CLIENT_ID,
    MERCHANT_PRIVATE_KEY,
    ALIPAY_PUBLIC_KEY
  );

  const request = new AntomPayConsultRequest();
  request.setProductCode(ProductCodeType.CASHIER_PAYMENT);
  request.setUserRegion('SG');

  const paymentAmount: Amount = {
    currency: 'USD',
    value: '1000'
  };
  request.setPaymentAmount(paymentAmount);

  const env: Env = {
    terminalType: TerminalType.APP,
    osType: OsType.IOS
  };
  request.setEnv(env);

  const settlementStrategy: SettlementStrategy = {
    settlementCurrency: 'USD'
  };
  request.setSettlementStrategy(settlementStrategy);

  request.setAllowedPaymentMethodRegions(['HK', 'US', 'CN']);

  try {
    const response = await client.execute(request);
    const responseData = JSON.parse(response);
    
    if (responseData.result?.resultStatus !== ResultStatusType.F) {
      console.log('Available payment options:', responseData.paymentOptions);
    } else {
      console.log('Consult failed:', responseData.result?.resultMessage);
    }
  } catch (error) {
    console.error('Consult error:', error);
  }
}

3. Payment Query Example

import {
  DefaultAntomClient,
  AntomPayQueryRequest
} from 'antom-nodejs-sdk';

async function payQuery(paymentId: string) {
  const client = new DefaultAntomClient(
    GATEWAY_HOST,
    CLIENT_ID,
    MERCHANT_PRIVATE_KEY,
    ALIPAY_PUBLIC_KEY
  );

  const request = new AntomPayQueryRequest();
  request.setPaymentId(paymentId);

  try {
    const response = await client.execute(request);
    const responseData = JSON.parse(response);
    
    if (responseData.result?.resultStatus !== ResultStatusType.F) {
      console.log('Payment ID:', responseData.paymentId);
      console.log('Payment Status:', responseData.paymentStatus);
    } else {
      console.log('Query failed:', responseData.result?.resultMessage);
    }
  } catch (error) {
    console.error('Query error:', error);
  }
}

4. Using Signature and Verification Utilities Directly

import { sign, verify } from 'antom-nodejs-sdk';

// Sign a request
const signature = sign(
  'POST',
  '/ams/api/v1/payments/pay',
  'your_client_id',
  '2023-10-25T02:06:10Z',
  '{"amount":{"currency":"USD","value":"100"}}',
  MERCHANT_PRIVATE_KEY
);

// Verify a response
const isValid = verify(
  'POST',
  '/ams/api/v1/payments/pay',
  'your_client_id',
  '2023-10-25T02:06:11Z',
  '{"result":{"resultCode":"SUCCESS"}}',
  'signature_string',
  ALIPAY_PUBLIC_KEY
);

API Reference

Core Classes

DefaultAntomClient

The main client for making API requests.

Constructor:

new DefaultAntomClient(
  gatewayUrl: string,
  clientId: string,
  merchantPrivateKey: string,
  alipayPublicKey: string,
  agentToken?: string
)

Methods:

  • execute(request: AntomRequest): Promise<string> - Execute an API request

AntomRequest

Base class for all API requests.

Properties:

  • path: string - API endpoint path
  • httpMethod: HttpMethod - HTTP method (GET, POST, etc.)
  • keyVersion?: string - Key version for signature

Methods:

  • toAmsJson(): string - Convert request to JSON string

Available Request Types

  • AntomPayRequest - Payment request
  • AntomPayConsultRequest - Payment consultation request
  • AntomPayQueryRequest - Payment query request
  • AntomPayCancelRequest - Payment cancellation request
  • AntomCaptureRequest - Capture request
  • AntomRefundRequest - Refund request
  • AntomRefundQueryRequest - Refund query request
  • AntomCreateSessionRequest - Create payment session request

Enums

  • ProductCodeType - Product code types
  • TerminalType - Terminal types
  • OsType - Operating system types
  • ResultStatusType - Result status types
  • HttpMethod - HTTP methods

Error Handling

The SDK throws AntomApiException for API-related errors:

try {
  const response = await client.execute(request);
  // Process response
} catch (error) {
  if (error instanceof AntomApiException) {
    console.error('API Error:', error.message);
  } else {
    console.error('Unexpected error:', error);
  }
}

Sandbox Mode

The SDK automatically detects sandbox mode when the client ID starts with "SANDBOX_". In sandbox mode, API paths are automatically adjusted from /ams/api to /ams/sandbox/api.

License

MIT License