Class: Dodopayments::Resources::Payments

Inherits:
Object
  • Object
show all
Defined in:
lib/dodopayments/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:



125
126
127
# File 'lib/dodopayments/resources/payments.rb', line 125

def initialize(client:)
  @client = client
end

Instance Method Details

#create(billing: , customer: , product_cart: , allowed_payment_method_types: nil, billing_currency: nil, discount_code: nil, force_3ds: nil, metadata: nil, payment_link: nil, return_url: nil, show_saved_payment_methods: nil, tax_id: nil, request_options: {}) ⇒ Dodopayments::Models::PaymentCreateResponse

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

Parameters:

  • billing (Dodopayments::Models::BillingAddress)

    Billing address details for the payment

  • customer (Dodopayments::Models::AttachExistingCustomer, Dodopayments::Models::NewCustomer)

    Customer information for the payment

  • product_cart (Array<Dodopayments::Models::OneTimeProductCartItem>)

    List of products in the cart. Must contain at least 1 and at most 100 items.

  • allowed_payment_method_types (Array<Symbol, Dodopayments::Models::PaymentMethodTypes>, nil)

    List of payment methods allowed during checkout.

  • billing_currency (Symbol, Dodopayments::Models::Currency, nil)

    Fix the currency in which the end customer is billed.

  • discount_code (String, nil)

    Discount Code to apply to the transaction

  • force_3ds (Boolean, nil)

    Override merchant default 3DS behaviour for this payment

  • metadata (Hash{Symbol=>String})

    Additional metadata associated with the payment.

  • payment_link (Boolean, nil)

    Whether to generate a payment link. Defaults to false if not specified.

  • return_url (String, nil)

    Optional URL to redirect the customer after payment.

  • show_saved_payment_methods (Boolean)

    Display saved payment methods of a returning customer

  • tax_id (String, nil)

    Tax ID in case the payment is B2B. If tax id validation fails the payment creati

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

Returns:

See Also:



40
41
42
43
44
45
46
47
48
49
# File 'lib/dodopayments/resources/payments.rb', line 40

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

#list(brand_id: nil, created_at_gte: nil, created_at_lte: nil, customer_id: nil, page_number: nil, page_size: nil, status: nil, subscription_id: nil, request_options: {}) ⇒ Dodopayments::Internal::DefaultPageNumberPagination<Dodopayments::Models::PaymentListResponse>

Parameters:

  • brand_id (String)

    filter by Brand id

  • created_at_gte (Time)

    Get events after this created time

  • created_at_lte (Time)

    Get events created before this time

  • customer_id (String)

    Filter by customer id

  • page_number (Integer)

    Page number default is 0

  • page_size (Integer)

    Page size default is 10 max is 100

  • status (Symbol, Dodopayments::Models::PaymentListParams::Status)

    Filter by status

  • subscription_id (String)

    Filter by subscription id

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

Returns:

See Also:



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/dodopayments/resources/payments.rb', line 92

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

#retrieve(payment_id, request_options: {}) ⇒ Dodopayments::Models::Payment

Parameters:

Returns:

See Also:



60
61
62
63
64
65
66
67
# File 'lib/dodopayments/resources/payments.rb', line 60

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

#retrieve_line_items(payment_id, request_options: {}) ⇒ Dodopayments::Models::PaymentRetrieveLineItemsResponse

Parameters:

Returns:

See Also:



113
114
115
116
117
118
119
120
# File 'lib/dodopayments/resources/payments.rb', line 113

def retrieve_line_items(payment_id, params = {})
  @client.request(
    method: :get,
    path: ["payments/%1$s/line-items", payment_id],
    model: Dodopayments::Models::PaymentRetrieveLineItemsResponse,
    options: params[:request_options]
  )
end