Class: Stripe::CustomerPaymentSourceService

Inherits:
StripeService show all
Defined in:
lib/stripe/services/customer_payment_source_service.rb

Instance Method Summary collapse

Methods inherited from StripeService

#initialize, #request, #request_stream

Constructor Details

This class inherits a constructor from Stripe::StripeService

Instance Method Details

#create(customer, params = {}, opts = {}) ⇒ Object

When you create a new credit card, you must specify a customer or recipient on which to create it.

If the card’s owner has no default card, then the new card will become the default. However, if the owner already has a default, then it will not change. To change the default, you should [update the customer](docs.stripe.com/api/customers/update) to have a new default_source.



11
12
13
14
15
16
17
18
19
# File 'lib/stripe/services/customer_payment_source_service.rb', line 11

def create(customer, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/customers/%<customer>s/sources", { customer: CGI.escape(customer) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#delete(customer, id, params = {}, opts = {}) ⇒ Object

Delete a specified source for a given customer.



22
23
24
25
26
27
28
29
30
# File 'lib/stripe/services/customer_payment_source_service.rb', line 22

def delete(customer, id, params = {}, opts = {})
  request(
    method: :delete,
    path: format("/v1/customers/%<customer>s/sources/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#list(customer, params = {}, opts = {}) ⇒ Object

List sources for a specified customer.



33
34
35
36
37
38
39
40
41
# File 'lib/stripe/services/customer_payment_source_service.rb', line 33

def list(customer, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/customers/%<customer>s/sources", { customer: CGI.escape(customer) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#retrieve(customer, id, params = {}, opts = {}) ⇒ Object

Retrieve a specified source for a given customer.



44
45
46
47
48
49
50
51
52
# File 'lib/stripe/services/customer_payment_source_service.rb', line 44

def retrieve(customer, id, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/customers/%<customer>s/sources/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#serialize_batch_create(customer, params = {}, opts = {}) ⇒ Object

Serializes a CustomerPaymentSource create request into a batch job JSONL line.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/stripe/services/customer_payment_source_service.rb', line 55

def serialize_batch_create(customer, params = {}, opts = {})
  request_id = SecureRandom.uuid
  stripe_version = opts[:stripe_version] || Stripe.api_version

  request_body = {
    id: request_id,
    params: params,
    stripe_version: stripe_version,
  }
  request_body[:path_params] = { customer: customer }
  request_body[:context] = opts[:stripe_context] if opts[:stripe_context]
  JSON.generate(request_body)
end

#serialize_batch_delete(customer, id, params = {}, opts = {}) ⇒ Object

Serializes a CustomerPaymentSource delete request into a batch job JSONL line.



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/stripe/services/customer_payment_source_service.rb', line 70

def serialize_batch_delete(customer, id, params = {}, opts = {})
  request_id = SecureRandom.uuid
  stripe_version = opts[:stripe_version] || Stripe.api_version

  request_body = {
    id: request_id,
    params: params,
    stripe_version: stripe_version,
  }
  request_body[:path_params] = { customer: customer, id: id }
  request_body[:context] = opts[:stripe_context] if opts[:stripe_context]
  JSON.generate(request_body)
end

#serialize_batch_update(customer, id, params = {}, opts = {}) ⇒ Object

Serializes a CustomerPaymentSource update request into a batch job JSONL line.



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/stripe/services/customer_payment_source_service.rb', line 85

def serialize_batch_update(customer, id, params = {}, opts = {})
  request_id = SecureRandom.uuid
  stripe_version = opts[:stripe_version] || Stripe.api_version

  request_body = {
    id: request_id,
    params: params,
    stripe_version: stripe_version,
  }
  request_body[:path_params] = { customer: customer, id: id }
  request_body[:context] = opts[:stripe_context] if opts[:stripe_context]
  JSON.generate(request_body)
end

#serialize_batch_verify(customer, id, params = {}, opts = {}) ⇒ Object

Serializes a CustomerPaymentSource verify request into a batch job JSONL line.



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/stripe/services/customer_payment_source_service.rb', line 100

def serialize_batch_verify(customer, id, params = {}, opts = {})
  request_id = SecureRandom.uuid
  stripe_version = opts[:stripe_version] || Stripe.api_version

  request_body = {
    id: request_id,
    params: params,
    stripe_version: stripe_version,
  }
  request_body[:path_params] = { customer: customer, id: id }
  request_body[:context] = opts[:stripe_context] if opts[:stripe_context]
  JSON.generate(request_body)
end

#update(customer, id, params = {}, opts = {}) ⇒ Object

Update a specified source for a given customer.



115
116
117
118
119
120
121
122
123
# File 'lib/stripe/services/customer_payment_source_service.rb', line 115

def update(customer, id, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/customers/%<customer>s/sources/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#verify(customer, id, params = {}, opts = {}) ⇒ Object

Verify a specified bank account for a given customer.



126
127
128
129
130
131
132
133
134
# File 'lib/stripe/services/customer_payment_source_service.rb', line 126

def verify(customer, id, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/customers/%<customer>s/sources/%<id>s/verify", { customer: CGI.escape(customer), id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end