mpower 1.0.10 → 1.1.0

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/.gitignore CHANGED
@@ -16,3 +16,4 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+ api_test.rb
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
@@ -1 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ end
7
+
8
+ desc "Run tests"
9
+ task :default => :test
@@ -45,11 +45,11 @@ module MPower
45
45
  end
46
46
 
47
47
  def get_items
48
- hash_to_json @items
48
+ @items
49
49
  end
50
50
 
51
51
  def get_taxes
52
- hash_to_json @taxes
52
+ @taxes
53
53
  end
54
54
 
55
55
  def get_customer_info(key)
@@ -2,7 +2,7 @@ module MPower
2
2
  module Checkout
3
3
  module Store
4
4
  @@name = "Untitled Store"
5
- @@tagline = "Put your online store's tagline here."
5
+ @@tagline = nil
6
6
  @@postal_address = nil
7
7
  @@phone_number = nil
8
8
  @@website_url = nil
@@ -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 = "https://app.mpowerpayments.com"
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
@@ -1,3 +1,3 @@
1
1
  module MPower
2
- VERSION = "1.0.10"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/mpower.rb CHANGED
@@ -5,6 +5,7 @@ require "mpower/version"
5
5
  require "mpower/setup"
6
6
  require "mpower/utilities"
7
7
  require "mpower/checkout"
8
+ require "mpower/direct_pay"
8
9
 
9
10
  module MPower
10
11
  SUCCESS = "success"
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.9')
23
+ gem.add_development_dependency('rake', '~> 10.0.2')
24
24
  end
@@ -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.10
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: 2012-11-17 00:00:00.000000000 Z
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: '0.9'
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: '0.9'
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.24
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: