The examples read them from ANTOM_GATEWAY_URL, ANTOM_CLIENT_ID,
ANTOM_MERCHANT_PRIVATE_KEY, and ANTOM_PUBLIC_KEY, respectively.
Keep keys in server-side configuration. Replace sample order data and callback
URLs with your own values before sending a request.
Payment
Save as main.go in your application module. Run go mod tidy to resolve the
example’s imports, configure the four environment variables above, then use
go run ..
API Key access is not yet available to all merchants. Use this client only if
API Key access has been enabled for your account; otherwise, use RSA.
Set ANTOM_GATEWAY_URL and ANTOM_API_KEY in your server environment.
This initializes the client; see the setup guide for a
complete sandbox request and its additional configuration.
package main
import (
"os"
antom "github.com/alipay/global-open-sdk-go/com/alipay/api"
)
func main() {
client, err := antom.NewApiKeyAlipayClient(
os.Getenv("ANTOM_GATEWAY_URL"), os.Getenv("ANTOM_API_KEY"))
if err != nil { panic(err) }
defer client.Close()
// Use client.Execute(request) with a business request.
}
Exact amount conversion
Available in SDK version 1.5.0 and later.
Convert a decimal amount string into Antom’s integer-string Amount.value,
convert it back to a fixed-precision decimal string, or validate an outbound
value. Conversion returns a string, not an Amount object, and uses bundled
currency rules without a network request.
This example checks the error returned by each operation:
Validate returns nil on success. Invalid input or bundled-rule loading
failures return a non-nil error.
Error messages include categories such as UNSUPPORTED_CURRENCY,
EXCESS_PRECISION, VALUE_TOO_LONG, and RULE_VIOLATION.
Pass amounts, values, and currency codes as strings. Use uppercase currency
codes and unsigned ASCII numbers, without spaces, separators, or exponents.
Supported currencies: AUD, BDT, BRL, CAD, CLP, CNY, EUR, GBP, HKD, IDR, JPY,
KRW, MXN, MYR, NZD, PEN, PHP, PKR, PLN, SGD, THB, TWD, USD, VND. Other codes
are rejected; there is no default conversion multiplier.
Conversion is exact and never rounds. Extra non-zero decimal places are
rejected; trailing zero decimal places are allowed. Zero is accepted, but
callers must check whether the target API permits a zero amount.
The 16-digit limit applies to Amount.value, not to the decimal input string
or the business transaction limit. Conversion to a value checks the normalized
result; conversion from a value and validation count all input digits,
including leading zeros.
For IDR, conversion to a value and outbound validation require the value to
be a multiple of 100. Conversion from a value does not apply this outbound
restriction and never rounds the response amount.
See Antom’s amount rules for the conversion
convention. Supported payment-method currencies, transaction limits, and
method-specific constraints (such as JKOPay TWD or Octopus HKD multiples) must
be checked separately; this utility does not validate payment-method context.
Upgrade notes
Billing integrations: availableAmount now uses Amount; the AvailableAmount
model has been removed.
Meter event upload
meter/createSession uses the regular signed AMS transport. Call
meter/uploadEvent with ExecuteWithHeaders and the returned X-Session-Id.
The SDK uses the gateway URL configured on the client without sandbox path
rewriting, request signing, response signature verification, or automatic
retries. This API requires HTTP/2 and supports the Go version declared in
go.mod. For production use, build applications with a currently supported
Go release containing the latest security fixes.
DefaultAlipayClient.Execute handles JSON serialization, signing, HTTP calls, and
response verification. The following is an implementation excerpt from the
client source, not a standalone application
example: private helpers are defined in the SDK package.
Antom SDK for Go
Latest release: 1.5.2
Installation
Requires Go 1.22.5+. Use a supported Go release with current security fixes.
Quick start
RSA and API Key clients share request/response models. File uploads and notification verification still require RSA credentials.
RSA configuration
Before using the RSA client, prepare these values from your Antom integration:
The examples read them from
ANTOM_GATEWAY_URL,ANTOM_CLIENT_ID,ANTOM_MERCHANT_PRIVATE_KEY, andANTOM_PUBLIC_KEY, respectively. Keep keys in server-side configuration. Replace sample order data and callback URLs with your own values before sending a request.Payment
Save as
main.goin your application module. Rungo mod tidyto resolve the example’s imports, configure the four environment variables above, then usego run ..API Key client (limited availability)
Set
ANTOM_GATEWAY_URLandANTOM_API_KEYin your server environment. This initializes the client; see the setup guide for a complete sandbox request and its additional configuration.Exact amount conversion
Available in SDK version 1.5.0 and later.
Convert a decimal amount string into Antom’s integer-string
Amount.value, convert it back to a fixed-precision decimal string, or validate an outbound value. Conversion returns a string, not anAmountobject, and uses bundled currency rules without a network request.This example checks the error returned by each operation:
Validatereturnsnilon success. Invalid input or bundled-rule loading failures return a non-nilerror. Error messages include categories such asUNSUPPORTED_CURRENCY,EXCESS_PRECISION,VALUE_TOO_LONG, andRULE_VIOLATION.Amount.value, not to the decimal input string or the business transaction limit. Conversion to a value checks the normalized result; conversion from a value and validation count all input digits, including leading zeros.See Antom’s amount rules for the conversion convention. Supported payment-method currencies, transaction limits, and method-specific constraints (such as JKOPay TWD or Octopus HKD multiples) must be checked separately; this utility does not validate payment-method context.
Upgrade notes
Billing integrations:
availableAmountnow usesAmount; theAvailableAmountmodel has been removed.Meter event upload
meter/createSessionuses the regular signed AMS transport. Callmeter/uploadEventwithExecuteWithHeadersand the returnedX-Session-Id. The SDK uses the gateway URL configured on the client without sandbox path rewriting, request signing, response signature verification, or automatic retries. This API requires HTTP/2 and supports the Go version declared ingo.mod. For production use, build applications with a currently supported Go release containing the latest security fixes.See the Meter example for a complete request.
Advanced usage
DefaultAlipayClient.Executehandles JSON serialization, signing, HTTP calls, and response verification. The following is an implementation excerpt from the client source, not a standalone application example: private helpers are defined in the SDK package.Support
For integration questions, contact overseas_support@service.alibaba.com.