Skip to main content
It is possible to use Secure Fields to collect card details on a profile page to store the card on a buyer’s account. Secure Fields can then be used to collect the security code at checkout, allowing a buyer to use a stored card together with a securely collected security code.

1. Store card for future use

The first step is to store the card data for future use. Use the checkout session as described in the quick-start to store the card details as a new payment method in the vault. This can be done either at the time of creating a transaction by setting the store property to true, or when creating a new payment method directly from the checkout session. Set store only when you first save the card. Storing the same card again creates a new payment method instead of reusing the existing one. The returned payment method includes details about the card that was used, as well as the id of the payment method that can be used in the next step.

2. Collect the CVV

At checkout, Secure Fields can be used to collect the CVV for a previously stored card. When initializing Secure Fields, pass the paymentMethod object with both the id and scheme of the previously stored card. This enables proper validation for the security code based on the card scheme (for example, 3 or 4 digits) and provides the appropriate security code label (CVV, CVC, CID) in the field data.
The paymentMethodId prop is deprecated but still supported for backward compatibility. We recommend using the new paymentMethod prop to benefit from scheme-specific CVV validation.
With this ID in place, you capture the security code securely.
When using the paymentMethodId or paymentMethod object with Secure Fields, only the security code can be captured. Attempting to add any of the other fields (number, expiration date) will result in an error.

3. Create a transaction

When Secure Fields is submitted, it collects the security code for the stored payment method. You can then create a transaction with the checkout session much like a regular Secure Fields transaction.
Don’t set store to true on this transaction. The card is already stored. If you send store: true and the transaction is declined or fails, for example because 3-D Secure fails, Gr4vy can remove the stored payment method from the buyer.
The returned transaction includes details about the payment method used, and the status of the transaction.

3-D Secure with a stored card

Native 3-D Secure in Secure Fields also works with a stored card. Secure Fields runs 3-D Secure against the checkout session, which uses the stored card.
  1. Create a checkout session with the transaction context, as described in Secure Fields and 3DS.
  2. Initialize Secure Fields with the paymentMethod of the stored card, as described in collect the CVV.
  3. Add the 3-D Secure component, as described in initialization.
  4. Call submit(). Secure Fields runs 3-D Secure and fires the start and finish events.
  5. Create a transaction with the checkout session.
If you don’t use Secure Fields, use hosted 3-D Secure instead.