Class: Wire::Resources::PaymentIntents

Inherits:
Base
  • Object
show all
Defined in:
lib/wire/resources/payment_intents.rb

Overview

PaymentIntents: create, retrieve, confirm, cancel, list.

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Wire::Resources::Base

Instance Method Details

#cancel(id, idempotency_key: nil) ⇒ Object



30
31
32
33
34
35
# File 'lib/wire/resources/payment_intents.rb', line 30

def cancel(id, idempotency_key: nil)
  @client.request(
    "POST", "/v1/payment_intents/#{escape(id)}/cancel",
    body: {}, idempotency_key: idempotency_key
  )
end

#confirm(id, params = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/wire/resources/payment_intents.rb', line 21

def confirm(id, params = {})
  params = params.dup
  key = params.delete(:idempotency_key) || params.delete("idempotency_key")
  @client.request(
    "POST", "/v1/payment_intents/#{escape(id)}/confirm",
    body: params, idempotency_key: key
  )
end

#create(params = {}) ⇒ Object

Parameters:

  • params (Hash) (defaults to: {})

    amount:, currency:, automatic_operator:, allowed_operators:, metadata:. Pass idempotency_key: to override.



11
12
13
14
15
# File 'lib/wire/resources/payment_intents.rb', line 11

def create(params = {})
  params = params.dup
  key = params.delete(:idempotency_key) || params.delete("idempotency_key")
  @client.request("POST", "/v1/payment_intents", body: params, idempotency_key: key)
end

#list(params = {}) ⇒ Object

Returns an Enumerator that auto-paginates across all pages.



38
39
40
# File 'lib/wire/resources/payment_intents.rb', line 38

def list(params = {})
  paginate("/v1/payment_intents", params)
end

#retrieve(id) ⇒ Object



17
18
19
# File 'lib/wire/resources/payment_intents.rb', line 17

def retrieve(id)
  @client.request("GET", "/v1/payment_intents/#{escape(id)}")
end