Method: ProcessOut::Token#create
- Defined in:
- lib/processout/token.rb
#create(customer_id, source, options = {}) ⇒ Object
Create a new token for the given customer ID. Params:
customer_id-
ID of the customer
source-
Source used to create the token (most likely a card token generated by ProcessOut.js)
options-
Hashof options
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/processout/token.rb', line 240 def create(customer_id, source, = {}) self.prefill() request = Request.new(@client) path = "/customers/" + CGI.escape(customer_id) + "/tokens" data = { "metadata" => @metadata, "settings" => .fetch(:settings, nil), "target" => .fetch(:target, nil), "source" => source } response = Response.new(request.post(path, data, )) return_values = Array.new body = response.body body = body["token"] return_values.push(self.fill_with_data(body)) return_values[0] end |