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:



246
247
248
# File 'lib/whop_sdk/resources/payments.rb', line 246

def initialize(client:)
  @client = client
end

Instance Method Details

#create(company_id: , member_id: , payment_method_id: , plan: , plan_id: , request_options: {}) ⇒ WhopSDK::Models::Payment

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

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`

Parameters:

  • company_id (String)

    The ID of the company to create the payment for.

  • member_id (String)

    The ID of the member to create the payment for.

  • payment_method_id (String)

    The ID of the payment method to use for the payment. It must be connected to the

  • plan (WhopSDK::Models::PaymentCreateParams::Plan)

    Pass this object to create a new plan for this payment

  • plan_id (String)

    An ID of an existing plan to use for the payment.

  • 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/payments.rb', line 45

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

#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:



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/whop_sdk/resources/payments.rb', line 137

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)

    The ID of the payment you want to update or take action upon.

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



172
173
174
175
176
177
178
179
180
181
# File 'lib/whop_sdk/resources/payments.rb', line 172

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:



77
78
79
80
81
82
83
84
# File 'lib/whop_sdk/resources/payments.rb', line 77

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:



204
205
206
207
208
209
210
211
# File 'lib/whop_sdk/resources/payments.rb', line 204

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:

  • id (String)

    The ID of the payment you want to void.

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

Returns:

See Also:



234
235
236
237
238
239
240
241
# File 'lib/whop_sdk/resources/payments.rb', line 234

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