mpower 1.0.10 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/Rakefile +8 -0
- data/lib/mpower/checkout/redirect_invoice.rb +2 -2
- data/lib/mpower/checkout/store.rb +1 -1
- data/lib/mpower/direct_pay.rb +27 -0
- data/lib/mpower/setup.rb +12 -1
- data/lib/mpower/version.rb +1 -1
- data/lib/mpower.rb +1 -0
- data/mpower.gemspec +1 -1
- data/test/test_mpower.rb +16 -0
- metadata +9 -6
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/nukturnal/mpower_ruby)
|
1
|
+
[![Code Climate](https://codeclimate.com/github/nukturnal/mpower_ruby.png)](https://codeclimate.com/github/nukturnal/mpower_ruby) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/nukturnal/mpower_ruby) [![Build Status](https://secure.travis-ci.org/nukturnal/mpower_ruby.png?branch=master)](https://travis-ci.org/nukturnal/mpower_ruby) [![Dependency Status](https://gemnasium.com/nukturnal/mpower_ruby.png)](https://gemnasium.com/nukturnal/mpower_ruby)
|
2
2
|
|
3
3
|
# Mpower Ruby Client API
|
4
4
|
========================
|
data/Rakefile
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
module MPower
|
2
|
+
class DirectPay
|
3
|
+
include MPower::Utilities
|
4
|
+
attr_accessor :status, :response_text, :response_code, :transaction_id, :description
|
5
|
+
|
6
|
+
def credit_account(payee_account,amount)
|
7
|
+
payload = {
|
8
|
+
:account_alias => payee_account,
|
9
|
+
:amount => amount
|
10
|
+
}
|
11
|
+
|
12
|
+
result = http_json_request(MPower::Setup.direct_pay_credit_base_url,payload)
|
13
|
+
if result["response_code"] == "00"
|
14
|
+
@transaction_id = result["transaction_id"]
|
15
|
+
@description = result["description"]
|
16
|
+
@response_code = result["response_code"]
|
17
|
+
@status = MPower::SUCCESS
|
18
|
+
true
|
19
|
+
else
|
20
|
+
@response_text = result["response_text"]
|
21
|
+
@response_code = result["response_code"]
|
22
|
+
@status = MPower::FAIL
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/mpower/setup.rb
CHANGED
@@ -6,16 +6,23 @@ module MPower
|
|
6
6
|
@@token = nil
|
7
7
|
@@mode = "test"
|
8
8
|
|
9
|
-
ROOT_URL_BASE = "
|
9
|
+
ROOT_URL_BASE = "http://localhost:3000"
|
10
|
+
|
10
11
|
LIVE_CHECKOUT_INVOICE_BASE_URL = "#{ROOT_URL_BASE}/api/v1/checkout-invoice/create"
|
11
12
|
TEST_CHECKOUT_INVOICE_BASE_URL = "#{ROOT_URL_BASE}/sandbox-api/v1/checkout-invoice/create"
|
13
|
+
|
12
14
|
LIVE_CHECKOUT_CONFIRM_BASE_URL = "#{ROOT_URL_BASE}/api/v1/checkout-invoice/confirm/"
|
13
15
|
TEST_CHECKOUT_CONFIRM_BASE_URL = "#{ROOT_URL_BASE}/sandbox-api/v1/checkout-invoice/confirm/"
|
16
|
+
|
14
17
|
LIVE_OPR_BASE_URL = "#{ROOT_URL_BASE}/api/v1/opr/create"
|
15
18
|
TEST_OPR_BASE_URL = "#{ROOT_URL_BASE}/sandbox-api/v1/opr/create"
|
19
|
+
|
16
20
|
LIVE_OPR_CHARGE_BASE_URL = "#{ROOT_URL_BASE}/api/v1/opr/charge"
|
17
21
|
TEST_OPR_CHARGE_BASE_URL = "#{ROOT_URL_BASE}/sandbox-api/v1/opr/charge"
|
18
22
|
|
23
|
+
LIVE_DIRECT_PAY_CREDIT_BASE_URL = "#{ROOT_URL_BASE}/api/v1/direct-pay/credit-account"
|
24
|
+
TEST_DIRECT_PAY_CREDIT_BASE_URL = "#{ROOT_URL_BASE}/sandbox-api/v1/direct-pay/credit-account"
|
25
|
+
|
19
26
|
def self.master_key=(master_key); @@master_key = master_key; end
|
20
27
|
def self.master_key; @@master_key; end
|
21
28
|
def self.private_key=(private_key); @@private_key = private_key; end
|
@@ -44,5 +51,9 @@ module MPower
|
|
44
51
|
@@mode == "live" ? LIVE_OPR_CHARGE_BASE_URL : TEST_OPR_CHARGE_BASE_URL
|
45
52
|
end
|
46
53
|
|
54
|
+
def self.direct_pay_credit_base_url
|
55
|
+
@@mode == "live" ? LIVE_DIRECT_PAY_CREDIT_BASE_URL : TEST_DIRECT_PAY_CREDIT_BASE_URL
|
56
|
+
end
|
57
|
+
|
47
58
|
end
|
48
59
|
end
|
data/lib/mpower/version.rb
CHANGED
data/lib/mpower.rb
CHANGED
data/mpower.gemspec
CHANGED
@@ -20,5 +20,5 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency('multi_json', '~> 1.1')
|
21
21
|
gem.add_dependency('faraday','~> 0.8.4')
|
22
22
|
gem.add_dependency('faraday_middleware')
|
23
|
-
gem.add_development_dependency('rake', '~> 0.
|
23
|
+
gem.add_development_dependency('rake', '~> 10.0.2')
|
24
24
|
end
|
data/test/test_mpower.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mpower'
|
3
|
+
|
4
|
+
class TestMPower < Test::Unit::TestCase
|
5
|
+
def test_checkout_invoice_items
|
6
|
+
invoice = MPower::Checkout::Invoice.new
|
7
|
+
invoice.add_item("Cart Item 1",1,10.00,10.00,"with optional description")
|
8
|
+
invoice.add_item("Cart Item 2",5,5.00,25.00)
|
9
|
+
invoice.total_amount = 55.00
|
10
|
+
invoice.description = "Unit::Test Invoice from Ruby lang"
|
11
|
+
assert_instance_of(Hash, invoice.get_items)
|
12
|
+
assert_equal(2, invoice.get_items.size)
|
13
|
+
assert_instance_of(Hash, invoice.get_items[:item_0])
|
14
|
+
assert_equal(5, invoice.get_items[:item_0].size)
|
15
|
+
end
|
16
|
+
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
|
4
|
+
version: 1.1.0
|
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:
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
85
|
+
version: 10.0.2
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: 10.0.2
|
94
94
|
description: Ruby library for integrating with the MPower Gateway
|
95
95
|
email:
|
96
96
|
- alfred@ncodedevlabs.com
|
@@ -109,10 +109,12 @@ files:
|
|
109
109
|
- lib/mpower/checkout/onsite_invoice.rb
|
110
110
|
- lib/mpower/checkout/redirect_invoice.rb
|
111
111
|
- lib/mpower/checkout/store.rb
|
112
|
+
- lib/mpower/direct_pay.rb
|
112
113
|
- lib/mpower/setup.rb
|
113
114
|
- lib/mpower/utilities.rb
|
114
115
|
- lib/mpower/version.rb
|
115
116
|
- mpower.gemspec
|
117
|
+
- test/test_mpower.rb
|
116
118
|
homepage: http://mpowerpayments.com/developers/docs/ruby.html
|
117
119
|
licenses: []
|
118
120
|
post_install_message:
|
@@ -133,9 +135,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
135
|
version: '0'
|
134
136
|
requirements: []
|
135
137
|
rubyforge_project:
|
136
|
-
rubygems_version: 1.8.
|
138
|
+
rubygems_version: 1.8.25
|
137
139
|
signing_key:
|
138
140
|
specification_version: 3
|
139
141
|
summary: Ruby client bindings for the MPower API
|
140
|
-
test_files:
|
142
|
+
test_files:
|
143
|
+
- test/test_mpower.rb
|
141
144
|
has_rdoc:
|