tns_payments 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.0.4 / 2012-03-08
4
+
5
+ * Check credit card token length as well as starting digit.
6
+ * Make `host` an accessor.
7
+ * Do not send an order reference when refunding.
8
+
3
9
  ## 0.0.3 / 2012-03-06
4
10
 
5
11
  * `Connection#session_token` updates when the setter is called or when nil.
@@ -4,8 +4,9 @@ require 'rest-client'
4
4
 
5
5
  module TNSPayments
6
6
  class Connection
7
- CREDIT_CARD_TOKEN_FORMAT = /^9/ # /\d{16}/
7
+ CREDIT_CARD_TOKEN_FORMAT = /^9\d{15}/
8
8
 
9
+ attr_accessor :host
9
10
  attr_writer :session_token
10
11
 
11
12
  def available?
@@ -15,10 +16,11 @@ module TNSPayments
15
16
  def initialize options
16
17
  @api_key = options[:api_key]
17
18
  @merchant_id = options[:merchant_id]
19
+ self.host = options.fetch(:host) { 'https://secure.ap.tnspayments.com' }
18
20
  end
19
21
 
20
22
  def payment_form_url
21
- "https://secure.ap.tnspayments.com/form/#{session_token}"
23
+ "#{host}/form/#{session_token}"
22
24
  end
23
25
 
24
26
  def purchase transaction, token
@@ -39,8 +41,7 @@ module TNSPayments
39
41
  transaction_id = transaction.transaction_id
40
42
  params = {
41
43
  'apiOperation' => 'REFUND',
42
- 'order' => {'reference' => transaction.reference},
43
- 'transaction' => {'amount' => transaction.amount.to_s, 'currency' => transaction.currency, 'reference' => transaction_id.to_s}
44
+ 'transaction' => {'amount' => transaction.amount.to_s, 'currency' => transaction.currency, 'reference' => transaction_id.to_s}
44
45
  }
45
46
 
46
47
  request :put, "/merchant/#{@merchant_id}/order/#{order_id}/transaction/#{transaction_id}", params
@@ -64,7 +65,7 @@ module TNSPayments
64
65
  private
65
66
 
66
67
  def api_url
67
- 'https://secure.ap.tnspayments.com/api/rest/version/4'
68
+ "#{host}/api/rest/version/4"
68
69
  end
69
70
 
70
71
  def encode_credentials
@@ -1,3 +1,3 @@
1
1
  module TNSPayments
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -208,13 +208,12 @@ private
208
208
  stub_request(:put, /https:\/\/:#{@api_key}@secure\.ap\.tnspayments\.com\/api\/rest\/version\/4\/merchant\/#{@merchant_id}\/order\/#{transaction.order_id}\/transaction\/#{transaction.transaction_id}/).
209
209
  with :body => JSON.generate({
210
210
  'apiOperation' => 'REFUND',
211
- 'order' => {'reference' => transaction.reference.to_s},
212
211
  'transaction' => {'amount' => transaction.amount.to_s, 'currency' => transaction.currency, 'reference' => transaction.transaction_id.to_s}
213
212
  }),
214
213
  :headers => {
215
214
  'Accept' => '*/*',
216
215
  'Accept-Encoding' => 'gzip, deflate',
217
- 'Content-Length' => '120',
216
+ 'Content-Length' => '89',
218
217
  'Content-Type' => 'Application/json;charset=UTF-8'
219
218
  }
220
219
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tns_payments
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tim Cooper
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-06 00:00:00 +10:00
18
+ date: 2012-03-08 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency