> For the complete documentation index, see [llms.txt](https://bitstream-technologies.gitbook.io/bitstream-technologies-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bitstream-technologies.gitbook.io/bitstream-technologies-1/accept-crypto-subscription-payment.md).

# Accept Crypto Subscription Payment

In this example, we will learn to start a subscription payment for 10 USDC/mo.

To create a subscription, you first need to create a plan in Bitstream Dashboard.

Let's create a plan to accept 10 USDC/mo.

Congratulations 🎉, you have successfully created your first plan on Copperx.

Now, let's move ahead and create a Checkout Session to create a subscription.

To create a Checkout Session, you will need `priceId` of the newly created plan. You will be able to find `priceId` of the plan from plan details page.

Now let's go ahead and create subscription of our plan.

Make sure you update `YOUR_API_KEY` and `PRICE_ID` in the code.

```
curl --request POST \
--url 'https://api.bitstream.io/api/v1/checkout/sessions' \
--header 'Authorization: Bearer {YOUR_API_KEY}' \
--header 'Content-Type: application/json'
--data-raw '{
    "successUrl": "https://bitstream.io?cid={CHECKOUT_SESSION_ID}",
    "mode": "subscription",
    "lineItems": [{
        "priceId": "{PRICE_ID}" 
    }]
}'
```

```
{
    "id": "6c88e598-335d-468b-aea5-fa7a3aa074bf",
    "createdAt": "2023-04-03T17:57:16.943Z",
    "updatedAt": "2023-04-03T17:57:16.982Z",
    "mode": "subscription",
    "paymentMethodTypes": [
        "superfluid"
    ],
    "paymentSetting": {
        "allowedChains": [
            {
                "chainId": 137
            }
        ],
        "paymentMethodTypes": null,
        "preferredChainId": 137,
        "allowSwap": false
    },
    "expiresAt": "2023-04-03T18:57:16.940Z",
    "customerCreation": "if_required",
    "customerUpdate": null,
    "submitType": "pay",
    "afterCompletion": null,
    "organizationId": "758cbac4-58b8-4e0a-b1a2-27b60d4b148d",
    "amountTotal": "10000000",
    "currency": "usdc",
    "paymentLinkId": null,
    "subscriptionId": null,
    "customerId": "820b4fa9-8f4d-4866-9333-527752e32775",
    "clientReferenceId": null,
    "successUrl": "https://bitstream.io?cid=6c88e598-335d-468b-aea5-fa7a3aa074bf",
    "cancelUrl": null,
    "status": "open",
    "paymentStatus": "unpaid",
    "metadata": null,
    "emailCollection": false,
    "phoneNumberCollection": false,
    "shippingAddressCollection": false,
    "billingAddressCollection": false,
    "afterCompletionConfirmMsg": null,
    "shippingDetails": {},
    "billingDetails": {},
    "url": "https://buy.bitstream.io/payment/checkout-session/6c88e598-335d-468b-aea5-fa7a3aa074bf",
    "customer": {
        "name": null,
        "email": null,
        "phone": null,
        "id": "820b4fa9-8f4d-4866-9333-527752e32775",
        "createdAt": "2023-04-03T17:57:16.921Z",
        "updatedAt": "2023-04-03T17:57:16.921Z",
        "customerReferenceId": null,
        "visibility": 10,
        "metadata": {}
    },
    "customerDetails": {
        "name": null,
        "email": null,
        "phone": null,
        "address": {}
    },
    "lineItems": {
        "object": "list",
        "data": [
            {
                "amountTotal": "10000000",
                "currency": "usdc",
                "description": null,
                "quantity": 1,
                "price": {
                    "id": "ae575f1d-57b0-47cd-b40b-f1c2a057c067",
                    "createdAt": "2023-04-03T17:57:16.909Z",
                    "updatedAt": "2023-04-03T17:57:16.909Z",
                    "billingScheme": "per_unit",
                    "currency": "usdc",
                    "productId": "a90004dc-48be-4d21-9f45-05cc3acacc52",
                    "interval": "month",
                    "usageType": null,
                    "type": "recurring",
                    "unitAmount": "10000000",
                    "unitAmountDecimal": null,
                    "customUnitMax": null,
                    "customUnitMin": null,
                    "customPreset": null,
                    "customUnitAmountSuggestions": null,
                    "product": {
                        "id": "a90004dc-48be-4d21-9f45-05cc3acacc52",
                        "createdAt": "2023-04-03T17:57:16.903Z",
                        "updatedAt": "2023-04-03T17:57:16.918Z",
                        "name": "Basic",
                        "description": "For early stage projects who are getting started",
                        "isActive": true,
                        "images": [],
                        "unitLabel": null,
                        "url": null,
                        "metadata": null,
                        "defaultPriceId": "ae575f1d-57b0-47cd-b40b-f1c2a057c067",
                        "visibility": 20
                    },
                    "metadata": null,
                    "isActive": true,
                    "visibility": 20
                }
            }
        ]
    },
    "addresses": [
        {
            "id": "c0e4bd0d-e7a4-4202-ac4d-f7bc60e6c474",
            "createdAt": "2023-04-03T17:57:16.982Z",
            "updatedAt": "2023-04-03T17:57:16.982Z",
            "checkoutSessionId": "6c88e598-335d-468b-aea5-fa7a3aa074bf",
            "asset": {
                "id": "13056880-798b-4bd4-a555-c1c71de017fa",
                "name": "USDC",
                "address": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
                "chainId": 137,
                "currency": "usdc",
                "symbol": "USDC",
                "decimals": 6,
                "coingeckoId": "usd-coin",
                "isPublic": true,
                "superToken": {
                    "address": "0xcaa7349cea390f89641fe306d93591f87595dc1f",
                    "symbol": "USDCx",
                    "decimals": 18
                },
                "chain": {
                    "id": 137,
                    "name": "Polygon",
                    "icon": "icon",
                    "currency": "matic",
                    "blockExplorerName": "Polygonscan",
                    "blockExplorerTransactionUrl": "https://polygonscan.com/tx/{hash}"
                }
            },
            "paymentAddress": "0xd55069e3b3a088dfe3690decac89740b897bd1e7"
        }
    ],
    "paymentIntent": {
        "id": "a6da4225-1d26-4ede-b4fa-259ed5a0a3ab",
        "createdAt": "2023-04-03T17:57:16.937Z",
        "updatedAt": "2023-04-03T17:57:16.937Z",
        "organizationId": "758cbac4-58b8-4e0a-b1a2-27b60d4b148d",
        "amount": "10000000",
        "amountReceived": null,
        "currency": "usdc",
        "status": "requires_payment_method",
        "paymentMethodId": null,
        "paymentMethodTypes": [
            "superfluid"
        ],
        "description": null,
        "transferAccountAddress": null,
        "transactions": []
    }
}
```

`url` = Hosted Checkout page for the Session. You need to redirect user to this URL.

Once you create a Checkout Session, you need to redirect user to the give **URL** in `url` parameter of the response.

Once user makes the payment, user will be redirected to the URL provided in `successUrl`.

If user cancels the payment, then user will be redirected to the URL provided in `cancelUrl`.
