vivapayapi 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b0bc11453875aad29fe37056d4edef684df950e
4
+ data.tar.gz: 08eb2d00952f60a293c3f8e5d1fe3284c443e258
5
+ SHA512:
6
+ metadata.gz: 74148e418249a5b578059fe860a476313c2bf92ce621223cccc0e115c4ee5c9b170128e48ac90ffa705636e8977d7af3698eb486b6ce798f8741cbaebc78b019
7
+ data.tar.gz: 2bb216734c82663a07e63eafdbc429adfb1b650cb973d1e3a41b0dd6e8e9b09a9a4131fe2c43f66a0b070a33c9e2722409e597498d3e03445b3d6151c7dc1a22
data/.gitignore ADDED
@@ -0,0 +1,47 @@
1
+ <<<<<<< HEAD
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ =======
12
+ *.rbc
13
+ capybara-*.html
14
+ .rspec
15
+ /log
16
+ /tmp
17
+ /db/*.sqlite3
18
+ /db/*.sqlite3-journal
19
+ /public/system
20
+ /coverage/
21
+ /spec/tmp
22
+ **.orig
23
+ rerun.txt
24
+ pickle-email-*.html
25
+
26
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
27
+ config/initializers/secret_token.rb
28
+ config/secrets.yml
29
+
30
+ ## Environment normalisation:
31
+ /.bundle
32
+ /vendor/bundle
33
+
34
+ # these should all be checked in to normalise the environment:
35
+ # Gemfile.lock, .ruby-version, .ruby-gemset
36
+
37
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
38
+ .rvmrc
39
+
40
+ # if using bower-rails ignore default bower_components path bower.json files
41
+ /vendor/assets/bower_components
42
+ *.bowerrc
43
+ bower.json
44
+
45
+ # Ignore pow environment settings
46
+ .powenv
47
+ >>>>>>> eaccfe54f114bc9276bd87b424079d4108fc2891
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vivapayapi.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 apoeco
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 all
13
+ 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 THE
21
+ SOFTWARE.
22
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Apostolis Economou
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,49 @@
1
+ # Vivapayapi
2
+
3
+ Wrapper for VivaPayments Pay with VivaWallet solution.
4
+ Caution:
5
+ Work in progress.
6
+ Demo mode only for now!
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'vivapayapi'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install vivapayapi
23
+
24
+ ## Usage
25
+ ```ruby
26
+ transaction = VivaPayAPI::Transaction.new("your_merchant_id_here","your_api_key_here")
27
+ transaction.capture("your_vivaWalletToken_here")
28
+
29
+ transaction.successful? #Returns returns true if error code equals to 0, nil if capture failed
30
+ transaction.transaction_id #Returns the transactions id, nil if capture failed
31
+ transaction.status #Returns the transactions status, nil if capture failed
32
+ transaction.amount #Returns the transactions amount, nil if capture failed
33
+ transaction.error_text #Returns the captures error text, nil if capture didnt happen
34
+ transaction.error_code #Returns the captures error code, nil if capture didnt happen
35
+ transaction.response #Returns the captures parsed response from HTTParty, nil if capture didnt happen
36
+ ```
37
+ ## Development
38
+
39
+ 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.
40
+
41
+ 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).
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/apoeco/vivapayapi/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "vivapayapi"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module Vivapayapi
2
+ VERSION = "0.1.0"
3
+ end
data/lib/vivapayapi.rb ADDED
@@ -0,0 +1,69 @@
1
+ require "vivapayapi/version"
2
+ require 'httparty'
3
+
4
+ module VivaPayAPI
5
+ class Transaction
6
+ include HTTParty
7
+ base_uri "http://demo.vivapayments.com/api/"
8
+
9
+ def initialize(username, password)
10
+ @auth = {:username => username , :password => password }
11
+ end
12
+
13
+ def capture(token)
14
+ @response = self.class.post("/transactions",
15
+ :basic_auth => @auth,
16
+ :body => {
17
+ :PaymentToken => token}.to_json,
18
+ :headers => { 'Content-Type' => 'application/json' },
19
+ :debug_output => $stdout).parsed_response
20
+ return @response
21
+ end
22
+
23
+ def transaction_id
24
+ unless @response.nil?
25
+ return @response["TransactionId"]
26
+ end
27
+ return nil
28
+ end
29
+
30
+ def status
31
+ unless @response.nil?
32
+ return @response["StatusId"]
33
+ end
34
+ return nil
35
+ end
36
+
37
+ def amount
38
+ unless @response.nil?
39
+ @response["Amount"]
40
+ end
41
+ return nil
42
+ end
43
+
44
+ def error_text
45
+ unless @response.nil?
46
+ return @response["ErrorText"]
47
+ end
48
+ return nil
49
+ end
50
+
51
+ def error_code
52
+ unless @response.nil?
53
+ return @response["ErrorCode"]
54
+ end
55
+ return nil
56
+ end
57
+
58
+ def response
59
+ @response
60
+ end
61
+
62
+ def successful?
63
+ unless @response.nil?
64
+ return @response["ErrorCode"]==0
65
+ end
66
+ return nil
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vivapayapi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vivapayapi"
8
+ spec.version = Vivapayapi::VERSION
9
+ spec.authors = ["Apostolis Economou"]
10
+ spec.email = ["apostolis.economou@gmail.com"]
11
+ spec.summary = "Wrapper for VivaPayments Pay with VivaWallet solution.Work in progress."
12
+ spec.homepage = "http://github.com/apoeco/vivapayapi"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.8"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_dependency "httparty", "0.13.3"
25
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vivapayapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Apostolis Economou
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: httparty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.13.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.13.3
55
+ description:
56
+ email:
57
+ - apostolis.economou@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - lib/vivapayapi.rb
71
+ - lib/vivapayapi/version.rb
72
+ - vivapayapi.gemspec
73
+ homepage: http://github.com/apoeco/vivapayapi
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.4.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Wrapper for VivaPayments Pay with VivaWallet solution.Work in progress.
97
+ test_files: []