Class: WhopSDK::Resources::Payments

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/payments.rb

Overview

Payments

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Payments

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 Payments.

Parameters:



300
301
302
# File 'lib/whop_sdk/resources/payments.rb', line 300

def initialize(client:)
  @client = client
end

Instance Method Details

#create(body:, request_options: {}) ⇒ WhopSDK::Models::Payment

Charge an existing member off-session using one of their stored payment methods. You can provide an existing plan, or create a new one in-line. This endpoint will respond with a payment object immediately, but the payment is processed asynchronously in the background. Use webhooks to be notified when the payment succeeds or fails.

Required permissions:

  • ‘payment:charge`

  • ‘plan:create`

  • ‘access_pass:create`

  • ‘access_pass:update`

  • ‘plan:basic:read`

  • ‘access_pass:basic:read`

  • ‘member:email:read`

  • ‘member:basic:read`

  • ‘member:phone:read`

  • ‘promo_code:basic:read`

  • ‘payment:dispute:read`

  • ‘payment:resolution_center_case:read`



37
38
39
40
41
42
43
44
45
46
# File 'lib/whop_sdk/resources/payments.rb', line 37

def create(params)
  parsed, options = WhopSDK::PaymentCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "payments",
    body: parsed[:body],
    model: WhopSDK::Payment,
    options: options
  )
end

#list(after: nil, before: nil, billing_reasons: nil, company_id: nil, created_after: nil, created_before: nil, currencies: nil, direction: nil, first: nil, include_free: nil, last: nil, order: nil, plan_ids: nil, product_ids: nil, query: nil, statuses: nil, substatuses: nil, updated_after: nil, updated_before: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::PaymentListResponse>

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

Returns a paginated list of payments for the actor in context, with optional filtering by product, plan, status, billing reason, currency, and creation date.

Required permissions:

  • ‘payment:basic:read`

  • ‘plan:basic:read`

  • ‘access_pass:basic:read`

  • ‘member:email:read`

  • ‘member:basic:read`

  • ‘member:phone:read`

  • ‘promo_code:basic:read`

Parameters:

  • after (String, nil)

    Returns the elements in the list that come after the specified cursor.

  • before (String, nil)

    Returns the elements in the list that come before the specified cursor.

  • billing_reasons (Array<Symbol, WhopSDK::Models::BillingReasons>, nil)

    Filter payments by their billing reason.

  • company_id (String, nil)

    The unique identifier of the company to list payments for.

  • created_after (Time, nil)

    Only return payments created after this timestamp.

  • created_before (Time, nil)

    Only return payments created before this timestamp.

  • currencies (Array<Symbol, WhopSDK::Models::Currency>, nil)

    Filter payments by their currency code.

  • direction (Symbol, WhopSDK::Models::Direction, nil)

    The direction of the sort.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • include_free (Boolean, nil)

    Whether to include payments with a zero amount.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • order (Symbol, WhopSDK::Models::PaymentListParams::Order, nil)

    The order to sort the results by.

  • plan_ids (Array<String>, nil)

    Filter payments to only those associated with these specific plan identifiers.

  • product_ids (Array<String>, nil)

    Filter payments to only those associated with these specific product identifiers

  • query (String, nil)

    Search payments by user ID, membership ID, user email, name, or username. Email

  • statuses (Array<Symbol, WhopSDK::Models::ReceiptStatus>, nil)

    Filter payments by their current status.

  • substatuses (Array<Symbol, WhopSDK::Models::FriendlyReceiptStatus>, nil)

    Filter payments by their current substatus for more granular filtering.

  • updated_after (Time, nil)

    Only return payments last updated after this timestamp.

  • updated_before (Time, nil)

    Only return payments last updated before this timestamp.

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

Returns:

See Also:



141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/whop_sdk/resources/payments.rb', line 141

def list(params = {})
  parsed, options = WhopSDK::PaymentListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "payments",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::PaymentListResponse,
    options: options
  )
end

#list_fees(id, after: nil, before: nil, first: nil, last: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::PaymentListFeesResponse>

Returns the list of fees associated with a specific payment, including platform fees and processing fees.

Required permissions:

  • ‘payment:basic:read`

Parameters:

  • id (String)

    The unique identifier of the payment to list fees for.

  • after (String, nil)

    Returns the elements in the list that come after the specified cursor.

  • before (String, nil)

    Returns the elements in the list that come before the specified cursor.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

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

Returns:

See Also:



178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/whop_sdk/resources/payments.rb', line 178

def list_fees(id, params = {})
  parsed, options = WhopSDK::PaymentListFeesParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["payments/%1$s/fees", id],
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::PaymentListFeesResponse,
    options: options
  )
end

#refund(id, partial_amount: nil, request_options: {}) ⇒ WhopSDK::Models::Payment

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

Issue a full or partial refund for a payment. The refund is processed through the original payment processor and the membership status is updated accordingly.

Required permissions:

  • ‘payment:manage`

  • ‘plan:basic:read`

  • ‘access_pass:basic:read`

  • ‘member:email:read`

  • ‘member:basic:read`

  • ‘member:phone:read`

  • ‘promo_code:basic:read`

  • ‘payment:dispute:read`

  • ‘payment:resolution_center_case:read`

Parameters:

  • id (String)

    The unique identifier of the payment to refund.

  • partial_amount (Float, nil)

    The amount to refund in the payment currency. If omitted, the full payment amoun

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

Returns:

See Also:



220
221
222
223
224
225
226
227
228
229
# File 'lib/whop_sdk/resources/payments.rb', line 220

def refund(id, params = {})
  parsed, options = WhopSDK::PaymentRefundParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["payments/%1$s/refund", id],
    body: parsed,
    model: WhopSDK::Payment,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::Payment

Retrieves the details of an existing payment.

Required permissions:

  • ‘payment:basic:read`

  • ‘plan:basic:read`

  • ‘access_pass:basic:read`

  • ‘member:email:read`

  • ‘member:basic:read`

  • ‘member:phone:read`

  • ‘promo_code:basic:read`

  • ‘payment:dispute:read`

  • ‘payment:resolution_center_case:read`

Parameters:

  • id (String)

    The unique identifier of the payment.

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

Returns:

See Also:



71
72
73
74
75
76
77
78
# File 'lib/whop_sdk/resources/payments.rb', line 71

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["payments/%1$s", id],
    model: WhopSDK::Payment,
    options: params[:request_options]
  )
end

#retry_(id, request_options: {}) ⇒ WhopSDK::Models::Payment

Retry a failed or pending payment. This re-attempts the charge using the original payment method and plan details.

Required permissions:

  • ‘payment:manage`

  • ‘plan:basic:read`

  • ‘access_pass:basic:read`

  • ‘member:email:read`

  • ‘member:basic:read`

  • ‘member:phone:read`

  • ‘promo_code:basic:read`

  • ‘payment:dispute:read`

  • ‘payment:resolution_center_case:read`

Parameters:

  • id (String)

    The unique identifier of the payment to retry.

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

Returns:

See Also:



255
256
257
258
259
260
261
262
# File 'lib/whop_sdk/resources/payments.rb', line 255

def retry_(id, params = {})
  @client.request(
    method: :post,
    path: ["payments/%1$s/retry", id],
    model: WhopSDK::Payment,
    options: params[:request_options]
  )
end

#void(id, request_options: {}) ⇒ WhopSDK::Models::Payment

Void a payment that has not yet been settled. Voiding cancels the payment before it is captured by the payment processor.

Required permissions:

  • ‘payment:manage`

  • ‘plan:basic:read`

  • ‘access_pass:basic:read`

  • ‘member:email:read`

  • ‘member:basic:read`

  • ‘member:phone:read`

  • ‘promo_code:basic:read`

  • ‘payment:dispute:read`

  • ‘payment:resolution_center_case:read`

Parameters:

  • id (String)

    The unique identifier of the payment to void.

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

Returns:

See Also:



288
289
290
291
292
293
294
295
# File 'lib/whop_sdk/resources/payments.rb', line 288

def void(id, params = {})
  @client.request(
    method: :post,
    path: ["payments/%1$s/void", id],
    model: WhopSDK::Payment,
    options: params[:request_options]
  )
end