Class: WhopSDK::Resources::Cards

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/cards.rb,
sig/whop_sdk/resources/cards.rbs

Overview

Cards represent Whop-issued virtual payment cards that spend from an account or user balance. Cards can be assigned to cardholders and configured with spending limits for controlled spending.

Use the Cards API to issue cards, list cards for an account or user, and retrieve active card details such as the card number and CVC.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Cards

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Cards.

Parameters:



173
174
175
# File 'lib/whop_sdk/resources/cards.rb', line 173

def initialize(client:)
  @client = client
end

Instance Method Details

#create(account_id: nil, assigned_user_id: nil, name: nil, spend_limit: nil, spend_limit_frequency: nil, transaction_limit: nil, user_id: nil, request_options: {}) ⇒ WhopSDK::Models::CardCreateResponse

Some parameter documentations has been truncated, see Models::CardCreateParams for more details.

Issues a virtual card. For an individual (consumer) card issuing account, the card is issued to the account's own cardholder. For a company (business) card issuing account, pass assigneduser_id to issue the card to a company member; if that member is not yet an approved card-issuing user, the card is provisioned asynchronously or an onboarding invitation is sent (HTTP 202). Pass exactly one of account_id (a biz identifier) or userid (a user identifier). Returns the newly created card resource.

comp

Parameters:

  • account_id (String)

    The owning account ID (a biz_ identifier). Provide this or user_id.

  • assigned_user_id (String)

    The company member (a user_ identifier) to assign the card to. Required for

  • name (String)

    A display name for the card.

  • spend_limit (Float)

    Spending limit amount, in dollars.

  • spend_limit_frequency (Symbol, WhopSDK::Models::CardCreateParams::SpendLimitFrequency)

    The spending limit window.

  • transaction_limit (Float)

    Per-transaction limit amount, in dollars.

  • user_id (String)

    The owning user ID (a user_ identifier). Provide this or account_id.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



45
46
47
48
49
50
51
52
53
54
# File 'lib/whop_sdk/resources/cards.rb', line 45

def create(params = {})
  parsed, options = WhopSDK::CardCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "cards",
    body: parsed,
    model: WhopSDK::Models::CardCreateResponse,
    options: options
  )
end

#list(account_id: nil, user_id: nil, request_options: {}) ⇒ WhopSDK::Models::CardListResponse

Lists issued Whop virtual cards for an account or user, including pending invitation cards that have not been issued by the card provider yet. Pass exactly one of accountid (a biz identifier) or userid (a user identifier). Non-owner team members only see cards assigned to them. Users without the payout:account:read scope can still list cards assigned to them (for example moderators or external cardholders). Use GET /cards/:card_id to retrieve a single card with its secrets.

Parameters:

  • account_id (String)

    The owning account ID (a biz_ identifier). Provide this or user_id.

  • user_id (String)

    The owning user ID (a user_ identifier). Provide this or account_id.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



158
159
160
161
162
163
164
165
166
167
168
# File 'lib/whop_sdk/resources/cards.rb', line 158

def list(params = {})
  parsed, options = WhopSDK::CardListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "cards",
    query: query,
    model: WhopSDK::Models::CardListResponse,
    options: options
  )
end

#retrieve(card_id, account_id: nil, user_id: nil, request_options: {}) ⇒ WhopSDK::Models::CardRetrieveResponse

Retrieves a single card by its icrd_ identifier, including its secrets (full card number, CVC, and cardholder name) for active cards.

Parameters:

  • card_id (String)

    Card ID to retrieve, prefixed icrd_.

  • account_id (String)

    The owning account ID (a biz_ identifier). Provide this or user_id.

  • user_id (String)

    The owning user ID (a user_ identifier). Provide this or account_id.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/whop_sdk/resources/cards.rb', line 72

def retrieve(card_id, params = {})
  parsed, options = WhopSDK::CardRetrieveParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["cards/%1$s", card_id],
    query: query,
    model: WhopSDK::Models::CardRetrieveResponse,
    options: options
  )
end

#update(card_id, account_id: nil, billing: nil, canceled: nil, frozen: nil, name: nil, pin: nil, remove_limit: nil, spend_limit: nil, spend_limit_frequency: nil, transaction_limit: nil, user_id: nil, request_options: {}) ⇒ WhopSDK::Models::CardUpdateResponse

Some parameter documentations has been truncated, see Models::CardUpdateParams for more details.

Updates an issued card. All fields are optional; only the fields you pass are changed. Updates the card name, billing address, and spending limits in one call, sets a new PIN, freezes or unfreezes the card, or cancels it. Pass canceled: true alone to cancel the card — cancellation is permanent and a canceled card cannot be uncanceled. Pass exactly one of accountid (a biz identifier) or userid (a user identifier). Assigned cardholders without the payout:account:update scope can update the PIN and freeze state of their own card. The PIN can only be changed on a card assigned to the acting user. Returns the updated card resource.

Parameters:

  • card_id (String)

    Card ID to retrieve, prefixed icrd_.

  • account_id (String)

    The owning account ID (a biz_ identifier). Provide this or user_id.

  • billing (WhopSDK::Models::CardUpdateParams::Billing)

    New billing address. Requires line1, city, region, postal_code, and country_code

  • canceled (Boolean)

    Pass true to permanently cancel the card. A canceled card cannot be uncanceled

  • frozen (Boolean)

    Pass true to freeze the card, false to unfreeze it.

  • name (String)

    A display name for the card.

  • pin (String)

    New 4-digit PIN. Can only be set on a card assigned to the acting user.

  • remove_limit (Boolean)

    Pass true to remove the spending limit (make the card unlimited).

  • spend_limit (Float)

    Spending limit amount, in dollars.

  • spend_limit_frequency (Symbol, WhopSDK::Models::CardUpdateParams::SpendLimitFrequency)

    The spending limit window.

  • transaction_limit (Float)

    Per-transaction limit amount, in dollars.

  • user_id (String)

    The owning user ID (a user_ identifier). Provide this or account_id.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



128
129
130
131
132
133
134
135
136
137
# File 'lib/whop_sdk/resources/cards.rb', line 128

def update(card_id, params = {})
  parsed, options = WhopSDK::CardUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["cards/%1$s", card_id],
    body: parsed,
    model: WhopSDK::Models::CardUpdateResponse,
    options: options
  )
end