mpower 1.0.2 → 1.0.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # MpowerRuby
2
2
 
3
- TODO: Write a gem description
3
+ MPower Payments Ruby Client Library
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,67 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ## Setup your API Keys
22
+ If you are using rails you may create an file under `RAILS_ROOT/config/initializers` and put these setting there.
23
+
24
+ MPower::Setup.master_key = "YOUR_API_MASTER_KEY"
25
+ MPower::Setup.public_key = "YOUR_API_PUBLIC_KEY"
26
+ MPower::Setup.private_key = "YOUR_API_PRIVATE_KEY"
27
+ MPower::Setup.mode = "test|live"
28
+ MPower::Setup.token = "YOUR_API_TOKEN"
29
+
30
+ ## Setup your checkout store information
31
+ Configurations for checkout store are all optional. You may however want to set your Store Name and Tagline :)
32
+
33
+ MPower::Checkout::Store.name = "NAME OF YOUR STORE"
34
+ MPower::Checkout::Store.tagline = "STORE'S TAGLINE"
35
+ MPower::Checkout::Store.postal_address = "STORE POSTAL ADDRESS"
36
+ MPower::Checkout::Store.phone_number = "STORE CONTACT NUMBER"
37
+ MPower::Checkout::Store.website_url = "STORE WEBSITE URL"
38
+ MPower::Checkout::Store.logo_url = "LOGO URL"
39
+
40
+ Customer will be redirected back to this URL when he cancels the checkout on MPower website
41
+
42
+ MPower::Checkout::Store.cancel_url = "CHECKOUT CANCEL URL"
43
+
44
+ MPower will automatically redirect customer to this URL after successfull payment.
45
+ This setup is optional and highly recommended you dont set it, unless you want to customize the payment experience of your customers.
46
+ When a returnURL is not set, MPower will redirect the customer to the receipt page.
47
+
48
+ MPower::Checkout::Store.return_url = "CHECKOUT RETURN URL"
49
+
50
+ ## Create your Checkout Invoice
51
+
52
+ co = MPower::Checkout::Invoice.new
53
+
54
+ Params for addItem function `add_item(name_of_item,quantity,unit_price,total_price)`
55
+
56
+ co.add_item("13' Apple Retina 500 HDD",1,999.99,999.99)
57
+ co.add_item("Case Logic laptop Bag",2,100.50,201)
58
+ co.add_item("Mordecai's Bag",2,100.50,400)
59
+
60
+ ## Set the total amount to be charged ! Important
61
+
62
+ co.total_amount = 1200.99
63
+
64
+ ## Setup Tax Information (Optional)
65
+
66
+ co.add_tax("VAT (15)",50);
67
+ co.add_tax("NHIL (10)",50);
68
+
69
+ ## You can add custom data to your invoice which can be called back later
70
+
71
+ co.custom_data["Firstname"] = "Alfred"
72
+ co.custom_data["Lastname"] = "Rowe"
73
+ co.custom_data["CartId"] = 929292872
74
+
75
+ ## Redirecting to your checkout invoice page
76
+
77
+ if co.create
78
+ redirect_to co.invoice_url
79
+ else
80
+ @message = co.response_text
81
+ end
22
82
 
23
83
  ## Contributing
24
84
 
@@ -27,3 +87,4 @@ TODO: Write usage instructions here
27
87
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
88
  4. Push to the branch (`git push origin my-new-feature`)
29
89
  5. Create new Pull Request
90
+
data/lib/mpower/setup.rb CHANGED
@@ -6,10 +6,10 @@ module MPower
6
6
  @@token = nil
7
7
  @@mode = "test"
8
8
 
9
- LIVE_CHECKOUT_INVOICE_BASE_URL = "https://app.mpowerpayments.com/api/v1/checkout-invoice/create";
10
- TEST_CHECKOUT_INVOICE_BASE_URL = "https://app.mpowerpayments.com/sandbox-api/v1/checkout-invoice/create";
11
- LIVE_CHECKOUT_CONFIRM_BASE_URL = "https://app.mpowerpayments.com/api/v1/checkout-invoice/confirm/";
12
- TEST_CHECKOUT_CONFIRM_BASE_URL = "https://app.mpowerpayments.com/sandbox-api/v1/checkout-invoice/confirm/";
9
+ LIVE_CHECKOUT_INVOICE_BASE_URL = "https://app.mpowerpayments.com/api/v1/checkout-invoice/create"
10
+ TEST_CHECKOUT_INVOICE_BASE_URL = "https://app.mpowerpayments.com/sandbox-api/v1/checkout-invoice/create"
11
+ LIVE_CHECKOUT_CONFIRM_BASE_URL = "https://app.mpowerpayments.com/api/v1/checkout-invoice/confirm/"
12
+ TEST_CHECKOUT_CONFIRM_BASE_URL = "https://app.mpowerpayments.com/sandbox-api/v1/checkout-invoice/confirm/"
13
13
 
14
14
  def self.master_key=(master_key); @@master_key = master_key; end
15
15
  def self.master_key; @@master_key; end
@@ -1,3 +1,3 @@
1
1
  module MPower
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
data/mpower.gemspec CHANGED
@@ -18,6 +18,6 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
  gem.add_dependency('rest-client', '~> 1.4')
20
20
  gem.add_dependency('multi_json', '~> 1.1')
21
- gem.add_dependency('faraday')
21
+ gem.add_dependency('faraday','~> 0.8.4')
22
22
  gem.add_dependency('faraday_middleware')
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mpower
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-29 00:00:00.000000000 Z
12
+ date: 2012-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -48,17 +48,17 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 0.8.4
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.8.4
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: faraday_middleware
64
64
  requirement: !ruby/object:Gem::Requirement