Payments

Create Auto Attempt

Create an automatic payment attempt using stored credentials

Create an automatic payment attempt using previously stored payment credentials without requiring customer interaction.

Endpoint

POST /api/intents/auto-attempt

Authentication: Required (API Key)

Description

This endpoint allows you to initiate payments on behalf of your customers without requiring any action from them. This functionality is particularly useful for collecting recurring payments (subscriptions), automatic top-ups, or other automated billing processes where customer interaction is not needed.

How It Works

  1. The endpoint creates a new payment intent in non-interactive mode
  2. It uses previously stored payment credentials to process the payment
  3. No customer action or redirection is required - the payment attempt is processed automatically

Prerequisites

Before initiating an automatic payment attempt, the following conditions must be met:

1. Prior Successful Payment

The customer must have completed a previous successful payment where:

  • allow_remember_credentials was set to true
  • Either request_unscheduled_mit or require_unscheduled_mit was set to true

2. Valid Stored Credential

You must provide a valid credential token that:

  • Was generated from a previous successful payment
  • Uses a payment method that supports MIT (Merchant-Initiated Transactions)

3. Obtaining Credential Tokens

The credential tokens required for auto-payments are provided in webhook notifications after a successful payment. When a customer completes a payment with allow_remember_credentials=true and the appropriate MIT settings, your system will receive a webhook notification containing the credential token.

Store credential tokens securely for future auto-payment attempts. For more information about webhook notifications, refer to the Webhook documentation.

Request

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token with your API key
Content-TypestringYesMust be application/json

Body Parameters

ParameterTypeRequiredDescription
amountintegerYesAmount in minor units (cents). E.g., 1000 = $10.00
currencystringYesISO 4217 currency code (e.g., USD, ZAR, EUR)
reference_idstringYesYour unique transaction reference
purchaser_idstring (min 3 chars)YesYour unique customer identifier (must match credential)
credentialsarray of stringsYesArray containing the credential token(s) to use
purchaser_infoobjectNoCustomer details (email, phone, country, locale)
splitobjectNoPayment split configuration for multiple beneficiaries

Purchaser Info Object

FieldTypeRequiredDescription
emailstringNoCustomer email address
phone_numberstringNoCustomer phone number
countrystringNoISO country code (e.g., ZA)
localestringNoLocale code (e.g., en-ZA)

Split Object

FieldTypeRequiredDescription
split_typestringYesCurrently only AMOUNT supported
splitsarray (min 2)YesList of beneficiary splits
descriptionstringNoOptional split description

See Split Payouts Guide for details.

Example Request

curl -X POST https://app.infinic.com/api/intents/auto-attempt \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 5000,
    "currency": "ZAR",
    "reference_id": "subscription_payment_456",
    "purchaser_id": "customer_abc",
    "credentials": ["luUOJ4pNipy3vdGPSD"],
    "purchaser_info": {
      "email": "customer@example.com",
      "phone_number": "+27123456789"
    }
  }'

Response

Success Response (201 Created)

{
  "id": 12345,
  "attempt_status": "pending",
  "method": "card",
  "failure_reason": null,
  "intent_id": "550e8400-e29b-41d4-a716-446655440000",
  "intent_status": "pending",
  "action": null,
  "redirect_url": null
}
FieldTypeDescription
idintegerUnique payment attempt identifier
attempt_statusstringStatus of the attempt (initiated, pending, success)
methodstringPayment method used (e.g., card, paypal)
failure_reasonstring / nullReason for failure (null if successful or pending)
intent_idstring (UUID)Associated payment intent ID
intent_statusstringStatus of the intent (pending, success, failed)
actionobject / nullAdditional action required (usually null for auto)
redirect_urlstring / nullRedirect URL (usually null for non-interactive)

Error Responses

401 Unauthorized

{
  "detail": "Invalid or missing API key"
}

Causes:

  • Missing Authorization header
  • Invalid API key
  • Using sandbox key with production URL (or vice versa)

403 Forbidden

{
  "detail": "Not authorized to use the provided credential"
}

Causes:

  • Credential belongs to different merchant
  • Credential was created by different merchant

404 Not Found

{
  "detail": "Credential not found"
}

Causes:

  • Invalid credential token
  • Credential has been deleted
  • Credential does not exist

422 Validation Error

{
  "detail": "Credential exists but cannot be used for MIT transactions"
}

Causes:

  • Credential is not MIT compatible
  • Payment method doesn't support merchant-initiated transactions
  • Original payment was not set up for auto-payments

Other validation errors:

{
  "detail": [
    {
      "loc": ["body", "amount"],
      "msg": "ensure this value is greater than or equal to 0",
      "type": "value_error"
    }
  ]
}

Monitoring Payment Status

After creating an auto payment attempt, you can check its status using:

  • GET /api/intents/{intent_id}?iauth={token} - Use the intent token (iauth) as a query parameter, or the API key in the Authorization header
  • The response includes the current intent status, attempt details, and transaction information
Set up webhook notifications to receive real-time updates on payment status. See Webhook Events for details.

Important Notes

Payment Method Support

Not all payment methods support MIT (Merchant-Initiated Transactions). The is_mit_compatible flag in the credential indicates whether it can be used for auto-payments.

Status Transitions

Auto payments follow the same status transitions as regular payments:

  • initiated → Payment attempt created
  • pending → Being processed by payment provider
  • success → Payment completed successfully
  • failed → Payment failed (intent goes directly to Failed since no user interaction is possible)

Failed Payments

If an auto payment fails, the intent will go directly to Failed state since no user interaction is possible to retry with a different payment method.

Security

  • Always store credential tokens securely (encrypted at rest)
  • Never expose credential tokens in client-side code
  • Validate the purchaser_id matches the credential owner
  • Implement rate limiting to prevent abuse

Use Cases

  1. Subscription Billing - Charge customers on a recurring schedule
  2. Automatic Top-ups - Refill customer accounts when balance is low
  3. Deferred Payments - Charge customers after service delivery
  4. Split Payments - Charge remaining balance after initial payment
  5. Penalty Fees - Apply late fees or other charges automatically

Next Steps

After creating an auto attempt:

  1. Monitor webhook events for payment status updates
  2. Handle failed payments appropriately (retry logic, customer notification)
  3. Update your system with payment results
See the Auto Payments Guide for a complete integration walkthrough.