Class: Tray::Checkout::TempTransaction

Inherits:
BaseService show all
Defined in:
lib/tray/checkout/temp_transaction.rb

Instance Method Summary collapse

Constructor Details

#initialize(token = nil) ⇒ TempTransaction

Returns a new instance of TempTransaction.



9
10
11
# File 'lib/tray/checkout/temp_transaction.rb', line 9

def initialize(token=nil)
  @token = token || Tray::Checkout.
end

Instance Method Details

#add_to_cart(params) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/tray/checkout/temp_transaction.rb', line 17

def add_to_cart(params)
  @response = request("create", parser.response_params(params))

  @token_transaction = @response.transaction[:token] if @response.transaction

  @response
end

#api_urlObject



5
6
7
# File 'lib/tray/checkout/temp_transaction.rb', line 5

def api_url
  "#{Tray::Checkout.api_url}/v1/tmp_transactions/"
end

#cart_urlObject



13
14
15
# File 'lib/tray/checkout/temp_transaction.rb', line 13

def cart_url
  "#{@response.transaction[:url_car]}#{@token_transaction}" if @token_transaction
end