africastalking-ruby 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +119 -0
- data/LICENSE.txt +21 -0
- data/README.md +332 -0
- data/Rakefile +6 -0
- data/africastalking-ruby.gemspec +40 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/AfricasTalking/Airtime.rb +72 -0
- data/lib/AfricasTalking/Application.rb +43 -0
- data/lib/AfricasTalking/Payments.rb +436 -0
- data/lib/AfricasTalking/Sms.rb +242 -0
- data/lib/AfricasTalking/Token.rb +66 -0
- data/lib/AfricasTalking/Voice.rb +141 -0
- data/lib/AfricasTalking/version.rb +3 -0
- data/lib/AfricasTalking.rb +118 -0
- metadata +131 -17
- data/lib/AfricasTalkingGateway.rb +0 -340
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2a117033fd96f8fd02fea7b920c4de4ca4fc3f867fd49e237f4c61a9db5a714f
|
4
|
+
data.tar.gz: 5ff1623f5cadeb1535c52edae7810875ae96d9d189da4b99051adc72ebde43fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1cccc4bb7c8d0b427fd0e0a5e7bc3c22761d16a651b9970a621c750416a9b4a5b28057f09458aeb0f4c6b6fd5cd0a480013e86e2f63a2075cf7ddcb76969b1d0
|
7
|
+
data.tar.gz: c25f68df3fda65f73978dd18cf864bb0e013f7ba0b246633f4b6f7ee051d975aa03b7999812072c5e2d138a66d38e971f454a812830990466583cebaa52529d0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at mwirigimichael@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
africastalking-ruby (2.0.0)
|
5
|
+
httparty (= 0.16.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionpack (5.2.0)
|
11
|
+
actionview (= 5.2.0)
|
12
|
+
activesupport (= 5.2.0)
|
13
|
+
rack (~> 2.0)
|
14
|
+
rack-test (>= 0.6.3)
|
15
|
+
rails-dom-testing (~> 2.0)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
17
|
+
actionview (5.2.0)
|
18
|
+
activesupport (= 5.2.0)
|
19
|
+
builder (~> 3.1)
|
20
|
+
erubi (~> 1.4)
|
21
|
+
rails-dom-testing (~> 2.0)
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
23
|
+
activesupport (5.2.0)
|
24
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
|
+
i18n (>= 0.7, < 2)
|
26
|
+
minitest (~> 5.1)
|
27
|
+
tzinfo (~> 1.1)
|
28
|
+
ast (2.4.0)
|
29
|
+
builder (3.2.3)
|
30
|
+
coderay (1.1.2)
|
31
|
+
concurrent-ruby (1.0.5)
|
32
|
+
crass (1.0.4)
|
33
|
+
diff-lcs (1.3)
|
34
|
+
erubi (1.7.1)
|
35
|
+
httparty (0.16.1)
|
36
|
+
multi_xml (>= 0.5.2)
|
37
|
+
i18n (1.0.0)
|
38
|
+
concurrent-ruby (~> 1.0)
|
39
|
+
loofah (2.2.2)
|
40
|
+
crass (~> 1.0.2)
|
41
|
+
nokogiri (>= 1.5.9)
|
42
|
+
method_source (0.9.0)
|
43
|
+
mini_portile2 (2.3.0)
|
44
|
+
minitest (5.11.3)
|
45
|
+
multi_xml (0.6.0)
|
46
|
+
nokogiri (1.8.2)
|
47
|
+
mini_portile2 (~> 2.3.0)
|
48
|
+
parallel (1.12.1)
|
49
|
+
parser (2.5.0.5)
|
50
|
+
ast (~> 2.4.0)
|
51
|
+
powerpack (0.1.1)
|
52
|
+
pry (0.11.3)
|
53
|
+
coderay (~> 1.1.0)
|
54
|
+
method_source (~> 0.9.0)
|
55
|
+
rack (2.0.4)
|
56
|
+
rack-test (1.0.0)
|
57
|
+
rack (>= 1.0, < 3)
|
58
|
+
rails-dom-testing (2.0.3)
|
59
|
+
activesupport (>= 4.2.0)
|
60
|
+
nokogiri (>= 1.6)
|
61
|
+
rails-html-sanitizer (1.0.4)
|
62
|
+
loofah (~> 2.2, >= 2.2.2)
|
63
|
+
railties (5.2.0)
|
64
|
+
actionpack (= 5.2.0)
|
65
|
+
activesupport (= 5.2.0)
|
66
|
+
method_source
|
67
|
+
rake (>= 0.8.7)
|
68
|
+
thor (>= 0.18.1, < 2.0)
|
69
|
+
rainbow (3.0.0)
|
70
|
+
rake (10.5.0)
|
71
|
+
rspec (3.7.0)
|
72
|
+
rspec-core (~> 3.7.0)
|
73
|
+
rspec-expectations (~> 3.7.0)
|
74
|
+
rspec-mocks (~> 3.7.0)
|
75
|
+
rspec-core (3.7.1)
|
76
|
+
rspec-support (~> 3.7.0)
|
77
|
+
rspec-expectations (3.7.0)
|
78
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
+
rspec-support (~> 3.7.0)
|
80
|
+
rspec-mocks (3.7.0)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.7.0)
|
83
|
+
rspec-rails (3.7.2)
|
84
|
+
actionpack (>= 3.0)
|
85
|
+
activesupport (>= 3.0)
|
86
|
+
railties (>= 3.0)
|
87
|
+
rspec-core (~> 3.7.0)
|
88
|
+
rspec-expectations (~> 3.7.0)
|
89
|
+
rspec-mocks (~> 3.7.0)
|
90
|
+
rspec-support (~> 3.7.0)
|
91
|
+
rspec-support (3.7.1)
|
92
|
+
rubocop (0.54.0)
|
93
|
+
parallel (~> 1.10)
|
94
|
+
parser (>= 2.5)
|
95
|
+
powerpack (~> 0.1)
|
96
|
+
rainbow (>= 2.2.2, < 4.0)
|
97
|
+
ruby-progressbar (~> 1.7)
|
98
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
99
|
+
ruby-progressbar (1.9.0)
|
100
|
+
thor (0.20.0)
|
101
|
+
thread_safe (0.3.6)
|
102
|
+
tzinfo (1.2.5)
|
103
|
+
thread_safe (~> 0.1)
|
104
|
+
unicode-display_width (1.3.0)
|
105
|
+
|
106
|
+
PLATFORMS
|
107
|
+
ruby
|
108
|
+
|
109
|
+
DEPENDENCIES
|
110
|
+
africastalking-ruby!
|
111
|
+
bundler (~> 1.16)
|
112
|
+
pry (~> 0)
|
113
|
+
rake (~> 10.0)
|
114
|
+
rspec (~> 3.0)
|
115
|
+
rspec-rails (~> 3.7.2)
|
116
|
+
rubocop (~> 0.54.0)
|
117
|
+
|
118
|
+
BUNDLED WITH
|
119
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Michael Mwirigi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,332 @@
|
|
1
|
+
# AfricasTalking SDK
|
2
|
+
|
3
|
+
> Provides convenient access to the Africa's Talking API from applications written in ruby.
|
4
|
+
|
5
|
+
## Documentation
|
6
|
+
Take a look at the [API docs here](http://docs.africastalking.com).
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem "africastalking-ruby", :git => "git@github.com:AfricasTalkingLtd/africastalking-ruby.git"
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
<!-- Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install AfricasTalking -->
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
The SDK needs to be instantiated using your username and API key, which you can get from the [dashboard](https://account/africastalking.com).
|
27
|
+
|
28
|
+
> You can use this SDK for either production or sandbox apps. For sandbox, the app username is **ALWAYS** `sandbox`
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require "AfricasTalking"
|
32
|
+
|
33
|
+
username = 'YOUR_USERNAME' # use 'sandbox' for development in the test environment
|
34
|
+
apiKey = 'YOUR_API_KEY' # use your sandbox app API key for development in the test environment
|
35
|
+
@AT=AfricasTalking::Initialize.new(username, apiKey)
|
36
|
+
```
|
37
|
+
|
38
|
+
You can now make API calls using the @AT object
|
39
|
+
|
40
|
+
### Token
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
token = @AT.token
|
44
|
+
```
|
45
|
+
|
46
|
+
#### Create authentication Token
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
token.createCheckoutToken options
|
50
|
+
```
|
51
|
+
- `options`
|
52
|
+
- `phoneNumber`: The phone number you want to create a subscription for
|
53
|
+
|
54
|
+
#### Create Checkout Token
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
token.generateAuthToken phoneNumber
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
### Airtime
|
62
|
+
|
63
|
+
Send airtime to phone numbers
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
airtime = @AT.airtime
|
67
|
+
|
68
|
+
airtime.send options
|
69
|
+
```
|
70
|
+
- `options`
|
71
|
+
- `recipients`: Contains an hash of arrays containing the following keys
|
72
|
+
- `phoneNumber`: Recipient of airtime
|
73
|
+
- `amount`: Amount sent `>= 10 && <= 10K` with currency e.g `KES 100`
|
74
|
+
|
75
|
+
### Sms
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
sms = @AT.sms
|
79
|
+
```
|
80
|
+
#### Send Sms
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
sms.send options
|
84
|
+
```
|
85
|
+
- `options`
|
86
|
+
- `message`: SMS content. `REQUIRED`
|
87
|
+
- `to`: A single recipient or a comma separated string of recipients. `REQUIRED`
|
88
|
+
- `from`: Shortcode or alphanumeric ID that is registered with Africa's Talking account. `OPTIONAL`
|
89
|
+
- `enqueue`: Set to `true` if you would like to deliver as many messages to the API without waiting for an acknowledgement from telcos. `OPTIONAL`
|
90
|
+
- `bulkSMSMode`: This parameter will be used by the Mobile Service Provider to determine who gets billed for a message sent using a Mobile-Terminated ShortCode. The default value is 1 (which means that the sender (The AfricasTalking account being used ) gets charged). `OPTIONAL`
|
91
|
+
- `retryDurationInHours`: t specifies the number of hours your subscription message should be retried in case it's not delivered to the subscriber. `OPTIONAL`
|
92
|
+
|
93
|
+
#### Send Premium SMS
|
94
|
+
```ruby
|
95
|
+
sms.sendPremium options
|
96
|
+
```
|
97
|
+
- `options`
|
98
|
+
- `message`: SMS content. `REQUIRED`
|
99
|
+
- `keyword`: The keyword to be used for a premium service. `REQUIRED`
|
100
|
+
- `linkId`: This parameter is used for premium services to send OnDemand messages. We forward the linkId to your application when the user send a message to your service.. `REQUIRED`
|
101
|
+
- `to`: A single recipient or a comma separated string of recipients. `REQUIRED`
|
102
|
+
- `from`: Shortcode or alphanumeric ID that is registered with Africa's Talking account. `OPTIONAL`
|
103
|
+
- `enqueue`: Set to `true` if you would like to deliver as many messages to the API without waiting for an acknowledgement from telcos. `OPTIONAL`
|
104
|
+
- `bulkSMSMode`: This parameter will be used by the Mobile Service Provider to determine who gets billed for a message sent using a Mobile-Terminated ShortCode. The default value is 1 (which means that the sender (The AfricasTalking account being used ) gets charged). `OPTIONAL`
|
105
|
+
- `retryDurationInHours`: t specifies the number of hours your subscription message should be retried in case it's not delivered to the subscriber. `OPTIONAL`
|
106
|
+
|
107
|
+
#### Fetch Messsages
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
sms.fetchMessages options
|
111
|
+
```
|
112
|
+
- `options`
|
113
|
+
- `lastReceivedId`: This is the id of the message that you last processed. The default is 0 `OPTIONAL`
|
114
|
+
|
115
|
+
#### Create subscription
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
sms.createSubcription options
|
119
|
+
```
|
120
|
+
- `options`
|
121
|
+
- `shortCode`: This is a premium short code mapped to your account. `REQUIRED`
|
122
|
+
- `keyword`: Value is a premium keyword under the above short code and mapped to your account. `REQUIRED`
|
123
|
+
- `phoneNumber`: The phoneNumber to be subscribed `REQUIRED`
|
124
|
+
- `checkoutToken`: This is a token used to validate the subscription request `REQUIRED`
|
125
|
+
|
126
|
+
#### Fetch Subscription
|
127
|
+
```ruby
|
128
|
+
sms.fetchSubscriptions options
|
129
|
+
```
|
130
|
+
- `options`
|
131
|
+
- `shortCode`: This is a premium short code mapped to your account. `REQUIRED`
|
132
|
+
- `keyword`: Value is a premium keyword under the above short code and mapped to your account. `REQUIRED`
|
133
|
+
- `lastReceivedId`: ID of the subscription you believe to be your last. Defaults to `0`
|
134
|
+
|
135
|
+
### Voice
|
136
|
+
```ruby
|
137
|
+
voice = @AT.voice
|
138
|
+
```
|
139
|
+
|
140
|
+
#### Making a call
|
141
|
+
```ruby
|
142
|
+
voice.call options
|
143
|
+
```
|
144
|
+
- `options`
|
145
|
+
- `to`: A single recipient or an array of recipients. `REQUIRED`
|
146
|
+
- array of recipients contains ['2XXXXXXXX', '2XXXXXXXX']
|
147
|
+
- `from`: Shortcode or alphanumeric ID that is registered with Africa's Talking account.`REQUIRED`
|
148
|
+
|
149
|
+
|
150
|
+
#### Fetch queued calls
|
151
|
+
```ruby
|
152
|
+
voice.fetchQueuedCalls options
|
153
|
+
```
|
154
|
+
- `options`
|
155
|
+
- `phoneNumber`: is phone number mapped to your AfricasTalking account. `REQUIRED`
|
156
|
+
|
157
|
+
|
158
|
+
#### Upload media file
|
159
|
+
```ruby
|
160
|
+
voice.uploadMediaFile options
|
161
|
+
```
|
162
|
+
- `options`
|
163
|
+
- `url`: The url of the file to upload. Don't forget to start with http:// `REQUIRED`
|
164
|
+
- `phoneNumber`: is phone number mapped to your AfricasTalking account. `REQUIRED`
|
165
|
+
|
166
|
+
### Account
|
167
|
+
```ruby
|
168
|
+
account = @AT.account
|
169
|
+
```
|
170
|
+
#### Fetch User data
|
171
|
+
```ruby
|
172
|
+
account.fetchUserData
|
173
|
+
```
|
174
|
+
|
175
|
+
### Payments
|
176
|
+
```ruby
|
177
|
+
payments = @AT.payments
|
178
|
+
```
|
179
|
+
#### Credit card checkout
|
180
|
+
```ruby
|
181
|
+
payments.cardCheckout options
|
182
|
+
```
|
183
|
+
- `options`
|
184
|
+
- `productName`: Payment Product as setup on your account. `REQUIRED`
|
185
|
+
- `currencyCode`: 3-digit ISO format currency code (only `NGN` is supported). `REQUIRED`
|
186
|
+
- `amount`: Payment amount. `REQUIRED`
|
187
|
+
- `narration`: A short description of the transaction `REQUIRED`
|
188
|
+
- `checkoutToken`: Token that has been generated by our APIs as as result of charging a user's Payment Card in a previous transaction. When using a token, the `paymentCard` data should NOT be populated. `OPTIONAL`
|
189
|
+
- `paymentCard`: Hash of payment Card to be charged: `OPTIONAL`
|
190
|
+
- `number`: The payment card number. `REQUIRED`
|
191
|
+
- `cvvNumber`: The 3 or 4 digit Card Verification Value. `REQUIRED`
|
192
|
+
- `expiryMonth`: The expiration month on the card (e.g `8`) `REQUIRED`
|
193
|
+
- `authToken`: The card's ATM PIN. `REQUIRED`
|
194
|
+
- `countryCode`: The 2-Digit countryCode where the card was issued (only `NG` is supported). `REQUIRED`
|
195
|
+
- `metadata`: Some optional data to associate with transaction. `OPTIONAL`
|
196
|
+
|
197
|
+
#### Validate credit card checkout
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
payments.validateCardCheckout options
|
201
|
+
```
|
202
|
+
- `options`
|
203
|
+
- `transactionId`: The transaction that your application wants to validate. `REQUIRED`
|
204
|
+
- `otp`: One Time Password that the card issuer sent to the client. `REQUIRED`
|
205
|
+
|
206
|
+
|
207
|
+
#### Initiate bank charge checkout
|
208
|
+
```ruby
|
209
|
+
payments.initiateBankChargeCheckout options
|
210
|
+
```
|
211
|
+
- `options`
|
212
|
+
- `productName`: Payment Product as setup on your account. `REQUIRED`
|
213
|
+
- `bankAccount`: Hash of bank account to be charged:
|
214
|
+
|
215
|
+
- `accountName`: The name of the bank account. `REQUIRED`
|
216
|
+
- `accountNumber`: The account number. `REQUIRED`
|
217
|
+
- `bankCode`: A 6-Digit [Integer Code](http://docs.africastalking.com/bank/checkout) for the bank that we allocate. See `payments.BANK.*` for supported banks. `REQUIRED`
|
218
|
+
- `dateOfBirth`: Date of birth of the account owner (`YYYY-MM-DD`). Required for Zenith Bank Nigeria.
|
219
|
+
|
220
|
+
- `currencyCode`: 3-digit ISO format currency code (only `NGN` is supported). `REQUIRED`
|
221
|
+
- `amount`: Payment amount. `REQUIRED`
|
222
|
+
- `narration`: A short description of the transaction `REQUIRED`
|
223
|
+
- `metadata`: Some optional data to associate with transaction`OPTIONAL`
|
224
|
+
|
225
|
+
|
226
|
+
#### Validate bank checkout
|
227
|
+
```ruby
|
228
|
+
payments.validateBankCheckout options
|
229
|
+
```
|
230
|
+
- `options`
|
231
|
+
- `transactionId`: The transaction that your application wants to validate. `REQUIRED`
|
232
|
+
- `otp`: One Time Password that the bank sent to the client. `REQUIRED`
|
233
|
+
|
234
|
+
|
235
|
+
#### Bank transfer
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
payments.bankTransfer options
|
239
|
+
```
|
240
|
+
- `options`
|
241
|
+
- `productName`: Payment Product as setup on your account. `REQUIRED`
|
242
|
+
- `recipients`: A list of recipients. Each recipient has:
|
243
|
+
- `bankAccount`: Bank account to be charged:
|
244
|
+
- `accountName`: The name of the bank account.
|
245
|
+
- `accountNumber`: The account number `REQUIRED`
|
246
|
+
- `bankCode`: A 6-Digit Integer Code for the bank that we allocate; See `payments.BANK.*` for supported banks. `REQUIRED`
|
247
|
+
- `currencyCode`: 3-digit ISO format currency code (only `NGN` is supported). `REQUIRED`
|
248
|
+
- `amount`: Payment amount. `REQUIRED`
|
249
|
+
- `narration`: A short description of the transaction `REQUIRED`
|
250
|
+
- `metadata`: Some optional data to associate with transaction.
|
251
|
+
|
252
|
+
#### Mobile Checkout
|
253
|
+
|
254
|
+
```ruby
|
255
|
+
payments.mobileCheckout options
|
256
|
+
```
|
257
|
+
- `options`
|
258
|
+
- `productName`: Your Payment Product. `REQUIRED`
|
259
|
+
- `phoneNumber`: The customer phone number (in international format; e.g. `25471xxxxxxx`). `REQUIRED`
|
260
|
+
- `currencyCode`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc.) `REQUIRED`
|
261
|
+
- `amount`: This is the amount. `REQUIRED`
|
262
|
+
- `metadata`: Some optional data to associate with transaction.`OPTIONAL`
|
263
|
+
|
264
|
+
#### Mobile B2C
|
265
|
+
```ruby
|
266
|
+
payments.mobileB2C options
|
267
|
+
```
|
268
|
+
- `options`
|
269
|
+
- `productName`: Your Payment Product. `REQUIRED`
|
270
|
+
- `recipients`: A list of **up to 10** recipients. Each recipient has:
|
271
|
+
|
272
|
+
- `phoneNumber`: The payee phone number (in international format; e.g. `25471xxxxxxx`). `REQUIRED`
|
273
|
+
- `currencyCode`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc.) `REQUIRED`
|
274
|
+
- `amount`: Payment amount. `REQUIRED`
|
275
|
+
- `providerChannel`: This represents the payment channel the payment will be made from. eg paybill number. The payment channel must be mapped to you. The AfricasTalking default provider channel is used if not specified.
|
276
|
+
- `reason`: This field contains a string showing the purpose for the payment. If set, it should be one of the following
|
277
|
+
|
278
|
+
```
|
279
|
+
SalaryPayment
|
280
|
+
SalaryPaymentWithWithdrawalChargePaid
|
281
|
+
BusinessPayment
|
282
|
+
BusinessPaymentWithWithdrawalChargePaid
|
283
|
+
PromotionPayment
|
284
|
+
```
|
285
|
+
|
286
|
+
- `metadata`: Some optional data to associate with transaction.
|
287
|
+
|
288
|
+
#### Mobile B2B
|
289
|
+
```ruby
|
290
|
+
payments.mobileB2B options
|
291
|
+
```
|
292
|
+
- `options`
|
293
|
+
- `productName`: Your Payment Product as setup on your account. `REQUIRED`
|
294
|
+
- `providerData`: Hash containing Provider details. this include; `REQUIRED`
|
295
|
+
|
296
|
+
- `provider`: String that shows the payment provider that is facilitating this transaction. Supported providers at the moment are:
|
297
|
+
|
298
|
+
```
|
299
|
+
Athena - Please note: This is not available on our production systems
|
300
|
+
Mpesa
|
301
|
+
```
|
302
|
+
- `transferType`: This contains the payment provider that is facilitating this transaction. Supported providers at the moment are:
|
303
|
+
|
304
|
+
```
|
305
|
+
BusinessBuyGoods
|
306
|
+
BusinessPayBill
|
307
|
+
DisburseFundsToBusiness
|
308
|
+
BusinessToBusinessTransfer
|
309
|
+
```
|
310
|
+
- `destinationChannel`: This value contains the name or number of the channel that will receive payment by the provider. `REQUIRED`
|
311
|
+
- `destinationAccount`: This value contains the account name used by the business to receive money on the provided destinationChannel. `REQUIRED`
|
312
|
+
- `currencyCode`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc.) `REQUIRED`
|
313
|
+
|
314
|
+
- `amount`: Payment amount. `REQUIRED`
|
315
|
+
- `metadata`: Some optional data to associate with transaction.`OPTIONAL`
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
## Development
|
321
|
+
|
322
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
323
|
+
|
324
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
325
|
+
|
326
|
+
## Contributing
|
327
|
+
|
328
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/AfricasTalkingLtd. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
329
|
+
|
330
|
+
## License
|
331
|
+
|
332
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "AfricasTalking/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "africastalking-ruby"
|
8
|
+
spec.version = AfricasTalking::VERSION
|
9
|
+
spec.authors = ["Michael Mwirigi"]
|
10
|
+
spec.email = ["mmwirigi@africastalking.com"]
|
11
|
+
|
12
|
+
spec.summary = "Simple gem that helps you build integrations with AfricasTalking"
|
13
|
+
spec.description = ""
|
14
|
+
spec.homepage = "https://africastalking.com"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "rspec-rails", "~> 3.7.2"
|
37
|
+
spec.add_development_dependency "rubocop", "~> 0.54.0"
|
38
|
+
spec.add_development_dependency "pry" , "~> 0"
|
39
|
+
spec.add_dependency "httparty", "0.16.1"
|
40
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "AfricasTalking"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|