pandapay_api 0.1.1

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: 4c65d47ee501ebcab460d1e0ec8290b5751798c1
4
+ data.tar.gz: a1b1d028ed6f8fd510ad7917e29955700774eebe
5
+ SHA512:
6
+ metadata.gz: c876366580df850460ae4026b19a753deaaf5c54a9f8df33a7f7950cd7e9420a13453d59cea7d927db58d714990cfb2105f0481a2cba281beeae6253686d5744
7
+ data.tar.gz: 7a0ed6aaa87828311b97894ab6e442cf27b9eb3de6d3d78cb08e302d93be33972d601e068628128533b09b891d3665636cd0ff37cee7516e87482d706e8cba17
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.15.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in pandapay.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Dalton Cole
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,139 @@
1
+ # PandaPay API Ruby Library [![Build Status](https://travis-ci.org/dalton-cole/pandapay-ruby.svg?branch=master)](https://travis-ci.org/dalton-cole/pandapay-ruby) [![Code Climate](https://codeclimate.com/github/dalton-cole/pandapay-ruby/badges/gpa.svg)](https://codeclimate.com/github/dalton-cole/pandapay-ruby)
2
+
3
+ The [PandaPay](https://www.pandapay.io/) API Ruby gem provides convenient access to the [PandaPay API](http://docs.pandapay.io/getting-started-pandapay-api/api-reference) for applications written in the Ruby language.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pandapay_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pandapay_api
20
+
21
+ ### Requirements
22
+
23
+ * Ruby 2.1+.
24
+
25
+ ## Usage
26
+
27
+ The library needs to be configured with your account's secret key which is
28
+ available in your [PandaPay Dashboard](https://dashboard.pandapay.io/dashboard). Set `PandaPay.api_key` to its
29
+ value:
30
+
31
+ ``` ruby
32
+ require "pandapay_api"
33
+ PandaPay.api_key = "sk_test_..."
34
+
35
+ # Create a customer
36
+ PandaPay::Customer.create(
37
+ email: "test@pandapay.io",
38
+ source: "V45VnfsKzGJR9LIT9fgt4Kna6gz"
39
+ )
40
+
41
+ ```
42
+
43
+ ### Panda.js Tokens
44
+ In order to create customer objects or donation objects without a `customer_id`, you will need a payment `source` token from panda.js. To get more information about this, please refer to the API section of your dashboard.
45
+
46
+
47
+ ### Donations
48
+ Creating a donation is simple with the Pandapay_API gem. All you need is the payment `source`, the `amount`, and the `receipt_email`. You can also add a `platform_fee`, `destination`, and `restriction`.
49
+
50
+ ``` ruby
51
+ # Create a donation
52
+ PandaPay::Donation.create(
53
+ source: "7uKpZcziQ5mrAQ5BVSMhm2ZPX7o",
54
+ amount: "5000",
55
+ receipt_email: "test@pandapay.io"
56
+ )
57
+
58
+ #Example response:
59
+ #<PandaPay::Donation:0x007fbedb04ee70 @id="ch_AZ4xFphfWsjhS0GW93ofmg", @object="donation", @created=1505171888, @livemode=false, @charge_amount=5000, @platform_fee=0, @donation_after_fees=4775, @currency="usd", @payment_token="7uKpZcziQ5mrAQ5BVSMhm2ZPX7o", @customer=nil, @grants=[], @receipt_email="test@pandapay.io", @destination="", @restriction=nil>
60
+
61
+
62
+
63
+ # Create a donation with a destination to automatically generate a grant
64
+ PandaPay::Donation.create(
65
+ source: "K2vUvDrRTTc37y0q26bppoEQ2Iy",
66
+ amount: "5000",
67
+ receipt_email: "test@pandapay.io",
68
+ destination: "95-4604782"
69
+ )
70
+
71
+ #Example response
72
+ #<PandaPay::Donation:0x007fbeda0be550 @id="ch_LTBoq-Ln2T9BFXTCmcwtjA", @object="donation", @created=1505172101, @livemode=false, @charge_amount=5000, @platform_fee=0, @donation_after_fees=4775, @currency="usd", @payment_token="K2vUvDrRTTc37y0q26bppoEQ2Iy", @customer=nil, @grants=["gr_ZMPNOx_7fMMZFQJuQs01qQ"], @receipt_email="test@pandapay.io", @destination="95-4604782", @restriction=nil>
73
+ ```
74
+
75
+ ### Grants
76
+ If you have a balance in your 'Unallocated Donation Amount' on your [PandaPay Dashboard](https://dashboard.pandapay.io/dashboard), you can create a grant. All you need to provide is an `amount` (less than the aformentioned balance) and a `destination`.
77
+
78
+ ``` ruby
79
+ PandaPay::Grant.create(
80
+ destination: "95-4604782",
81
+ amount: "10000"
82
+ )
83
+
84
+ #Example Response
85
+ #<PandaPay::Grant:0x007fbeda85fde0 @id="gr_RmL6PhFwlyWugBTdSmy5vw", @object="grant", @created=1505172414, @livemode=false, @amount=10000, @status="pending", @currency="usd", @type="npo", @destination="95-4604782", @restriction=nil>
86
+
87
+ ```
88
+
89
+ ### Customers
90
+ The PandaPay_API Ruby gem permits customer creation, updates, and deletion using the following methods. To create a user, you must provide an `email` and a panda.js payment `source` token. To update a user, you need to provide a PandaPay `customer_id` and the value you want to update (`email` and/or `source`). To delete a user, you just need the `customer_id`.
91
+
92
+ ``` ruby
93
+ # Create a customer
94
+ PandaPay::Customer.create(
95
+ email: "test@pandapay.io",
96
+ source: "V45VnfsKzGJR9LIT9fgt4Kna6gz"
97
+ )
98
+
99
+ #Example response:
100
+ #<PandaPay::Customer:0x007fb5cc87d1e0 @id="cus_XZh_d56chDzNqFZyqT7YcA", @object="customer", @email="test@pandapay.io", @livemode=false, @cards=[{"id"=>"card_V45VnfsKzGJR9LIT9fgt4Kna6gz", "object"=>"card", "created"=>1505170021, "livemode"=>false, "customer"=>"cus_XZh_d56chDzNqFZyqT7YcA", "last4"=>"1111"}]>
101
+
102
+
103
+
104
+ # Update a customer
105
+ PandaPay::Customer.update(
106
+ customer_id: "cus_IOHfSE0z4KxVbF53DzSxhA",
107
+ source: "SPfZl6YXK1zsc3gDZrOCc8Y3NRp",
108
+ email: "newemail@pandapay.io"
109
+ )
110
+
111
+ #Example response:
112
+ #<PandaPay::Customer:0x007fb5cb82fc70 @id="cus_IOHfSE0z4KxVbF53DzSxhA", @object="customer", @email="newemail@pandapay.io", @livemode=false, @cards=[{"id"=>"card_88SB6AJIjVCCPCMtiyd3ykuDQ8F", "object"=>"card", "created"=>1505168696, "livemode"=>false, "customer"=>"cus_IOHfSE0z4KxVbF53DzSxhA", "last4"=>"1111"}, {"id"=>"card_SPfZl6YXK1zsc3gDZrOCc8Y3NRp", "object"=>"card", "created"=>1505170178, "livemode"=>false, "customer"=>"cus_IOHfSE0z4KxVbF53DzSxhA", "last4"=>"1111"}]>
113
+
114
+
115
+
116
+ # Delete a customer
117
+ PandaPay::Customer.delete(
118
+ customer_id: "cus_IOHfSE0z4KxVbF53DzSxhA"
119
+ )
120
+
121
+ #Example response
122
+ #<PandaPay::Customer:0x007fb5cca14a08 @id="cus_IOHfSE0z4KxVbF53DzSxhA", @object="customer", @email="newemail@pandapay.io", @livemode=false, @cards=[{"id"=>"card_88SB6AJIjVCCPCMtiyd3ykuDQ8F", "object"=>"card", "created"=>1505168696, "livemode"=>false, "customer"=>"cus_IOHfSE0z4KxVbF53DzSxhA", "last4"=>"1111"}, {"id"=>"card_SPfZl6YXK1zsc3gDZrOCc8Y3NRp", "object"=>"card", "created"=>1505170178, "livemode"=>false, "customer"=>"cus_IOHfSE0z4KxVbF53DzSxhA", "last4"=>"1111"}]>
123
+ ```
124
+
125
+
126
+
127
+ ## Development
128
+
129
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
130
+
131
+ 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).
132
+
133
+ ## Contributing
134
+
135
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dalton-cole/pandapay.
136
+
137
+ ## License
138
+
139
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "test/**/*_test.rb"
6
+ end
7
+
8
+ task :default => :test
@@ -0,0 +1,54 @@
1
+ module PandaPay
2
+ class Customer
3
+
4
+ attr_reader :id, :object, :email, :livemode, :cards
5
+
6
+ def initialize(attributes)
7
+ @id = attributes["id"]
8
+ @object = attributes["object"]
9
+ @email = attributes["email"]
10
+ @livemode = attributes["livemode"]
11
+ @cards = attributes["cards"]
12
+ end
13
+
14
+ def self.create(email: , source: )
15
+ conn = Faraday.new(:url => "https://#{PandaPay.secret_key}:@#{PandaPay_API_URL}")
16
+ response = conn.post '/v1/customers', { :email => email, :source => source}
17
+ attributes = JSON.parse(response.body)
18
+ if attributes.has_key? "error" or attributes.has_key? "errors"
19
+ raise response.body
20
+ else
21
+ new(attributes)
22
+ end
23
+ end
24
+
25
+ def self.update(customer_id: , email: nil, source: nil)
26
+ params = {}
27
+ unless email.nil?
28
+ params[:email] = email
29
+ end
30
+ unless source.nil?
31
+ params[:source] = source
32
+ end
33
+ conn = Faraday.new(:url => "https://#{PandaPay.secret_key}:@#{PandaPay_API_URL}")
34
+ response = conn.put "/v1/customers/#{customer_id}", params
35
+ attributes = JSON.parse(response.body)
36
+ if attributes.has_key? "error" or attributes.has_key? "errors"
37
+ raise response.body
38
+ else
39
+ new(attributes)
40
+ end
41
+ end
42
+
43
+ def self.delete(customer_id: )
44
+ conn = Faraday.new(:url => "https://#{PandaPay.secret_key}:@#{PandaPay_API_URL}")
45
+ response = conn.delete "/v1/customers/#{customer_id}"
46
+ attributes = JSON.parse(response.body)
47
+ if attributes.has_key? "error" or attributes.has_key? "errors"
48
+ raise response.body
49
+ else
50
+ new(attributes)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,33 @@
1
+ module PandaPay
2
+ class Donation
3
+ attr_reader :id, :object, :created, :livemode, :charge_amount, :platform_fee, :donation_after_fees, :currency, :payment_token, :customer, :grants, :receipt_email, :destination, :restriction
4
+
5
+ def initialize(attributes)
6
+ @id = attributes["id"]
7
+ @object = attributes["object"]
8
+ @created = attributes["created"]
9
+ @livemode = attributes["livemode"]
10
+ @charge_amount = attributes["charge_amount"]
11
+ @platform_fee = attributes["platform_fee"]
12
+ @donation_after_fees = attributes["donation_after_fees"]
13
+ @currency = attributes["currency"]
14
+ @payment_token = attributes["payment_token"]
15
+ @customer = attributes["customer"]
16
+ @grants = attributes["grants"]
17
+ @receipt_email = attributes["receipt_email"]
18
+ @destination = attributes["destination"]
19
+ @restriction = attributes["restriction"]
20
+ end
21
+
22
+ def self.create(amount: , destination: "", restriction: "", source: , receipt_email: , platform_fee: "0", currency: "USD")
23
+ conn = Faraday.new(:url => "https://#{PandaPay.secret_key}:@#{PandaPay_API_URL}")
24
+ response = conn.post '/v1/donations', { :amount => amount, :currency => currency, :source => source, :receipt_email => receipt_email, :platform_fee => platform_fee, :destination => destination, :restriction => restriction }
25
+ attributes = JSON.parse(response.body)
26
+ if attributes.has_key? "error" or attributes.has_key? "errors"
27
+ raise response.body
28
+ else
29
+ new(attributes)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ module PandaPay
2
+ class Grant
3
+
4
+ attr_reader :id, :object, :created, :livemode, :amount, :status, :currency, :type, :destination, :restriction
5
+
6
+ def initialize(attributes)
7
+ @id = attributes["id"]
8
+ @object = attributes["object"]
9
+ @created = attributes["created"]
10
+ @livemode = attributes["livemode"]
11
+ @amount = attributes["amount"]
12
+ @status = attributes["status"]
13
+ @currency = attributes["currency"]
14
+ @type = attributes["type"]
15
+ @destination = attributes["destination"]
16
+ @restriction = attributes["restriction"]
17
+ end
18
+
19
+ def self.create(amount: , destination: , restricted: "", currency: "USD")
20
+ conn = Faraday.new(:url => "https://#{PandaPay.secret_key}:@#{PandaPay_API_URL}")
21
+ response = conn.post '/v1/grants', {:restricted => restricted, :amount => amount, :currency => currency, :destination => destination}
22
+ attributes = JSON.parse(response.body)
23
+ if attributes.has_key? "error" or attributes.has_key? "errors"
24
+ raise response.body
25
+ else
26
+ new(attributes)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module PandaPay
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,14 @@
1
+ require_relative "pandapay/version"
2
+ require_relative "pandapay/customer"
3
+ require_relative "pandapay/donation"
4
+ require_relative "pandapay/grant"
5
+ require 'faraday'
6
+ require 'json'
7
+
8
+ PandaPay_API_URL = "api.pandapay.io"
9
+
10
+ module PandaPay
11
+ class << self
12
+ attr_accessor :secret_key
13
+ end
14
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "pandapay/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pandapay_api"
8
+ spec.version = PandaPay::VERSION
9
+ spec.authors = ["Dalton Cole"]
10
+ spec.email = ["dalton@alphaparse.com"]
11
+
12
+ spec.summary = %q{Gem to wrap PandaPay API}
13
+ spec.description = %q{Gem to wrap PandaPay API}
14
+ spec.homepage = "https://www.pandapay.io/"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+ spec.required_ruby_version = '>= 2.1'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.15"
24
+ spec.add_development_dependency "rake", "~> 12.0"
25
+ spec.add_development_dependency "minitest", "~> 5.10"
26
+ spec.add_development_dependency "vcr"
27
+ spec.add_development_dependency "webmock"
28
+
29
+ spec.add_dependency "json", "~> 2.1"
30
+ spec.add_dependency "faraday"
31
+ end
@@ -0,0 +1,72 @@
1
+ require './test/test_helper'
2
+
3
+ class PandaPayCustomerTest < Minitest::Test
4
+ def test_exists
5
+ assert PandaPay::Customer
6
+ end
7
+
8
+ def test_it_creates_a_customer
9
+ VCR.use_cassette('created_customer') do
10
+ customer = PandaPay::Customer.create(email: "test_email@PandaPay.io", source: "QD4gs3Fonhc2AIanNdsqM5lygVf")
11
+ assert_equal PandaPay::Customer, customer.class
12
+ assert_equal "test_email@PandaPay.io", customer.email
13
+ assert_equal "customer", customer.object
14
+ assert_equal true, customer.respond_to?(:id)
15
+ assert_equal true, customer.respond_to?(:cards)
16
+ assert_equal true, customer.respond_to?(:livemode)
17
+ assert_equal false, customer.respond_to?(:force_false)
18
+ end
19
+ end
20
+
21
+ def test_it_errors_on_create_if_no_email
22
+ assert_raises ArgumentError do
23
+ PandaPay::Customer.create(source: "QD4gs3Fonhc2AIanNdsqM5lygVf")
24
+ end
25
+ end
26
+
27
+ def test_it_errors_on_create_if_no_payment_source
28
+ assert_raises ArgumentError do
29
+ PandaPay::Customer.create(email: "test_email@PandaPay.io")
30
+ end
31
+ end
32
+
33
+
34
+ def test_it_updates_a_customer
35
+ VCR.use_cassette('updated_customer') do
36
+ customer = PandaPay::Customer.update(customer_id: "cus_0moNz0xVxp11OTPncj7w9Q", email: "new_test_email@PandaPay.io")
37
+ assert_equal PandaPay::Customer, customer.class
38
+ assert_equal "new_test_email@PandaPay.io", customer.email
39
+ assert_equal "customer", customer.object
40
+ assert_equal true, customer.respond_to?(:id)
41
+ assert_equal true, customer.respond_to?(:cards)
42
+ assert_equal true, customer.respond_to?(:livemode)
43
+ assert_equal false, customer.respond_to?(:force_false)
44
+ end
45
+ end
46
+
47
+ def test_it_errors_on_update_if_no_customer_id
48
+ assert_raises ArgumentError do
49
+ PandaPay::Customer.update(email: "new_test_email@PandaPay.io")
50
+ end
51
+ end
52
+
53
+
54
+ def test_it_deletes_a_customer
55
+ VCR.use_cassette('deleted_customer') do
56
+ customer = PandaPay::Customer.delete(customer_id: "cus_0moNz0xVxp11OTPncj7w9Q")
57
+ assert_equal PandaPay::Customer, customer.class
58
+ assert_equal "new_test_email@PandaPay.io", customer.email
59
+ assert_equal "customer", customer.object
60
+ assert_equal true, customer.respond_to?(:id)
61
+ assert_equal true, customer.respond_to?(:cards)
62
+ assert_equal true, customer.respond_to?(:livemode)
63
+ assert_equal false, customer.respond_to?(:force_false)
64
+ end
65
+ end
66
+
67
+ def test_it_errors_on_delete_if_no_customer_id
68
+ assert_raises ArgumentError do
69
+ PandaPay::Customer.delete
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,47 @@
1
+ require './test/test_helper'
2
+
3
+ class PandaPayDonationTest < Minitest::Test
4
+ def test_exists
5
+ assert PandaPay::Donation
6
+ end
7
+
8
+ def test_it_creates_a_donation
9
+ VCR.use_cassette('created_donation') do
10
+ donation = PandaPay::Donation.create(source: "MkZO20xPRPf1segAvqxXihZPd1N", receipt_email: "firsttest@PandaPay.io", amount: "5000")
11
+ assert_equal PandaPay::Donation, donation.class
12
+ assert_equal "firsttest@PandaPay.io", donation.receipt_email
13
+ assert_equal 5000, donation.charge_amount
14
+ assert_equal "donation", donation.object
15
+ assert_equal "MkZO20xPRPf1segAvqxXihZPd1N", donation.payment_token
16
+ assert_equal true, donation.respond_to?(:id)
17
+ assert_equal true, donation.respond_to?(:created)
18
+ assert_equal true, donation.respond_to?(:livemode)
19
+ assert_equal true, donation.respond_to?(:platform_fee)
20
+ assert_equal true, donation.respond_to?(:donation_after_fees)
21
+ assert_equal true, donation.respond_to?(:currency)
22
+ assert_equal true, donation.respond_to?(:customer)
23
+ assert_equal true, donation.respond_to?(:grants)
24
+ assert_equal true, donation.respond_to?(:destination)
25
+ assert_equal true, donation.respond_to?(:restriction)
26
+ assert_equal false, donation.respond_to?(:force_false)
27
+ end
28
+ end
29
+
30
+ def test_it_errors_if_no_amount
31
+ assert_raises ArgumentError do
32
+ PandaPay::Donation.create(receipt_email: "test@PandaPay.io", source: "MkZO20xPRPf1segAvqxXihZPd1N")
33
+ end
34
+ end
35
+
36
+ def test_it_errors_if_no_payment_source
37
+ assert_raises ArgumentError do
38
+ PandaPay::Donation.create(amount: "5000", receipt_email: "test@PandaPay.io")
39
+ end
40
+ end
41
+
42
+ def test_it_errors_if_no_receipt_email
43
+ assert_raises ArgumentError do
44
+ PandaPay::Donation.create(amount: "5000", source: "MkZO20xPRPf1segAvqxXihZPd1N")
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.pandapay.io/v1/customers
6
+ body:
7
+ encoding: UTF-8
8
+ string: email=test_email%40PandaPay.io&source=QD4gs3Fonhc2AIanNdsqM5lygVf
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx/1.4.6 (Ubuntu)
25
+ Date:
26
+ - Tue, 12 Sep 2017 03:48:26 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ Access-Control-Allow-Origin:
40
+ - "*"
41
+ Etag:
42
+ - W/"d7152f455e3d54a4a2df2701844fd77c"
43
+ Cache-Control:
44
+ - max-age=0, private, must-revalidate
45
+ X-Request-Id:
46
+ - 4f9311a1-27d0-40a2-be07-d9d7519a4e34
47
+ X-Runtime:
48
+ - '0.713026'
49
+ Vary:
50
+ - Origin
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"id":"cus_0moNz0xVxp11OTPncj7w9Q","object":"customer","email":"test_email@PandaPay.io","livemode":false,"cards":[{"id":"card_QD4gs3Fonhc2AIanNdsqM5lygVf","object":"card","created":1505188106,"livemode":false,"customer":"cus_0moNz0xVxp11OTPncj7w9Q","last4":"1111"}]}'
54
+ http_version:
55
+ recorded_at: Tue, 12 Sep 2017 03:48:27 GMT
56
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.pandapay.io/v1/donations
6
+ body:
7
+ encoding: UTF-8
8
+ string: amount=5000&currency=USD&destination=&platform_fee=0&receipt_email=firsttest%40PandaPay.io&restriction=&source=MkZO20xPRPf1segAvqxXihZPd1N
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx/1.4.6 (Ubuntu)
25
+ Date:
26
+ - Tue, 12 Sep 2017 03:29:44 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ Access-Control-Allow-Origin:
40
+ - "*"
41
+ Etag:
42
+ - W/"ead3811244d6b87544c4a9d20361095d"
43
+ Cache-Control:
44
+ - max-age=0, private, must-revalidate
45
+ X-Request-Id:
46
+ - d4f59d09-c4d2-42eb-aab3-7ca75c327417
47
+ X-Runtime:
48
+ - '0.692076'
49
+ Vary:
50
+ - Origin
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"id":"ch_0FKx_7S0-gbXB9UwDt9jkg","object":"donation","created":1505186984,"livemode":false,"charge_amount":5000,"platform_fee":0,"donation_after_fees":4775,"currency":"usd","payment_token":"MkZO20xPRPf1segAvqxXihZPd1N","customer":null,"grants":[],"receipt_email":"firsttest@PandaPay.io","destination":"","restriction":""}'
54
+ http_version:
55
+ recorded_at: Tue, 12 Sep 2017 03:29:45 GMT
56
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.pandapay.io/v1/grants
6
+ body:
7
+ encoding: UTF-8
8
+ string: amount=5000&currency=USD&destination=95-4604782&restricted=
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx/1.4.6 (Ubuntu)
25
+ Date:
26
+ - Tue, 12 Sep 2017 03:37:08 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ Access-Control-Allow-Origin:
40
+ - "*"
41
+ Etag:
42
+ - W/"4302afce605e3db3093b50e3a6abf041"
43
+ Cache-Control:
44
+ - max-age=0, private, must-revalidate
45
+ X-Request-Id:
46
+ - 1e3e1c3e-8527-4e69-98ee-da093889109c
47
+ X-Runtime:
48
+ - '0.358425'
49
+ Vary:
50
+ - Origin
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"id":"gr_nSgbFokegMLSfIUU6jJbwg","object":"grant","created":1505187428,"livemode":false,"amount":5000,"status":"pending","currency":"usd","type":"npo","destination":"95-4604782","restriction":null}'
54
+ http_version:
55
+ recorded_at: Tue, 12 Sep 2017 03:37:08 GMT
56
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://api.pandapay.io/v1/customers/cus_0moNz0xVxp11OTPncj7w9Q
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx/1.4.6 (Ubuntu)
23
+ Date:
24
+ - Tue, 12 Sep 2017 03:55:36 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ Access-Control-Allow-Origin:
38
+ - "*"
39
+ Etag:
40
+ - W/"50bd04e1ff55d414da3203f9b65f888d"
41
+ Cache-Control:
42
+ - max-age=0, private, must-revalidate
43
+ X-Request-Id:
44
+ - 957e5807-3bef-4321-baad-815a13175586
45
+ X-Runtime:
46
+ - '0.240877'
47
+ Vary:
48
+ - Origin
49
+ body:
50
+ encoding: UTF-8
51
+ string: '{"id":"cus_0moNz0xVxp11OTPncj7w9Q","object":"customer","email":"new_test_email@PandaPay.io","livemode":false,"cards":[{"id":"card_QD4gs3Fonhc2AIanNdsqM5lygVf","object":"card","created":1505188106,"livemode":false,"customer":"cus_0moNz0xVxp11OTPncj7w9Q","last4":"1111"}]}'
52
+ http_version:
53
+ recorded_at: Tue, 12 Sep 2017 03:55:37 GMT
54
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: https://api.pandapay.io/v1/customers/cus_0moNz0xVxp11OTPncj7w9Q
6
+ body:
7
+ encoding: UTF-8
8
+ string: email=new_test_email%40PandaPay.io
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx/1.4.6 (Ubuntu)
25
+ Date:
26
+ - Tue, 12 Sep 2017 03:54:38 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Frame-Options:
34
+ - SAMEORIGIN
35
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ Access-Control-Allow-Origin:
40
+ - "*"
41
+ Etag:
42
+ - W/"50bd04e1ff55d414da3203f9b65f888d"
43
+ Cache-Control:
44
+ - max-age=0, private, must-revalidate
45
+ X-Request-Id:
46
+ - a0a0597e-ca25-4268-b967-eab426268815
47
+ X-Runtime:
48
+ - '0.245560'
49
+ Vary:
50
+ - Origin
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"id":"cus_0moNz0xVxp11OTPncj7w9Q","object":"customer","email":"new_test_email@PandaPay.io","livemode":false,"cards":[{"id":"card_QD4gs3Fonhc2AIanNdsqM5lygVf","object":"card","created":1505188106,"livemode":false,"customer":"cus_0moNz0xVxp11OTPncj7w9Q","last4":"1111"}]}'
54
+ http_version:
55
+ recorded_at: Tue, 12 Sep 2017 03:54:38 GMT
56
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,37 @@
1
+ require './test/test_helper'
2
+
3
+ class PandaPayGrantTest < Minitest::Test
4
+ def test_exists
5
+ assert PandaPay::Grant
6
+ end
7
+
8
+ def test_it_creates_a_grant
9
+ VCR.use_cassette('created_grant') do
10
+ grant = PandaPay::Grant.create(destination: "95-4604782", amount: "5000")
11
+ assert_equal PandaPay::Grant, grant.class
12
+ assert_equal "95-4604782", grant.destination
13
+ assert_equal 5000, grant.amount
14
+ assert_equal "grant", grant.object
15
+ assert_equal true, grant.respond_to?(:id)
16
+ assert_equal true, grant.respond_to?(:created)
17
+ assert_equal true, grant.respond_to?(:livemode)
18
+ assert_equal true, grant.respond_to?(:status)
19
+ assert_equal true, grant.respond_to?(:currency)
20
+ assert_equal true, grant.respond_to?(:type)
21
+ assert_equal true, grant.respond_to?(:restriction)
22
+ assert_equal false, grant.respond_to?(:force_false)
23
+ end
24
+ end
25
+
26
+ def test_it_errors_if_no_amount
27
+ assert_raises ArgumentError do
28
+ PandaPay::Grant.create(destination: "95-4604782")
29
+ end
30
+ end
31
+
32
+ def test_it_errors_if_no_destination
33
+ assert_raises ArgumentError do
34
+ PandaPay::Grant.create(amount: "5000")
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,9 @@
1
+ require './lib/pandapay_api'
2
+ require 'minitest/autorun'
3
+ require 'webmock/minitest'
4
+ require 'vcr'
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = "test/fixtures"
8
+ c.hook_into :webmock
9
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pandapay_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Dalton Cole
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-13 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Gem to wrap PandaPay API
112
+ email:
113
+ - dalton@alphaparse.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - lib/pandapay/customer.rb
125
+ - lib/pandapay/donation.rb
126
+ - lib/pandapay/grant.rb
127
+ - lib/pandapay/version.rb
128
+ - lib/pandapay_api.rb
129
+ - pandapay_api.gemspec
130
+ - test/customer/customer_test.rb
131
+ - test/donation/donation_test.rb
132
+ - test/fixtures/created_customer.yml
133
+ - test/fixtures/created_donation.yml
134
+ - test/fixtures/created_grant.yml
135
+ - test/fixtures/deleted_customer.yml
136
+ - test/fixtures/updated_customer.yml
137
+ - test/grant/grant_test.rb
138
+ - test/test_helper.rb
139
+ homepage: https://www.pandapay.io/
140
+ licenses:
141
+ - MIT
142
+ metadata: {}
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '2.1'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 2.4.5.1
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: Gem to wrap PandaPay API
163
+ test_files:
164
+ - test/customer/customer_test.rb
165
+ - test/donation/donation_test.rb
166
+ - test/fixtures/created_customer.yml
167
+ - test/fixtures/created_donation.yml
168
+ - test/fixtures/created_grant.yml
169
+ - test/fixtures/deleted_customer.yml
170
+ - test/fixtures/updated_customer.yml
171
+ - test/grant/grant_test.rb
172
+ - test/test_helper.rb