paystackapi 0.2.0 → 0.3.0

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: 0f597d711da0da4f7cfc5a6726d516a24fe0fdb0d5b420388b1386b1a98e35f9
4
- data.tar.gz: 8797e2fccf21eec53b6c6b3b4f2cebf4de4fd37458ad2af3a18205a8d40395d6
3
+ metadata.gz: 18f3ee40677cc57e49748782109113f13f61343bb660d34797ae5535b8d53547
4
+ data.tar.gz: 93ed210d71f031a906391b5853fdb2838e625cbe1aaefe9cf4ef1dc5745e9e6f
5
5
  SHA512:
6
- metadata.gz: 49355c378a2b21433438e8da86e8b7a6d09cfc06e58207a94a59340111026c431b90c7f4c49dd323152c75127738d8d8e8bfe588444abedca750fb678e69d670
7
- data.tar.gz: b638a833f2485d3ee3f32156a3db4644715bb06916ab11f3bc7a4c6f1671956da4a4a62e064d08df420786777681ac6f7de6218b508003fa1d7adb9eb1b6b68a
6
+ metadata.gz: c2eeca44758bb69e135af17453f1eeb487c8f1ba4002a70692bd640ca83b38c525faa6bc062b63852f7ece4faa752e8fe792b9b58fb55421bb1eb5f0d5e8ef2b
7
+ data.tar.gz: 5ce4697c0920529c83a029586ae7f3654db325da83644f9b407f7b48db53bebf010442e72d796155b1bc84a2c8727b0d89ccdec7bf46707bedf26826989fe1ed
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2019 samuel52
3
+ Copyright (c) 2019 Samuel Joseph
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
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.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,43 +1,144 @@
1
- # Paystackapi
1
+ # Paystackapi :moneybag:
2
+ [![CircleCI](https://circleci.com/gh/samuel52/PaystackRubyApi.svg?style=shield)](https://circleci.com/gh/samuel52/PaystackRubyApi)
3
+ [![Gem Version](https://badge.fury.io/rb/paystackapi.svg)](https://badge.fury.io/rb/paystackapi)
2
4
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/paystackapi`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ Paystack gem for Ruby api only application
6
+ ### Installation
4
7
 
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
8
+ Simply add this line to your application's Gemfile:
10
9
 
11
10
  ```ruby
12
11
  gem 'paystackapi'
13
12
  ```
14
13
 
15
14
  And then execute:
16
-
17
- $ bundle
15
+ ```ruby
16
+ bundle install
17
+ ```
18
18
 
19
19
  Or install it yourself as:
20
+ ```ruby
21
+ gem install paystackapi
22
+ ```
23
+
24
+ ### Usage
20
25
 
21
- $ gem install paystackapi
26
+ You may need to install [Dotenv](https://github.com/bkeepers/dotenv) to set you environmental variables. Set the requirements in your controller files where needed.
22
27
 
23
- ## Usage
28
+ ```ruby
29
+ require 'paystackapi'
30
+ require 'dotenv/load'
31
+ ```
24
32
 
25
- TODO: Write usage instructions here
33
+ ### Transactions :credit_card:
34
+ ###### Verify Payment
26
35
 
27
- ## Development
36
+ ```ruby
37
+
38
+ def validate_payment
39
+ paystack_ref = params[:reference_code] # get payment ref after initializing payment from the frontend
40
+ verify = Paystackapi::PaystackTransactions.verify(paystack_ref)
41
+ end
42
+ ```
43
+ ###### Other Transaction Methods :point_down:
44
+
45
+ ```ruby
46
+ Paystackapi::PaystackTransactions.list # list all transactions
47
+ Paystackapi::PaystackTransactions.totals # show transaction totals
48
+ Paystackapi::PaystackTransactions.list_single(arg) # list single transaction
49
+ Paystackapi::PaystackTransactions.charge(arg) # charge authorization from card
50
+ ```
51
+ ### Customers :two_men_holding_hands:
52
+
53
+ ```ruby
54
+ def customers
55
+ customerEmail = params[:customer_email]
56
+ customer = Paystackapi::PaystackCustomers.create(customerEmail)
57
+ end
58
+ ```
59
+ ###### Other Customer Methods
60
+
61
+ ```ruby
62
+ Paystackapi::PaystackCustomers.list #list all customers
63
+ Paystackapi::PaystackCustomers.list_single(arg) #get by id
64
+ ```
65
+ ### Plans :cyclone:
66
+
67
+ ```ruby
68
+ def plans
69
+ createPlan = {
70
+ CustomerName = params[:name]
71
+ interval = params[:interval]
72
+ amount = params[:amount]
73
+ }
74
+ customer = Paystackapi::PaystackPlans.create(createPlan)
75
+ end
76
+ ```
77
+ ###### Other Plans Methods
78
+
79
+ ```ruby
80
+ Paystackapi::PaystackPlans.list #list all paystack plans
81
+ Paystackapi::PaystackPlans.list_single(arg) #get by id
82
+ Paystackapi::PaystackPlans.update(arg) #update plan by id
83
+ ```
84
+ ### Subscription :electric_plug:
85
+ ```ruby
86
+ def subscription
87
+ createSub = {
88
+ CustomerToken = "CUS_xnxdt6s1zg1f4nx"
89
+ planCode = "PLN_gx2wn530m0i3w3m"
90
+ }
91
+
92
+ customer = Paystackapi::PaystackSubscription.create(createSub)
93
+ end
94
+ ```
95
+ ###### Other Subcription Methods
96
+
97
+ ```ruby
98
+ Paystackapi::PaystackSubscription.list #list all subs
99
+ Paystackapi::PaystackSubscription.list_single(arg) #get subs by id
100
+ Paystackapi::PaystackSubscription.disable #disable subs
101
+ Paystackapi::PaystackSubscription.enable #enable subs
102
+ ```
103
+ ### Paystack Transfer :boom:
104
+ ```ruby
105
+ def transfer
106
+ createTrans = {
107
+ type = "nuban" #use params[:something] to get the parameters from your endpoint
108
+ name = "Raz"
109
+ description = "Razite"
110
+ account_number = "01000000419"
111
+ bank_code = "044"
112
+ currency = "NGN"
113
+ }
114
+ customer = Paystackapi::PaystackTransfer.generate(createTrans)
115
+ end
116
+ ```
117
+ ###### Other Transfer Methods
118
+
119
+ ```ruby
120
+ Paystackapi::PaystackTransfer.list_reciept #list all transfers Reciept
121
+ Paystackapi::PaystackTransfer.update_reciept(arg, arg) #update reciept
122
+ Paystackapi::PaystackTransfer.initailize(arg) #initalize a transfer (triggers an otp here)
123
+ Paystackapi::PaystackTransfer.list_transfer #list all transfers
124
+ Paystackapi::PaystackTransfer.finalize(arg) #finalize a transfer
125
+
126
+ ```
127
+ ### Bank List :bank:
128
+ ```ruby
129
+ Paystackapi::PaystackSubscription.list_banks #list all Nigerian Banks
130
+ ```
28
131
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
132
+ ### Contributing
30
133
 
31
- 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).
134
+ Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
32
135
 
33
- ## Contributing
136
+ ### Who are you?
34
137
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/paystackapi. 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.
138
+ I'm Sam, find me on [twitter](https://twitter.com/sammyngn).
36
139
 
37
- ## License
140
+ ### License
38
141
 
39
142
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
143
 
41
- ## Code of Conduct
42
144
 
43
- Everyone interacting in the Paystackapi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/paystackapi/blob/master/CODE_OF_CONDUCT.md).
data/lib/paystackapi.rb CHANGED
@@ -1,164 +1,103 @@
1
- require 'paystackapi/version'
2
- require 'paystackapi/base.rb'
1
+ require 'paystackapi/core/version'
2
+ require 'paystackapi/core/base.rb'
3
+ require 'paystackapi/core/transaction.rb'
4
+ require 'paystackapi/core/bank.rb'
5
+ require 'paystackapi/core/customer.rb'
6
+ require 'paystackapi/core/otp.rb'
7
+ require 'paystackapi/core/plan.rb'
8
+ require 'paystackapi/core/transfer.rb'
9
+ require 'paystackapi/core/subscription.rb'
3
10
  require 'httparty'
4
- require 'openssl'
5
11
  require 'dotenv'
6
12
 
7
13
  module Paystackapi
8
14
  class PaystackTransactions
9
- def self.verify_payment(body)
10
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::TRANSACTION_PATH}" + "/verify/#{body}",
11
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
12
- return api
13
- end
14
- def self.list_transactions()
15
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::TRANSACTION_PATH}",
16
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
17
- return api
18
- end
19
- def self.list_transaction_totals()
20
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::TRANSACTION_PATH}/" + "totals",
21
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
22
- return api
23
- end
24
- def self.fetch_transaction(body)
25
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::TRANSACTION_PATH}/" + "#{body}",
26
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
27
- return api
28
- end
29
- def self.charge_authorization(body)
30
- api = HTTParty.post("#{API::BASE_URL}" + "#{API::TRANSACTION_PATH}/" + "charge_authorization",
31
- :body => body.to_json,
32
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
33
- return api
15
+ def self.verify(body)
16
+ Transaction.verify_payment(body)
17
+ end
18
+ def self.list
19
+ Transaction.list_transactions
20
+ end
21
+ def self.totals
22
+ Transaction.list_transaction_totals
23
+ end
24
+ def self.list_single(body)
25
+ Transaction.fetch_transaction(body)
26
+ end
27
+ def self.charge(body)
28
+ Transaction.charge_authorization(body)
34
29
  end
35
30
  end
36
31
  class PaystackCustomers
37
- def self.create_customer(body)
38
- api = HTTParty.post("#{API::BASE_URL}" + "#{API::CUSTOMER_PATH}",
39
- :body => body.to_json,
40
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
41
- return api
42
- end
43
- def self.list_customer()
44
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::CUSTOMER_PATH}",
45
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
46
- return api
47
- end
48
- def self.fetch_a_customer(body)
49
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::CUSTOMER_PATH}/" + "#{body}",
50
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
51
- return api
32
+ def self.create(body)
33
+ Transaction.create_customer(body)
34
+ end
35
+ def self.list
36
+ Transaction.list_customer
37
+ end
38
+ def self.list_single(body)
39
+ Transaction.fetch_a_customer(body)
52
40
  end
53
41
  end
54
42
 
55
43
  class PaystackPlans
56
- def self.create_plan(body)
57
- api = HTTParty.post("#{API::BASE_URL}" + "#{API::PLAN_PATH}",
58
- :body => body.to_json,
59
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
60
- return api
61
- end
62
- def self.list_plans()
63
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::PLAN_PATH}",
64
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
65
- return api
66
- end
67
- def self.list_single_plan(body)
68
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::PLAN_PATH}" + "#{body}",
69
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
70
- return api
71
- end
72
- def self.update_plan(body)
73
- api = HTTParty.put("#{API::BASE_URL}" + "#{API::PLAN_PATH}" + "#{body}",
74
- :body => body.to_json,
75
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
76
- return api
44
+ def self.create(body)
45
+ Transaction.create_plan(body)
46
+ end
47
+ def self.list
48
+ Transaction.list_plans
49
+ end
50
+ def self.list_single(body)
51
+ Transaction.list_single_plan(body)
52
+ end
53
+ def self.update(body)
54
+ Transaction.update_plan(body)
77
55
  end
78
56
  end
79
57
 
80
58
 
81
59
  class PaystackSubscription
82
- def self.create_subscription(body)
83
- api = HTTParty.post("#{API::BASE_URL}" + "#{API::SUBSCRIPTION_PATH}",
84
- :body => body.to_json,
85
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
86
- return api
87
- end
88
- def self.list_subscription()
89
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::SUBSCRIPTION_PATH}",
90
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
91
- return api
92
- end
93
- def self.list_single_subscription(body)
94
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::SUBSCRIPTION_PATH}" + "#{body}",
95
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
96
- return api
97
- end
98
- def self.disable_subscription()
99
- api = HTTParty.post("#{API::BASE_URL}" + "#{API::SUBSCRIPTION_PATH}/" + "disable",
100
- :body => body.to_json,
101
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
102
- return api
103
- end
104
- def self.enable_subscription()
105
- api = HTTParty.post("#{API::BASE_URL}" + "#{API::SUBSCRIPTION_PATH}/" + "enable",
106
- :body => body.to_json,
107
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
108
- return api
60
+ def self.create(body)
61
+ Transaction.create_subscription(body)
62
+ end
63
+ def self.list
64
+ Transaction.list_subscription
65
+ end
66
+ def self.list_single(body)
67
+ Transaction.list_single_subscription(body)
68
+ end
69
+ def self.disable
70
+ Transaction.disable_subscription
71
+ end
72
+ def self.enable
73
+ Transaction.enable_subscription
109
74
  end
110
-
111
75
  end
112
76
 
113
77
  class PaystackTransfer
114
- def self.create_transfer_reciept(body)
115
- api = HTTParty.post("#{API::BASE_URL}" + "#{API::RECIPIENT_PATH}",
116
- :body => body.to_json,
117
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
118
- return api
119
- end
120
- def self.list_transfer_reciept(body)
121
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::RECIPIENT_PATH}",
122
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
123
- return api
124
- end
125
- def self.update_transfer_reciept(body, trf_code)
126
- api = HTTParty.put("#{API::BASE_URL}" + "#{API::RECIPIENT_PATH}" + "#{trf_code}",
127
- :body => body.to_json,
128
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
129
- return api
130
- end
131
- def self.init_transfer(body)
132
- api = HTTParty.post("#{API::BASE_URL}" + "#{API::TRANSFER_PATH}",
133
- :body => body.to_json,
134
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
135
- return api
136
- end
137
- def self.list_transfers(body)
138
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::TRANSFER_PATH}",
139
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
140
- return api
141
- end
142
- def self.finalize_transfers(body)
143
- api = HTTParty.post("#{API::BASE_URL}" + "#{API::TRANSFER_PATH}" + "/finalize_transfer",
144
- :body => body.to_json,
145
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
146
- return api
147
- end
148
- def self.resend_otp(body)
149
- api = HTTParty.post("#{API::BASE_URL}" + "#{API::TRANSFER_PATH}" + "/resend_otp",
150
- :body => body.to_json,
151
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
152
- return api
78
+ def self.generate(body)
79
+ Transaction.create_transfer_reciept(body)
80
+ end
81
+ def self.list_reciept
82
+ Transaction.list_transfer_reciept
83
+ end
84
+ def self.update_reciept(body, trf_code)
85
+ Transaction.update_transfer_reciept(body)
86
+ end
87
+ def self.initailize(body)
88
+ Transaction.init_transfer(body)
89
+ end
90
+ def self.list_transfer
91
+ Transaction.list_transfers
92
+ end
93
+ def self.finalize(body)
94
+ Transaction.finalize_transfers(body)
153
95
  end
154
-
155
96
  end
156
97
 
157
98
  class PaystackBank
158
- def self.banks()
159
- api = HTTParty.get("#{API::BASE_URL}" + "#{API::BANK_PATH}",
160
- :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
161
- return api
99
+ def self.list_banks
100
+ Transaction.banks
162
101
  end
163
102
  end
164
103
  end
@@ -0,0 +1,7 @@
1
+ module Bank
2
+ def self.banks
3
+ api = HTTParty.get("#{API::BASE_URL}" + "#{API::BANK_PATH}",
4
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
5
+ return api
6
+ end
7
+ end
File without changes
@@ -0,0 +1,18 @@
1
+ module Customer
2
+ def self.create_customer(body)
3
+ api = HTTParty.post("#{API::BASE_URL}" + "#{API::CUSTOMER_PATH}",
4
+ :body => body.to_json,
5
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
6
+ return api
7
+ end
8
+ def self.list_customer
9
+ api = HTTParty.get("#{API::BASE_URL}" + "#{API::CUSTOMER_PATH}",
10
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
11
+ return api
12
+ end
13
+ def self.fetch_a_customer(body)
14
+ api = HTTParty.get("#{API::BASE_URL}" + "#{API::CUSTOMER_PATH}/" + "#{body}",
15
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
16
+ return api
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ module Otp
2
+ def self.resend_otp(body)
3
+ api = HTTParty.post("#{API::BASE_URL}" + "#{API::TRANSFER_PATH}" + "/resend_otp",
4
+ :body => body.to_json,
5
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
6
+ return api
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ module Plan
2
+ def self.create_plan(body)
3
+ api = HTTParty.post("#{API::BASE_URL}" + "#{API::PLAN_PATH}",
4
+ :body => body.to_json,
5
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
6
+ return api
7
+ end
8
+ def self.list_plans
9
+ api = HTTParty.get("#{API::BASE_URL}" + "#{API::PLAN_PATH}",
10
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
11
+ return api
12
+ end
13
+ def self.list_single_plan(body)
14
+ api = HTTParty.get("#{API::BASE_URL}" + "#{API::PLAN_PATH}" + "#{body}",
15
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
16
+ return api
17
+ end
18
+ def self.update_plan(body)
19
+ api = HTTParty.put("#{API::BASE_URL}" + "#{API::PLAN_PATH}" + "#{body}",
20
+ :body => body.to_json,
21
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
22
+ return api
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ module Subscription
2
+ def self.create_subscription(body)
3
+ api = HTTParty.post("#{API::BASE_URL}" + "#{API::SUBSCRIPTION_PATH}",
4
+ :body => body.to_json,
5
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
6
+ return api
7
+ end
8
+ def self.list_subscription
9
+ api = HTTParty.get("#{API::BASE_URL}" + "#{API::SUBSCRIPTION_PATH}",
10
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
11
+ return api
12
+ end
13
+ def self.list_single_subscription(body)
14
+ api = HTTParty.get("#{API::BASE_URL}" + "#{API::SUBSCRIPTION_PATH}" + "#{body}",
15
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
16
+ return api
17
+ end
18
+ def self.disable_subscription
19
+ api = HTTParty.post("#{API::BASE_URL}" + "#{API::SUBSCRIPTION_PATH}/" + "disable",
20
+ :body => body.to_json,
21
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
22
+ return api
23
+ end
24
+ def self.enable_subscription
25
+ api = HTTParty.post("#{API::BASE_URL}" + "#{API::SUBSCRIPTION_PATH}/" + "enable",
26
+ :body => body.to_json,
27
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
28
+ return api
29
+ end
30
+ end
@@ -1,15 +1,15 @@
1
- class Transaction
1
+ module Transaction
2
2
  def self.verify_payment(body)
3
3
  api = HTTParty.get("#{API::BASE_URL}" + "#{API::TRANSACTION_PATH}" + "/verify/#{body}",
4
4
  :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
5
5
  return api
6
6
  end
7
- def self.list_transactions()
7
+ def self.list_transactions
8
8
  api = HTTParty.get("#{API::BASE_URL}" + "#{API::TRANSACTION_PATH}",
9
9
  :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
10
10
  return api
11
11
  end
12
- def self.list_transaction_totals()
12
+ def self.list_transaction_totals
13
13
  api = HTTParty.get("#{API::BASE_URL}" + "#{API::TRANSACTION_PATH}/" + "totals",
14
14
  :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
15
15
  return api
@@ -24,5 +24,5 @@ class Transaction
24
24
  :body => body.to_json,
25
25
  :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
26
26
  return api
27
- end
27
+ end
28
28
  end
@@ -0,0 +1,36 @@
1
+ module Transfer
2
+ def self.create_transfer_reciept(body)
3
+ api = HTTParty.post("#{API::BASE_URL}" + "#{API::RECIPIENT_PATH}",
4
+ :body => body.to_json,
5
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
6
+ return api
7
+ end
8
+ def self.list_transfer_reciept
9
+ api = HTTParty.get("#{API::BASE_URL}" + "#{API::RECIPIENT_PATH}",
10
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
11
+ return api
12
+ end
13
+ def self.update_transfer_reciept(body, trf_code)
14
+ api = HTTParty.put("#{API::BASE_URL}" + "#{API::RECIPIENT_PATH}" + "#{trf_code}",
15
+ :body => body.to_json,
16
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
17
+ return api
18
+ end
19
+ def self.init_transfer(body)
20
+ api = HTTParty.post("#{API::BASE_URL}" + "#{API::TRANSFER_PATH}",
21
+ :body => body.to_json,
22
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
23
+ return api
24
+ end
25
+ def self.list_transfers
26
+ api = HTTParty.get("#{API::BASE_URL}" + "#{API::TRANSFER_PATH}",
27
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
28
+ return api
29
+ end
30
+ def self.finalize_transfers(body)
31
+ api = HTTParty.post("#{API::BASE_URL}" + "#{API::TRANSFER_PATH}" + "/finalize_transfer",
32
+ :body => body.to_json,
33
+ :headers => { "Authorization"=> ENV["PAYSTACK_SECRET_KEY"], "content-type" => "application/json"})
34
+ return api
35
+ end
36
+ end
@@ -1,3 +1,3 @@
1
1
  module Paystackapi
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paystackapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Joseph
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-01 00:00:00.000000000 Z
11
+ date: 2019-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,12 +94,18 @@ extensions: []
94
94
  extra_rdoc_files: []
95
95
  files:
96
96
  - CODE_OF_CONDUCT.md
97
- - LICENSE.txt
97
+ - LICENSE.md
98
98
  - README.md
99
99
  - lib/paystackapi.rb
100
- - lib/paystackapi/base.rb
101
- - lib/paystackapi/transaction.rb
102
- - lib/paystackapi/version.rb
100
+ - lib/paystackapi/core/bank.rb
101
+ - lib/paystackapi/core/base.rb
102
+ - lib/paystackapi/core/customer.rb
103
+ - lib/paystackapi/core/otp.rb
104
+ - lib/paystackapi/core/plan.rb
105
+ - lib/paystackapi/core/subscription.rb
106
+ - lib/paystackapi/core/transaction.rb
107
+ - lib/paystackapi/core/transfer.rb
108
+ - lib/paystackapi/core/version.rb
103
109
  homepage: https://github.com/samuel52/PaystackRubyApi.git
104
110
  licenses:
105
111
  - MIT