avangate 0.2.4 → 0.2.5

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: b886c3978f5213168be5a7fdfe9bd22f0731a949
4
- data.tar.gz: 635d0feb131998e549802d9f251763958fab33b7
3
+ metadata.gz: 0146d41a2dbe9f16202054ce05b0d8e1136b4c2d
4
+ data.tar.gz: 73c1210b0944999ff5f5bf4e801f6ef1dea3e530
5
5
  SHA512:
6
- metadata.gz: bb9bffd522fe3de4f651d0ecabf504958c33c8830b5708028623863e3cdfa7dfdb052c4b74f06aa7ff04f5b77448158509fb119cf33f1b57f98f161cac44deca
7
- data.tar.gz: f15e211c860a83df6c9e35fb91486c5b8035353348cebd984657d95a1d0c4b6d58f2b58a5c7e806de0b9e5ea00b64e991aed751333f6e021431c7516ef70446e
6
+ metadata.gz: e272725372a7d8922a5ba76c67382f2efb40f257bfd1c85bb842dd0812c29ecd155335332f943ae904292670ea357382c2673a54d985ce637211c71263afd35d
7
+ data.tar.gz: df4dd399881426ec166d8cd7ca3d44721201f3b64817cb2063be0ada8a0a9bfc426f0882b032142be2ec84500c59460c9506e400f4dcedac007f57cd63f82d45
data/README.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Avangate
2
2
 
3
3
  This gem is a library to interact with Avangate SOAP API
4
+ And to manage IPN - Payment Notifications
4
5
 
5
6
  Current methods implemented:
6
7
 
8
+ SOAP:
9
+
7
10
  #login
8
11
  #addProduct
9
12
  #setBillingDetails
13
+ #get_product_by_code
14
+
15
+ Notifications:
16
+
17
+ #generate_receipt
10
18
 
11
19
  ## Installation
12
20
 
@@ -33,27 +41,35 @@ Inside you can and set up:
33
41
  Avangate::Base.secret_key = "SECRET_KEY"
34
42
  Avangate::Base.merchant_code = "MERCHANT_CODE"
35
43
 
36
- ## Usage
44
+ ## Example of usage
45
+
46
+ SOAP:
37
47
 
38
48
  @sessionId = Avangate::SOAP.login
39
49
  Avangate::SOAP.add_product({session_id: @sessionId, product_id: 423221})
40
50
  Avangate::SOAP.set_billing_details({
41
- session_id: @sessionId,
42
- address: '4 street',
43
- city: 'dream city',
44
- country: 'US',
45
- email: 'john.doe@example.com',
46
- first_name: 'John',
47
- last_name: 'Doe',
48
- postal_code: '12333',
49
- state: 'Alabama'
50
- })
51
-
52
- ## Development
53
-
54
- 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.
55
-
56
- 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).
51
+ session_id: @sessionId,
52
+ address: '4 street',
53
+ city: 'dream city',
54
+ country: 'US',
55
+ email: 'john.doe@example.com',
56
+ first_name: 'John',
57
+ last_name: 'Doe',
58
+ postal_code: '12333',
59
+ state: 'Alabama'
60
+ })
61
+
62
+
63
+ product = Avangate::SOAP.get_product_by_code({
64
+ session_id: @sessionId,
65
+ product_code: 123
66
+ })
67
+
68
+
69
+ IPN:
70
+
71
+ render text: Avangate::Notification.generate_receipt
72
+
57
73
 
58
74
  ## Contributing
59
75
 
@@ -2,6 +2,7 @@ require "savon"
2
2
  require "avangate/version"
3
3
  require "avangate/base"
4
4
  require "avangate/errors"
5
+ require "avangate/notifications"
5
6
 
6
7
  module Avangate
7
8
 
@@ -12,7 +13,7 @@ module Avangate
12
13
  def self.login
13
14
  begin
14
15
  response = client.call :login, message: login_params
15
- return response.body.first[1].first[1]
16
+ return response.body[:login_response][:login_return]
16
17
  rescue Savon::SOAPFault => e
17
18
  return false
18
19
  end
@@ -23,7 +24,7 @@ module Avangate
23
24
  require_session_id
24
25
  require_product_id
25
26
  response = client.call :add_product, message: add_product_params
26
- return response.body.first[1].first[1]
27
+ return response.body[:add_product_response][:add_product_return]
27
28
  end
28
29
 
29
30
  def self.set_billing_details(options={})
@@ -31,7 +32,7 @@ module Avangate
31
32
  require_session_id
32
33
  require_set_billing_details_params
33
34
  response = client.call :set_billing_details, message: set_billing_details_params
34
- return response.body.first[1].first[1]
35
+ return response.body[:set_billing_details_response][:set_billing_details_return]
35
36
  end
36
37
 
37
38
  def self.get_product_by_code(options={})
@@ -39,7 +40,7 @@ module Avangate
39
40
  require_session_id
40
41
  require_product_code
41
42
  response = client.call :get_product_by_code, message: get_product_by_code_params
42
- return response.body.first[1].first[1]
43
+ return response.body[:get_product_by_code_response][:get_product_by_code_return]
43
44
  end
44
45
 
45
46
  private
@@ -0,0 +1,37 @@
1
+ module Avangate
2
+
3
+ class Notifications
4
+
5
+ def initialize(params)
6
+ @ipn_pid0 = params[:IPN_PID].first
7
+ @ipn_pname0 = params[:IPN_PNAME].first
8
+ @date = params[:DATE]
9
+ end
10
+
11
+ def generate_receipt
12
+ "<EPAYMENT>#{@date}|#{hash}</EPAYMENT>"
13
+ end
14
+
15
+ private
16
+
17
+
18
+ def hash
19
+ OpenSSL::HMAC.hexdigest OpenSSL::Digest.new('md5'), secret_key, data_for_hash
20
+ end
21
+
22
+ def data_for_hash
23
+ values = [@ipn_pid0, @ipn_pname0, @date, @date]
24
+ str = ""
25
+ values.each do |value|
26
+ str << value.size.to_s + value.to_s
27
+ end
28
+ str
29
+ end
30
+
31
+ def secret_key
32
+ Avangate::Base.secret_key
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -1,3 +1,3 @@
1
1
  module Avangate
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avangate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2015-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,6 +96,7 @@ files:
96
96
  - lib/avangate.rb
97
97
  - lib/avangate/base.rb
98
98
  - lib/avangate/errors.rb
99
+ - lib/avangate/notifications.rb
99
100
  - lib/avangate/version.rb
100
101
  homepage: https://github.com/lmajowka/avangate
101
102
  licenses: