# Export payment source

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


[Idempotency Supported](/docs/api/idempotency)

Copies this payment source information to the gateway specified in the API.

This is useful if you want to port your customer's card details into another gateway.

This operation does not support copying of cards from Stripe and Braintree gateways. If you need help using this API, contact [Chargebee Support](https://www.chargebee.com/docs/billing/2.0/kb/getting-started/how-to-contact-chargebees-support-team?utm_source=docs_api&utm_medium=content&utm_campaign=support).

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/payment_sources/pm___test__XpbTXGTSRp4TUQEq/export_payment_source \
     -u {site_api_key}:\
     -d gateway_account_id="gw___test__5SK2lMpwSRp4SXM2z"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = PaymentSource.ExportPaymentSource("pm___test__XpbTXGTSRp4TUQEq")
		.GatewayAccountId("gw___test__5SK2lMpwSRp4SXM2z")
		.Request();

ThirdPartyPaymentMethod thirdPartyPaymentMethod = result.ThirdPartyPaymentMethod;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    paymentsourceAction "github.com/chargebee/chargebee-go/v3/actions/paymentsource"
    "github.com/chargebee/chargebee-go/v3/models/paymentsource"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := paymentsourceAction.ExportPaymentSource("pm___test__XpbTXGTSRp4TUQEq", &paymentsource.ExportPaymentSourceRequestParams{
        GatewayAccountId : "gw___test__5SK2lMpwSRp4SXM2z",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        ThirdPartyPaymentMethod := res.ThirdPartyPaymentMethod
    }
}
```

#### 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.PaymentSourceExportPaymentSourceRequest{
    GatewayAccountId : "gw___test__5SK2lMpwSRp4SXM2z",
}
  res, err := client.PaymentSource.ExportPaymentSource("pm___test__XpbTXGTSRp4TUQEq", req)
      if err != nil {
        fmt.Println(err)
    } else {
        ThirdPartyPaymentMethod := res.ThirdPartyPaymentMethod
    }
}
```

#### Java

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

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = PaymentSource.exportPaymentSource("pm___test__XpbTXGTSRp4TUQEq")
            .gatewayAccountId("gw___test__5SK2lMpwSRp4SXM2z")
            .request();

        ThirdPartyPaymentMethod thirdPartyPaymentMethod = result.thirdPartyPaymentMethod();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.paymentSource.params.ExportPaymentSourceParams;
import com.chargebee.v4.models.paymentSource.responses.ExportPaymentSourceResponse;
import com.chargebee.v4.models.thirdPartyPaymentMethod.ThirdPartyPaymentMethod;

public class ExportPaymentSource {

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

        ExportPaymentSourceParams params = ExportPaymentSourceParams.builder()
            .gatewayAccountId("gw___test__5SK2lMpwSRp4SXM2z")
            .build();

        ExportPaymentSourceResponse response = client
            .paymentSources()
            .exportPaymentSource("pm___test__XpbTXGTSRp4TUQEq", params);

        ThirdPartyPaymentMethod thirdPartyPaymentMethod = response.getThirdPartyPaymentMethod();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.paymentSource.exportPaymentSource("pm___test__XpbTXGTSRp4TUQEq", {
        gateway_account_id: "gw___test__5SK2lMpwSRp4SXM2z"
    });

    console.log(result);
    const thirdPartyPaymentMethod = result.third_party_payment_method;
} 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()->exportPaymentSource("pm___test__XpbTXGTSRp4TUQEq", [
    "gateway_account_id" => "gw___test__5SK2lMpwSRp4SXM2z"
]);
$thirdPartyPaymentMethod = $result->third_party_payment_method;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.PaymentSource.export_payment_source("pm___test__XpbTXGTSRp4TUQEq",
    cb_client.PaymentSource.ExportPaymentSourceParams(
        gateway_account_id="gw___test__5SK2lMpwSRp4SXM2z"
    )
)
third_party_payment_method = response.third_party_payment_method
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::PaymentSource.export_payment_source("pm___test__XpbTXGTSRp4TUQEq",{
  :gateway_account_id => "gw___test__5SK2lMpwSRp4SXM2z"
})

third_party_payment_method = result.third_party_payment_method
```

## Sample Response

```json
{
  "third_party_payment_method": {
    "gateway": "stripe",
    "gateway_account_id": "gw___test__5SK2lMpwSRp4SXM2z",
    "object": "third_party_payment_method",
    "reference_id": "cus_J7rVdlHN2uZpSx/card_1IVbmjJv9j0DyntJPYARLiEw",
    "type": "card"
  }
}
```

## URL Format

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

## Input Parameters

- `gateway_account_id` (required, string, max chars=50)
  The gateway account you want to copy the card.

## Returns

- `third_party_payment_method` (Third party payment method object)
  Resource object representing third\_party\_payment\_method
