# List Gateway Payment Method Tokens For A Payment Source

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Eventually Consistent](/docs/api/read-consistency)

Lists gateway payment method token mappings stored for this payment source. A payment source can have multiple gateway tokens when vaulting and backup gateway merchant-initiated transactions (MIT) are enabled.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/payment_sources/pm___test__KyVmmpTSneqVht/gateway_payment_method_tokens \
     -u {site_api_key}:
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
ListResult result = PaymentSource.ListGatewayTokensForPaymentSource("pm___test__KyVmmpTSneqVht").Request();

foreach (var listItem in result.List){
  GatewayPaymentMethodToken gatewayPaymentMethodToken = listItem.GatewayPaymentMethodToken;
}
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    paymentsourceAction "github.com/chargebee/chargebee-go/v3/actions/paymentsource"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := paymentsourceAction.ListGatewayTokensForPaymentSource("pm___test__KyVmmpTSneqVht", nil).ListRequest()
    if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            GatewayPaymentMethodToken := res.List[idx].GatewayPaymentMethodToken
        }
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.PaymentSourceListGatewayTokensForPaymentSourceRequest{}
  res, err := client.PaymentSource.ListGatewayTokensForPaymentSource("pm___test__KyVmmpTSneqVht", req)
      if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            GatewayPaymentMethodToken := res.List[idx].GatewayPaymentMethodToken
        }
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;
import java.util.List;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        ListResult result = PaymentSource.listGatewayTokensForPaymentSource("pm___test__KyVmmpTSneqVht").request();

        for (ListResult.Entry entry : result) {
            GatewayPaymentMethodToken gatewayPaymentMethodToken = entry.gatewayPaymentMethodToken();
        }
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.gatewayPaymentMethodToken.GatewayPaymentMethodToken;
import com.chargebee.v4.models.paymentSource.params.ListGatewayTokensForPaymentSourceParams;
import com.chargebee.v4.models.paymentSource.responses.ListGatewayTokensForPaymentSourceResponse;
import java.util.List;

public class ListGatewayTokensForPaymentSource {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        ListGatewayTokensForPaymentSourceResponse response = client.paymentSources().listGatewayTokensForPaymentSource("pm___test__KyVmmpTSneqVht");
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.paymentSource.listGatewayTokensForPaymentSource("pm___test__KyVmmpTSneqVht");
    result.list.forEach((entry) => {
        console.log(entry);
        const gatewayPaymentMethodToken = entry.gateway_payment_method_token;
    });
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->paymentSource()->listGatewayTokensForPaymentSource("pm___test__KyVmmpTSneqVht");
foreach($result->list as $entry) {
    $gatewayPaymentMethodToken = $entry->gateway_payment_method_token;
}
```

#### Python

```python
from chargebee import Chargebee, Filters

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
entries = cb_client.PaymentSource.list_gateway_tokens_for_payment_source("pm___test__KyVmmpTSneqVht")
for entry in entries.list:
    gateway_payment_method_token = entry.gateway_payment_method_token
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

list = ChargeBee::PaymentSource.list_gateway_tokens_for_payment_source("pm___test__KyVmmpTSneqVht")

list.each do |entry|
  gateway_payment_method_token = entry.gateway_payment_method_token
end
```

## Sample Response

```json
{
  "list": [
    {
      "gateway_payment_method_token": {
        "created_at": 1517487233,
        "gateway": "braintree",
        "gateway_account_id": "gw___test__5SK2lMpwSRp4Sb831",
        "id": "token_12345",
        "invalid_reason": "account_updater/generic",
        "object": "gateway_payment_method_token",
        "reference_id": "cus_xxx/card_xxx",
        "status": "invalid"
      }
    },
    {..}
  ],
  "next_offset": "[\"1517487233000\",\"12345\"]"
}
```

## URL Format

**GET** https://[site].chargebee.com/api/v2/payment_sources/{cust-payment-source-id}/gateway_payment_method_tokens

## Input Parameters

- `limit` (optional, integer, default=10, min=1, max=100)
  The number of resources to be returned.

- `offset` (optional, string, max chars=1000)
  Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set 'offset' to the value of 'next\_offset' obtained in the previous iteration of the API call.

- `include_deleted` (optional, boolean, default=false)
  Indicates whether to include deleted objects in the list. The deleted objects have the attribute '`deleted`' as '`true`'.

## Returns

- `next_offset` (optional, string, max chars=1000)
  This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter `offset`.

- `gateway_payment_method_token` (Gateway payment method token object)
  Resource object representing a gateway payment method token mapping stored for this payment source. Includes `id`, `gateway`, `gateway_account_id`, `reference_id`, `status` (`valid`, `invalid`, or `pending_verification`), `created_at`, and optionally `invalid_reason` when the token is invalid.
