openpayu 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +45 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +10 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +193 -0
  11. data/Rakefile +1 -0
  12. data/doc/EmptyResponseError.html +123 -0
  13. data/doc/HttpStatusException.html +123 -0
  14. data/doc/NotImplementedException.html +123 -0
  15. data/doc/OpenPayU.html +436 -0
  16. data/doc/OpenPayU/Configuration.html +1530 -0
  17. data/doc/OpenPayU/Connection.html +381 -0
  18. data/doc/OpenPayU/Document.html +705 -0
  19. data/doc/OpenPayU/Documents.html +117 -0
  20. data/doc/OpenPayU/Documents/Request.html +503 -0
  21. data/doc/OpenPayU/Documents/Response.html +783 -0
  22. data/doc/OpenPayU/Models.html +117 -0
  23. data/doc/OpenPayU/Models/Address.html +861 -0
  24. data/doc/OpenPayU/Models/Buyer.html +587 -0
  25. data/doc/OpenPayU/Models/Buyer/Delivery.html +312 -0
  26. data/doc/OpenPayU/Models/Card.html +507 -0
  27. data/doc/OpenPayU/Models/Fee.html +367 -0
  28. data/doc/OpenPayU/Models/Model.html +1208 -0
  29. data/doc/OpenPayU/Models/NotifyResponse.html +297 -0
  30. data/doc/OpenPayU/Models/Order.html +1155 -0
  31. data/doc/OpenPayU/Models/PayMethod.html +507 -0
  32. data/doc/OpenPayU/Models/Product.html +787 -0
  33. data/doc/OpenPayU/Models/Refund.html +1020 -0
  34. data/doc/OpenPayU/Models/ShippingMethod.html +367 -0
  35. data/doc/OpenPayU/Models/StatusUpdate.html +647 -0
  36. data/doc/OpenPayU/Models/Token.html +507 -0
  37. data/doc/OpenPayU/Order.html +924 -0
  38. data/doc/OpenPayU/Refund.html +269 -0
  39. data/doc/OpenPayU/Token.html +288 -0
  40. data/doc/OpenPayU/XmlBuilder.html +277 -0
  41. data/doc/WrongConfigurationError.html +123 -0
  42. data/doc/WrongNotifyRequest.html +123 -0
  43. data/doc/WrongOrderParameters.html +267 -0
  44. data/doc/WrongSignatureException.html +123 -0
  45. data/doc/_index.html +446 -0
  46. data/doc/class_list.html +54 -0
  47. data/doc/css/common.css +1 -0
  48. data/doc/css/full_list.css +57 -0
  49. data/doc/css/style.css +338 -0
  50. data/doc/file.README.html +281 -0
  51. data/doc/file_list.html +56 -0
  52. data/doc/frames.html +26 -0
  53. data/doc/index.html +281 -0
  54. data/doc/js/app.js +214 -0
  55. data/doc/js/full_list.js +178 -0
  56. data/doc/js/jquery.js +4 -0
  57. data/doc/method_list.html +1007 -0
  58. data/doc/top-level-namespace.html +114 -0
  59. data/lib/openpayu.rb +66 -0
  60. data/lib/openpayu/configuration.rb +62 -0
  61. data/lib/openpayu/connection.rb +65 -0
  62. data/lib/openpayu/document.rb +105 -0
  63. data/lib/openpayu/documents/request.rb +34 -0
  64. data/lib/openpayu/documents/response.rb +48 -0
  65. data/lib/openpayu/exceptions.rb +19 -0
  66. data/lib/openpayu/models/address.rb +12 -0
  67. data/lib/openpayu/models/buyer.rb +11 -0
  68. data/lib/openpayu/models/buyer/delivery.rb +7 -0
  69. data/lib/openpayu/models/buyer/invoice.rb +8 -0
  70. data/lib/openpayu/models/card.rb +10 -0
  71. data/lib/openpayu/models/fee.rb +9 -0
  72. data/lib/openpayu/models/model.rb +151 -0
  73. data/lib/openpayu/models/notify_response.rb +9 -0
  74. data/lib/openpayu/models/order.rb +28 -0
  75. data/lib/openpayu/models/pay_method.rb +10 -0
  76. data/lib/openpayu/models/product.rb +10 -0
  77. data/lib/openpayu/models/refund.rb +41 -0
  78. data/lib/openpayu/models/shipping_method.rb +9 -0
  79. data/lib/openpayu/models/status_update.rb +14 -0
  80. data/lib/openpayu/models/token.rb +10 -0
  81. data/lib/openpayu/order.rb +119 -0
  82. data/lib/openpayu/refund.rb +26 -0
  83. data/lib/openpayu/token.rb +27 -0
  84. data/lib/openpayu/version.rb +4 -0
  85. data/lib/openpayu/xml_builder.rb +23 -0
  86. data/lib/openpayu_ruby.rb +2 -0
  87. data/openpayu_ruby.gemspec +40 -0
  88. data/spec/cassettes/cancel_order.yml +50 -0
  89. data/spec/cassettes/create_order.yml +51 -0
  90. data/spec/cassettes/refund_order.yml +100 -0
  91. data/spec/cassettes/retrieve_order.yml +51 -0
  92. data/spec/cassettes/update_order.yml +50 -0
  93. data/spec/integration/order_spec.rb +103 -0
  94. data/spec/openpayu.yml +11 -0
  95. data/spec/spec_helper.rb +27 -0
  96. data/spec/test_objects/order.rb +97 -0
  97. data/spec/unit/configuration_spec.rb +71 -0
  98. data/spec/unit/document_spec.rb +18 -0
  99. data/spec/unit/models/order_spec.rb +82 -0
  100. data/spec/unit/models/refund_spec.rb +24 -0
  101. data/spec/unit/openpayu_spec.rb +27 -0
  102. metadata +327 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NmU5MTA2MGMwNmY3ZTE4ODJjOGMyODQ1NTBlZWJjMzAxZmQ1MTczMw==
5
+ data.tar.gz: !binary |-
6
+ OTQ4YWY1YzljNjFhMTE0NWEwN2IxYzNjMzZlZjM3N2RjZDQ2NWIwMQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZjJlYWEwYWMxNDVjMzRjYzI5MDEyZmQzNDg3MTBlNjQyOTEyOWZhZjA4MTY5
10
+ ZjQ4NTdmMDY0MmEzODMyZTk4MDhkN2Y5NDQ1YTFmZTY4ZWI4Y2M5ODE3Y2Zj
11
+ MjFiOGYzMDQ3NzIyZjU0MTY1MmI4NGJmNTQwM2UwNGFhYzAzOTY=
12
+ data.tar.gz: !binary |-
13
+ ZGE1YzRjMjVkMTA1OTMzZTY3MWYyZTk0MmY3ZDE0YmY4YjVmYmRkNDZhMWMy
14
+ ZjUxYjg1YzhhZDZmY2U5ZTE3MDQzMmQ1MmUyNjgwYjc4OGI5OWE0MDJkYjQz
15
+ NzYwYmE5NGI3YzYzMjk3ODcxYzkzM2JlMGI2NDdhMWI5MjU4ZTU=
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ dokumenty
18
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+
data/.rubocop.yml ADDED
@@ -0,0 +1,45 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+
3
+ MethodLength:
4
+ Max: 22
5
+
6
+ LineLength:
7
+ Max: 80
8
+
9
+ ClassLength:
10
+ Max: 140
11
+
12
+ CyclomaticComplexity:
13
+ Max: 10
14
+
15
+ Output:
16
+ Ignore:
17
+ - '^.*\.rake$'
18
+ - '^.*/script/.*$'
19
+ - '^.*/tasks/.*$'
20
+ - 'Rakefile$'
21
+ - '^.*/config/recipes/.*$'
22
+
23
+ Documentation:
24
+ Description: 'Document classes and non-namespace modules.'
25
+ Enabled: false
26
+
27
+ EmptyLinesAroundBody:
28
+ Description: "Keeps track of blank lines around expression bodies."
29
+ Enabled: false
30
+
31
+ SymbolName:
32
+ Description: 'Symbol literals should use snake_case.'
33
+ Enabled: false
34
+
35
+ BracesAroundHashParameters:
36
+ Description: 'Enforce braces style inside hash parameters.'
37
+ Enabled: false
38
+
39
+ AlignParameters:
40
+ Description: Align the parameters of a method call if they span more than.
41
+ Enabled: false
42
+
43
+ SignalException:
44
+ Description: 'Checks for proper usage of fail and raise.'
45
+ Enabled: false
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ openpayu_sdk_ruby
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p194
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ # uncomment this line if your project needs to run something other than `rake`:
7
+ script: bundle exec rspec spec
8
+ addons:
9
+ code_climate:
10
+ repo_token: a909fe634532217548c2a59fa663bb2bad564b0218993c1a6b4e2a2d97664d51
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in openpayu_ruby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Krzysztof Streflik
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,193 @@
1
+ [![Build Status](https://magnum.travis-ci.com/PayU/openpayu_ruby_sdk.png?token=sqp5QvsmzqEqtVB3sNsK&branch=master)](https://magnum.travis-ci.com/PayU/openpayu_ruby_sdk)
2
+ [![Code Climate](https://codeclimate.com/repos/524eb044f3ea00329815dff1/badges/885c2d52f25c02295344/gpa.png)](https://codeclimate.com/repos/524eb044f3ea00329815dff1/feed)
3
+
4
+ # OpenpayuSdkRuby
5
+
6
+ The OpenPayU Ruby library provides integration access to the PayU Gateway API ver. 2.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'openpayu'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install openpayu
21
+
22
+ ##Configure Gem
23
+ To configure OpenPayU environment add a file to config/initializers/openpayu.rb containing:
24
+
25
+ OpenPayU::Configuration.configure do |config|
26
+ config.merchant_pos_id = '8389534'
27
+ config.signature_key = '95873498573498573897fb42d'
28
+ config.algorithm = 'MD5' # MD5, SHA-1, SHA-256
29
+ config.service_domain = 'payu.com'
30
+ config.protocol = 'https'
31
+ config.data_format = 'json' # json, xml
32
+ config.env = 'secure'
33
+ config.order_url = 'http://localhost/order'
34
+ config.notify_url = 'http://localhost/notify'
35
+ config.continue_url = 'http://localhost/success'
36
+ end
37
+
38
+ Or by providing a path to YAML file
39
+
40
+ OpenPayU::Configuration.configure File.join(Rails.root, 'config/openpayu.yml')
41
+
42
+ Structure of YAML file:
43
+
44
+ development:
45
+ merchant_pos_id: '8389534'
46
+ signature_key: 95873498573498573897fb42d
47
+ algorithm: MD5 # MD5, SHA-1, SHA-256
48
+ service_domain: payu.com
49
+ protocol: https
50
+ data_format: json # json, xml
51
+ env: secure
52
+ order_url: http://localhost/order
53
+ notify_url: http://localhost/notify
54
+ continue_url: http://localhost/success
55
+ production:
56
+ merchant_pos_id: '8389534'
57
+ signature_key: 95873498573498573897fb42d
58
+ algorithm: MD5 # MD5, SHA-1, SHA-256
59
+ service_domain: payu.com
60
+ protocol: https
61
+ data_format: json # json, xml
62
+ env: secure
63
+ order_url: http://localhost/order
64
+ notify_url: http://localhost/notify
65
+ continue_url: http://localhost/success
66
+
67
+ ##Usage
68
+
69
+ ###Creating Transparent order
70
+ To create an order you must provide a Hash with order:
71
+
72
+ order = {
73
+ merchant_pos_id: "8389534",
74
+ customer_ip: "127.0.0.1", # You can user request.remote_ip in your controller
75
+ ext_order_id: 1342, #Order id in your system
76
+ order_url: "http://localhost/",
77
+ description: "New order",
78
+ currency_code: "PLN",
79
+ total_amount: 10000,
80
+ notify_url: "http://localhost/",
81
+ continue_url: "http://localhost/",
82
+ validity_time: '48000',
83
+ buyer: {
84
+ email: 'dd@ddd.pl',
85
+ phone: '123123123',
86
+ first_name: 'Jan',
87
+ last_name: 'Kowalski',
88
+ language: 'pl_PL',
89
+ NIN: "123456"
90
+ },
91
+ products: [
92
+ {
93
+ name: 'Mouse',
94
+ unit_price: 10000,
95
+ quantity: 1
96
+ }
97
+ ],
98
+ pay_methods: [
99
+ {
100
+ type: 'CARD_TOKEN',
101
+ value: 'Token value'
102
+ }
103
+ ]
104
+ }
105
+
106
+ When you have ready order Hash you can create new order:
107
+
108
+ @response = OpenPayU::Order.create(order)
109
+
110
+ If request succeed to create it will return "COMPLETE" as a status_code.
111
+ There might be also a redirect to page with confirmation.
112
+ There are three redirect types:
113
+
114
+ * WARNING_CONTINUE_REDIRECT
115
+ * WARNING_CONTINUE_CVV
116
+ * WARNING_CONTINUE_3DS
117
+
118
+ ```
119
+ case @response.status["status_code"]
120
+ when 'COMPLETE'
121
+ # order has been created
122
+ when /WARNING_CONTINUE_/
123
+ #need to redirec user to a provided URL
124
+ redirect_to @response.redirect_uri
125
+ else
126
+ #in other cases something went wrong
127
+ logger.info "Unable to create order.
128
+ Status: #{@response.status["status_code"]}.
129
+ Response: #{@response}"
130
+ end
131
+ ```
132
+
133
+ ###Creating Hosted order
134
+
135
+ If you pass the same Hash of order as above to hosted_order_form you will
136
+ get a String containgin a form to embed in your view
137
+
138
+ #in your controller
139
+ @order_form_data = OpenPayU.hosted_order_form(order)
140
+
141
+ # in your view
142
+ <%= @order_form_data.html_safe %>
143
+
144
+ ###Retrieving order from OpenPayU
145
+ You can retrieve order by its PayU order_id
146
+
147
+ @response = OpenPayU::Order.retrieve("Z963D5JQR2230925GUEST000P01")
148
+
149
+ ###Cancelling order
150
+ You can cancel order by its PayU order_id
151
+
152
+ @response = OpenPayU::Order.cancel("Z963D5JQR2230925GUEST000P01")
153
+
154
+ ###Updating order status
155
+ You can update order status to accept order when Autoreceive in POS is turned off
156
+
157
+ status_update = {
158
+ order_id: "Z963D5JQR2230925GUEST000P01",
159
+ order_status: 'COMPLETED'
160
+ }
161
+ @response = OpenPayU::Order.status_update(status_update)
162
+
163
+ ###Handling notifications from PayU
164
+ PayU sends requests to your application when order status changes
165
+
166
+ @response = OpenPayU::Order.consume_notification(request) #request object from controller
167
+ @response.order_status #NEW PENDING CANCELLED REJECTED COMPLETED WAITING_FOR_CONFIRMATION
168
+ #you should response to PayU with special structure (OrderNotifyResponse)
169
+ render json: OpenPayU::Order.build_notify_response(@response.req_id)
170
+
171
+
172
+ ###Refund money
173
+
174
+ @refund = OpenPayU::Refund.create({
175
+ order_id: "Z963D5JQR2230925GUEST000P01", #required
176
+ description: "Money refund", #required
177
+ ext_refund_id: 21312, #Refund Id in your syste, optional
178
+ amount: 1000, #If not provided, returns whole transaction, optional
179
+ commission_amount: 123, #optional
180
+ currency_code: "PLN" #optional
181
+ })
182
+
183
+
184
+
185
+
186
+
187
+ ## Contributing
188
+
189
+ 1. Fork it
190
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
191
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
192
+ 4. Push to the branch (`git push origin my-new-feature`)
193
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,123 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Exception: EmptyResponseError
8
+
9
+ &mdash; Documentation by YARD 0.8.7.2
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index (E)</a> &raquo;
35
+
36
+
37
+ <span class="title">EmptyResponseError</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Exception: EmptyResponseError
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName">StandardError</span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">StandardError</li>
82
+
83
+ <li class="next">EmptyResponseError</li>
84
+
85
+ </ul>
86
+ <a href="#" class="inheritanceTree">show all</a>
87
+
88
+ </dd>
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+ <dt class="r2 last">Defined in:</dt>
99
+ <dd class="r2 last">lib/openpayu/exceptions.rb</dd>
100
+
101
+ </dl>
102
+ <div class="clear"></div>
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+ </div>
115
+
116
+ <div id="footer">
117
+ Generated on Tue Dec 17 15:20:59 2013 by
118
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
+ 0.8.7.2 (ruby-1.9.3).
120
+ </div>
121
+
122
+ </body>
123
+ </html>