> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Xóa Phương Thức Thanh Toán

> Xóa một phương thức thanh toán liên kết với khách hàng.

Xóa một phương thức thanh toán đã lưu khỏi tài khoản của khách hàng. Sử dụng điều này để dọn dẹp các phương thức thanh toán không cần thiết hoặc lỗi thời.

<Warning>
  Nếu phương thức thanh toán bị xóa là phương thức duy nhất có trong hồ sơ cho một đăng ký đang hoạt động, đăng ký có thể không gia hạn được trong chu kỳ thanh toán tiếp theo. Đảm bảo khách hàng có phương thức thanh toán thay thế trước khi xóa.
</Warning>

## Các Trường Hợp Sử Dụng

* **Yêu cầu của khách hàng**: Xóa phương thức thanh toán mà khách hàng không còn muốn giữ trong hồ sơ
* **Thẻ hết hạn**: Dọn dẹp các phương thức thanh toán với thông tin thẻ đã hết hạn
* **Bảo mật**: Lập tức xóa các phương thức thanh toán bị xâm phạm


## OpenAPI

````yaml delete /customers/{customer_id}/payment-methods/{payment_method_id}
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.106.2
servers:
  - url: https://test.dodopayments.com/
    description: Test Mode Server Host
  - url: https://live.dodopayments.com/
    description: Live Mode Server Host
security: []
tags:
  - name: Products
  - name: Payments
  - name: Subscriptions
  - name: Addons
  - name: Customers
  - name: Refunds
  - name: Disputes
  - name: Events
  - name: License Keys
  - name: Entitlements
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Credit Entitlements
  - name: Credit Entitlement Balances
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
  - name: Payment Connector Webhooks
paths:
  /customers/{customer_id}/payment-methods/{payment_method_id}:
    delete:
      tags:
        - Customers
      operationId: delete_customer_payment_method
      parameters:
        - name: customer_id
          in: path
          description: Customer Id
          required: true
          schema:
            type: string
          example: cus_TV52uJWWXt2yIoBBxpjaa
        - name: payment_method_id
          in: path
          description: Payment Method Id
          required: true
          schema:
            type: string
      responses:
        '204':
          description: Payment method deleted successfully
        '409':
          description: Payment method is in use by an active subscription
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import DodoPayments from 'dodopayments';

            const client = new DodoPayments({
              bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
            });

            await client.customers.deletePaymentMethod('payment_method_id', {
              customer_id: 'cus_TV52uJWWXt2yIoBBxpjaa',
            });
        - lang: Python
          source: |-
            import os
            from dodopayments import DodoPayments

            client = DodoPayments(
                bearer_token=os.environ.get("DODO_PAYMENTS_API_KEY"),  # This is the default and can be omitted
            )
            client.customers.delete_payment_method(
                payment_method_id="payment_method_id",
                customer_id="cus_TV52uJWWXt2yIoBBxpjaa",
            )
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/dodopayments/dodopayments-go\"\n\t\"github.com/dodopayments/dodopayments-go/option\"\n)\n\nfunc main() {\n\tclient := dodopayments.NewClient(\n\t\toption.WithBearerToken(\"My Bearer Token\"),\n\t)\n\terr := client.Customers.DeletePaymentMethod(\n\t\tcontext.TODO(),\n\t\t\"cus_TV52uJWWXt2yIoBBxpjaa\",\n\t\t\"payment_method_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n"
        - lang: Java
          source: >-
            package com.dodopayments.api.example;


            import com.dodopayments.api.client.DodoPaymentsClient;

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;

            import
            com.dodopayments.api.models.customers.CustomerDeletePaymentMethodParams;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

                    CustomerDeletePaymentMethodParams params = CustomerDeletePaymentMethodParams.builder()
                        .customerId("cus_TV52uJWWXt2yIoBBxpjaa")
                        .paymentMethodId("payment_method_id")
                        .build();
                    client.customers().deletePaymentMethod(params);
                }
            }
        - lang: Kotlin
          source: >-
            package com.dodopayments.api.example


            import com.dodopayments.api.client.DodoPaymentsClient

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient

            import
            com.dodopayments.api.models.customers.CustomerDeletePaymentMethodParams


            fun main() {
                val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

                val params: CustomerDeletePaymentMethodParams = CustomerDeletePaymentMethodParams.builder()
                    .customerId("cus_TV52uJWWXt2yIoBBxpjaa")
                    .paymentMethodId("payment_method_id")
                    .build()
                client.customers().deletePaymentMethod(params)
            }
        - lang: Ruby
          source: |-
            require "dodopayments"

            dodo_payments = Dodopayments::Client.new(
              bearer_token: "My Bearer Token",
              environment: "test_mode" # defaults to "live_mode"
            )

            result = dodo_payments.customers.delete_payment_method(
              "payment_method_id",
              customer_id: "cus_TV52uJWWXt2yIoBBxpjaa"
            )

            puts(result)
        - lang: PHP
          source: |-
            <?php

            require_once dirname(__DIR__) . '/vendor/autoload.php';

            use Dodopayments\Client;
            use Dodopayments\Core\Exceptions\APIException;

            $client = new Client(
              bearerToken: getenv('DODO_PAYMENTS_API_KEY') ?: 'My Bearer Token',
              environment: 'test_mode',
            );

            try {
              $result = $client->customers->deletePaymentMethod(
                'payment_method_id', customerID: 'cus_TV52uJWWXt2yIoBBxpjaa'
              );

              var_dump($result);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: |-
            using DodoPayments.Client;
            using DodoPayments.Client.Models.Customers;

            DodoPaymentsClient client = new();

            CustomerDeletePaymentMethodParams parameters = new()
            {
                CustomerID = "cus_TV52uJWWXt2yIoBBxpjaa",
                PaymentMethodID = "payment_method_id",
            };

            await client.Customers.DeletePaymentMethod(parameters);
        - lang: Rust
          source: |-
            use dodopayments::Client;

            #[tokio::main]
            async fn main() -> dodopayments::Result<()> {
                let client = Client::from_env()?;
                let customer_id = "customer_id";
                let payment_method_id = "payment_method_id";
                let result = client
                    .customers()
                    .delete_payment_method()
                    .customer_id(customer_id)
                    .payment_method_id(payment_method_id)
                    .await?;
                println!("{result:?}");
                Ok(())
            }
components:
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````