Charge a payment

Charge a card or bank account in one step with a sale, or check that it's valid without charging it with a verify.

A sale charges a customer's payment method and transfers the funds to the merchant in one step. A verify checks that a payment method is valid without charging it. Use a sale when the merchant can fulfill the order right away. To hold funds now and collect them later, see Authorize and capture a payment.

Before you start, make sure you have the following:

  • The merchant's ID, for a merchant with a connection that accepts the payment method. See Supported connections.
  • The payment method, as a Preczn token or as card data. See the Tokenization Overview.
  • A way to route the transaction: the connection's name in processor, or a routing plan assigned to the merchant. See Choose a routing method.

Sale

A sale charges a customer's payment method for goods or services, and transfers funds from the customer's account to the merchant's account. This section shows a card. To charge a bank account, see Charge a bank account.

To run a sale, complete the following steps:

  1. Send POST /v1/transactions with type set to sale, the merchantId, the payment, and the amount. Send amount as an integer in the smallest currency unit, such as 145 for $1.45 USD or 100 for ¥100. Send the payment method as a token in payment.token, or as card data.

    {
        "merchantId": "{merchantId}",
        "type": "sale",
        "payment": {
            "token": "{tokenId}"
        },
        "amount": 145
    }
    {
        "merchantId": "{merchantId}",
        "type": "sale",
        "payment": {
            "number": "4321000000000012",
            "cvv": "123",
            "expiration": "1235"
        },
        "amount": 145
    }
  2. Check authorization.status in the response. A means approved. For the other values, see Transaction status. authorization.cvv and authorization.avs carry the card's verification results. See Card verification results.

    {
        "id": "{transactionId}",
        "type": "sale",
        "amount": 145,
        "currency": "USD",
        "merchantId": "{merchantId}",
        "authorization": {
            "status": "A",
            "approvedAmount": 145,
            "partial": false,
            "cvv": "M",
            "avs": "U",
            "processorCode": "{processorCode}",
            "processorMessage": "{processorMessage}",
            "processorTransactionId": "{processorTransactionId}"
        },
        "payment": {
            "bin": "432100",
            "brand": "VISA",
            "last4": "0012",
            "type": "CREDIT"
        },
        "processor": {
            "id": "{platformConnectionId}",
            "name": "Stripe"
        }
    }

    This response is abbreviated. Every transaction type returns the same transaction object. For every field, see Process Transaction.


Verify

A verify checks that a customer's payment method is valid without charging it. Each connection handles it differently, but most run a $0.00 authorization against the account.

The common use is exchanging a single-use token, such as one from PaymentElements, for a multi-use token that you store and reuse later. To learn more about tokens, see the Tokenization Overview.

To verify a payment method, complete the following steps:

  1. Send POST /v1/transactions with type set to verify, the merchantId, and the payment. To get a multi-use token back, add the ?tokenize=true query parameter. Without it, an approved verify returns no multi-use token.

    {
        "merchantId": "{merchantId}",
        "type": "verify",
        "payment": {
            "number": "4321000000000012",
            "cvv": "123",
            "expiration": "1235"
        }
    }
  2. Check authorization.status in the response. A verify response carries no amount or approvedAmount, because nothing is charged.

To verify a bank account, see Verify a bank account. To return funds from a sale, see Void or refund a transaction.


Did this page help you?