You can use Shopify's integration with [Stripe](https://stripe.com) to tokenize credit cards on behalf of merchants that have enabled Shopify Payments as their payment gateway solution.

## Requirements

- You've learned how to [create a checkout with the Checkout API](/docs/apps/build/sales-channels/checkout-api/create-checkout).
- You have a Stripe [Connect account](https://stripe.com/docs/connect) to process credit cards as a Shopify sales channel app.

## Step 1: Obtain token create access

You'll need token create access to tokenize credit cards on behalf of Shopify's Custom accounts in Stripe.

To get token create access, provide Shopify with your Stripe account `id`. You can query for this `id` using the [Stripe API](https://stripe.com/docs/api/accounts).

## Step 2: Retrieve `shopify_payments_account_id`

When you create a [checkout object](/docs/apps/build/sales-channels/checkout-api/create-checkout) for a transaction, Shopify returns the merchant's `shopify_payments_account_id`.

> Note:
> If the product requires shipping, then you will need to specify the shipping and billing addresses, poll for shipping rates, and set the applicable shipping rate.

## Step 3: Send `shopify_payments_account_id` and the card information to Stripe

Send the merchant's `shopify_payments_account_id` and the card information from your platform account to Stripe using the [tokens endpoint](https://stripe.com/docs/api/tokens/create_card). The secret key corresponds to your Stripe secret key which you can get from the API section of your Stripe account.

```
POST /v1/tokens HTTPS/1.1
Host: api.stripe.com
Authentication: Basic #{secret_key}
Stripe-Account: #{shopify_payments_account_id}

card: {
  number: '4242424242424242',
  exp_month: 12,
  exp_year: 2019,
  cvc: 123
}
```

A successful request returns a token for the customer's credit card.

> Note:
> If you've already [tokenized the customer's credit card](https://stripe.com/docs/api/tokens/create_card) and [created a customer](https://stripe.com/docs/api/customers/create) in your Stripe platform account, then you can send the `customer` id from your platform account instead of sending the card information.

## Step 4: Send the token to Shopify

Send the token using the Checkout API to process the payment in Shopify. The `unique_token` can be any [client-generated unique identifier](/docs/api/usage/idempotent-requests):

```
POST /admin/checkouts/#{token}/payments.json HTTPS/1.1
Host: shop-name.myshopify.com
X-Shopify-Access-Token: #{shopify_access_token}
X-Shopify-Checkout-Version: 2022-01-01

{
  "payment": {
    "amount": "33.00",
    "unique_token": "12345",
    "payment_token": {
      "payment_data": "tok_1AgzvXGp4JCfxblBH7gs5kLB",
      "type": "stripe_vault_token" },
    "request_details": {
      "ip_address": "123.1.1.1",
      "accept_language": "en"
      "user_agent": "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/54.0.2840.98 Safari\/537.36"
    },
  }
}
```

A successful request completes payment using the Stripe token and a corresponding order is created in the shop.

For more information about vaulting with Stripe, refer to the [Stripe API Reference](https://stripe.com/docs/api).

## Next steps

- [Bill for your sales channel app](/docs/apps/launch/billing).