Skip to Content
Docs

Forward cards to another provider

Send cards saved with Pay.com to another provider in the provider's own request, without card data reaching your servers.

Vault forwarding sends the cards you saved with Pay.com to another provider, such as an acquirer, a gateway, or a fraud service. You write the provider's request with placeholders where the card data goes, and send it to Pay.com. Pay.com fills in the card data, sends the request to the provider, and returns the provider's response. Card data never reaches your servers, in either direction.

Before you begin

To forward a card, you need:

  • A sandbox API key.
  • A card saved with Pay.com (a tok_card_ token or a pm_card_ payment method). In the sandbox, tokenize the test card 4242 4242 4242 4242.
  • The provider's host, paths, HTTP methods, required card fields, and credentials.

Forward a card

Set up a destination and its credentials once, then forward requests to it.

  1. 1

    Request a destination

    A destination defines the allowed provider host, path prefixes, HTTP methods, and card fields. Request only what the provider needs.

    curl -X POST https://forward.sandbox.pay.com/v1/destinations \
      -u ':sk-pay-com-sandbox-…' \
      -H "Content-Type: application/json" \
      -d '{
        "name": "Acquirer X sandbox",
        "host": "api.sandbox.acquirer.example",
        "path_prefixes": ["/v2/payments"],
        "methods": ["POST"],
        "allowed_fields": ["number", "exp_month", "exp_year", "cvc"]
      }'

    Pay.com reviews every destination before any card can be forwarded to it. It stays pending until approved, and your account owners receive an email when it becomes active. You can also request a destination in the Pay.com dashboard.

  2. 2

    Store the provider's credentials

    Store the provider's API key or other secret once for the destinations that use it. Pay.com encrypts each value and never returns it.

    curl -X POST https://forward.sandbox.pay.com/v1/credentials \
      -u ':sk-pay-com-sandbox-…' \
      -H "Content-Type: application/json" \
      -d '{
        "name": "Acquirer X sandbox key",
        "destinations": ["fdst_01JDQ3V8M4T6K2P9R5X7Z1C3B5"],
        "fields": { "api_key": "<your Acquirer X sandbox key>" }
      }'

    Your requests then reference the secret as {{ fcred_01JDQ5H7K9M1N3P5Q7R9S1T3V5.api_key }}. You can also send provider credentials directly in each request instead. Pay.com passes them through without logging them.

  3. 3

    Forward a request

    Write the provider's request in the format the provider expects, placing a placeholder wherever card data or a stored credential goes. Send it inside request along with the destination ID (in the example below, amount 1000 represents €10.00 EUR in minor units):

    curl -X POST https://forward.sandbox.pay.com/v1/forward_requests \
      -u ':sk-pay-com-sandbox-…' \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: order-1093" \
      -d '{
        "destination": "fdst_01JDQ3V8M4T6K2P9R5X7Z1C3B5",
        "request": {
          "method": "POST",
          "url": "https://api.sandbox.acquirer.example/v2/payments",
          "headers": {
            "Content-Type": "application/json",
            "X-Api-Key": "{{ fcred_01JDQ5H7K9M1N3P5Q7R9S1T3V5.api_key }}"
          },
          "body": {
            "amount": 1000,
            "currency": "EUR",
            "card": {
              "number": "{{ tok_card_296645958265997326.number }}",
              "expiry": "{{ tok_card_296645958265997326.exp_month }}/{{ tok_card_296645958265997326.exp_year | yy }}",
              "cvv": "{{ tok_card_296645958265997326.cvc }}"
            }
          }
        }
      }'

    If the token holds the test card 4242 4242 4242 4242 with expiration date 12/30 and CVV 123, the provider receives:

    {
      "amount": 1000,
      "currency": "EUR",
      "card": {
        "number": "4242424242424242",
        "expiry": "12/30",
        "cvv": "123"
      }
    }
    • A placeholder references a card or credential ID followed by a field name, such as {{ tok_card_….number }}. Filters transform the value (for example, | yy extracts the last two digits of the year).
    • Placeholders are allowed in header values and the request body, never in the URL.
    • Every card field must be listed in the destination's allowed_fields, and every credential must be stored for the destination.
    • Pay.com rejects requests containing a raw card number outside a placeholder and forwards nothing.

    The placeholder language lists every field and filter.

  4. 4

    Read the response

    When the provider responds, Pay.com returns HTTP 200 with the provider's response inside response, regardless of the provider's HTTP status:

    {
      "id": "fwd_01JDQ6W2X4Y6Z8A0B2C4D6E8F0",
      "resource": "forward_request",
      "destination": "fdst_01JDQ3V8M4T6K2P9R5X7Z1C3B5",
      "response": {
        "status": 201,
        "headers": { "content-type": "application/json" },
        "body": { "id": "pay_789", "status": "authorized" }
      },
      "tokenized": [],
      "timing": { "total_ms": 412, "upstream_ms": 371 }
    }

    Read response.status for the provider's status code (including provider 4xx and 5xx responses). Save id (also returned in the x-pay-com-forward-id header) to inspect the forward record later.

Card data in the reply

Pay.com never returns a card number from a provider's reply unchanged. Any card number in the reply's body or headers is masked to its first six and last four digits, as 424242******4242.

To keep a card the provider returns, ask Pay.com to save it. Name the card number, the expiration month, and the expiration year in response.tokenize. Pay.com replaces the number with a tok_card_ token you can use like any other. To remove other fields, name them in response.redact:

"response": {
  "tokenize": [{ "json_path": "$.card.number", "exp_month": "$.card.exp_month", "exp_year": "$.card.exp_year" }],
  "redact": ["$.card.security_code"]
}

tokenized then has one entry for each path: { "json_path": "$.card.number", "token": "tok_card_…" }. If Pay.com couldn't save that card, the entry is { "json_path": "$.card.number", "error": "tokenize_failed" } and the card is replaced with "[REDACTED]".

When a forward fails

When Pay.com can't get a response from the provider, it returns an error with upstream_sent, which says whether the provider got the request:

{
  "error": {
    "type": "api_error",
    "code": "upstream_timeout",
    "message": "The destination did not answer in time."
  },
  "upstream_sent": true
}
upstream_sentWhat happenedWhat to do
falseNothing reached the provider.Fix the issue in the error message, or retry.
trueThe provider received the full request and may have acted on it.Check with the provider before retrying, unless the provider endpoint is idempotent.
"unknown"Pay.com couldn't confirm whether the provider received the request.Inspect the forward record before retrying.

An error without upstream_sent was rejected before Pay.com checked the destination, so nothing reached the provider.

To inspect a forward request, retrieve it using the ID from the x-pay-com-forward-id header. The record shows whether the request reached the provider and its HTTP status, but not the response body. Confirm the transaction outcome with the provider. The error codes list every rejection reason.

Retry with an idempotency key

Send an Idempotency-Key header with each forward and reuse the same key when retrying:

  • If the first attempt reached the provider (or might have), Pay.com returns the original response with x-pay-com-idempotent-replayed: true without forwarding again. Responses are retained for 24 hours.
  • If nothing reached the provider, the key is released and a retry is forwarded normally.
  • While the first attempt is still running, a retry returns 409 with idempotency_in_flight.
  • Reusing a key with a different request returns 422 with idempotency_key_reused.

A key must be 1 to 255 printable ASCII characters without spaces. Make it unique for each forward (for example, derived from your order ID).

The CVV is sent once

A CVV stays usable for up to 15 minutes after collection. Forwarding deletes it as soon as a request carrying it is sent to the provider (regardless of the provider's response), unless Pay.com configured the destination to reuse CVVs. If the request didn't reach the provider (upstream_sent: false), the CVV is kept so you can retry.

If a forward requests a CVV that has expired or was already consumed, the API returns 422 with cvc_unavailable. Ask the customer to re-enter their CVV.

Test in the sandbox

The sandbox and live environments use separate forwarding hosts, keys, and destinations:

  • Send sandbox forwards to https://forward.sandbox.pay.com/v1 with a sandbox key.
  • Use test cards only, and register the provider's sandbox host as the destination.
  • To go live, request a destination for the provider's live host on https://forward.pay.com/v1 with a live key.

Next steps

Was this page helpful?