paymentsds-mpesa 0.1.0.pre.alpha.8 → 0.1.0.pre.alpha.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c7608231b0ba49b2a9f1dbab086051abc086cdba8e2815e045d0c2e9b67adc4
4
- data.tar.gz: 231917dfaec6609aac73bc37f281575a2f03c31c6bab7d52216609b844d6be93
3
+ metadata.gz: 382655187d79e081000c1ce3b1cd664fa86e8d4d2397958e2add9875cf3b471c
4
+ data.tar.gz: 144c2c56e1b236296e931db9dc870ef4fbec7f8727682423a3aa33710239a082
5
5
  SHA512:
6
- metadata.gz: a9ed824441084ecb7ab57e0061f1a68c636a102b7715f25c0f94ac8700eb9d3b313c4bde9e0bc907829cc9926188607e092e693ea4aecae51fbc82d12adc02e7
7
- data.tar.gz: 7d069e7fafad64f80644a8bb5fc5a6c1f9bc7819a8982612436da7ebd8c83b58c6b71aad1f43359bfdf76c121a9f00ae862f20a3236c68cf987e30d9a218ab2e
6
+ metadata.gz: 45148c1776339bbe17d8538636b97117f137fc0240a5a369c13351db1a0151d6fde8c3a556acd862c78aeb514a9c42b645ced4ded50ed1c80e2072545c16292f
7
+ data.tar.gz: '094269d5f9de88db2c0092cbd1105ad1e3aca770b44ce77d0fc2956cfb30afe136ce1e0a76561edf97cba80c314bf6b00a10b31fa97c5cd8766f748dcd45844f'
@@ -3,6 +3,7 @@
3
3
  require_relative 'mpesa/version'
4
4
  require_relative 'mpesa/operation'
5
5
  require_relative 'mpesa/constants'
6
+ require_relative 'mpesa/environment'
6
7
  require_relative 'mpesa/configuration'
7
8
  require_relative 'mpesa/result'
8
9
  require_relative 'mpesa/error_type'
@@ -6,6 +6,7 @@ module Paymentsds
6
6
  def initialize
7
7
  @service = Service.new
8
8
  yield(@service.config) if block_given?
9
+ @service.apply
9
10
  end
10
11
 
11
12
  def send(intent)
@@ -21,9 +21,23 @@ module Paymentsds
21
21
  attr_reader :auth
22
22
 
23
23
  def initialize
24
+ @user_agent = 'Paymentsds Ruby'
25
+ @origin = "*"
26
+ @verify_ssl = false
27
+ @timeout = 0
28
+ @environment =
29
+
24
30
  yield(self) if block_given?
25
31
  end
26
32
 
33
+ def apply
34
+ @environment = if @environment == :production
35
+ Paymentsds::MPesa::Environment.new('https', 'api.vm.co.mz').freeze
36
+ else
37
+ Paymentsds::MPesa::Environment.new('https', 'api.sandbox.vm.co.mz').freeze
38
+ end
39
+ end
40
+
27
41
  def generate_access_token
28
42
  has_keys = instance_variable_defined?('@api_key') && instance_variable_defined?('@public_key')
29
43
  has_access_token = instance_variable_defined?('@access_token')
@@ -0,0 +1,13 @@
1
+ module Paymentsds
2
+ module MPesa
3
+ class Environment
4
+ attr_accessor :scheme
5
+ attr_accessor :domain
6
+
7
+ def initialize(scheme, dommain)
8
+ @scheme = scheme
9
+ @domain = domain
10
+ end
11
+ end
12
+ end
13
+ end
@@ -9,6 +9,10 @@ module Paymentsds
9
9
  @config = Paymentsds::MPesa::Configuration.new
10
10
  end
11
11
 
12
+ def apply
13
+ @config.apply
14
+ end
15
+
12
16
  def handle_send(intent)
13
17
  operation = detect_operation(intent)
14
18
  handle_request(operation, intent)
@@ -71,7 +75,7 @@ module Paymentsds
71
75
  errors = []
72
76
 
73
77
  intent.each do |k, _v|
74
- errors.push(k) unless (intent[k]).match operation.validation[k]
78
+ errors.push(k) unless (intent[k]).match operation[:validation][k]
75
79
  end
76
80
 
77
81
  errors
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Paymentsds
4
4
  module MPesa
5
- VERSION = '0.1.0.pre.alpha.8'
5
+ VERSION = '0.1.0.pre.alpha.13'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paymentsds-mpesa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.alpha.8
4
+ version: 0.1.0.pre.alpha.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edson Michaque
@@ -113,6 +113,7 @@ files:
113
113
  - lib/paymentsds/mpesa/client.rb
114
114
  - lib/paymentsds/mpesa/configuration.rb
115
115
  - lib/paymentsds/mpesa/constants.rb
116
+ - lib/paymentsds/mpesa/environment.rb
116
117
  - lib/paymentsds/mpesa/error_type.rb
117
118
  - lib/paymentsds/mpesa/operation.rb
118
119
  - lib/paymentsds/mpesa/patterns.rb