Class: PromisePay::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/promise_pay/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Session



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/promise_pay/session.rb', line 25

def initialize(options = {})
  @current_user_id    = options.fetch :current_user_id,     nil
  @currency           = options.fetch :currency,            nil
  @item_name          = options.fetch :item_name,           nil
  @amount             = options.fetch :amount,              nil
  @seller_lastname    = options.fetch :seller_lastname,     nil
  @seller_firstname   = options.fetch :seller_firstname,    nil
  @buyer_lastname     = options.fetch :buyer_lastname,      nil
  @buyer_firstname    = options.fetch :buyer_firstname,     nil
  @seller_email       = options.fetch :seller_email,        nil
  @buyer_email        = options.fetch :buyer_email,         nil
  @external_item_id   = options.fetch :external_item_id,    nil
  @external_seller_id = options.fetch :external_seller_id,  nil
  @external_buyer_id  = options.fetch :external_buyer_id,   nil
  @fee_ids            = options.fetch :fee_ids,             nil
  @payment_type_id    = options.fetch :payment_type_id,     nil
  @country_code       = options.fetch :country_code,        nil
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



11
12
13
# File 'lib/promise_pay/session.rb', line 11

def amount
  @amount
end

#buyer_emailObject

Returns the value of attribute buyer_email.



17
18
19
# File 'lib/promise_pay/session.rb', line 17

def buyer_email
  @buyer_email
end

#buyer_firstnameObject

Returns the value of attribute buyer_firstname.



15
16
17
# File 'lib/promise_pay/session.rb', line 15

def buyer_firstname
  @buyer_firstname
end

#buyer_lastnameObject

Returns the value of attribute buyer_lastname.



14
15
16
# File 'lib/promise_pay/session.rb', line 14

def buyer_lastname
  @buyer_lastname
end

#country_codeObject

Returns the value of attribute country_code.



23
24
25
# File 'lib/promise_pay/session.rb', line 23

def country_code
  @country_code
end

#currencyObject

Returns the value of attribute currency.



9
10
11
# File 'lib/promise_pay/session.rb', line 9

def currency
  @currency
end

#current_user_idObject

Returns the value of attribute current_user_id.



8
9
10
# File 'lib/promise_pay/session.rb', line 8

def current_user_id
  @current_user_id
end

#external_buyer_idObject

Returns the value of attribute external_buyer_id.



20
21
22
# File 'lib/promise_pay/session.rb', line 20

def external_buyer_id
  @external_buyer_id
end

#external_item_idObject

Returns the value of attribute external_item_id.



18
19
20
# File 'lib/promise_pay/session.rb', line 18

def external_item_id
  @external_item_id
end

#external_seller_idObject

Returns the value of attribute external_seller_id.



19
20
21
# File 'lib/promise_pay/session.rb', line 19

def external_seller_id
  @external_seller_id
end

#fee_idsObject

Returns the value of attribute fee_ids.



21
22
23
# File 'lib/promise_pay/session.rb', line 21

def fee_ids
  @fee_ids
end

#item_nameObject

Returns the value of attribute item_name.



10
11
12
# File 'lib/promise_pay/session.rb', line 10

def item_name
  @item_name
end

#payment_type_idObject

Returns the value of attribute payment_type_id.



22
23
24
# File 'lib/promise_pay/session.rb', line 22

def payment_type_id
  @payment_type_id
end

#seller_emailObject

Returns the value of attribute seller_email.



16
17
18
# File 'lib/promise_pay/session.rb', line 16

def seller_email
  @seller_email
end

#seller_firstnameObject

Returns the value of attribute seller_firstname.



13
14
15
# File 'lib/promise_pay/session.rb', line 13

def seller_firstname
  @seller_firstname
end

#seller_lastnameObject

Returns the value of attribute seller_lastname.



12
13
14
# File 'lib/promise_pay/session.rb', line 12

def seller_lastname
  @seller_lastname
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/promise_pay/session.rb', line 7

def token
  @token
end

Instance Method Details

#request_tokenObject



44
45
46
47
48
49
50
51
52
# File 'lib/promise_pay/session.rb', line 44

def request_token
  enforce_valid_params!

  request = PromisePay::Request.new(path: api_resource)
  response = request.execute

  @token = JSON.parse(response)["token"]
  token
end