remitano 1.5.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile.lock +97 -55
  4. data/README.md +57 -17
  5. data/lib/remitano/client/merchant_charges.rb +28 -4
  6. data/lib/remitano/client/merchant_withdrawals.rb +16 -2
  7. data/lib/remitano/client/net.rb +15 -5
  8. data/lib/remitano/version.rb +1 -1
  9. data/remitano.gemspec +1 -1
  10. data/spec/client/merchant_charges_spec.rb +84 -7
  11. data/spec/client/merchant_withdrawals_spec.rb +39 -0
  12. data/spec/client/net_spec.rb +57 -0
  13. data/spec/fixtures/vcr_cassettes/Remitano_Client_merchant_charges/_create/valid_params_currency_is_coin/returns_created_charge.yml +55 -0
  14. data/spec/fixtures/vcr_cassettes/Remitano_Client_merchant_charges/_create/valid_params_currency_is_fiat/returns_created_charge.yml +55 -0
  15. data/spec/fixtures/vcr_cassettes/Remitano_Client_merchant_charges/_list/filter_by_status/returns_status_matched_merchant_charges.yml +48 -0
  16. data/spec/fixtures/vcr_cassettes/Remitano_Client_merchant_charges/_list/page_and_per_page_specified/returns_merchant_charges_in_specified_page.yml +48 -0
  17. data/spec/fixtures/vcr_cassettes/Remitano_Client_merchant_charges/_list/returns_merchant_charges.yml +69 -0
  18. data/spec/fixtures/vcr_cassettes/Remitano_Client_merchant_withdrawals/_list/filter_by_status/returns_status_matched_merchant_withdrawals.yml +48 -0
  19. data/spec/fixtures/vcr_cassettes/Remitano_Client_merchant_withdrawals/_list/page_and_per_page_specified/returns_merchant_withdrawals_in_specified_page.yml +48 -0
  20. data/spec/fixtures/vcr_cassettes/Remitano_Client_merchant_withdrawals/_list/returns_merchant_withdrawals.yml +48 -0
  21. metadata +14 -6
  22. data/spec/fixtures/vcr_cassettes/Remitano_Client_merchant_charges/_create/valid_params/returns_created_charge.yml +0 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd1f544b9323fc82089e1541a286b96bcef386d81b13fd004b998a4033b0d07a
4
- data.tar.gz: 568bfa758b7c634b3d198b50c4b1e4d50de585175ef04748691f41c547221ed2
3
+ metadata.gz: 24e8c36290375607bbe4756eb87a067b83aad43d65cb2a17fc9c609f786c28b1
4
+ data.tar.gz: 907e3d596439e7cdbc9a6532465f8cb3f0150a6aa83a12b6704e6707907d43cf
5
5
  SHA512:
6
- metadata.gz: 6c5fcb59a0e5d9cae326351b197ab896c340d49f761e1e6e41ecb237ea22cb416b64d99735b02ca0fe89f5977761ae8029d4f9d3616c7ca064755f740e3bbdaf
7
- data.tar.gz: a09249bd663fc9ea826c60f09672ab897fa8b79b04401f411f2ff6ab6169db05001ea940757891ead3586b281b14d557501b519407db7c26f4c6d5281073d368
6
+ metadata.gz: 200294dd5c029dd351a74cfaf5e008ac1eca68c2d50022a400c725dead107d7d3d4cd9322a6fabb73bf4ee2396d698aca0c9309128a93c6912a54b157faa5470
7
+ data.tar.gz: 229c0dcd269e2826a097ded83a8d3cb96979b46d758716ada0c705be4a38b8dfc576e369cb8f6f040ed16f99e3feccdde84724603374a7e47ddeb4323d314330
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  .env
2
2
  tags
3
+
4
+ .byebug_history
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- remitano (1.5.1)
4
+ remitano (1.7.0)
5
5
  activesupport (>= 4.2.10)
6
6
  api-auth (~> 2.1.0)
7
7
  hashie
@@ -12,94 +12,136 @@ PATH
12
12
  GEM
13
13
  remote: http://rubygems.org/
14
14
  specs:
15
- activesupport (5.2.5)
15
+ activesupport (5.2.6)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 0.7, < 2)
18
18
  minitest (~> 5.1)
19
19
  tzinfo (~> 1.1)
20
- addressable (2.5.2)
21
- public_suffix (>= 2.0.2, < 4.0)
20
+ addressable (2.7.0)
21
+ public_suffix (>= 2.0.2, < 5.0)
22
22
  api-auth (2.1.0)
23
- ast (2.4.0)
24
- byebug (3.5.1)
25
- columnize (~> 0.8)
26
- debugger-linecache (~> 1.2)
27
- slop (~> 3.6)
28
- columnize (0.9.0)
29
- concurrent-ruby (1.1.8)
30
- crack (0.4.3)
31
- safe_yaml (~> 1.0.0)
32
- debugger-linecache (1.2.0)
33
- diff-lcs (1.3)
23
+ ast (2.4.2)
24
+ builder (3.2.4)
25
+ byebug (11.1.3)
26
+ concurrent-ruby (1.1.9)
27
+ crack (0.4.5)
28
+ rexml
29
+ descendants_tracker (0.0.4)
30
+ thread_safe (~> 0.3, >= 0.3.1)
31
+ diff-lcs (1.4.4)
34
32
  domain_name (0.5.20190701)
35
33
  unf (>= 0.0.5, < 1.0.0)
36
- dotenv (2.0.0)
37
- git (1.2.5)
38
- hashdiff (0.3.7)
39
- hashie (4.1.0)
34
+ dotenv (2.0.2)
35
+ faraday (1.4.2)
36
+ faraday-em_http (~> 1.0)
37
+ faraday-em_synchrony (~> 1.0)
38
+ faraday-excon (~> 1.1)
39
+ faraday-net_http (~> 1.0)
40
+ faraday-net_http_persistent (~> 1.1)
41
+ multipart-post (>= 1.2, < 3)
42
+ ruby2_keywords (>= 0.0.4)
43
+ faraday-em_http (1.0.0)
44
+ faraday-em_synchrony (1.0.0)
45
+ faraday-excon (1.1.0)
46
+ faraday-net_http (1.0.1)
47
+ faraday-net_http_persistent (1.1.0)
48
+ git (1.8.1)
49
+ rchardet (~> 1.8)
50
+ github_api (0.19.0)
51
+ addressable (~> 2.4)
52
+ descendants_tracker (~> 0.0.4)
53
+ faraday (>= 0.8, < 2)
54
+ hashie (~> 3.5, >= 3.5.2)
55
+ oauth2 (~> 1.0)
56
+ hashdiff (1.0.1)
57
+ hashie (3.6.0)
58
+ highline (2.0.3)
59
+ http-accept (1.7.0)
40
60
  http-cookie (1.0.3)
41
61
  domain_name (~> 0.5)
42
62
  i18n (1.8.10)
43
63
  concurrent-ruby (~> 1.0)
44
- jaro_winkler (1.5.1)
45
- jeweler (1.8.4)
46
- bundler (~> 1.0)
64
+ jeweler (2.0.1)
65
+ builder
66
+ bundler (>= 1.0)
47
67
  git (>= 1.2.5)
68
+ github_api
69
+ highline (>= 1.6.15)
70
+ nokogiri (>= 1.5.10)
48
71
  rake
49
72
  rdoc
50
73
  json (1.8.6)
51
- mime-types (3.2.2)
74
+ jwt (2.2.3)
75
+ mime-types (3.3.1)
52
76
  mime-types-data (~> 3.2015)
53
- mime-types-data (3.2018.0812)
77
+ mime-types-data (3.2021.0225)
78
+ mini_portile2 (2.4.0)
54
79
  minitest (5.14.4)
80
+ multi_json (1.15.0)
81
+ multi_xml (0.6.0)
82
+ multipart-post (2.1.1)
55
83
  netrc (0.11.0)
56
- parallel (1.12.1)
57
- parser (2.5.3.0)
58
- ast (~> 2.4.0)
59
- powerpack (0.1.2)
60
- public_suffix (3.0.2)
84
+ nokogiri (1.10.10)
85
+ mini_portile2 (~> 2.4.0)
86
+ oauth2 (1.4.7)
87
+ faraday (>= 0.8, < 2.0)
88
+ jwt (>= 1.0, < 3.0)
89
+ multi_json (~> 1.3)
90
+ multi_xml (~> 0.5)
91
+ rack (>= 1.2, < 3)
92
+ parallel (1.20.1)
93
+ parser (3.0.1.1)
94
+ ast (~> 2.4.1)
95
+ public_suffix (4.0.6)
96
+ rack (2.2.3)
61
97
  rainbow (3.0.0)
62
- rake (10.0.4)
98
+ rake (13.0.3)
99
+ rchardet (1.8.0)
63
100
  rdoc (3.12.2)
64
101
  json (~> 1.4)
65
- rest-client (2.0.2)
102
+ regexp_parser (2.1.1)
103
+ rest-client (2.1.0)
104
+ http-accept (>= 1.7.0, < 2.0)
66
105
  http-cookie (>= 1.0.2, < 2.0)
67
106
  mime-types (>= 1.16, < 4.0)
68
107
  netrc (~> 0.8)
108
+ rexml (3.2.5)
69
109
  rotp (6.2.0)
70
- rspec (3.8.0)
71
- rspec-core (~> 3.8.0)
72
- rspec-expectations (~> 3.8.0)
73
- rspec-mocks (~> 3.8.0)
74
- rspec-core (3.8.0)
75
- rspec-support (~> 3.8.0)
76
- rspec-expectations (3.8.1)
110
+ rspec (3.10.0)
111
+ rspec-core (~> 3.10.0)
112
+ rspec-expectations (~> 3.10.0)
113
+ rspec-mocks (~> 3.10.0)
114
+ rspec-core (3.10.1)
115
+ rspec-support (~> 3.10.0)
116
+ rspec-expectations (3.10.1)
77
117
  diff-lcs (>= 1.2.0, < 2.0)
78
- rspec-support (~> 3.8.0)
79
- rspec-mocks (3.8.0)
118
+ rspec-support (~> 3.10.0)
119
+ rspec-mocks (3.10.2)
80
120
  diff-lcs (>= 1.2.0, < 2.0)
81
- rspec-support (~> 3.8.0)
82
- rspec-support (3.8.0)
83
- rubocop (0.60.0)
84
- jaro_winkler (~> 1.5.1)
121
+ rspec-support (~> 3.10.0)
122
+ rspec-support (3.10.2)
123
+ rubocop (1.12.1)
85
124
  parallel (~> 1.10)
86
- parser (>= 2.5, != 2.5.1.1)
87
- powerpack (~> 0.1)
125
+ parser (>= 3.0.0.0)
88
126
  rainbow (>= 2.2.2, < 4.0)
127
+ regexp_parser (>= 1.8, < 3.0)
128
+ rexml
129
+ rubocop-ast (>= 1.2.0, < 2.0)
89
130
  ruby-progressbar (~> 1.7)
90
- unicode-display_width (~> 1.4.0)
131
+ unicode-display_width (>= 1.4.0, < 3.0)
132
+ rubocop-ast (1.4.1)
133
+ parser (>= 2.7.1.5)
91
134
  ruby-hmac (0.4.0)
92
- ruby-progressbar (1.10.0)
93
- safe_yaml (1.0.4)
94
- slop (3.6.0)
95
- thor (0.20.0)
135
+ ruby-progressbar (1.11.0)
136
+ ruby2_keywords (0.0.4)
137
+ thor (1.1.0)
96
138
  thread_safe (0.3.6)
97
139
  tzinfo (1.2.9)
98
140
  thread_safe (~> 0.1)
99
141
  unf (0.1.4)
100
142
  unf_ext
101
143
  unf_ext (0.0.7.7)
102
- unicode-display_width (1.4.0)
144
+ unicode-display_width (2.0.0)
103
145
  vcr (4.0.0)
104
146
  webmock (3.3.0)
105
147
  addressable (>= 2.3.6)
@@ -107,13 +149,13 @@ GEM
107
149
  hashdiff
108
150
 
109
151
  PLATFORMS
110
- ruby
152
+ x86_64-darwin-18
111
153
 
112
154
  DEPENDENCIES
113
155
  bundler
114
156
  byebug
115
157
  dotenv (~> 2.0.0)
116
- jeweler (~> 1.8.4)
158
+ jeweler (~> 2.0.0)
117
159
  rdoc (~> 3.12)
118
160
  remitano!
119
161
  rspec
@@ -124,4 +166,4 @@ DEPENDENCIES
124
166
  webmock (~> 3.3.0)
125
167
 
126
168
  BUNDLED WITH
127
- 1.17.3
169
+ 2.2.19
data/README.md CHANGED
@@ -37,7 +37,7 @@ Remitano::Client.default # => the default client
37
37
  ```
38
38
  or
39
39
  ```ruby
40
- client = new Remitano::Client(
40
+ client = Remitano::Client.new(
41
41
  key: YOUR_API_KEY,
42
42
  secret: YOUR_API_SECRET,
43
43
  authenticator_secret: YOUR_AUTHENTICATOR_SECRET,
@@ -47,26 +47,47 @@ client = new Remitano::Client(
47
47
  ### Payment gateway
48
48
  Visit https://developers.remitano.com/api-explorer - Merchant section for more information.
49
49
  #### Charges
50
- ##### Get
50
+ ##### Get charge with remitano id
51
51
  ```ruby
52
52
  client.merchant_charges.get(id)
53
53
  ```
54
- ##### Create
54
+ ##### Create charge
55
+ 1. With coin currency
56
+ Note: For now, we only support `usdt` as the price coin currency.
55
57
  ```ruby
56
58
  client.merchant_charges.create(
57
59
  coin_currency: "usdt",
58
60
  coin_amount: 10.99,
59
- cancelled_or_completed_callback_url: "https://example.com/payments/callback?id=example"
61
+ cancelled_or_completed_callback_url: "https://example.com/payments/callback?id=example", # optional
62
+ description: "Example charge" # optional
63
+ )
64
+ ```
65
+ 2. With fiat currency
66
+ Note: We support fiat currency of 56 countries that Remitano are supporting, i.e., `USD`, `AUD`. (You could find entire list in our [developer docs](https://developers.remitano.com/docs/getting-started/getting-started)).
67
+ ```ruby
68
+ client.merchant_charges.create(
69
+ fiat_currency: "AUD",
70
+ fiat_amount: 10.99,
71
+ cancelled_or_completed_callback_url: "https://example.com/payments/callback?id=example", # optional
72
+ description: "Example charge" # optional
73
+ )
74
+ ```
75
+
76
+ ##### Get paginated charge list
77
+ ```ruby
78
+ client.merchant_charges.list(
79
+ status: "completed", # optional
80
+ page: 2, # optional
81
+ per_page: 25 # optional
60
82
  )
61
83
  ```
62
- Note: For now, we only support `usdt` as the price coin currency.
63
84
 
64
85
  #### Withdrawals
65
- ##### Get
86
+ ##### Get withdrawal with remitano id
66
87
  ```ruby
67
88
  client.merchant_withdrawals.get(id)
68
89
  ```
69
- ##### Create
90
+ ##### Create withdrawal
70
91
  1. Withdraw to external coin address
71
92
  ```ruby
72
93
  client.merchant_withdrawals.create(
@@ -74,9 +95,9 @@ client.merchant_withdrawals.create(
74
95
  coin_currency: "xrp",
75
96
  coin_amount: 10.99,
76
97
  receiver_pay_fee: true, # defines who will be charged for the withdrawal fee
77
- cancelled_or_completed_callback_url: "http://sample.com/123/callback",
98
+ cancelled_or_completed_callback_url: "http://sample.com/123/callback", # optional
78
99
  coin_address: "rLpumSZQNJ6Cve7hfQcdkG9rJbJhkSV8AD0",
79
- destination_tag: 1710676231 # include destination_tag if coin_currency is xrp, otherwise, leave it nil
100
+ destination_tag: 1710676231 # optional, required when coin_currency is xrp
80
101
  )
81
102
  ```
82
103
  2. Withdraw to other remitano account
@@ -91,20 +112,39 @@ client.merchant_withdrawals.create(
91
112
  remitano_phone_number: "+234 1 123 4567"
92
113
  )
93
114
  ```
94
-
95
- #### Callbacks
96
- When Charge or Withdrawal is changed to completed or cancelled in our system, we will send
97
- a POST callback request to `object.cancelled_or_completed_callback_url` with following
98
- request json body:
115
+ ##### Get paginated withdrawal list
99
116
  ```ruby
100
- { "id" => object.id }
117
+ client.merchant_withdrawals.list(
118
+ status: "completed", # optional
119
+ page: 2, # optional
120
+ per_page: 25 # optional
121
+ )
101
122
  ```
102
- then you could call `client.merchant_charges.get(id)` or `client.merchant_withdrawals.get(id)`
103
- to get the updated information and process accordingly.
123
+
124
+ #### Callbacks
125
+ ##### Charges
126
+ Whenever a charge is changed to completed or cancelled in our system:
127
+ - we will send a POST request to `charge.cancelled_or_completed_callback_url` with `remitano_id` param.
128
+ - if user is still on our site, we will also redirect user to `object.cancelled_or_completed_callback_url` with `remitano_id` param (GET request).
129
+
130
+ After receiving these callbacks, you could call `client.merchant_charges.get(params[:remitano_id])` to get the updated information and process accordingly.
131
+
132
+ ##### Withdrawals
133
+ Whenever a withdrawal is changed to completed or cancelled in our system:
134
+ - we will send a POST request to `withdrawal.cancelled_or_completed_callback_url` with `remitano_id` param.
135
+
136
+ After receiving these callbacks, you could call `client.merchant_withdrawals.get(params[:remitano_id])` to get the updated information and process accordingly.
104
137
 
105
138
  ### Errors
106
139
  When receiving non 200-299 http code, a Remitano::Client::Request::RequestError will be raised.
107
140
 
141
+ ### Sandbox testing
142
+ We have a Testnet at https://remidemo.com.
143
+
144
+ You could register an account there, then submit a request at [this google form](https://forms.gle/jvJyWPBNwTWfowSm9) with your Remidemo username, so we could help to setup your testing account as a merchant.
145
+
146
+ After that, you could start your sandbox testing by setting `ENV["REMITANO_SANDBOX"]` to `"true"`.
147
+
108
148
  ## Contributing
109
149
 
110
150
  1. Fork it
@@ -12,12 +12,36 @@ module Remitano
12
12
  config.net.get("/merchant/merchant_charges/#{id}").execute
13
13
  end
14
14
 
15
- def create(coin_currency:, coin_amount:, cancelled_or_completed_callback_url:)
16
- config.net.post(
17
- "/merchant/merchant_charges",
15
+ def create(
16
+ coin_currency: nil, coin_amount: nil,
17
+ fiat_currency: nil, fiat_amount: nil,
18
+ cancelled_or_completed_callback_url: nil, description: nil
19
+ )
20
+ params = {
18
21
  coin_currency: coin_currency,
19
22
  coin_amount: coin_amount,
20
- cancelled_or_completed_callback_url: cancelled_or_completed_callback_url
23
+ fiat_currency: fiat_currency,
24
+ fiat_amount: fiat_amount,
25
+ cancelled_or_completed_callback_url: cancelled_or_completed_callback_url,
26
+ description: description
27
+ }
28
+ params.reject! { |_k, v| v.nil? }
29
+ config.net.post(
30
+ "/merchant/merchant_charges",
31
+ params
32
+ ).execute
33
+ end
34
+
35
+ def list(status: nil, page: nil, per_page: nil)
36
+ params = {
37
+ status: status,
38
+ page: page,
39
+ per_page: per_page
40
+ }
41
+ params.reject! { |_k, v| v.nil? }
42
+ config.net.get(
43
+ "/merchant/merchant_charges",
44
+ params
21
45
  ).execute
22
46
  end
23
47
  end
@@ -13,8 +13,9 @@ module Remitano
13
13
  end
14
14
 
15
15
  def create(
16
- merchant_withdrawal_ref:, coin_currency:, coin_amount:, receiver_pay_fee:, cancelled_or_completed_callback_url:,
17
- coin_address: nil, destination_tag: nil, remitano_username: nil, remitano_phone_number: nil
16
+ merchant_withdrawal_ref:, coin_currency:, coin_amount:, receiver_pay_fee:,
17
+ cancelled_or_completed_callback_url: nil, coin_address: nil, destination_tag: nil,
18
+ remitano_username: nil, remitano_phone_number: nil
18
19
  )
19
20
  withdrawal = config.net.post(
20
21
  "/merchant/merchant_withdrawals",
@@ -34,5 +35,18 @@ module Remitano
34
35
 
35
36
  withdrawal
36
37
  end
38
+
39
+ def list(status: nil, page: nil, per_page: nil)
40
+ params = {
41
+ status: status,
42
+ page: page,
43
+ per_page: per_page
44
+ }
45
+ params.reject! { |_k, v| v.nil? }
46
+ config.net.get(
47
+ "/merchant/merchant_withdrawals",
48
+ params
49
+ ).execute
50
+ end
37
51
  end
38
52
  end
@@ -1,4 +1,6 @@
1
- require 'api-auth'
1
+ # frozen_string_literal: true
2
+
3
+ require "api-auth"
2
4
 
3
5
  module Remitano
4
6
  class Client::Request
@@ -22,16 +24,20 @@ module Remitano
22
24
  class Client::Net
23
25
  attr_reader :config
24
26
 
27
+ REMITANO_PRODUCTION_SERVER = "https://api.remitano.com"
28
+ REMITANO_SANDBOX_SERVER = "https://api.remidemo.com"
29
+
25
30
  def initialize(config:)
26
31
  @config = config
27
32
  end
28
33
 
29
34
  def self.to_uri(path)
30
- return "#{server}/api/v1#{path}"
35
+ "#{server}/api/v1#{path}"
31
36
  end
32
37
 
33
38
  def self.server
34
- @server ||= (ENV['REMITANO_SERVER'] || "https://api.remitano.com")
39
+ ENV["REMITANO_SERVER"] ||
40
+ (ENV["REMITANO_SANDBOX"] == "true" ? REMITANO_SANDBOX_SERVER : REMITANO_PRODUCTION_SERVER)
35
41
  end
36
42
 
37
43
  def self.public_get(path, params = {})
@@ -79,8 +85,12 @@ module Remitano
79
85
 
80
86
  usec = Time.now.usec
81
87
  if method == :get
82
- path += (path.include?("?") ? "&" : "?")
83
- path += "usec=#{usec}"
88
+ uri = URI(path)
89
+ request_params = URI.decode_www_form(uri.query || "")
90
+ request_params.concat(params.to_a)
91
+ request_params << ["usec", usec]
92
+ uri.query = URI.encode_www_form(request_params)
93
+ path = uri.to_s
84
94
  else
85
95
  params[:usec] = usec
86
96
  options[:payload] = params.to_json