Class: Yellow::Client
- Inherits:
-
Object
- Object
- Yellow::Client
- Defined in:
- lib/yellow-sdk/client.rb
Instance Method Summary collapse
- #create_invoice(hash = {}) ⇒ Object
-
#initialize(api_key, api_secret) ⇒ Client
constructor
A new instance of Client.
- #query_invoice(invoice_id) ⇒ Object
- #verify_ipn(host_url, request_signature, request_nonce, request_body) ⇒ Object
Constructor Details
#initialize(api_key, api_secret) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/yellow-sdk/client.rb', line 9 def initialize(api_key, api_secret) @api_key = api_key @api_secret = api_secret end |
Instance Method Details
#create_invoice(hash = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/yellow-sdk/client.rb', line 14 def create_invoice(hash={}) #### # This method creates a yellow invoices based on the following options: # # #param hash hash hash keys matching the expected # HTTP arguments described here: # http://yellowpay.co/docs/api/#creating-invoices # #returns JSON parsed data #### endpoint = "/v1/invoice/" make_request('POST', endpoint, hash.to_json) end |
#query_invoice(invoice_id) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yellow-sdk/client.rb', line 29 def query_invoice(invoice_id) #### # Use this method to query an invoice you created earlier using its ID # # #param str invoice_id the ID of the invoice you're querying # # #returns JSON parsed data #### endpoint = "/v1/invoice/#{invoice_id}/" make_request('GET', endpoint, "") end |
#verify_ipn(host_url, request_signature, request_nonce, request_body) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/yellow-sdk/client.rb', line 42 def verify_ipn(host_url, request_signature, request_nonce, request_body) #### # This is a helper method to verify that the request you just received really is from Yellow: # # #param str host_url the callback URL you set when you created the invoice # #param str request_signature the signature header of the request # #param str request_nonce the nonce header of the request # #param str request_body the body of the request # # #returns boolean #### signature = get_signature(host_url, request_body, request_nonce, @api_secret) signature == request_signature end |