Class: Mintchip::Hosted
- Inherits:
-
Object
- Object
- Mintchip::Hosted
- Defined in:
- lib/mintchip/hosted.rb,
lib/mintchip/hosted/info.rb,
lib/mintchip/hosted/transaction_log_entry.rb
Defined Under Namespace
Classes: Info, TransactionLogEntry
Constant Summary collapse
- RESOURCE_BASE =
"https://remote.mintchipchallenge.com/mintchip"
Instance Method Summary collapse
-
#create_value1(vrm) ⇒ Object
POST /payments/request.
- #create_value2(payee_id, currency_name, amount_in_cents) ⇒ Object
-
#credit_log(start, stop) ⇒ Object
GET /receipts/startindex/stopindex/responseformat.
-
#debit_log(start, stop) ⇒ Object
GET /payments/startindex/stopindex/responseformat.
-
#info ⇒ Object
GET /info/responseformat.
-
#initialize(key, password) ⇒ Hosted
constructor
A new instance of Hosted.
-
#last_debit ⇒ Object
GET /payments/lastdebit.
-
#load_value(vm) ⇒ Object
POST /receipts.
Constructor Details
#initialize(key, password) ⇒ Hosted
Returns a new instance of Hosted.
16 17 18 |
# File 'lib/mintchip/hosted.rb', line 16 def initialize(key, password) @p12 = OpenSSL::PKCS12.new(key, password) end |
Instance Method Details
#create_value1(vrm) ⇒ Object
POST /payments/request
33 34 35 |
# File 'lib/mintchip/hosted.rb', line 33 def create_value1(vrm) post "/payments/request", vrm, "application/vnd.scg.ecn-request" end |
#create_value2(payee_id, currency_name, amount_in_cents) ⇒ Object
37 38 39 40 |
# File 'lib/mintchip/hosted.rb', line 37 def create_value2(payee_id, currency_name, amount_in_cents) currency_code = Mintchip.currency_code(currency_name) post "/payments/#{payee_id}/#{currency_code}/#{amount_in_cents}" end |
#credit_log(start, stop) ⇒ Object
GET /receipts/startindex/stopindex/responseformat
54 55 56 57 |
# File 'lib/mintchip/hosted.rb', line 54 def credit_log(start, stop) list = JSON.parse get "/receipts/#{start}/#{stop}/json" list.map{|item| TransactionLogEntry.new item} end |
#debit_log(start, stop) ⇒ Object
GET /payments/startindex/stopindex/responseformat
48 49 50 51 |
# File 'lib/mintchip/hosted.rb', line 48 def debit_log(start, stop) list = JSON.parse get "/payments/#{start}/#{stop}/json" list.map{|item| TransactionLogEntry.new item} end |
#info ⇒ Object
GET /info/responseformat
21 22 23 |
# File 'lib/mintchip/hosted.rb', line 21 def info @info ||= Info.new get "/info/json" end |
#last_debit ⇒ Object
GET /payments/lastdebit
43 44 45 |
# File 'lib/mintchip/hosted.rb', line 43 def last_debit get "/payments/lastdebit" end |
#load_value(vm) ⇒ Object
POST /receipts
26 27 28 29 30 |
# File 'lib/mintchip/hosted.rb', line 26 def load_value(vm) res = post "/receipts", vm, "application/vnd.scg.ecn-message" # body is an empty string on success, which is gross. res == "" end |