payoneer-ruby 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 988a5c0a2f12c8219f953c5ecdbf2088d81a67bc
4
- data.tar.gz: 89d4cbe6d5b5002c4b30f6230e8d128d843170fb
3
+ metadata.gz: 1754950672d279745fef0971068e24908bf5b6e5
4
+ data.tar.gz: fe79e44015d50ce11aa406dc11cd7d90941a8e92
5
5
  SHA512:
6
- metadata.gz: 087a2159e56f333de854a1b59c69ccef349b9b1c8bcee3f2fc856faaa262c6b0e790e19171a300acfa900b5e1a34c7f9d44eea27c3bab88d75dda6bbc14682ed
7
- data.tar.gz: bc66c7806d5601c489a11c692efee63bb2ab7bcaa594a9bbe274dfcb5117fab2976a40825dd1da60aea79232cd87195aaa9fb9dc87c544b58abb0c136610a41e
6
+ metadata.gz: 646ce920c9031711512d5be056ece6633bad156a27a9c3b29913c96b1df1680ee899d7fd10480ce6408d0cf1474acdca12464adc991c91be82e67472353704ae
7
+ data.tar.gz: 2f38bd2d19cd9e106d96dadda837d91d88c8c5e0df7d19a4497d963eefa5acfed13569da2f4e917219248d8d0bf0922567e99e2d517febd5c7ddf1373f1cff56
data/README.md CHANGED
@@ -1,9 +1,3 @@
1
- # Payoneer::Ruby
2
-
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/payoneer/ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
1
  ## Installation
8
2
 
9
3
  Add this line to your application's Gemfile:
@@ -22,11 +16,50 @@ Or install it yourself as:
22
16
 
23
17
  ## Usage
24
18
 
25
- TODO: Write usage instructions here
19
+ ```ruby
20
+ # Configuration
21
+ Payoneer.configure do |c|
22
+ c.environment = 'production'
23
+ c.partner_id = '<payoneer_account_id>'
24
+ c.partner_username = '<payoneer_account_username>'
25
+ c.partner_api_password = '<payoneer_api_password>'
26
+ c.auto_approve_sandbox_accounts = true # if you want sandbox accounts to be automatically approved after signup
27
+ end
28
+
29
+ # Check Payoneer API status. See Payoneer documentation for possible error codes
30
+ response = Payoneer::System.status
31
+ response.code
32
+ => "000"
33
+ response.body
34
+ => "Echo OK - All systems are up"
35
+ response.ok?
36
+ => true
37
+
38
+ # Get Payee Signup URL
39
+ Payoneer::Payee.signup_url('payee_1')
40
+ Payoneer::Payee.signup_url('payee_1', redirect_url: 'http://<redirect_url>.com')
41
+ Payoneer::Payee.signup_url('payee_1', redirect_url: 'http://<redirect_url>.com', redirect_time: 10) #seconds
42
+
43
+ response = Payoneer::Payee.signup_url('payee_1')
44
+ signup_url = response.body if response.ok?
45
+
46
+ # Perform Payout for Payee
47
+ response = Payoneer::Payout.create(
48
+ program_id: '<payoneer_program_id>',
49
+ payment_id: 'payment_1',
50
+ payee_id: 'payee_1',
51
+ amount: 4.20,
52
+ description: 'payee payout',
53
+ payment_date: Time.now, #defaults to Time.now
54
+ currency: 'USD' #defaults to USD
55
+ )
56
+
57
+ p 'Payout created!' if response.ok?
58
+ ```
26
59
 
27
60
  ## Development
28
61
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
62
+ After checking out the repo, run `bin/console` for an interactive prompt that will allow you to experiment.
30
63
 
31
64
  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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
65
 
@@ -21,20 +21,16 @@ require 'payoneer/errors/unexpected_response_error'
21
21
  require 'payoneer/errors/configuration_error'
22
22
 
23
23
  module Payoneer
24
- class << self
25
- attr_accessor :configuration
26
- end
27
-
28
24
  def self.configure
29
- yield(_configuration)
25
+ yield(configuration)
30
26
  end
31
27
 
32
28
  def self.make_api_request(method_name, params = {})
33
- _configuration.validate!
29
+ configuration.validate!
34
30
 
35
31
  request_params = default_params.merge(mname: method_name).merge(params)
36
32
 
37
- response = RestClient.post(_configuration.api_url, request_params)
33
+ response = RestClient.post(configuration.api_url, request_params)
38
34
 
39
35
  fail Errors::UnexpectedResponseError.new(response.code, response.body) unless response.code == 200
40
36
 
@@ -43,17 +39,15 @@ module Payoneer
43
39
  inner_content
44
40
  end
45
41
 
46
- private
47
-
48
- def self._configuration
49
- self.configuration ||= Configuration.new
42
+ def self.configuration
43
+ @configuration ||= Configuration.new
50
44
  end
51
45
 
52
46
  def self.default_params
53
47
  {
54
- p1: _configuration.partner_username,
55
- p2: _configuration.partner_api_password,
56
- p3: _configuration.partner_id,
48
+ p1: configuration.partner_username,
49
+ p2: configuration.partner_api_password,
50
+ p3: configuration.partner_id,
57
51
  }
58
52
  end
59
53
  end
@@ -5,14 +5,23 @@ module Payoneer
5
5
  DEVELOPMENT_API_URL = 'https://api.sandbox.payoneer.com/Payouts/HttpApi/API.aspx?'
6
6
  PRODUCTION_API_URL = 'https://api.payoneer.com/Payouts/HttpApi/API.aspx?'
7
7
 
8
- attr_accessor :environment, :partner_id, :partner_username, :partner_api_password
8
+ attr_accessor :environment, :partner_id, :partner_username, :partner_api_password, :auto_approve_sandbox_accounts
9
9
 
10
10
  def initialize
11
11
  @environment = DEVELOPMENT_ENVIRONMENT
12
+ @auto_approve_sandbox_accounts = false
13
+ end
14
+
15
+ def production?
16
+ environment == PRODUCTION_ENVIRONMENT
12
17
  end
13
18
 
14
19
  def api_url
15
- environment == PRODUCTION_ENVIRONMENT ? PRODUCTION_API_URL : DEVELOPMENT_API_URL
20
+ production? ? PRODUCTION_API_URL : DEVELOPMENT_API_URL
21
+ end
22
+
23
+ def auto_approve_sandbox_accounts?
24
+ !production? && auto_approve_sandbox_accounts
16
25
  end
17
26
 
18
27
  def validate!
@@ -9,7 +9,8 @@ module Payoneer
9
9
  p4: payee_id,
10
10
  p6: redirect_url,
11
11
  p8: redirect_time,
12
- p10: true, #returns an xml response
12
+ p9: Payoneer.configuration.auto_approve_sandbox_accounts?,
13
+ p10: true, # returns an xml response
13
14
  }
14
15
 
15
16
  response = Payoneer.make_api_request(SIGNUP_URL_API_METHOD_NAME, payoneer_params)
@@ -1,3 +1,3 @@
1
1
  module Payoneer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payoneer-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tieshun Roquerre
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-05-04 00:00:00.000000000 Z
12
+ date: 2015-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client