Docs API Reference

BAMS Payment Gateway API Reference

Complete developer reference for the BAMS Payment Gateway API — covering authentication, sandbox testing, payment processing, customer vault, recurring billing, reporting, and account management.

Last updated: March 2026
Enter your sandbox API key once — it will be used across all "Try it" panels below.

Introduction

The BAMS Payment Gateway API gives you full programmatic control over payment processing, merchant onboarding, customer management, and reporting. Two API generations are available:

API VersionBase URLAuth MethodFormat
Classic API (transact.php)https://www.bamsgateway.com/api/transact.phpsecurity_key in POST bodyForm-encoded POST / query-string response
Query API (query.php)https://www.bamsgateway.com/api/query.phpsecurity_key in POST bodyForm-encoded POST / XML response
v3 / v5 REST APIhttps://www.bamsgateway.com/v3security-key headerJSON

Most payment processing (sales, refunds, subscriptions, customer vault) uses the Classic API. The REST API is used for merchant management, applications, invoicing, and administration.

New to BAMS Payment Gateway? Start by creating a free sandbox account — you'll have full API access within seconds, no credit card required.

Authentication

All API requests require a Security Key (API key) associated with your merchant account. There are two key types:

Key TypeUse CaseExposure
Public KeyClient-side tokenization (Collect.js, hosted fields)Safe to embed in browser/mobile code
Private KeyAll server-side API callsMust never be exposed client-side

Getting Your API Key

  1. Log into the BAMS Gateway Merchant Portal
  2. Navigate to Settings → Security Keys
  3. Click Add a New Key
  4. Enter a descriptive name, select the associated user, and choose the permission scope
  5. Copy the generated key — it will only be shown once

Classic API — Key in Request Body

For transact.php and query.php, include your key as the security_key field in the POST body:

bash
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE&type=sale&amount=10.00&ccnumber=4111111111111111&ccexp=1026&cvv=999"

REST API — Key in Header

For v3/v5 REST endpoints, pass your key in the security-key request header:

bash
curl https://www.bamsgateway.com/v3/transactions \
  -H "Content-Type: application/json" \
  -H "security-key: YOUR_API_KEY_HERE" \
  -d '{"type":"sale","amount":"10.00","ccnumber":"4111111111111111","ccexp":"1026","cvv":"999"}'

JavaScript / Node.js Example

javascript
const axios = require('axios');

const response = await axios.post(
  'https://www.bamsgateway.com/v3/transactions',
  { type: 'sale', amount: '10.00', ccnumber: '4111111111111111', ccexp: '1026', cvv: '999' },
  { headers: { 'security-key': process.env.BAMS_API_KEY, 'Content-Type': 'application/json' } }
);
Keep your private key secret. Never expose it in client-side JavaScript, public repositories, or log files. Rotate keys immediately if they are compromised. Generate separate keys for development, staging, and production.

Sends a lightweight query request to confirm your API key is valid. A 200 response with response=1 means you are authenticated.

Testing Methods

The sandbox environment is identical to production — it just never moves real funds. Use your sandbox API key (obtained from the sandbox sign-up page) for all test requests. The sandbox endpoint is the same URL as production; the key determines the environment.

Never use real API keys when testing. Always use a dedicated sandbox/test merchant key. BAMS allows partners to create unlimited Test Merchant Accounts.

Test Credit Card Numbers

Card NumberNetworkResult
4111111111111111VisaApproved
4111111111111129VisaDeclined
5431111111111111MastercardApproved
6011000991300009DiscoverApproved
341111111111111American ExpressApproved
30205252489926Diner's ClubApproved
3541963594572595JCBApproved
6799990100000000019MaestroApproved

Use any future expiration date in MMYY format (e.g. 1226) and CVV 999 for all test cards.

Test ACH / eCheck Accounts

Account NumberRouting NumberResult
123456789021000021Approved
123456789011000015Declined

For ACH transactions set payment=check, account_type=checking, account_holder_type=personal, and sec_code=WEB.

AVS & CVV Test Values

ScenarioZIPAddressCVV
Full AVS match + CVV match10101101 Main St999
ZIP match only10101(any other)999
CVV mismatch(any)(any)901

Rate Limiting

Rate limits are enforced per API key to ensure platform stability. Exceeding a limit returns HTTP 429 Too Many Requests.

Limit TypeValue
Requests per second50
Requests per minute1,000
Requests per hour30,000

Every response includes these rate-limit headers:

HeaderDescription
X-RateLimit-LimitMaximum requests allowed per minute
X-RateLimit-RemainingRequests remaining in the current window
X-RateLimit-ResetUnix timestamp when the window resets

Pagination

List endpoints return paginated results. Use offset and limit to navigate pages.

bash
curl "https://www.bamsgateway.com/v3/transactions?limit=25&offset=50" \
  -H "security-key: YOUR_API_KEY_HERE"
ParameterDefaultMaxDescription
limit25200Number of records to return
offset0Number of records to skip

All paginated responses include a meta object:

json
{
  "data": [ ... ],
  "meta": {
    "total": 1420,
    "limit": 25,
    "offset": 50,
    "has_more": true
  }
}

Response Codes

The Classic API returns a response field and a numeric response_code. The response value is:

responseMeaning
1Approved / Success
2Declined
3Error

Numeric Response Codes

CodeMeaning
100Transaction approved
DECLINED BY PROCESSOR (200–264)
200Declined by processor
201Do not honor
202Insufficient funds
203Over limit
204Transaction not allowed
220Incorrect payment information
221No such card issuer
222No card number on file with issuer
223Expired card
224Invalid expiration date
225Invalid security code (CVV)
226Invalid PIN
240Call issuer for further information
250Pick up card
251Lost card
252Stolen card
253Fraudulent card
260Declined with further instructions available — see responsetext
261Declined — stop all recurring billing
262Declined — stop this recurring program
263Declined — update cardholder data available
264Declined — retry in a few days
GATEWAY / PROCESSOR ERRORS (300–461)
300Rejected by gateway
400Processor error
410Invalid merchant configuration
411Merchant account inactive
420Communication error — unable to reach processor
421Communication error — invalid response from processor
430Duplicate transaction
440Processor format error
441Invalid transaction information
460Processor feature not available
461Unsupported card type
REST API HTTP CODES
200OK — request succeeded
201Created — resource successfully created
400Bad Request — missing or invalid parameters
401Unauthorized — invalid or missing API key
403Forbidden — insufficient permissions
404Not Found — resource does not exist
409Conflict — duplicate request or state conflict
429Too Many Requests — rate limit exceeded
500Internal Server Error — contact support

Classic API error responses also include a responsetext field with a human-readable description of the decline reason.

Merchant Sign-Up

Applications

The Applications API lets partners submit merchant account applications for automated risk review and underwriting. Applications move through a defined status lifecycle:

Submitted Under Review Approved Active

Upon approval, BAMS provisions a Gateway ID and Merchant ID automatically. You can monitor progress by polling the application status endpoint or subscribing to application webhooks.

bash
# Submit a new merchant application
curl -X POST https://www.bamsgateway.com/v3/applications \
  -H "Content-Type: application/json" \
  -H "security-key: YOUR_API_KEY_HERE" \
  -d '{
    "business_name": "Acme Retail LLC",
    "business_type": "retail",
    "email": "owner@acmecorp.com",
    "phone": "5551234567",
    "address": {
      "street": "123 Main St",
      "city": "New York",
      "state": "NY",
      "zip": "10001",
      "country": "US"
    },
    "owner": {
      "first_name": "Jane",
      "last_name": "Smith",
      "ssn_last4": "1234",
      "dob": "1980-06-15"
    }
  }'
bash
# Get application status
curl https://www.bamsgateway.com/v3/applications/{application_id} \
  -H "security-key: YOUR_API_KEY_HERE"

Packages

Packages define the pricing tier and feature set for a merchant account — including interchange rates, monthly fees, enabled payment methods, and processing limits. Assign a package when submitting an application.

bash
# List available packages
curl https://www.bamsgateway.com/v3/packages \
  -H "security-key: YOUR_API_KEY_HERE"
json
{
  "data": [
    {
      "id": "pkg_retail_standard",
      "name": "Retail Standard",
      "monthly_fee": "25.00",
      "per_transaction_fee": "0.10",
      "enabled_payment_methods": ["card", "ach"]
    }
  ]
}

Webhook Subscriptions

Subscribe to application lifecycle events so your platform receives real-time notifications as merchant applications move through the review workflow.

bash
curl -X POST https://www.bamsgateway.com/v3/webhook-subscriptions \
  -H "Content-Type: application/json" \
  -H "security-key: YOUR_API_KEY_HERE" \
  -d '{
    "url": "https://yoursite.com/webhooks/bams",
    "events": [
      "application.approved",
      "application.declined",
      "application.pending_review",
      "merchant.activated"
    ]
  }'
Online Payments

Transactions

The Transaction API is a POST endpoint that processes payments in real time. Transaction details are sent form-encoded; the gateway responds immediately with a query-string result.

Transaction Types

typeDescription
saleAuthorize and capture a payment in a single step
authAuthorize only — places a hold; capture separately
captureSettle a prior auth; requires transactionid
voidCancel an unsettled transaction; requires transactionid
refundReturn funds on a settled transaction; requires transactionid
creditPush funds to a card without a prior charge
validateVerify a card number is valid without charging ($0 auth)

Sale — Charge a Card

bash
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "type=sale" \
  -d "amount=49.99" \
  -d "ccnumber=4111111111111111" \
  -d "ccexp=1226" \
  -d "cvv=999" \
  -d "firstname=Jane" \
  -d "lastname=Smith" \
  -d "email=jane@example.com" \
  -d "address1=123 Main St" \
  -d "city=New York" \
  -d "state=NY" \
  -d "zip=10001" \
  -d "country=US" \
  -d "ipaddress=203.0.113.42" \
  -d "orderid=ORD-20260115-0042"

Authorize Only

bash
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "type=auth" \
  -d "amount=49.99" \
  -d "ccnumber=4111111111111111" \
  -d "ccexp=1226" \
  -d "cvv=999"

Capture / Void / Refund

bash
# Capture an auth
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE&type=capture&transactionid=BAMS-TXN-001&amount=49.99"

# Void an unsettled transaction
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE&type=void&transactionid=BAMS-TXN-001"

# Refund a settled transaction (full or partial)
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE&type=refund&transactionid=BAMS-TXN-001&amount=25.00"

ACH / eCheck Transaction

bash
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "type=sale" \
  -d "payment=check" \
  -d "amount=49.99" \
  -d "checkname=Jane Smith" \
  -d "checkaba=021000021" \
  -d "checkaccount=123456789" \
  -d "account_type=checking" \
  -d "account_holder_type=personal" \
  -d "sec_code=WEB" \
  -d "email=jane@example.com"

Core Request Parameters

ParameterRequiredDescription
security_keyRequiredYour API Security Key
typeRequiredTransaction type: sale, auth, capture, void, refund, credit, validate
amountRequiredCharge amount in x.xx format (e.g. 49.99)
ccnumberRequired*Credit card number (*not required when using customer_vault_id)
ccexpRequired*Expiration date in MMYY format
cvvRecommendedCard security code (strongly recommended for e-commerce)
transactionidConditionalOriginal transaction ID — required for capture, void, refund
currencyOptionalISO 4217 currency code (default: USD)
orderidOptionalYour order reference number
order_descriptionOptionalDescription of the order
ipaddressOptionalCardholder IP address (recommended for fraud scoring)
industryOptionalecommerce, moto, retail, restaurant, or lodging
customer_receiptOptionaltrue to send email receipt to cardholder
dup_secondsOptionalDuplicate detection window in seconds (0 disables; max 7862400)
processor_idOptionalRoute to a specific processor (Multiple MID setups)
partial_paymentsOptionalsettle_partial or payment_in_full

Billing & Shipping Parameters

ParameterDescription
firstnameCardholder first name
lastnameCardholder last name
companyCompany name
address1Billing address line 1
address2Billing address line 2
cityBilling city
stateBilling state (2-letter code)
zipBilling ZIP / postal code
countryBilling country (ISO 3166-1 alpha-2)
phoneCustomer phone number
faxCustomer fax number
emailCustomer email (required for customer_receipt=true)
shipping_firstnameShipping recipient first name
shipping_lastnameShipping recipient last name
shipping_address1Shipping address line 1
shipping_cityShipping city
shipping_stateShipping state
shipping_zipShipping ZIP
shipping_countryShipping country (ISO 3166-1 alpha-2)
shipping_emailShipping contact email

Fees & Order Detail Parameters

ParameterDescription
shippingFreight / shipping amount (x.xx)
taxSales tax amount (x.xx); use -1 for tax-exempt
surchargeSurcharge amount (x.xx)
convenience_feeConvenience fee amount (x.xx)
tipTip amount (x.xx)
ponumberPurchase order number

Stored Credentials (CIT / MIT)

Use stored credential indicators to distinguish between customer-initiated transactions (CIT) and merchant-initiated transactions (MIT) for compliance with card brand requirements.

ParameterValuesDescription
initiated_bycustomer | merchantWho initiated the transaction
stored_credential_indicatorstored | usedstored = first use, used = subsequent
initial_transaction_idTransaction IDThe original CIT transaction ID for MIT references
bash
# Initial customer-initiated transaction (stores credential)
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE&type=sale&amount=29.99&ccnumber=4111111111111111&ccexp=1226" \
  -d "initiated_by=customer&stored_credential_indicator=stored"

# Subsequent merchant-initiated transaction (e.g. subscription renewal)
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE&type=sale&amount=29.99&ccnumber=4111111111111111&ccexp=1226" \
  -d "initiated_by=merchant&stored_credential_indicator=used&initial_transaction_id=BAMS-TXN-001"

3D Secure Parameters

ParameterDescription
cardholder_auth3DS result: verified or attempted
cavvCardholder Authentication Verification Value
xidCardholder authentication transaction ID
three_ds_version3DS version: 2.0.0 or 2.2.0
transaction_session_id32-character Kount DDC session ID

Merchant Defined Fields

Attach up to 20 custom key-value pairs to any transaction. These are stored and returned in reporting.

bash
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE&type=sale&amount=10.00&ccnumber=4111111111111111&ccexp=1226" \
  -d "merchant_defined_field_1=store_42" \
  -d "merchant_defined_field_2=promo_SUMMER2026"

Response Fields

FieldDescription
response1=approved, 2=declined, 3=error
responsetextHuman-readable result (e.g. SUCCESS, DECLINE)
authcodeAuthorization code from the issuing bank
transactionidUnique BAMS transaction identifier
avsresponseAddress Verification result code
cvvresponseCVV verification result code (M=match, N=no match, P=not processed)
orderidYour order ID echoed back
typeTransaction type echoed back
response_codeNumeric response code (see Response Codes section)
customer_vault_idVault ID created (if customer_vault=add_customer was sent)
text
# Example response (query string format)
response=1&responsetext=SUCCESS&authcode=123456&transactionid=BAMS-20260115-00001234&avsresponse=Y&cvvresponse=M&orderid=ORD-0042&type=sale&response_code=100

Runs a live call against the sandbox. Use the test card numbers from the Testing section — no real funds are charged.

Customer Vault

The Customer Vault securely stores payment information (card numbers, ACH account details, and billing data) in a Level 1 PCI-certified facility. Once stored, you reference customers by a customer_vault_id instead of raw card data — eliminating the need to handle or store sensitive payment information on your own servers.

PCI Scope Reduction. When you use the Customer Vault exclusively, sensitive payment data never touches your server. This significantly reduces your PCI DSS compliance scope and breach liability.

How Tokenization Works

  1. Customer's card or ACH details are sent to the gateway over SSL
  2. Gateway stores the data in a PCI-compliant vault and returns a customer_vault_id
  3. You store only the customer_vault_id — no card data on your server
  4. Future charges reference the vault ID; the gateway decrypts and processes the data automatically

Add a Customer to the Vault

Pass customer_vault=add_customer alongside a sale or validate transaction. The vault record is created and the ID returned in the response:

bash
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "type=sale" \
  -d "amount=49.99" \
  -d "ccnumber=4111111111111111" \
  -d "ccexp=1226" \
  -d "cvv=999" \
  -d "firstname=Jane" \
  -d "lastname=Smith" \
  -d "email=jane@example.com" \
  -d "customer_vault=add_customer"

Response includes: customer_vault_id=cv_abc123def456

Charge a Vaulted Customer

Use the customer_vault_id in place of ccnumber / ccexp for subsequent transactions:

bash
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "type=sale" \
  -d "amount=29.99" \
  -d "customer_vault_id=cv_abc123def456"

Update a Vault Record

bash
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "customer_vault=update_customer" \
  -d "customer_vault_id=cv_abc123def456" \
  -d "ccnumber=5431111111111111" \
  -d "ccexp=0128"

Delete a Vault Record

bash
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "customer_vault=delete_customer" \
  -d "customer_vault_id=cv_abc123def456"

Customer Vault Parameters

ParameterValuesDescription
customer_vaultadd_customer | update_customer | delete_customerVault operation to perform
customer_vault_idStringVault record ID (auto-generated on add_customer if omitted)

Invoicing

Create and send payment invoices directly to customers via email. Customers pay via a hosted BAMS-branded payment page — no additional integration required on the payment side.

Create an Invoice

bash
curl -X POST https://www.bamsgateway.com/v3/invoices \
  -H "Content-Type: application/json" \
  -H "security-key: YOUR_API_KEY_HERE" \
  -d '{
    "customer_id": "cust_abc123",
    "amount": "250.00",
    "due_date": "2026-04-15",
    "memo": "Project retainer — March 2026",
    "line_items": [
      { "description": "Consulting Services", "quantity": 5, "unit_price": "50.00" }
    ]
  }'

Invoice Endpoints

MethodEndpointDescription
POST/v3/invoicesCreate a new invoice and email it to the customer
GET/v3/invoicesList invoices (supports filters: status, date range, customer)
GET/v3/invoices/{id}Retrieve a specific invoice
PUT/v3/invoices/{id}Update an open invoice
POST/v3/invoices/{id}/sendRe-send invoice email to the customer
DELETE/v3/invoices/{id}Close/cancel an invoice

Subscriptions

Create recurring billing schedules that automatically charge customers on a defined interval. The gateway handles retry logic, failed payment notifications, and Automatic Card Updater (ACU) for expiring cards.

Add a Subscription

bash
# Subscribe using an existing plan
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "recurring=add_subscription" \
  -d "plan_id=plan_monthly_pro" \
  -d "ccnumber=4111111111111111" \
  -d "ccexp=1226" \
  -d "firstname=Jane" \
  -d "lastname=Smith" \
  -d "email=jane@example.com"
bash
# Create a custom monthly subscription (no plan required)
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "recurring=add_subscription" \
  -d "plan_amount=29.99" \
  -d "plan_payments=12" \
  -d "month_frequency=1" \
  -d "day_of_month=15" \
  -d "start_date=20260401" \
  -d "ccnumber=4111111111111111" \
  -d "ccexp=1226" \
  -d "firstname=Jane" \
  -d "lastname=Smith"
bash
# Custom daily billing (every 7 days)
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "recurring=add_subscription" \
  -d "plan_amount=9.99" \
  -d "plan_payments=0" \
  -d "day_frequency=7" \
  -d "start_date=20260401" \
  -d "ccnumber=4111111111111111" \
  -d "ccexp=1226" \
  -d "firstname=Jane" \
  -d "lastname=Smith"

ACH Subscription

bash
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "recurring=add_subscription" \
  -d "payment=check" \
  -d "plan_id=plan_monthly_ach" \
  -d "checkname=Jane Smith" \
  -d "checkaba=021000021" \
  -d "checkaccount=123456789" \
  -d "account_type=checking" \
  -d "account_holder_type=personal" \
  -d "sec_code=PPD"

Update / Delete a Subscription

bash
# Update subscription (change amount or payment method)
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "recurring=update_subscription" \
  -d "subscription_id=sub_xyz789" \
  -d "plan_amount=39.99" \
  -d "ccnumber=5431111111111111" \
  -d "ccexp=0228"

# Cancel / delete a subscription
curl -X POST https://www.bamsgateway.com/api/transact.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "recurring=delete_subscription" \
  -d "subscription_id=sub_xyz789"

Subscription Parameters

ParameterRequiredDescription
recurringRequiredadd_subscription, update_subscription, or delete_subscription
plan_idConditionalExisting plan ID (required if not specifying custom billing fields)
plan_amountConditionalCharge per cycle in x.xx format (required for custom plans)
plan_paymentsOptionalNumber of charges (0 = bill indefinitely until canceled)
month_frequencyConditionalMonths between charges (1–24). Use either this or day_frequency, not both.
day_of_monthConditionalDay of month to charge (1–31; if month lacks that date, last day is used)
day_frequencyConditionalDays between charges. Use either this or month_frequency, not both.
start_dateOptionalDate of first charge in YYYYMMDD format
subscription_idConditionalRequired for update_subscription and delete_subscription
acu_enabledOptionaltrue (default) to enable Automatic Card Updater for expiring cards
paused_subscriptionOptionaltrue to pause billing without canceling

Subscription Response Fields

FieldDescription
response1=success, 2=failed, 3=error
subscription_idCreated or modified subscription identifier
responsetextHuman-readable result
customer_vault_idVault ID if a vault record was created or used

Customers

The REST Customers API provides CRUD operations over Customer Vault records. Use it to manage customer profiles and payment methods from your admin or CRM, separate from the transaction flow.

bash
# Create a customer vault record (no charge)
curl -X POST https://www.bamsgateway.com/v3/customers \
  -H "Content-Type: application/json" \
  -H "security-key: YOUR_API_KEY_HERE" \
  -d '{
    "firstname": "Jane",
    "lastname": "Smith",
    "email": "jane@example.com",
    "ccnumber": "4111111111111111",
    "ccexp": "1226"
  }'
MethodEndpointDescription
POST/v3/customersCreate a new customer vault record
GET/v3/customersList customer vault records
GET/v3/customers/{id}Retrieve a specific customer
PUT/v3/customers/{id}Update customer billing information or card
DELETE/v3/customers/{id}Delete a customer vault record
In-Person Payments

Devices

Manage card-present terminals through the Devices API. BAMS Payment Gateway supports a wide range of certified EMV/NFC terminals. Each device is registered to a merchant account and can be targeted for Cloud API transactions.

bash
# List registered terminals for your account
curl https://www.bamsgateway.com/v3/devices \
  -H "security-key: YOUR_API_KEY_HERE"
bash
# Get a specific device
curl https://www.bamsgateway.com/v3/devices/{device_id} \
  -H "security-key: YOUR_API_KEY_HERE"

Cloud API

The Cloud API lets you initiate card-present transactions remotely from your server. Send a payment request to a specific terminal — the customer taps or dips their card on the device and the result is delivered via webhook or polling.

bash
# Initiate a sale on a specific terminal
curl -X POST https://www.bamsgateway.com/v3/devices/{device_id}/transactions \
  -H "Content-Type: application/json" \
  -H "security-key: YOUR_API_KEY_HERE" \
  -d '{
    "type": "sale",
    "amount": "24.99",
    "tip_mode": "on_device",
    "orderid": "ORD-20260115-0043"
  }'
bash
# Poll for transaction result
curl https://www.bamsgateway.com/v3/devices/{device_id}/transactions/{transaction_id} \
  -H "security-key: YOUR_API_KEY_HERE"
Account Management

Merchants

Retrieve and update merchant account details including business information, processing limits, enabled payment methods, and processor configuration. Partners can use this API to manage all merchants under their umbrella.

bash
# Get merchant details
curl https://www.bamsgateway.com/v3/merchants/{merchant_id} \
  -H "security-key: YOUR_API_KEY_HERE"
bash
# Update merchant settings
curl -X PUT https://www.bamsgateway.com/v3/merchants/{merchant_id} \
  -H "Content-Type: application/json" \
  -H "security-key: YOUR_API_KEY_HERE" \
  -d '{"business_name": "Acme Retail LLC (Updated)", "email": "newcontact@acme.com"}'

Settlement

Query settlement batches and funding status. BAMS Payment Gateway offers next-business-day funding for qualifying merchants. Batch summaries include gross sales, refunds, chargebacks, fees, and net deposit amounts.

bash
# List settlement batches for a date range
curl "https://www.bamsgateway.com/v3/settlements?start_date=2026-01-01&end_date=2026-01-31" \
  -H "security-key: YOUR_API_KEY_HERE"
bash
# Get a specific batch
curl https://www.bamsgateway.com/v3/settlements/{batch_id} \
  -H "security-key: YOUR_API_KEY_HERE"

Fee Schedules

Retrieve the fee schedule applied to a merchant account, including interchange-plus margins, monthly statement fees, chargeback fees, and per-transaction rates by card type.

bash
curl https://www.bamsgateway.com/v3/merchants/{merchant_id}/fee-schedule \
  -H "security-key: YOUR_API_KEY_HERE"
Reporting

Transaction Data (Query API)

The Query API (query.php) retrieves transaction history, customer vault records, recurring subscriptions, and account data. Post your query parameters form-encoded; the response is XML.

bash
# Query recent transactions
curl -X POST https://www.bamsgateway.com/api/query.php \
  -d "security_key=YOUR_API_KEY_HERE" \
  -d "report_type=transaction" \
  -d "start_date=20260101" \
  -d "end_date=20260131" \
  -d "result_limit=50"

Report Types

report_typeDescription
transactionTransaction history — sales, auths, voids, refunds
recurringSubscription / recurring billing records
customer_vaultCustomer vault records
invoicesInvoice history and status

Query Parameters

ParameterDescription
report_typeType of report (see above)
start_dateStart date in YYYYMMDD format (or YYYYMMDDHHMMSS)
end_dateEnd date in YYYYMMDD format
result_limitMaximum records to return (default 1000)
transaction_idLook up a specific transaction by ID
order_idFilter by your order ID
conditionFilter by status: complete, pending, failed
action_typeFilter by type: sale, refund, void, etc.
first_name / last_nameFilter by customer name
emailFilter by customer email
cc_numberFilter by last 4 digits of card number
amountFilter by exact amount

The REST endpoint also supports flexible querying:

bash
curl "https://www.bamsgateway.com/v3/transactions?start_date=2026-01-01&status=approved&limit=50" \
  -H "security-key: YOUR_API_KEY_HERE"

Billing

Access itemized billing statements for your merchant account, including processing fees, monthly charges, chargeback costs, and any adjustments. Statements are generated monthly.

bash
# List billing statements
curl https://www.bamsgateway.com/v3/billing/statements \
  -H "security-key: YOUR_API_KEY_HERE"
bash
# Get a specific statement
curl https://www.bamsgateway.com/v3/billing/statements/{statement_id} \
  -H "security-key: YOUR_API_KEY_HERE"
Administration

API Keys

Create, rotate, and revoke API keys programmatically. Keys inherit the permission scope of the user account they are associated with. Follow the principle of least privilege — scope each key to only the permissions it needs.

Key Permission Scopes

ScopeAccess
transactions:writeCreate and modify transactions
transactions:readQuery transaction history
customers:writeCreate and modify vault records
customers:readRead customer vault data
reporting:readAccess billing and settlement reports
adminFull access including key management and user management
bash
# Create a scoped API key
curl -X POST https://www.bamsgateway.com/v3/api-keys \
  -H "Content-Type: application/json" \
  -H "security-key: YOUR_ADMIN_KEY_HERE" \
  -d '{
    "name": "Production Integration — transactions only",
    "scopes": ["transactions:write", "customers:read"]
  }'
bash
# Revoke a key
curl -X DELETE https://www.bamsgateway.com/v3/api-keys/{key_id} \
  -H "security-key: YOUR_ADMIN_KEY_HERE"

Users

Manage user accounts and role-based access control within your merchant organization. BAMS Payment Gateway supports granular permission scopes — invite team members with only the access they need.

bash
# Invite a team member
curl -X POST https://www.bamsgateway.com/v3/users \
  -H "Content-Type: application/json" \
  -H "security-key: YOUR_API_KEY_HERE" \
  -d '{
    "email": "finance@yourcompany.com",
    "role": "reporting_only",
    "first_name": "Alex",
    "last_name": "Johnson"
  }'
RoleDescription
adminFull access including user and key management
developerAPI and integration access; cannot manage users
reporting_onlyRead-only access to transactions and reports
supportCan view transactions and issue refunds; no admin access

Webhooks

Webhooks deliver real-time event notifications to your server via HTTPS POST. BAMS Payment Gateway signs all payloads with HMAC-SHA256 so you can verify their authenticity before processing.

Event Types

CategoryEvents
TransactionsSales, auths, captures, voids, refunds, and credits — filterable by successful, failed, or unknown
Check StatusACH/eCheck settled, returned, or late return
RecurringNew subscription created, subscription updated, subscription canceled, plan created/updated
SettlementBatch closed and funded — filterable by successful or failed
ChargebacksChargeback received, chargeback won, chargeback lost (requires processor support)
Automatic Card UpdaterCard updated, card closed, customer contact info updated

Register a Webhook Endpoint

All webhook URLs must start with https:// and have valid TLS encryption.

bash
curl -X POST https://www.bamsgateway.com/v3/webhooks \
  -H "Content-Type: application/json" \
  -H "security-key: YOUR_API_KEY_HERE" \
  -d '{
    "url": "https://yoursite.com/webhooks/bams",
    "events": [
      "transaction.approved",
      "transaction.declined",
      "chargeback.created",
      "recurring.subscription_canceled"
    ]
  }'

Webhook Payload Structure

Every webhook POST contains three top-level fields:

json
{
  "event_id":   "evt_a1b2c3d4e5f6",
  "event_type": "transaction.approved",
  "event_body": {
    "transactionid": "BAMS-20260115-00001234",
    "type": "sale",
    "amount": "49.99",
    "response": "1",
    "authcode": "123456",
    ...
  }
}

Verifying Webhook Signatures

Each webhook request includes a X-BAMS-Signature header in the format t={nonce},s={signature}. Verify the signature before processing the event:

php
function webhookIsVerified(string $webhookBody, string $signingKey, string $header): bool {
    // Header format: t={nonce},s={signature}
    if ( ! preg_match( '/t=([^,]+),s=(.+)/', $header, $m ) ) return false;
    $nonce = $m[1];
    $sig   = $m[2];
    $expected = hash_hmac( 'sha256', $nonce . '.' . $webhookBody, $signingKey );
    return hash_equals( $expected, $sig );
}

// In your webhook handler:
$rawBody = file_get_contents( 'php://input' );
$header  = $_SERVER['HTTP_X_BAMS_SIGNATURE'] ?? '';
if ( ! webhookIsVerified( $rawBody, BAMS_WEBHOOK_SECRET, $header ) ) {
    http_response_code( 401 );
    exit( 'Invalid signature' );
}
$event = json_decode( $rawBody, true );
javascript
const crypto = require('crypto');

function verifyWebhook(rawBody, signingKey, header) {
  const match = header.match(/t=([^,]+),s=(.+)/);
  if (!match) return false;
  const [, nonce, sig] = match;
  const expected = crypto.createHmac('sha256', signingKey)
                         .update(`${nonce}.${rawBody}`)
                         .digest('hex');
  return crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
}

IP Allowlist

For additional security, restrict your webhook endpoint to only accept requests from BAMS Gateway IP ranges:

text
104.192.32.81  –  104.192.32.87
104.192.36.81  –  104.192.36.87

Retry Logic

If your endpoint does not return HTTP 200, BAMS will retry the webhook delivery with exponential back-off. Respond with 200 as quickly as possible — process the event asynchronously if needed.

Configure via Portal. Webhooks can also be configured in the BAMS Merchant Portal under Settings → Webhooks. Click Create, enter your HTTPS URL, and select the event types you want to receive.