pin_payment 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
  SHA1:
3
- metadata.gz: 93c994264a5a964b1edaca7bc46ece35138ac7c4
4
- data.tar.gz: 537bac59e0f8e9ca495444af48ad49c11b2e9125
3
+ metadata.gz: 369e911042369c7cd9c343e4bc51ec5f0c48d4fc
4
+ data.tar.gz: 281569a5aec0327fc79a00fe5b58aebc0f4a1ae3
5
5
  SHA512:
6
- metadata.gz: ded7ba081a51539cfa65adf6a0d1baec4d658bf84d5d3752502b2dee8ec7534b038617337fb16c974a424c3a52aada8cf02b9b217d012280da7a8a5cacf70935
7
- data.tar.gz: 37592f8453b6fba91e8afac78b0a4bf754d7b742592486bf2d93585aa3b1c05b3fc1b1af55c3315ff5772d7b2b45b19c542b091e98610b6cce19eaed4998e545
6
+ metadata.gz: 23240d1e4d1d32fa85b7e0221f03c5cbce8ab11ad040dd5875ec0eab6c3166e922e2be7980512590008a03d2aa93ee00d56125a7d900c9d6b03aa85325196c4e
7
+ data.tar.gz: 0a58b3ed5b0d72eb7f3abdfa3bd274f6bf11b02c4c937a376b1c92bbb84dceaad4f1262a732895a9abf9f289307bcf8c67e9fa0979f536e8c944602ee0ac4f76
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pin_payment (0.2.0)
4
+ pin_payment (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -95,7 +95,7 @@ charge = PinPayment::Charge.create(
95
95
  amount: 1000,
96
96
  currency: 'USD', # only AUD and USD are supported by pin.net.au
97
97
  description: 'Widgets',
98
- ip_address: request.ip
98
+ ip_address: request.ip,
99
99
  card: {
100
100
  number: 5520000000000000,
101
101
  expiry_month: 5,
@@ -112,7 +112,7 @@ charge = PinPayment::Charge.create(
112
112
  ```
113
113
 
114
114
  You can refund charges as well, either directly on the charge object with
115
- `charge.refund!` or you can pass a charge object or token directory into
115
+ `charge.refund!` or you can pass a charge object or token directly into
116
116
  `PinPayment::Refund.create`
117
117
 
118
118
  Both the Charge and Customer objects have an `all` method that you can use to
@@ -1,5 +1,6 @@
1
1
  require 'json'
2
2
  require 'pin_payment/error'
3
+ require 'net/http'
3
4
 
4
5
  module PinPayment
5
6
  class Base
@@ -1,7 +1,7 @@
1
1
  module PinPayment
2
2
  class Charge < Base
3
- attr_accessor :token, :amount, :currency, :description, :email, :ip_address, :created_at, :card, :customer, :success
4
- protected :token=, :amount=, :currency=, :description=, :email=, :ip_address=, :created_at=, :card=, :customer=, :success=
3
+ attr_accessor :token, :amount, :currency, :description, :email, :ip_address, :created_at, :card, :customer, :success, :total_fees
4
+ protected :token=, :amount=, :currency=, :description=, :email=, :ip_address=, :created_at=, :card=, :customer=, :success=, :total_fees=
5
5
 
6
6
  # Uses the pin API to create a charge.
7
7
  #
@@ -55,7 +55,7 @@ module PinPayment
55
55
  protected
56
56
 
57
57
  def self.attributes
58
- [:token, :amount, :currency, :description, :email, :ip_address, :created_at, :card, :customer, :success]
58
+ [:token, :amount, :currency, :description, :email, :ip_address, :created_at, :card, :customer, :success, :total_fees]
59
59
  end
60
60
  end
61
61
  end
@@ -1,7 +1,7 @@
1
1
  module PinPayment
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 2
4
+ MINOR = 3
5
5
  PATCH = 0
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
@@ -2,9 +2,10 @@
2
2
  charge:
3
3
  token_already_used: '{"error":"token_already_used","error_description":"Token already used. Card tokens can only be used once, to create a charge or assign a card to a customer."}'
4
4
  invalid_amount: '{"error":"invalid_resource","error_description":"One or more parameters were missing or invalid.","messages":[{"param":"amount","code":"amount_invalid","message":"Amount must be an integer"},{"param":"amount","code":"amount_invalid","message":"Amount must be more than 1 USD"}]}'
5
- success: '{"response":{"token":"ch_BjGW-S6WUisI6mOgpDRimg","success":true,"amount":1000,"currency":"USD","description":"Widgets","email":"foo@example.com","ip_address":"127.0.0.1","created_at":"2013-06-12T23:55:38Z","status_message":"Success!","error_message":null,"card":{"token":"card_qMwnMfpG-olOhfJeyxmrcg","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"123 Main St","address_line2":"","address_city":"Melbourne","address_postcode":"3000","address_state":"Victoria","address_country":"Australia"},"transfer":[],"amount_refunded":0,"total_fees":null,"merchant_entitlement":null,"refund_pending":false}}'
6
- create_with_card: '{"response":{"token":"ch_lfUYEBK14zotCTykezJkfg","success":true,"amount":400,"currency":"AUD","description":"test charge","email":"roland@pin.net.au","ip_address":"203.192.1.172","created_at":"2013-06-27T00:39:07Z","status_message":"Success","error_message":null,"card":{"token":"card_jxk5A8fjTtmz6Y81NX9G7w","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"42 Sevenoaks St","address_line2":null,"address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"},"transfer":null}}'
7
- all: '{"response":[{"token":"ch_lfUYEBK14zotCTykezJkfg","success":true,"amount":400,"currency":"AUD","description":"test charge","email":"roland@pin.net.au","ip_address":"203.192.1.172","created_at":"2013-06-27T00:39:07Z","status_message":"Success","error_message":null,"card":{"token":"card_nytGw7koRg23EEp9NTmz9w","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"42 Sevenoaks St","address_line2":null,"address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"},"transfer":null},{"token":"ch_shldvbE5eqBQuyY9Fryhzw","success":true,"amount":400,"currency":"AUD","description":"test charge","email":"roland@pin.net.au","ip_address":"203.192.1.172","created_at":"2013-06-27T00:38:41Z","status_message":"Success","error_message":null,"card":{"token":"card_nytGw7koRg23EEp9NTmz9w","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"42 Sevenoaks St","address_line2":null,"address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"},"transfer":null}],"count":2,"pagination":{"current":1,"previous":null,"next":1,"per_page":25,"pages":1,"count":2}}'
5
+ success: '{"response":{"token":"ch_BjGW-S6WUisI6mOgpDRimg","success":true,"amount":1000,"total_fees":20,"currency":"USD","description":"Widgets","email":"foo@example.com","ip_address":"127.0.0.1","created_at":"2013-06-12T23:55:38Z","status_message":"Success!","error_message":null,"card":{"token":"card_qMwnMfpG-olOhfJeyxmrcg","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"123 Main St","address_line2":"","address_city":"Melbourne","address_postcode":"3000","address_state":"Victoria","address_country":"Australia"},"transfer":[],"amount_refunded":0,"total_fees":null,"merchant_entitlement":null,"refund_pending":false}}'
6
+ create_with_card: '{"response":{"token":"ch_lfUYEBK14zotCTykezJkfg","success":true,"amount":400,"total_fees":10,"currency":"AUD","description":"test charge","email":"roland@pin.net.au","ip_address":"203.192.1.172","created_at":"2013-06-27T00:39:07Z","status_message":"Success","error_message":null,"card":{"token":"card_jxk5A8fjTtmz6Y81NX9G7w","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"42 Sevenoaks St","address_line2":null,"address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"},"transfer":null}}'
7
+ create_with_customer: '{"response":{"token":"ch_eITc7wXVSNQjuSxTqvnx4Q","success":true,"amount":400,"total_fees":10,"currency":"AUD","description":"test charge","email":"roland@pin.net.au","ip_address":"203.192.1.172","created_at":"2013-08-12T01:16:13Z","status_message":"Success","error_message":null,"card":{"token":"card_G7js7YN7xoI9xRQqJrCLlA","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"42 Sevenoaks St","address_line2":null,"address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"},"transfer":[],"amount_refunded":0,"total_fees":42,"merchant_entitlement":358,"refund_pending":false}}'
8
+ all: '{"response":[{"token":"ch_lfUYEBK14zotCTykezJkfg","success":true,"amount":400,"total_fees":10,"currency":"AUD","description":"test charge","email":"roland@pin.net.au","ip_address":"203.192.1.172","created_at":"2013-06-27T00:39:07Z","status_message":"Success","error_message":null,"card":{"token":"card_nytGw7koRg23EEp9NTmz9w","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"42 Sevenoaks St","address_line2":null,"address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"},"transfer":null},{"token":"ch_shldvbE5eqBQuyY9Fryhzw","success":true,"amount":400,"currency":"AUD","description":"test charge","email":"roland@pin.net.au","ip_address":"203.192.1.172","created_at":"2013-06-27T00:38:41Z","status_message":"Success","error_message":null,"card":{"token":"card_nytGw7koRg23EEp9NTmz9w","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"42 Sevenoaks St","address_line2":null,"address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"},"transfer":null}],"count":2,"pagination":{"current":1,"previous":null,"next":1,"per_page":25,"pages":1,"count":2}}'
8
9
  customer:
9
10
  blank_email: '{"error":"invalid_resource","error_description":"One or more parameters were missing or invalid.","messages":[{"param":"email","code":"email_invalid","message":"Email can''t be blank"}]}'
10
11
  updated: '{"response":{"token":"cus__03Cn1lSk3offZ0IGkwpCg","email":"changed@example.com","created_at":"2013-06-12T10:08:30Z","card":{"token":"card_qMwnMfpG-olOhfJeyxmrcg","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"123 Main St","address_line2":"","address_city":"Melbourne","address_postcode":"3000","address_state":"Victoria","address_country":"Australia"}}}'
@@ -27,6 +27,13 @@ class TestPinCharge < MiniTest::Unit::TestCase
27
27
  assert charge.card.token.length > 0
28
28
  end
29
29
 
30
+ def test_create_charge_with_customer_token
31
+ customer = created_customer
32
+ FakeWeb.register_uri(:post, 'https://test-api.pin.net.au/1/charges', body: fixtures['responses']['charge']['create_with_customer'])
33
+ charge = PinPayment::Charge.create(charge_hash.merge(customer: customer.token).reject{|k| k == :card })
34
+ assert_equal true, charge.success?
35
+ end
36
+
30
37
  def test_find_charge
31
38
  charge = created_charge
32
39
  FakeWeb.register_uri(:get, "https://test-api.pin.net.au/1/charges/#{charge.token}", body: fixtures['responses']['charge']['success'])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pin_payment
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
  - Danial Pearce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-09 00:00:00.000000000 Z
11
+ date: 2014-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fakeweb
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.0.2
105
+ rubygems_version: 2.0.14
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Ruby bindings for the Pin API