---
updatedAt: 2025-03-08T01:38:04.000Z
agentTools:
  projectIndex: https://mealmeapi.readme.io/llms.txt
---

# Payment

In this guide we'll demonstrate utilizing the Payment APIs for creating orders.

## Create Payment Method

In order to create an order using the [Create Order API](https://docs.mealme.ai/reference/post_order_v2), a `payment_method_id` representing either your payment method or the end consumer's payment method must be provided.

Here's an example [Create Payment Method API](https://docs.mealme.ai/reference/post_payment_create) request that demonstrates creating a payment method for an example user with the email `steve@apple.com` and user ID `7B36A9CF`.

```curl cURL Request
curl --request POST \
     --url https://api.mealme.ai/payment/create \
     --header 'Id-Token: <API KEY>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "payment_method": {
    "card_number": 4242424242424242,
    "expiration_year": 2034,
    "expiration_month": 12,
    "cvc": 123
  },
  "user_email": "steve@apple.com",
  "user_id": "7B36A9CF"
}
'
```
```json JSON Response
{
  "status": "Successfully created payment method",
  "payment_method_id": "pm_1MupdLEFrDExIlIkSl6aeDLg"
}
```

> 📘
>
> * The first successful request for any given `user_email` will permanently attach the `user_id` to the `user_email`. This means that all subsequent requests including the same `user_email` must also provide the same `user_id`, else they will fail.
> * A `payment_method_id` created using your sandbox API key can only be used in [Create Order API](https://docs.mealme.ai/reference/post_order_v2) requests using your sandbox API key. The same applies when using your production API key.
> * When using your sandbox API key, the following requirements must be met:
>   * `card_number` must be `4242424242424242`
>   * `expiration_year` and `expiration_month` must be a valid future date
>   * `cvc` can be any 3-digit number

## List Payment Methods

All of a user's payment methods, previously created using the [Create Payment Method API](https://docs.mealme.ai/reference/post_payment_create), can be retrieved using the [List Payment Methods API](https://docs.mealme.ai/reference/get_payment_listhttps://docs.mealme.ai/reference/get_payment_listhttps://docs.mealme.ai/reference/post_payment_create).

Here's an [List Payment Methods API](https://docs.mealme.ai/reference/get_payment_listhttps://docs.mealme.ai/reference/get_payment_listhttps://docs.mealme.ai/reference/post_payment_create) example request that demonstrates retrieving payment methods for the example user we created a payment method for in the [Create Payment Method guide](https://docs.mealme.ai/docs/payment-1#create-payment-method).

```curl cURL Request
curl --request GET \
     --url 'https://api.mealme.ai/payment/list?user_id=7B36A9CF&user_email=steve@apple.com' \
     --header 'Id-Token: <API KEY>' \
     --header 'accept: application/json'
```
```json JSON Response
{
  "payment_methods": [
    {
      "id": "pm_1MupdLEFrDExIlIkSl6aeDLg",
      "exp_month": 12,
      "exp_year": 2034,
      "last4": "4242",
      "network": "visa"
    }
  ]
}
```

> 📘
>
> * When using your sandbox API key, only payment methods that were created using your sandbox API key will be returned. The same applies when using your production API key.

## Delete Payment Method

Here's an [Delete Payment Method API](https://docs.mealme.ai/reference/post_payment_delete) example request that demonstrates deleting the payment method that was created for the example user  in the [Create Payment Method guide](https://docs.mealme.ai/docs/payment-1#create-payment-method).

```curl cURL Request
curl --request POST \
     --url https://api.mealme.ai/payment/delete \
     --header 'Id-Token: <API KEY>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "user_email": "steve@apple.com",
  "user_id": "7B36A9CF",
  "payment_method_id": "pm_1MupdLEFrDExIlIkSl6aeDLg"
}
'
```
```json JSON Response
{
  "status": "Successfully deleted payment method: pm_1MupdLEFrDExIlIkSl6aeDLg"
}
```

> 📘
>
> * When using your sandbox API key, only payment methods that were created using your sandbox API key can be deleted. The same applies when using your production API key.