paytrail-client 0.1.1 → 0.1.2

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: 7688bc32d7a5c6a3f8bca80fae3c405327e87acd
4
- data.tar.gz: 00689379a953b8586d5ea6320a4d1dc2628e0a0e
3
+ metadata.gz: 8d1e57c3c46687abab5311541327080c20a84b34
4
+ data.tar.gz: 0071f9635631174bd8c9e33496e08f393c28fe19
5
5
  SHA512:
6
- metadata.gz: 00fbc52510278ec6b7c41946cf9c518107353842de34e3507bb75270ea022e8a51ba4240263490beccfe68b027195d8a04bda316350693219bde666973029940
7
- data.tar.gz: 9238f38bf982032418ee160a8b6716c71fdb112986840957815af41b986b427b7cc4ac369b3fcdd7ac28184be06216cb527e5ee0558e904e0648fd2d0fca1a1b
6
+ metadata.gz: 7c56227e19fca6b14779048e973fa01943a1755b4537d50a5ab504f6a0ef6bdd491e975a5037efe71b21cf151d4061753c0ff8ad1a5d4f2714a7f886bc1651d6
7
+ data.tar.gz: 84239f0994f302bcd111199886543435eabecce80ecbecec36a4c4f15aaeaa87f589ca2299a1d8061ee4c5d1b791f6605f3587fbbf5e4a17e080d3bcf36be54c
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.1
4
+ - 2.3.0
4
5
  before_install: gem install bundler -v 1.10.6
data/README.md CHANGED
@@ -38,6 +38,21 @@ token = PaytrailClient::Payment.create(order_number: '1234',
38
38
  # Redirect to received url
39
39
  redirect_to(token['url'])
40
40
 
41
+
42
+ # Verify payment
43
+
44
+ begin
45
+ PaytrailClient::Payment.verify_payment!(
46
+ params['ORDER_NUMBER'],
47
+ params['TIMESTAMP'],
48
+ params['PAID'],
49
+ params['METHOD'],
50
+ params['RETURN_AUTHCODE'])
51
+ puts 'Payment verified'
52
+ rescue PaytrailClient::InvalidPaymentError
53
+ puts 'Could not verify payment'
54
+ end
55
+
41
56
  ```
42
57
 
43
58
  ## Contributing
@@ -2,6 +2,6 @@ module PaytrailClient
2
2
  GEM_ROOT = File.expand_path('../', __FILE__)
3
3
  end
4
4
 
5
- %w(version paytrail_client helpers request payment).each do |file|
5
+ %w(version errors paytrail_client helpers request payment).each do |file|
6
6
  require File.join(PaytrailClient::GEM_ROOT, 'paytrail_client', file)
7
7
  end
@@ -0,0 +1,4 @@
1
+ module PaytrailClient
2
+ class PaytrailClientError < StandardError; end
3
+ class InvalidPaymentError < PaytrailClientError; end
4
+ end
@@ -4,4 +4,15 @@ module PaytrailClient::Payment
4
4
  def self.create(payload)
5
5
  post('https://payment.paytrail.com/api-payment/create', payload)
6
6
  end
7
+
8
+ def self.verify_payment!(order_number, time_stamp, paid, method, auth_code)
9
+ unless Digest::MD5.hexdigest(
10
+ [order_number,
11
+ time_stamp,
12
+ paid,
13
+ method,
14
+ PaytrailClient.configuration.merchant_secret].join('|')).casecmp(auth_code).zero?
15
+ raise PaytrailClient::InvalidPaymentError
16
+ end
17
+ end
7
18
  end
@@ -1,3 +1,3 @@
1
1
  module PaytrailClient
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paytrail-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Antman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-09 00:00:00.000000000 Z
11
+ date: 2016-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -152,6 +152,7 @@ files:
152
152
  - Rakefile
153
153
  - lib/paytrail-client.rb
154
154
  - lib/paytrail_client.rb
155
+ - lib/paytrail_client/errors.rb
155
156
  - lib/paytrail_client/helpers.rb
156
157
  - lib/paytrail_client/payment.rb
157
158
  - lib/paytrail_client/paytrail_client.rb