Payment methods

Payment Methods

List payment methods

This endpoint retrieves all payment methods associated with the user in paginated format with filtering & ordering enabled.

Request & Response

GET https://proxy.webshare.io/api/v2/payment/method/
list_payment_methods.py
import requests
 
response = requests.get(
  "https://proxy.webshare.io/api/v2/payment/method/",
  headers={"Authorization": "Token APIKEY"}
)
 
response.json()

The commands above return JSON structured like this:

response.json
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 1,
      "type": "StripeCard",
      "brand": "visa",
      "last4": "4242",
      "name": null,
      "expiration_year": 2023,
      "expiration_month": 6,
      "created_at": "2022-06-14T11:58:10.246406-07:00",
      "updated_at": "2022-06-14T11:58:10.246406-07:00",
      "line": "123 George Street",
      "city": "Sydney",
      "state": null,
      "postal_code": "2000",
      "country": "AU"
    }
  ]
}

Get payment method

This endpoint retrieves the payment method by ID. You can find the active payment method id from the subscription object.

URL parameters

ParameterTypeDescription
idinteger

The ID of the payment method to retrieve

Request & Response

GET https://proxy.webshare.io/api/v2/payment/method/1/
get_payment_methods.py
import requests
 
response = requests.get(
    "https://proxy.webshare.io/api/v2/payment/method/1/",
    headers={"Authorization": "Token APIKEY"}
)
 
response.json()

The commands above return JSON structured like this:

response.json
{
  "id": 1,
  "type": "StripeCard",
  "brand": "visa",
  "last4": "4242",
  "name": null,
  "expiration_year": 2023,
  "expiration_month": 6,
  "created_at": "2022-06-14T11:58:10.246406-07:00",
  "updated_at": "2022-06-14T11:58:10.246406-07:00",
  "line": "123 George Street",
  "city": "Sydney",
  "state": null,
  "postal_code": "2000",
  "country": "AU"
}

Remove payment method

Remove the card currently saved on the subscription. The endpoint takes no ID: it always removes the card attached to the subscription, and DELETE on a specific payment method is not supported. If no card is saved, the request succeeds and nothing changes.

Request & Response

DELETE https://proxy.webshare.io/api/v2/payment/method/
remove_payment_method.py
import requests
 
response = requests.delete(
    "https://proxy.webshare.io/api/v2/payment/method/",
    headers={"Authorization": "Token APIKEY"}
)

Returns 204 No Content on success with an empty body.

Error responses

When the card cannot be removed, the endpoint returns a validation error of the form [{"message": "<message>", "code": "<error code>"}].

Error codeHTTP codeDescription
paid_plan_active400

The subscription has a paid plan: Cannot remove the payment method while a paid plan is active. Cancel auto-renewal instead. Cancel auto-renewal first, which removes the card as part of the cancellation.