Save a card for later use

Save a card or bank account as a multi-use token during a transaction, and charge the token on later transactions.

Save a customer's card or bank account during a transaction, and charge it later without asking the customer to enter it again. You send the first transaction with the tokenize=true query parameter, Preczn returns a multi-use token, and you send that token on later transactions in place of the account details.

Use this guide in the following cases:

  • Recurring charges. You bill a customer on a schedule, such as a monthly service plan.
  • Returning customers. A customer chooses to save a payment method at checkout so they can pay faster next time.
  • Charges after checkout. You charge a customer after the visit, such as for an invoice.

The Dashboard doesn't save cards. You save a card through the API.

Prerequisites

  • An API key for your platform. Every request uses it in the x-api-key header.
  • A merchant whose connection processes the transaction. You send its merchantId on each request.
  • The customer's payment details in one of these forms:
  • A choice of token scope. A multi-use token belongs to one merchant or to every merchant on your platform, and you can't change the scope later. See Choosing a Token Scope.

Save the payment method and charge it later

  1. Send a Sale, Auth, or Verify to Process Transaction, and add tokenize=true to the query string: POST /v1/transactions?tokenize=true. To save the card without charging it, send a Verify. For a merchant-scoped token, also add merchantToken=true. Without it, Preczn creates a platform token.

    {
      "merchantId": "mid_test_{merchantId}",
      "type": "sale",
      "amount": 1234,
      "currency": "USD",
      "payment": {
        "token": "tkn_test_{singleUseToken}"
      }
    }
  2. Read the multi-use token from payment.token in the response. Preczn returns a token when the transaction is approved or pending. A declined transaction doesn't return one, and Apple Pay and Google Pay payments don't return a multi-use token. Store the token against the customer in your system.

    {
      "id": "txn_test_{transactionId}",
      "merchantId": "mid_test_{merchantId}",
      "type": "sale",
      "amount": 1234,
      "authorization": {
        "status": "A"
      },
      "payment": {
        "token": "tkn_test_{multiUseToken}",
        "brand": "VISA",
        "last4": "0012"
      }
    }

    The response above is shortened to the fields this step uses.

  3. On each later charge, send the stored token in payment.token to Process Transaction (POST /v1/transactions), in place of the account details. Leave out tokenize=true.

    {
      "merchantId": "mid_test_{merchantId}",
      "type": "sale",
      "amount": 1234,
      "currency": "USD",
      "payment": {
        "token": "tkn_test_{multiUseToken}"
      }
    }
⚠️

Multi-use tokens don't store the CVV

Preczn doesn't store the card verification value (CVV) with a multi-use token. Make sure each processor's risk rules don't require a CVV on charges that use a stored token.

If the customer saves the same card number and expiration date again on your platform, Preczn returns the same multi-use token. For a platform token, that's true for every merchant on your platform. A merchant token is separate for each merchant. Bank accounts follow the same steps.


Next


Did this page help you?