Skip to content

Accept a Payment on your Website

Learn how to accept a one-time card payment on your website with Finix.js and the Finix API. After setup, you can charge buyers from a checkout page you own and control.

Prerequisites

Before you start, you need:

  • A Finix Sandbox account.
  • A Sandbox API key. The Finix API uses HTTP Basic Authentication with the key's username and password.
  • Your Application ID, which initializes Finix.js.
  • Your Merchant ID, which tells Finix which merchant receives the funds.

To find these values, see Set Up Development Environment.

Step 1: Create your buyer

Create an Identity

On your back end, create an Identity to represent the buyer. Every field on a buyer Identity is optional. Collect at least the buyer's name and email to help with reconciliation and disputes.

Don't pass the business_type field when you create a buyer Identity. Including business_type makes Finix treat the Identity as a seller.

cURL
curl -i -X POST \
  -u US6RE3TRcse4wjkgDCkaLckN:c019209f-46fa-49a8-9e3f-11e5a5a2059b \
  https://finix.sandbox-payments-api.com/identities \
  -H 'Content-Type: application/json' \
  -d '{
    "additional_underwriting_data": {
      "annual_ach_volume": 200000,
      "average_ach_transfer_amount": 200000,
      "average_card_transfer_amount": 200000,
      "business_description": "SB3 vegan cafe",
      "card_volume_distribution": {
        "card_present_percentage": 30,
        "ecommerce_percentage": 60,
        "mail_order_telephone_order_percentage": 10
      },
      "credit_check_allowed": true,
      "credit_check_ip_address": "42.1.1.112",
      "credit_check_timestamp": "2021-04-28T16:42:55Z",
      "credit_check_user_agent": "Mozilla 5.0(Macintosh; IntelMac OS X 10_14_6)",
      "merchant_agreement_accepted": true,
      "merchant_agreement_ip_address": "42.1.1.113",
      "merchant_agreement_timestamp": "2021-04-28T16:42:55Z",
      "merchant_agreement_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6)",
      "refund_policy": "MERCHANDISE_EXCHANGE_ONLY",
      "volume_distribution_by_business_type": {
        "business_to_business_volume_percentage": 100,
        "business_to_consumer_volume_percentage": 0,
        "consumer_to_consumer_volume_percentage": 0,
        "other_volume_percentage": 0,
        "person_to_person_volume_percentage": 0
      }
    },
    "entity": {
      "ach_max_transaction_amount": 1000000,
      "annual_card_volume": 12000000,
      "business_address": {
        "city": "San Mateo",
        "country": "USA",
        "line1": "741 Douglass St",
        "line2": "Apartment 8",
        "postal_code": "94114",
        "region": "CA"
      },
      "business_name": "Finix Flowers",
      "business_phone": "+1 (408) 756-4497",
      "business_tax_id": "123456789",
      "business_type": "INDIVIDUAL_SOLE_PROPRIETORSHIP",
      "default_statement_descriptor": "Finix Flowers",
      "dob": {
        "day": 27,
        "month": 6,
        "year": 1978
      },
      "doing_business_as": "Finix Flowers",
      "email": "john.smith@example.com",
      "first_name": "John",
      "has_accepted_credit_cards_previously": true,
      "incorporation_date": {
        "day": 27,
        "month": 6,
        "year": 1978
      },
      "last_name": "Smith",
      "max_transaction_amount": 1000000,
      "mcc": "4900",
      "ownership_type": "PRIVATE",
      "personal_address": {
        "city": "San Mateo",
        "country": "USA",
        "line1": "741 Douglass St",
        "line2": "Apartment 7",
        "postal_code": "94114",
        "region": "CA"
      },
      "phone": "14158885080",
      "principal_percentage_ownership": 50,
      "tax_id": "123456789",
      "title": "CEO",
      "url": "https://www.finix.com"
    },
    "identity_roles": [
      "SELLER"
    ],
    "tags": {
      "order_id": "ORD-123"
    },
    "type": "BUSINESS"
  }'

The response returns the buyer's Identity. Save the id to create the Payment Instrument in Step 2.

Identity - Buyer
{
  "id": "IDgdNdwvY26TK2ACZJKuwQNi",
  "created_at": "2026-11-28T01:25:53.79Z",
  "updated_at": "2026-11-28T01:25:53.79Z",
  "application": "APt9MknRZxiDMkeReFPMdr7R",
  "entity": {
    "ach_max_transaction_amount": 0,
    "amex_mid": null,
    "annual_card_volume": 0,
    "business_address": null,
    "business_name": null,
    "business_phone": null,
    "business_tax_id_fingerprint": null,
    "business_tax_id_provided": false,
    "business_type": null,
    "default_statement_descriptor": null,
    "discover_mid": null,
    "dob": null,
    "doing_business_as": null,
    "email": "john.smith@example.com",
    "first_name": "John",
    "has_accepted_credit_cards_previously": false,
    "incorporation_date": null,
    "last_name": "Smith",
    "max_transaction_amount": 0,
    "mcc": null,
    "ownership_type": null,
    "personal_address": {
      "line1": "741 Douglass St",
      "line2": "Apartment 7",
      "city": "San Mateo",
      "region": "CA",
      "postal_code": "94114",
      "country": "USA"
    },
    "phone": "14158885080",
    "principal_percentage_ownership": null,
    "short_business_name": null,
    "tax_authority": null,
    "tax_id_fingerprint": null,
    "tax_id_provided": false,
    "title": null,
    "url": null
  },
  "identity_roles": [ 
    "BUYER"
  ],
  "tags": {},
  "type": "PERSONAL",
  "_links": {
    "self": {
      "href": "https://finix.sandbox-payments-api.com/identities/IDgdNdwvY26TK2ACZJKuwQNi"
    },
    "verifications": {
      "href": "https://finix.sandbox-payments-api.com/identities/IDgdNdwvY26TK2ACZJKuwQNi/verifications"
    },
    "merchants": {
      "href": "https://finix.sandbox-payments-api.com/identities/IDgdNdwvY26TK2ACZJKuwQNi/merchants"
    },
    "settlements": {
      "href": "https://finix.sandbox-payments-api.com/identities/IDgdNdwvY26TK2ACZJKuwQNi/settlements"
    },
    "authorizations": {
      "href": "https://finix.sandbox-payments-api.com/identities/IDgdNdwvY26TK2ACZJKuwQNi/authorizations"
    },
    "transfers": {
      "href": "https://finix.sandbox-payments-api.com/identities/IDgdNdwvY26TK2ACZJKuwQNi/transfers"
    },
    "payment_instruments": {
      "href": "https://finix.sandbox-payments-api.com/identities/IDgdNdwvY26TK2ACZJKuwQNi/payment_instruments"
    },
    "associated_identities": {
      "href": "https://finix.sandbox-payments-api.com/identities/IDgdNdwvY26TK2ACZJKuwQNi/associated_identities"
    },
    "disputes": {
      "href": "https://finix.sandbox-payments-api.com/identities/IDgdNdwvY26TK2ACZJKuwQNi/disputes"
    },
    "application": {
      "href": "https://finix.sandbox-payments-api.com/applications/APt9MknRZxiDMkeReFPMdr7R"
    }
  }
}

Step 2: Collect your buyer's payment details

Add the payment form to your checkout page

Finix.js renders the card fields in iframes hosted by Finix, so card details never touch your servers. Try the form with a test card to see the token it returns.

Loading payment form…

Finix.PaymentForm("payment-form", "sandbox", "APc9vhYcPsRuTSpKD9KpMtPe", {
  theme: "finix",
  paymentMethods: ["card"],
  showAddress: false,
  defaultValues: { address_country: "USA" },
  enableDarkMode: true,
  styles: {
    dark: { form: { default: {
      backgroundColor: "#22242b",
      margin: 0,
      boxShadow: "0 0 0 100px #22242b",
    } } },
  },
  onSubmit: function (error, response) { /* ... */ },
});

Add the Finix.js library to the page that hosts your checkout, along with an empty element for the form to render into.

checkout.html
<script src="https://js.finix.com/v/2/finix.js"></script>

<div id="payment-form"></div>

Always load Finix.js directly from https://js.finix.com. Don't self-host the library or include it in your own code bundle.

Next, initialize the form with Finix.PaymentForm. When the buyer submits the form, the onSubmit callback returns a token with a TK prefix. Send the token to your back end.

checkout.js
Finix.PaymentForm("payment-form", "sandbox", "<APPLICATION_ID>", {
  paymentMethods: ["card"],
  onSubmit: function (error, response) {
    if (error) {
      console.error("Tokenization error:", error);
      return;
    }

    const token = response.data.id;

    fetch("/your/backend/payments", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ token: token }),
    });
  },
});

To customize the fields, styling, and payment methods the form accepts, see Tokenization Forms.

Create a Payment Instrument

Exchange the token for a Payment Instrument, which represents the buyer's card. Include:

  • token - The token ID that Finix.js returns.
  • type - TOKEN.
  • identity - The buyer's Identity ID from Step 1.
Tokens expire after 30 minutes

Create the Payment Instrument as soon as your back end receives the token. You can't use a token after it expires.

cURL
curl -i -X POST \
  -u US6RE3TRcse4wjkgDCkaLckN:c019209f-46fa-49a8-9e3f-11e5a5a2059b \
  https://finix.sandbox-payments-api.com/payment_instruments \
  -H 'Content-Type: application/json' \
  -d '{
    "address": {
      "city": "San Francisco",
      "country": "USA",
      "line1": "900 Metro Center Blv",
      "postal_code": "94404",
      "region": "CA"
    },
    "expiration_month": 12,
    "expiration_year": 2029,
    "identity": "IDbwBF3EpHK52X7sVqWyQAQn",
    "name": "John Smith",
    "number": "5200828282828210",
    "security_code": "022",
    "type": "PAYMENT_CARD"
  }'

The response returns the Payment Instrument. Save the id to charge the card in the next step, and to charge it again later without asking the buyer to re-enter their details.

Payment Instrument - Card
{
  "id": "PImmCg3Po7oNi7jaZcXhfkEu",
  "created_at": "2022-10-10T05:32:17.78Z",
  "updated_at": "2022-10-10T05:32:17.78Z",
  "account_updater_enabled": false,
  "application": "APt9MknRZxiDMkeReFPMdr7R",
  "created_via": "API",
  "currency": "USD",
  "enabled": true,
  "fingerprint": "FPRiCenDk2SoRng7WjQTr7RJY",
  "identity": "IDjvxGeXBLKH1V9YnWm1CS4n",
  "instrument_type": "PAYMENT_CARD",
  "address": {
    "line1": "900 Metro Center Blv",
    "line2": null,
    "city": "San Francisco",
    "region": "CA",
    "postal_code": "94404",
    "country": "USA"
  },
  "address_verification": "UNKNOWN",
  "bin": "520082",
  "brand": "MASTERCARD",
  "card_type": "DEBIT",
  "expiration_month": 12,
  "expiration_year": 2029,
  "issuer_country": "USA",
  "last_four": "8210",
  "name": "Amy White",
  "network_token_enabled": false,
  "network_token_state": "NOT_ENABLED",
  "security_code_verification": "UNKNOWN",
  "tags": {
    "card_name": "Business Card"
  },
  "type": "PAYMENT_CARD",
  "_links": {
    "self": {
      "href": "https://finix.sandbox-payments-api.com/payment_instruments/PImmCg3Po7oNi7jaZcXhfkEu"
    },
    "authorizations": {
      "href": "https://finix.sandbox-payments-api.com/payment_instruments/PImmCg3Po7oNi7jaZcXhfkEu/authorizations"
    },
    "transfers": {
      "href": "https://finix.sandbox-payments-api.com/payment_instruments/PImmCg3Po7oNi7jaZcXhfkEu/transfers"
    },
    "verifications": {
      "href": "https://finix.sandbox-payments-api.com/payment_instruments/PImmCg3Po7oNi7jaZcXhfkEu/verifications"
    },
    "application": {
      "href": "https://finix.sandbox-payments-api.com/applications/APt9MknRZxiDMkeReFPMdr7R"
    },
    "identity": {
      "href": "https://finix.sandbox-payments-api.com/identities/IDjvxGeXBLKH1V9YnWm1CS4n"
    },
    "updates": {
      "href": "https://finix.sandbox-payments-api.com/payment_instruments/PImmCg3Po7oNi7jaZcXhfkEu/updates"
    }
  }
}
Testing without a front end

In Sandbox, you can skip the payment form and create a Payment Instrument with test card details instead of a token. Sending raw card details in Live requires PCI DSS Level 1 or Level 2 compliance. For more information, see Handling Raw Card Data.

Step 3: Make a sale

Create a Transfer

Create a Transfer to charge the buyer. Include:

  • amount - The payment total in cents. For example, 10000 charges $100.00.
  • currency - USD or CAD.
  • merchant - Your Merchant ID.
  • source - The Payment Instrument ID from Step 2.

If you're a platform, each of your sellers has their own Merchant ID. For more information, see Onboarding Sellers.

cURL
curl -i -X POST \
  -u US6RE3TRcse4wjkgDCkaLckN:c019209f-46fa-49a8-9e3f-11e5a5a2059b \
  https://finix.sandbox-payments-api.com/transfers \
  -H 'Content-Type: application/json' \
  -d '{
    "amount": 10000,
    "currency": "USD",
    "merchant": "MUfUoWEk3MBJ9m5cCnggfKMf",
    "source": "PIjkxmtZreJ3TTGE3BciARnf"
  }'

A successful payment returns 201 Created with a Transfer where:

  • state is SUCCEEDED.
  • type is DEBIT.
Transfer
{
  "id": "TRsGLKwasMwBgpxVM4xiDHXr",
  "created_at": "2026-11-28T00:29:59.77Z",
  "updated_at": "2026-11-28T00:29:59.77Z",
  "3d_secure_session": null,
  "additional_buyer_charges": null,
  "additional_healthcare_data": null,
  "additional_lodging_data": null,
  "additional_motor_vehicle_rental_data": null,
  "additional_purchase_data": null,
  "address_verification": "POSTAL_CODE_AND_STREET_MATCH",
  "amount": 10000,
  "amount_requested": 10000,
  "application": "APt9MknRZxiDMkeReFPMdr7R",
  "created_via": "UNKNOWN",
  "currency": "USD",
  "destination": null,
  "externally_funded": "UNKNOWN",
  "failure_code": null,
  "failure_message": null,
  "fee": 0,
  "fee_profile": "FPmtT4MYmiAs1qjLjneQmk4d",
  "idempotency_id": null,
  "ip_address_details": null,
  "merchant": "MUfUoWEk3MBJ9m5cCnggfKMf",
  "merchant_identity": "ID6TZEVtE3TGH9ZDwb8iUhsE",
  "messages": [],
  "network_details": {
    "brand": "VISA",
    "authorization_code": "271371",
    "acquirer_reference_number": null
  },
  "operation_key": "CARD_NOT_PRESENT_SALE",
  "parent_transfer": null,
  "parent_transfer_trace_id": null,
  "processed_at": "2026-11-28T00:30:00.13Z",
  "raw": null,
  "ready_to_settle_at": "2026-11-29T00:29:59.77Z",
  "receipt_last_printed_at": null,
  "security_code_verification": "MATCHED",
  "source": "PIjkxmtZreJ3TTGE3BciARnf",
  "split_transfers": [],
  "state": "SUCCEEDED", 
  "statement_descriptor": "FLX*FINIX FLOWERS",
  "subtype": "API",
  "supplemental_fee": null,
  "tags": {},
  "third_party_details": null,
  "tip_amount": null,
  "trace_id": "e82da656-89a0-4d26-b2f4-e9480883d541",
  "type": "DEBIT", 
  "_links": {
    "application": {
      "href": "https://finix.sandbox-payments-api.com/applications/APt9MknRZxiDMkeReFPMdr7R"
    },
    "self": {
      "href": "https://finix.sandbox-payments-api.com/transfers/TRsGLKwasMwBgpxVM4xiDHXr"
    },
    "merchant_identity": {
      "href": "https://finix.sandbox-payments-api.com/identities/ID6TZEVtE3TGH9ZDwb8iUhsE"
    },
    "payment_instruments": {
      "href": "https://finix.sandbox-payments-api.com/transfers/TRsGLKwasMwBgpxVM4xiDHXr/payment_instruments"
    },
    "reversals": {
      "href": "https://finix.sandbox-payments-api.com/transfers/TRsGLKwasMwBgpxVM4xiDHXr/reversals"
    },
    "fees": {
      "href": "https://finix.sandbox-payments-api.com/fees?linked_to=TRsGLKwasMwBgpxVM4xiDHXr"
    },
    "disputes": {
      "href": "https://finix.sandbox-payments-api.com/transfers/TRsGLKwasMwBgpxVM4xiDHXr/disputes"
    },
    "source": {
      "href": "https://finix.sandbox-payments-api.com/payment_instruments/PIjkxmtZreJ3TTGE3BciARnf"
    },
    "fee_profile": {
      "href": "https://finix.sandbox-payments-api.com/fee_profiles/FPmtT4MYmiAs1qjLjneQmk4d"
    }
  }
}

A declined payment also returns 201 Created, with state set to FAILED and a failure_code that explains why. Check state on every response instead of relying on the HTTP status. For more information, see Handling Declined Payments.

The buyer is now charged. Finix adds the payment to a Settlement and pays out the funds, minus fees, to the merchant's bank account. For more information, see Payouts.

You can also:

  • Place a hold on the card and capture the funds later by creating an Authorization instead of a Transfer. For more information, see Auth and Captures.
  • Include an idempotency_id so that a retried request doesn't charge the buyer twice. For more information, see API Idempotency.

Test your integration

In Sandbox, use the test card numbers on Testing Your Integration. To test failures, pass one of the following amounts in Step 3.

amountResult
102The payment is declined.
193The payment fails for insufficient funds.
888888The payment is disputed.

Additional Resources

To see a working example, visit the Finix sample store and its GitHub project.

To accept payments in a mobile app, with the Finix API, or without writing code, see Accept a Payment.

Next steps