Class: WhopSDK::Resources::Payments

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

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:



193
194
195
# File 'lib/whop_sdk/resources/payments.rb', line 193

def initialize(client:)
  @client = client
end

Instance Method Details

#list(company_id: , after: nil, before: nil, billing_reasons: 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, statuses: nil, substatuses: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::PaymentListResponse>

Lists payments

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:

  • company_id (String)

    The ID of the company to list payments 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.

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

    The billing reason for the payment

  • created_after (Time, nil)

    The minimum creation date to filter by

  • created_before (Time, nil)

    The maximum creation date to filter by

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

    The currency of the payment.

  • 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 free payments.

  • 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)

    A specific plan.

  • product_ids (Array<String>, nil)

    A specific product.

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

    The status of the payment.

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

    The substatus of the payment.

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

Returns:

See Also:



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/whop_sdk/resources/payments.rb', line 86

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

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

Refunds a payment

Required permissions:

  • ‘payment:manage`

  • ‘plan:basic:read`

  • ‘access_pass:basic:read`

  • ‘member:email:read`

  • ‘member:basic:read`

  • ‘member:phone:read`

  • ‘promo_code:basic:read`

Parameters:

  • id (String)
  • partial_amount (Float, nil)

    An amount if the refund is supposed to be partial.

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

Returns:

See Also:



121
122
123
124
125
126
127
128
129
130
# File 'lib/whop_sdk/resources/payments.rb', line 121

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 a payment by ID

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:

Returns:

See Also:



26
27
28
29
30
31
32
33
# File 'lib/whop_sdk/resources/payments.rb', line 26

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

Retries a payment

Required permissions:

  • ‘payment:manage`

  • ‘plan:basic:read`

  • ‘access_pass:basic:read`

  • ‘member:email:read`

  • ‘member:basic:read`

  • ‘member:phone:read`

  • ‘promo_code:basic:read`

Parameters:

Returns:

See Also:



152
153
154
155
156
157
158
159
# File 'lib/whop_sdk/resources/payments.rb', line 152

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

Voids a payment

Required permissions:

  • ‘payment:manage`

  • ‘plan:basic:read`

  • ‘access_pass:basic:read`

  • ‘member:email:read`

  • ‘member:basic:read`

  • ‘member:phone:read`

  • ‘promo_code:basic:read`

Parameters:

Returns:

See Also:



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

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