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.
- data/README.md +17 -21
- data/lib/yellow-sdk.rb +1 -1
- 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
|
-
|
5
|
+
gem install yellow-sdk
|
6
6
|
```
|
7
7
|
|
8
8
|
Examples
|
9
9
|
---------
|
10
10
|
```
|
11
|
-
|
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
|
-
|
16
|
+
options = {
|
17
|
+
:base_ccy => 'USD',
|
18
|
+
:base_price => '20',
|
19
|
+
:callback => "https://anycallback.com"
|
20
|
+
}
|
16
21
|
|
17
|
-
|
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
|
-
|
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`
|
46
|
+
To query an invoice that you created, just pass in the `invoice_id` to the `query_invoice` method:
|
49
47
|
```
|
50
|
-
|
51
|
-
invoice
|
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
|
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(
|
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