Payment lifecycle
Authentication, captures, cancellations, refunds and uncertain outcomes.
Use test payment details only. No real money moves; live activation is separate.
| Status | Meaning |
|---|---|
requires_payment_method | Waiting for a payment method. With last_payment_error, an attempt has failed (see below); without it, no attempt has been made |
requires_action | Customer must complete authentication |
processing | Awaiting a confirmed outcome; do not submit another charge |
partially_captured | Some principal captured; inspect the remaining reservation |
succeeded | Entire requested principal captured |
failed | Terminal failure; inspect the current record before starting another attempt |
canceled | Cancellation is confirmed |
When an attempt fails
After a failed card attempt the payment returns to requires_payment_method and carries last_payment_error, so a failed attempt reads differently from one never started. The same field is in the payment.attempt_failed event and every later event for the payment, until a new attempt starts or the payment succeeds.
{"status": "requires_payment_method", "captured_amount": 0, "last_payment_error": {"type": "card_declined", "code": "insufficient_funds"}}type | Meaning |
|---|---|
authentication_failed | 3D Secure was not completed, or failed at the cardholder's bank. No authorization was attempted. code is authentication_failed. |
card_declined | The bank declined the authorization, usually after successful 3D Secure. code carries the bank's reason, such as insufficient_funds, try_again_later or expired_card. Reasons that should not be shown to a shopper are reported as generic_decline. |
processing_error | The attempt could not be completed for a technical reason. |
For a direct-card payment, treat payment.attempt_failed, or a read showing requires_payment_method with last_payment_error, as a failed outcome for that checkout. Do not wait for it to change: it will not, unless you start a new attempt. The payment ID returned at creation stays the identifier throughout; there is no separate ID for the authenticated attempt.
A payment keeps the same ID throughout authentication, processing and any subsequent refunds. A timeout does not mean failure. Retrieve that payment or wait for its verified webhook before deciding what to do next.
Server-to-server confirmation
Create the payment first
POST /v1/payments requires amount, currency and reference. Without payment_method, it creates a payment record and returns hosted checkout. The separately activated direct-card flow accepts a card object and attempts payment in the same request. Tokens belong only on the confirmation endpoint.
curl 'https://sandbox-api.aimatlantic.com/v1/payments' \
-H "Authorization: Bearer $AIM_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: create_order_0001' \
-d '{"amount":1000,"currency":"USD","reference":"order-0001","customer":{"name":"Example Customer","email":"customer@example.com"}}'This creates a USD 10.00 payment. 100000 means USD 1,000.00. Keep the returned payment id and complete checkout_url.
Use your customer's actual name and email in customer. Both fields are required when that object is present; customer.id is rejected. We find or create the customer wallet in the background, scoped to your organization and environment. Returning customers use the same email and a new payment idempotency key for each new order. Omitting customer creates an unattributed payment. The same rules apply to hosted, token and direct-card payments. See customer wallets.
To return the customer to your website after checkout or 3DS, include optional success_url, failure_url and cancel_url in this creation request. See the checkout return URL example. These fields do not belong in the confirmation request.
To test S2S immediately, continue with the sandbox test-token example below. Alternatively, open checkout_url in a browser, enter the successful 3DS test card listed below in its secure fields, and complete the authentication challenge. No tokenization integration is needed for either sandbox test path.
For your own checkout UI, first arrange the secure card-tokenization integration with Aim Atlantic. Then follow the token confirmation step below. Direct card submission is a separate integration that requires explicit activation for each workspace and environment; see direct-card processing.
Test S2S with a sandbox token
After creating the payment above, set PAYMENT_ID to its returned id. Use this published test fixture to exercise backend confirmation without collecting card details:
curl "https://sandbox-api.aimatlantic.com/v1/payments/$PAYMENT_ID/confirm" \
-H "Authorization: Bearer $AIM_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: confirm_order_0001' \
-d '{"payment_method_token":"tok_threeDSecure2Required"}'Use your own sandbox aa_test_ API key with payments:write and payments:read. The published token above is sandbox-only and cannot charge a real card. It is a test fixture, not a live card token or an API key.
- Expect HTTP
200withstatus: "requires_action"from confirmation. - Open the complete returned
checkout_urlin a browser. Authentication starts automatically once the secure SDK is ready; complete the test 3DS challenge. If authentication is interrupted and the payment remainsrequires_action, select Retry authentication. If the processor rejects authentication, follow the displayed error and current payment status instead. Do not create another payment while the result is unresolved. - Retrieve the same payment to confirm
status: "succeeded"andcaptured_amount: 1000, or verify the corresponding signedpayment.succeededwebhook if you have registered an endpoint.
curl "https://sandbox-api.aimatlantic.com/v1/payments/$PAYMENT_ID" \
-H "Authorization: Bearer $AIM_API_KEY"Creation and confirmation use different idempotency keys. Retain each key and its request body when retrying that operation. Choose new keys and a new reference for a separate test. A 200 confirmation response alone does not mean the payment has succeeded. S2S handles the backend API calls; interactive 3DS still requires the customer's browser.
Confirm a securely collected token
POST /v1/payments/{id}/confirm accepts payment_method_token containing a single-use card token collected through the secure components agreed during onboarding. It rejects raw card fields and reusable payment-method IDs. Confirm the tokenization setup with Aim Atlantic before implementing S2S confirmation; arbitrary tokens from another payment integration are not interchangeable.
Both sandbox and approved live workspaces support this server-to-server API flow. A card payment that requires customer authentication still needs a browser step; it cannot be completed entirely by backend requests. Dashboard sign-in and MFA are separate from merchant API authentication.
Create the payment using POST /v1/payments first. Then confirm its returned id from your backend:
curl "https://sandbox-api.aimatlantic.com/v1/payments/$PAYMENT_ID/confirm" \
-H "Authorization: Bearer $AIM_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: confirm_order_0001' \
-d "{\"payment_method_token\":\"$PAYMENT_METHOD_TOKEN\"}"AIM_API_KEY is your workspace's sandbox server key with payments:write. Outside the documented sandbox test fixture above, PAYMENT_METHOD_TOKEN must be a single-use token from the configured card collector; it is not an API key, a reusable pm_ identifier or an invented placeholder. If token collection has not been configured for your integration, use the sandbox fixture or the payment's checkout_url to complete testing. Live payments require the approved tokenization setup or hosted card collection. The separate direct-card creation flow handles tokenization internally; it does not return reusable card credentials.
When confirmation returns requires_action, open the returned checkout_url in the customer's browser and complete authentication. Keep the same payment ID and retrieve it until the outcome is known, or consume its signed webhook. A 200 response alone does not mean the payment succeeded.
Live S2S integration
Use https://api.aimatlantic.com with an active aa_live_ server key. Live and sandbox share this two-step token contract. Separately activated direct-card integrations use the single creation request described below:
POST /v1/paymentswithamount,currency,referenceand any return URLs. This creates the payment; it does not collect a card or confirm payment.POST /v1/payments/{id}/confirmwith onlypayment_method_token, using a real single-use token from the live secure card collector configured for your integration. Keep raw card details in the secure collector. Sandbox fixtures and tokens from another account/environment cannot be used for live payments.- Follow the returned status. Open
checkout_urlforrequires_actionto complete 3DS for that same submitted card. Do not open checkout unconditionally after creation if you intend to confirm a token from your backend first.
curl "https://api.aimatlantic.com/v1/payments/$PAYMENT_ID/confirm" \
-H "Authorization: Bearer $AIM_LIVE_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: confirm_live_order_0001' \
-d "{\"payment_method_token\":\"$PAYMENT_METHOD_TOKEN\"}"A checkout_url in the response is a continuation link, not evidence that S2S was ignored. If you open it while the payment is still requires_payment_method, it shows card collection because no payment method has been confirmed, or a prior method was declined. An accepted token confirmation requiring 3DS returns requires_action, and checkout starts authentication automatically for the submitted card. Retry authentication remains available after an interrupted attempt if the payment still requires authentication. A rejected authentication can instead return the payment to card collection. For succeeded, verify the payment or signed webhook before fulfillment; for processing, await the final result.
If your own live tokenization integration is not configured yet, contact Aim Atlantic for the embedded collector and matching publishable key. Enabling live API access does not automatically install a collector in your application. Aim Atlantic's hosted checkout already supplies its own collector and key: for that option, create the payment and redirect to checkout_url without calling /confirm yourself. Never send card numbers, expiry dates, CVCs or raw request bodies to support.
Troubleshooting S2S requests
| Response | Next step |
|---|---|
401 unauthorized | Pair an active aa_test_ key with the sandbox API or aa_live_ with the live API. |
403 forbidden | Check that the key includes payments:write. |
400 idempotency_key_required | Send an Idempotency-Key containing 8–128 letters, digits, underscores or hyphens. |
400 invalid_payment_method_token | Send exactly the token field shown above, using the agreed card collector for the same environment. |
400 invalid_request | Check the JSON syntax, payment UUID and documented fields. |
409 idempotency_conflict | Retry with the original confirmation key and token; use checkout if you need another card. |
429 or 503 | Follow Retry-After and retain the same payment, key and request. Read the payment status before attempting another charge. |
For support, retain the response's error.request_id or X-Request-Id header and the test time. Do not send API keys, card details, tokens or full checkout URLs in logs or support messages.
If creation returns invalid_request, verify reference and the exact request schema. Card numbers and CVCs must be strings; expiry fields must be integers. If the valid direct-card shape returns direct_card_not_enabled, your workspace has not been activated for that flow. Do not repeatedly submit card data; use the hosted or token flow until activation is confirmed.
Retain the same idempotency key and token on retries. Each payment supports one S2S token confirmation attempt in this pilot. Continue at the returned checkout_url when authentication is required. If a different payment method is needed, use that payment's checkout or cancel it before creating another order attempt.
New customer-initiated card payments request 3DS and use authorization before capture. Aim Atlantic captures only after successful authentication (authenticated); attempted or unsupported authentication is canceled. Successful frictionless 3DS can satisfy this policy without a visible challenge. Consented automatic renewals use a separate off-session policy: they can succeed without a new challenge, and renewals requiring customer action need the manual recovery procedure described in the recurring guide. See recurring payments. Validate your chosen flow in sandbox before live activation.
Direct-card processing
Separate activation required. This contract is opt-in, disabled by default and enabled independently for each merchant and environment. Ordinary live API access does not enable it. Aim Atlantic must confirm the processor’s raw-card API access and the applicable PCI validation before enabling real card submissions. Do not send real card data until your activation is confirmed.
Your backend can use one request to create a payment and submit its card. Aim Atlantic sends the card to the processor for tokenization and confirms the resulting token. You do not call /confirm or implement client-side tokenization for this flow. Supplying card details does not bypass 3DS: initial payments retain the successful-authentication requirement.
Use your existing server API key with payments:write for the selected environment. Activation is separate for sandbox and live; it does not require a replacement key.
| Environment | Payment creation endpoint | Server key |
|---|---|---|
| Sandbox | https://sandbox-api.aimatlantic.com/v1/payments | Your sandbox key (aa_test_...); test cards only |
| Production | https://api.aimatlantic.com/v1/payments | Your live key (aa_live_...); genuine authorized payments only |
For direct-card payments that need browser authentication, the continuation page shows a processing screen and starts 3DS automatically. It does not show card-entry fields or ask the customer to enter their card again. After full capture, the browser returns to your success_url. A confirmed unsuccessful attempt with no captured funds returns to your failure_url (or cancel_url for older requests without a failure URL). Pending payments and connection errors stay on the status screen until the outcome is confirmed. If the API returns a final outcome without requiring browser authentication, your application handles its own navigation.
The following is a sandbox-only fixture, for use only after sandbox direct-card activation. The corresponding live host is https://api.aimatlantic.com, with separate live credentials and activation.
{
"amount": 500,
"currency": "USD",
"reference": "direct-test-0001",
"customer": {
"name": "Example Customer",
"email": "customer@example.com"
},
"success_url": "https://merchant.example/payments/success",
"failure_url": "https://merchant.example/payments/failure",
"cancel_url": "https://merchant.example/payments/cancel",
"payment_method": {
"type": "card",
"billing_details": {
"name": "Example Customer",
"email": "customer@example.com",
"phone": "+12025550123",
"address": {
"line1": "123 Example Street",
"city": "Newark",
"state": "DE",
"postal_code": "19713",
"country": "US"
}
},
"card": {
"number": "4000008400000027",
"exp_month": 12,
"exp_year": 2034,
"cvc": "123"
}
}
}Send this JSON to POST /v1/payments with your server API key, Content-Type: application/json and an Idempotency-Key. Card number and CVC are digit strings; expiry month and four-digit year are integers. Spaces, numeric card numbers, expired cards and unknown fields are rejected with fixed validation guidance that does not echo input.
| Direct response | Handling |
|---|---|
requires_action | Open next_action.url in the customer’s browser. It equals checkout_url and automatically starts authentication for the submitted card once the secure SDK is ready. The bank may still require customer verification. Use Retry authentication after an interrupted attempt while authentication is still required; otherwise follow the current status and displayed error. |
succeeded | Confirm full captured amount on your backend or verify the signed success webhook. checkout_url and next_action are null. |
processing | Show a waiting screen and resolve it using the signed event or backend payment retrieval. Both URL/action fields are null; do not create another charge. If the customer is already on our checkout, its waiting screen checks automatically until the payment leaves the pending state. |
requires_payment_method with payment_error.code: card_declined | The attempt did not succeed. Both URL/action fields are null; no silent hosted-checkout fallback occurs. last_payment_error gives the reason. |
canceled | Authentication policy or cancellation ended the payment. Do not fulfill the order. |
An HTTP 200 or 201 alone does not confirm payment. Always follow the returned status: frictionless 3DS can still require a browser continuation even when no challenge is shown. If the API returns succeeded, no continuation is needed. When browser authentication is needed, the saved success/cancel destinations apply as in hosted checkout. Your application handles navigation itself when the direct request completes without a browser step.
If payment_method is omitted entirely, the same endpoint returns the usual hosted checkout_url and does not attempt a card charge. /confirm continues to accept only a token; do not send a card object there.
Billing details and customer context
These additions are optional and apply only to direct-card creation. Existing requests without them still work. client_context is not required by the processor or for 3DS and is omitted from the recommended request above. All identity and address values above are synthetic sandbox fixtures; replace them with genuine shopper information in production, or omit unavailable fields.
| Field | Meaning and handling |
|---|---|
payment_method.billing_details.name, email, phone | Actual cardholder billing contact details, sent to Stripe's billing fields before confirmation. Phone uses international format, such as +12025550123. |
payment_method.billing_details.address | Actual billing address: line1, optional line2, city, state, postal_code, and uppercase two-letter country. Supply available fields; omit missing values instead of sending blanks or invented addresses. |
client_context.ip_address | Shopper IPv4 or IPv6 address, obtained by your backend from the original shopper request using your trusted proxy configuration. Do not substitute your server IP, use an untrusted forwarding header, or send an IP list. |
client_context.user_agent | Shopper browser's User-Agent, forwarded by your backend; max 500 characters. Do not substitute your API client's User-Agent. |
client_context.checkout_url | Original public HTTPS checkout page, max 500 characters. Remove query parameters, credentials and fragments so it contains no tokens or customer details. This is optional operational context; it does not control the required 3DS continuation. Open any returned continuation link top-level. |
customer continues to identify the wallet beneficiary. Billing details identify the cardholder; we do not assume those are the same person or copy one into the other. Do not send empty billing/address/context objects.
Stripe handling: billing data uses Stripe's native billing fields. IP, User-Agent and checkout URL are sent as clearly labelled merchant-reported PaymentMethod metadata (aim_reported_customer_ip, aim_reported_user_agent, aim_reported_checkout_url) for operational review. They are not native Radar device signals and do not populate Radar's built-in IP attributes. A Radar Session collected from the shopper's browser is a separate integration. These fields cannot guarantee approval or frictionless authentication and do not bypass fraud rules or the authenticated-capture requirement.
Your backend can forward details it already receives without adding a frontend SDK. If you do not already collect billing details, you must obtain them from the shopper. Aim Atlantic never guesses these values from the server-to-server connection. We send the additional fields to Stripe and retain only a context digest for retries; we do not add their plaintext values to our payment records, responses, queues or merchant webhooks. Stripe retains the transmitted billing data and review metadata under its own retention policies. Avoid logging raw requests and keep your privacy disclosures accurate.
A return URL is a navigation destination, not proof of success. If you use the same URL for success and cancellation, or omit failure_url and rely on the cancel fallback, your return handler must retrieve the payment using payment_id and show its actual status. Only succeeded with the full captured amount is a successful payment. A signed failure event remains a failure even if the browser returns to the same page as a successful checkout.
Direct-card retries and errors
- Reuse the same creation key and identical request body after an uncertain response. Application records retain payment facts and a fixed flow marker, not card details or CVC-derived hashes. Processor idempotency controls repeated tokenization and confirmation. Never change card details under an existing key; retries may return the existing result rather than inspect replacement card data.
- Switching between hosted and direct collection under the same creation key, or changing amount/currency/reference/return URLs, normalized customer name/email, billing details or client context, returns
409 idempotency_conflict. Adding or removing context also conflicts. Preserve the original context on retries; do not replace it with the retrying server's current details. See idempotency and errors. 403 direct_card_not_enabledmeans the workspace or environment is not enabled; the platform creates no payment for that rejected request.503 direct_card_unavailablemeans processor-side direct collection is unavailable. Send only the request ID to support.- An error after a payment record is created includes
error.payment_id. Retrieve it and retain the original key before retrying. Unknown outcomes must not be treated as declines. - Ambiguous confirmation cannot be resubmitted after the safe provider-idempotency window.
409 reconciliation_requiredneeds operator review, not a new retry key. - A different card requires a separate deliberate payment attempt after the previous payment has been reconciled/canceled. Do not store the card or CVC in retry queues, logs, analytics, support messages or URLs. Automatic renewals use the separately consented saved-method flow; do not retain CVC for renewals.
Sandbox checkout testing
Use the following test cards in secure hosted fields, or in a separately activated sandbox direct-card integration. Enter a future expiry date, such as 12/34, and a three-digit CVC. Never use these fixtures against the live API.
| Scenario | Test card | What to check |
|---|---|---|
| Successful payment with 3DS | 4000 0084 0000 0027 | Complete the test authentication challenge, then retrieve the payment until its status is succeeded. |
| Decline after authentication | 4000 0084 0000 1629 | Complete authentication; the payment must not be treated as captured. |
| Card declined | 4000 0000 0000 0002 | Confirm the checkout shows a declined attempt and your integration does not fulfill the order. |
A generic successful test card that does not authenticate may be canceled by the initial-payment 3DS policy. Start with the successful 3DS card above. Use a fresh payment and idempotency key for each independent scenario; reuse the same key only when retrying the same operation.
Refunds and cancellations
Cancel an uncaptured payment with POST /v1/payments/{id}/cancel. Treat cancellation as complete only when the payment status is canceled. Use refunds for captured payments.
A refund reserves refundable principal so concurrent refunds cannot exceed the captured amount. Pending refunds retain that reservation. Retry an uncertain refund with the same idempotency key. Refunds preserve the original gross captured amount; they are separate records and events.
The sandbox dashboard shows payments, refunds, disputes, recurring schedules, fees and monthly ledger statements. Capture is not bank settlement. Balances and settlements explains the distinction. Approved live workspaces use their separate production dashboard and credentials. Merchant bank transfers are handled manually.