yellow-sdk 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.md +17 -21
  2. data/lib/yellow-sdk.rb +1 -1
  3. metadata +1 -1
data/README.md CHANGED
@@ -2,28 +2,26 @@ Yellow Python SDK
2
2
  =====================
3
3
  This is the Yellow Ruby SDK. This simple SDK contains couple of Ruby methods that makes it easy to integrate with the Yellow API. To get started just:
4
4
  ```
5
- pip install yellow-sdk-python
5
+ gem install yellow-sdk
6
6
  ```
7
7
 
8
8
  Examples
9
9
  ---------
10
10
  ```
11
- import json
12
- import yellow
11
+ require 'yellow-sdk'
13
12
 
13
+ # pass your API key and secret respectively
14
+ yellow = Yellow::Client.new("Eo2XE5SrHcJVdqK9uIDU", "73jnZflRHpGReqFxzwF_JtynRNmZXoQspPaxTtsy")
14
15
 
15
- # You can get your api key/secret from your merchant dashboard.
16
+ options = {
17
+ :base_ccy => 'USD',
18
+ :base_price => '20',
19
+ :callback => "https://anycallback.com"
20
+ }
16
21
 
17
- api_key = "YOUR_API_KEY" # store it in environment variable for better security
18
- api_secret = "YOUR_API_SECRET" # store it in environment variable for better security
19
- base_ccy = "USD" # Required: A 3-letter currency code
20
- base_price = "0.05" # Required: The invoice price in the above currency
21
- callback = "https://example.com" # Optional: URL for Yellow to POST to as a callback
22
+ invoice = yellow.create_invoice(options)
22
23
 
23
- created_invoice = yellow.create_invoice(api_key, api_secret, base_ccy, base_price, callback)
24
-
25
- # Print the result beautifully!
26
- print json.dumps(created_invoice.json(), sort_keys=True, indent=4)
24
+ puts invoice
27
25
  ```
28
26
  You should see something similar to the following in your terminal:
29
27
  ```
@@ -45,19 +43,17 @@ You should see something similar to the following in your terminal:
45
43
  }
46
44
 
47
45
  ```
48
- To query an invoice that you created, just pass in the `invoice_id` to the `query_invoice` function:
46
+ To query an invoice that you created, just pass in the `invoice_id` to the `query_invoice` method:
49
47
  ```
50
- invoice_id = "..." # invoice ID you received when you created the invoice.
51
- invoice = yellow.query_invoice(api_key, api_secret, invoice_id)
52
- print json.dumps(invoice.json(), sort_keys=True, indent=4)
48
+ invoice = yellow.query_invoice("6dd264975861fddbfs4404ed995f1ca4")
49
+ puts invoice
53
50
  ```
54
51
  You should see exactly the same returned data you got from `create_invoice` above!
55
52
 
56
53
  Verifying Yellow POST requests
57
54
  ---------------------------
58
- To verify that the request you just receive really is from us, we created a helper function that checks the signature of the request. Just pass in your api_secret, the callback URL you passed when you created the invoice, and the request object.
59
-
60
- This function will return True if the signature matches (verified), or False if it doesn't match (not verified).
55
+ To verify that the request you just receive really is from us, we created a helper method that checks the signature of the request. This method will return true if the signature matches (verified), or false if it doesn't match (not verified).
61
56
  ```
62
- is_verified = yellow.verify_ipn(api_secret, host_url, request)
57
+ is_verified = yellow.verify_ipn(host_url, request_signature, request_nonce, request_body)
63
58
  ```
59
+ Since this method only works in the context of a web app, check the [full demo code](https://github.com/YellowPay/yellowdemo-ruby) for more info on how to use it.
data/lib/yellow-sdk.rb CHANGED
@@ -3,4 +3,4 @@ require 'json'
3
3
  require 'uri'
4
4
  require 'net/http'
5
5
  require "openssl"
6
- require "always_verify_ssl_certificates"
6
+ #require "always_verify_ssl_certificates"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yellow-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: