Skip to Content
Docs

Create a charge

Capture funds from a customer's card or saved payment method directly from your server with POST /v1/charges.

Send a POST /v1/charges request from your server to authorize and capture a payment immediately. Use this server-to-server flow when you charge a saved payment method (pm_…), a card token (tok_card_…), or raw card details under full PCI DSS compliance (SAQ-D).

Building a browser checkout? Use Universal checkout or Headless checkout with Pay.com.js instead, so raw card details never touch your server.

Requirements

Before you start, make sure you have:

  • Your API credentials. The examples use the sandbox (https://api.sandbox.pay.com/v1) with an sk-pay-com-sandbox- key.
  • A unique idempotency-key header for each POST request.
  • PCI DSS SAQ-D compliance if you send raw card numbers in source_data.card.

Process a charge

Follow these steps to create a charge, inspect its status, and handle 3D Secure authentication when required.

  1. 1

    Send the charge request

    Call POST /v1/charges with amount (in minor units, so 8000 equals $80.00 USD), currency, and a payment source:

    • source: A saved payment method ID (pm_…) or a card token (tok_card_…).
    • source_data: Raw card details, an alternative payment method, or an encrypted Apple Pay or Google Pay payload.

    The duplicate card check declines a card that another customer already uses. duplicate_card_check: false turns it off for the request, so the sandbox doesn't decline a test card number you've used before (decline_code: duplicate_card). Leave the option out of live requests, so the check stays on.

    POST https://api.sandbox.pay.com/v1/charges

    {
      "amount": 8000,
      "currency": "usd",
      "source_data": {
        "type": "card",
        "card": {
          "number": "4242424242424242",
          "expiry_month": "12",
          "expiry_year": "2028",
          "cvv": "123",
          "name": "John Smith"
        }
      },
      "payment_method_options": {
        "card": {
          "duplicate_card_check": false
        }
      }
    }

    The paid boolean indicates whether funds have settled to your bank account, not whether the charge was approved. A newly approved charge returns status: "succeeded" with paid: false. Always check status to confirm approval.

  2. 2

    Check the payment status

    Inspect the status field in the 201 response:

    • succeeded: The charge was approved and the funds are captured. Settlement to your bank account happens later (see paid).
    • pending: The charge is waiting for confirmation, as with asynchronous methods such as SEPA or ACH.
    • requires_authentication: The customer must complete a 3D Secure challenge or a bank login before the funds can be captured. This happens when regulations such as PSD2 require it, when you enforce 3D Secure for fraud prevention, or when an alternative payment method needs a bank login. Complete the next step.
    • requires_confirmation: Authentication is complete. Confirm the charge to finish it.
    • succeeded_partially: The charge was approved for less than the requested amount. See Handle partial approvals.
    • requires_partial_approval_action: The charge was partially approved and server-to-server partial approval is on. Confirm or cancel the partial amount, as Handle partial approvals describes.
    • awaiting_final_confirmation: The payment method approved the charge, but its final confirmation is still pending. Wait for the final status before you fulfill the order.

    A declined charge (failed) and a charge a risk rule blocked (blocked) both return HTTP 400 with error.type: "payment_method_error", error.code: "card_declined", and a decline_code. The charge is still created, so you can retrieve it to see its status. See Decline codes.

  3. 3

    Handle customer authentication (when required)

    If status is requires_authentication, call POST /v1/sessions/authentication/linked with the charge ID in resource. Set confirm based on whether Pay.com completes the charge automatically after the challenge:

    Pay.com authorizes the charge automatically after the customer completes the challenge and sends a charge.succeeded or charge.failed webhook. No additional API call is needed.

    POST https://api.sandbox.pay.com/v1/sessions/authentication/linked

    {
      "resource": "chrg_686511994907394048",
      "confirm": true,
      "return_url": "https://your-site.com/payment/complete"
    }

    Redirect the customer to url. Pay.com finishes authorization after the challenge and sends the result in a webhook.

Listen for webhooks

Confirm payment outcomes on your backend through webhooks rather than relying only on synchronous responses. Subscribe to:

  • charge.succeeded: Funds are captured. Fulfill the order.
  • charge.failed: The charge was declined or couldn't complete.

Verify the Pay-Signature header on every incoming event before acting on it. See Verify webhook signatures and Webhook events.

Next steps

Related payment guides:

Was this page helpful?