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
@@ -0,0 +1,26 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module OpenPayU
3
+
4
+ # Create Refund for an Order
5
+
6
+ class Refund
7
+
8
+ # Creates a RefundCreateRequest
9
+ #
10
+ # @param [Hash] data A Hash object containing full {Models::Refund} object
11
+ # @return [Documents::Response] Response class object order
12
+ # with RefundCreateResponse
13
+ def self.create(data)
14
+ refund = Models::Refund.new(data)
15
+ url = Configuration.get_base_url + "order/#{refund.order_id}/refund." +
16
+ OpenPayU::Configuration.data_format
17
+ request = Documents::Request.new(
18
+ refund.prepare_data('RefundCreateRequest')
19
+ )
20
+ @response = Documents::Response.new(
21
+ Connection.post(url, request.body, request.headers),
22
+ 'RefundCreateResponse'
23
+ )
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module OpenPayU
3
+
4
+ # Create Token
5
+
6
+ class Token
7
+
8
+ # Creates a TokenCreateRequest
9
+ #
10
+ # @param [Hash] data A Hash object containing full {Models::Token} object
11
+ # @return [Documents::Response] Response class object order
12
+ # with TokenCreateResponse
13
+ # @note Not yet implemented in API
14
+ def self.create(data)
15
+ raise NotImplementedException, 'This feature is not yet implemented'
16
+ url = Configuration.get_base_url + 'token.'
17
+ url << OpenPayU::Configuration.data_format
18
+ token = Models::Token.new(data)
19
+ request = Documents::Request.new(token.prepare_data('TokenCreateRequest'))
20
+ OpenPayU::Documents::Response.new(
21
+ Connection.post(url, request.data, request.header),
22
+ 'TokenCreateResponse'
23
+ )
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module OpenPayU
3
+ VERSION = '0.0.2'
4
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'builder/xmlmarkup'
3
+
4
+ module OpenPayU
5
+ class XmlBuilder < ::Builder::XmlMarkup
6
+
7
+ def initialize(req_type, options = {})
8
+ @req_type = req_type
9
+ super(options)
10
+ end
11
+
12
+ def tag!(sym, *args, &block)
13
+ if @level == 0 # Root element
14
+ args << {
15
+ 'xsi:type' => @req_type,
16
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
17
+ }
18
+ end
19
+ super(sym, *args, &block)
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,2 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'openpayu'
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'openpayu/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "openpayu"
8
+ spec.version = OpenPayU::VERSION
9
+ spec.authors = ["Krzysztof Streflik"]
10
+ spec.email = ["krzysztof.streflik@allegro.pl"]
11
+ spec.description = %q{A SDK for OpenPayU API}
12
+ spec.summary = %q{A SDK for OpenPayU API}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ if RUBY_VERSION < "1.9.3"
25
+ spec.add_development_dependency "activemodel", '~> 3.2'
26
+ spec.add_development_dependency "activesupport", '~> 3.2'
27
+ spec.add_runtime_dependency "activemodel", '~> 3.2'
28
+ spec.add_runtime_dependency "activesupport", '~> 3.2'
29
+ else
30
+ spec.add_development_dependency "activemodel"
31
+ spec.add_development_dependency "activesupport"
32
+ spec.add_runtime_dependency "activemodel"
33
+ spec.add_runtime_dependency "activesupport"
34
+ end
35
+ spec.add_development_dependency "vcr"
36
+ spec.add_development_dependency "fakeweb"
37
+ spec.add_development_dependency "yard"
38
+ spec.add_development_dependency "rdoc"
39
+ spec.add_development_dependency "codeclimate-test-reporter"
40
+ end
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: http://platnosci-dev5.dc2/api/v2/order/28161ZT5TF131121GUEST000P01.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ openpayu-signature:
11
+ - sender=45654;signature=69c369ae89fba8f8183f6534a1410b1b;algorithm=MD5
12
+ accept:
13
+ - ! '*/*'
14
+ user-agent:
15
+ - Ruby
16
+ content-type:
17
+ - application/json
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ date:
24
+ - Thu, 21 Nov 2013 14:32:35 GMT
25
+ server:
26
+ - Apache/2.2.17 (Unix) DAV/2 mod_ssl/2.2.17 OpenSSL/1.0.0c mod_jk/1.2.31 PHP/5.3.5
27
+ mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
28
+ openpayu-signature:
29
+ - signature=06227acee76617a610039a273faed13f;algorithm=MD5;sender=checkout;content=DOCUMENT;
30
+ x-openpayu-signature:
31
+ - signature=06227acee76617a610039a273faed13f;algorithm=MD5;sender=checkout;content=DOCUMENT;
32
+ content-language:
33
+ - pl
34
+ content-length:
35
+ - '166'
36
+ set-cookie:
37
+ - payu_persistent=mobile_agent-false#; Expires=Sun, 16-Nov-2014 14:32:35 GMT;
38
+ Path=/
39
+ - CSESSIONID=90F64A8F648CF038A543C0A68BDD3804.01; Path=/pl/standard/co
40
+ connection:
41
+ - close
42
+ content-type:
43
+ - application/json;charset=UTF-8
44
+ body:
45
+ encoding: US-ASCII
46
+ string: ! '{"OpenPayU":{"OrderCancelResponse":{"Status":{"StatusCode":"SUCCESS","StatusDesc":"Request
47
+ successful"},"ExtOrderId":"1342","OrderId":"28161ZT5TF131121GUEST000P01"}}}'
48
+ http_version: '1.1'
49
+ recorded_at: Thu, 21 Nov 2013 14:32:35 GMT
50
+ recorded_with: VCR 2.6.0
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://platnosci-dev5.dc2/api/v2/order.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ! '{"OpenPayU":{"OrderCreateRequest":{"merchant_pos_id":"45654","customer_ip":"127.0.0.1","ext_order_id":1342,"order_url":"http://localhost/","description":"New
9
+ order","currency_code":"PLN","total_amount":10000,"notify_url":"http://localhost/","continue_url":"http://localhost/","validity_time":"48000","buyer":{"email":"dd@ddd.pl","phone":"123123123","first_name":"Jan","last_name":"Kowalski","language":"pl_PL","NIN":"123456","validation_context":null,"errors":{}},"products":[{"name":"Mouse","unit_price":10000,"quantity":1,"all_errors":{},"validation_context":null,"errors":{}}],"pay_methods":[{"type":"CARD_TOKEN","value":"TOK_1HPPNU4HIOWT180pPDWhuhAmM3ym","all_errors":{},"validation_context":null,"errors":{}}],"req_id":"{a746b206-b72e-4302-b623-1c519bb32bdd}","all_errors":{},"validation_context":null,"errors":{},"MerchantPosId":"45654","CustomerIp":"127.0.0.1","ExtOrderId":1342,"OrderUrl":"http://localhost/","Description":"New
10
+ order","CurrencyCode":"PLN","TotalAmount":10000,"NotifyUrl":"http://localhost/","ContinueUrl":"http://localhost/","ValidityTime":"48000","Buyer":{"Email":"dd@ddd.pl","Phone":"123123123","FirstName":"Jan","LastName":"Kowalski","Language":"pl_PL","NIN":"123456"},"Products":[{"Product":{"Name":"Mouse","UnitPrice":10000,"Quantity":1}}],"PayMethods":[{"PayMethod":{"Type":"CARD_TOKEN","Value":"TOK_1HPPNU4HIOWT180pPDWhuhAmM3ym"}}],"ReqId":"{a746b206-b72e-4302-b623-1c519bb32bdd}"}}}'
11
+ headers:
12
+ accept:
13
+ - ! '*/*'
14
+ user-agent:
15
+ - Ruby
16
+ content-type:
17
+ - application/json
18
+ openpayu-signature:
19
+ - sender=45654;signature=2a4046802854830e9bd2b27541ef977a;algorithm=MD5
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ date:
26
+ - Thu, 21 Nov 2013 14:32:33 GMT
27
+ server:
28
+ - Apache/2.2.17 (Unix) DAV/2 mod_ssl/2.2.17 OpenSSL/1.0.0c mod_jk/1.2.31 PHP/5.3.5
29
+ mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
30
+ openpayu-signature:
31
+ - signature=e15c458b67bd01c2a170b55033f59507;algorithm=MD5;sender=checkout;content=DOCUMENT;
32
+ x-openpayu-signature:
33
+ - signature=e15c458b67bd01c2a170b55033f59507;algorithm=MD5;sender=checkout;content=DOCUMENT;
34
+ content-language:
35
+ - pl
36
+ content-length:
37
+ - '337'
38
+ set-cookie:
39
+ - payu_persistent=mobile_agent-false#; Expires=Sun, 16-Nov-2014 14:32:33 GMT;
40
+ Path=/
41
+ - CSESSIONID=06B5736A0A8FA9D394730EDF27EB05A0.01; Path=/pl/standard/co
42
+ connection:
43
+ - close
44
+ content-type:
45
+ - application/json;charset=UTF-8
46
+ body:
47
+ encoding: US-ASCII
48
+ string: ! '{"OpenPayU":{"OrderCreateResponse":{"Status":{"StatusCode":"SUCCESS"},"OrderId":"28161ZT5TF131121GUEST000P01","ResId":"{a746b206-b72e-4302-b623-1c519bb32bdd}","PayMethods":{"PayMethod":{"Value":"TOKC_TMWKMHX4VYTZPWPQM17ERFGKDHZ","Type":"CARD_TOKEN","Card":{"ExpirationYear":"2014","ExpirationMonth":"12","Number":"510005******6818"}}}}}}'
49
+ http_version: '1.1'
50
+ recorded_at: Thu, 21 Nov 2013 14:32:35 GMT
51
+ recorded_with: VCR 2.6.0
@@ -0,0 +1,100 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://platnosci-dev5.dc2/api/v2/order/28161ZT5TF131121GUEST000P01/refund.xml
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ! "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <OpenPayU xmlns=\"http://www.openpayu.com/20/openpayu.xsd\"><RefundCreateRequest
9
+ xsi:type=\"RefundCreateRequest\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n
10
+ \ <OrderId>28161ZT5TF131121GUEST000P01</OrderId>\n <Refund>\n <OrderId>28161ZT5TF131121GUEST000P01</OrderId>\n
11
+ \ <Description>Money refund</Description>\n </Refund>\n</RefundCreateRequest>\n</OpenPayU>"
12
+ headers:
13
+ accept:
14
+ - ! '*/*'
15
+ user-agent:
16
+ - Ruby
17
+ content-type:
18
+ - application/xml
19
+ openpayu-signature:
20
+ - sender=45654;signature=78a4d3140aec53f8dadd2f38e9b43563;algorithm=MD5
21
+ response:
22
+ status:
23
+ code: 200
24
+ message: OK
25
+ headers:
26
+ date:
27
+ - Thu, 26 Sep 2013 08:22:04 GMT
28
+ server:
29
+ - Apache/2.2.17 (Unix) DAV/2 mod_ssl/2.2.17 OpenSSL/1.0.0c mod_jk/1.2.31 PHP/5.3.5
30
+ mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
31
+ openpayu-signature:
32
+ - signature=5687e10debc25d2605e3d50a746e9d50;algorithm=MD5;sender=checkout;content=DOCUMENT;
33
+ x-openpayu-signature:
34
+ - signature=5687e10debc25d2605e3d50a746e9d50;algorithm=MD5;sender=checkout;content=DOCUMENT;
35
+ content-language:
36
+ - pl
37
+ content-length:
38
+ - '640'
39
+ set-cookie:
40
+ - payu_persistent=mobile_agent-false#; Expires=Sun, 21-Sep-2014 08:22:04 GMT;
41
+ Path=/
42
+ - CSESSIONID=FD0D29BFF48F01C027ADA3F234711265.01; Path=/pl/standard/co
43
+ connection:
44
+ - close
45
+ content-type:
46
+ - application/xml;charset=UTF-8
47
+ body:
48
+ encoding: US-ASCII
49
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><OpenPayU xmlns="http://www.openpayu.com/20/openpayu.xsd"><RefundCreateResponse><Status><StatusCode>SUCCESS</StatusCode></Status><OrderId>28161ZT5TF131121GUEST000P01</OrderId><Refund><RefundId>87045</RefundId><ExtRefundId>20130926102204</ExtRefundId><Type>REFUND_PAYMENT_STANDARD</Type><Amount>10000</Amount><CurrencyCode>PLN</CurrencyCode><Description>Uznanie
50
+ 87045 Money refund</Description><CreationDateTime>2013-09-26T10:22:04.805+02:00</CreationDateTime><Status>INIT</Status><StatusDateTime>2013-09-26T10:22:06.009+02:00</StatusDateTime></Refund></RefundCreateResponse></OpenPayU>
51
+ http_version: '1.1'
52
+ recorded_at: Thu, 26 Sep 2013 08:22:05 GMT
53
+ - request:
54
+ method: post
55
+ uri: http://platnosci-dev5.dc2/api/v2/order/28161ZT5TF131121GUEST000P01/refund.json
56
+ body:
57
+ encoding: US-ASCII
58
+ string: ! '{"OpenPayU":{"RefundCreateRequest":{"OrderId":"28161ZT5TF131121GUEST000P01","Refund":{"OrderId":"28161ZT5TF131121GUEST000P01","Description":"Money
59
+ refund"}}}}'
60
+ headers:
61
+ accept:
62
+ - ! '*/*'
63
+ user-agent:
64
+ - Ruby
65
+ content-type:
66
+ - application/json
67
+ openpayu-signature:
68
+ - sender=45654;signature=5148e34fd91bb884cae08da7a4df3642;algorithm=MD5
69
+ response:
70
+ status:
71
+ code: 200
72
+ message: OK
73
+ headers:
74
+ date:
75
+ - Thu, 26 Sep 2013 08:23:49 GMT
76
+ server:
77
+ - Apache/2.2.17 (Unix) DAV/2 mod_ssl/2.2.17 OpenSSL/1.0.0c mod_jk/1.2.31 PHP/5.3.5
78
+ mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
79
+ openpayu-signature:
80
+ - signature=7cbbb385c8e51b62d078c3bc44b346f6;algorithm=MD5;sender=checkout;content=DOCUMENT;
81
+ x-openpayu-signature:
82
+ - signature=7cbbb385c8e51b62d078c3bc44b346f6;algorithm=MD5;sender=checkout;content=DOCUMENT;
83
+ content-language:
84
+ - pl
85
+ content-length:
86
+ - '404'
87
+ set-cookie:
88
+ - payu_persistent=mobile_agent-false#; Expires=Sun, 21-Sep-2014 08:23:49 GMT;
89
+ Path=/
90
+ - CSESSIONID=D2B119012855F2250A7B1E75141A25DD.01; Path=/pl/standard/co
91
+ connection:
92
+ - close
93
+ content-type:
94
+ - application/json;charset=UTF-8
95
+ body:
96
+ encoding: US-ASCII
97
+ string: ! '{"OpenPayU":{"RefundCreateResponse":{"Status":{"StatusCode":"SUCCESS"},"OrderId":"28161ZT5TF131121GUEST000P01","Refund":{"Status":"INIT","Description":"Uznanie
98
+ 87046 Money refund","Amount":"10000","RefundId":"87046","ExtRefundId":"20130926102349","CreationDateTime":"2013-09-26T10:23:49.256+02:00","Type":"REFUND_PAYMENT_STANDARD","StatusDateTime":"2013-09-26T10:23:49.491+02:00","CurrencyCode":"PLN"}}}}'
99
+ http_version: '1.1'
100
+ recorded_at: Thu, 26 Sep 2013 08:23:48 GMT
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://platnosci-dev5.dc2/api/v2/order/28161ZT5TF131121GUEST000P01.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ openpayu-signature:
11
+ - sender=45654;signature=69c369ae89fba8f8183f6534a1410b1b;algorithm=MD5
12
+ accept:
13
+ - ! '*/*'
14
+ user-agent:
15
+ - Ruby
16
+ content-type:
17
+ - application/json
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ date:
24
+ - Thu, 21 Nov 2013 14:32:35 GMT
25
+ server:
26
+ - Apache/2.2.17 (Unix) DAV/2 mod_ssl/2.2.17 OpenSSL/1.0.0c mod_jk/1.2.31 PHP/5.3.5
27
+ mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
28
+ openpayu-signature:
29
+ - signature=7bd43e0b99c03a76aca60c7896bce9cf;algorithm=MD5;sender=checkout;content=DOCUMENT;
30
+ x-openpayu-signature:
31
+ - signature=7bd43e0b99c03a76aca60c7896bce9cf;algorithm=MD5;sender=checkout;content=DOCUMENT;
32
+ content-language:
33
+ - pl
34
+ content-length:
35
+ - '550'
36
+ set-cookie:
37
+ - payu_persistent=mobile_agent-false#; Expires=Sun, 16-Nov-2014 14:32:35 GMT;
38
+ Path=/
39
+ - CSESSIONID=699C5F1B2B7FA87764F99990BDA185EF.01; Path=/pl/standard/co
40
+ connection:
41
+ - close
42
+ content-type:
43
+ - application/json;charset=UTF-8
44
+ body:
45
+ encoding: US-ASCII
46
+ string: ! '{"OpenPayU":{"OrderRetrieveResponse":{"Status":{"StatusCode":"SUCCESS","StatusDesc":"Request
47
+ processed successfully."},"Orders":{"Order":{"ExtOrderId":"1342","Description":"New
48
+ order","Products":{"Product":{"Name":"Mouse","Quantity":"1","UnitPrice":"10000"}},"OrderId":"28161ZT5TF131121GUEST000P01","CurrencyCode":"PLN","CustomerIp":"127.0.0.1","Status":"PENDING","NotifyUrl":"http://localhost/","ValidityTime":"48000","MerchantPosId":"45654","OrderCreateDate":"2013-11-21T15:32:34.067+01:00","OrderUrl":"http://localhost/","TotalAmount":"10000"}}}}}'
49
+ http_version: '1.1'
50
+ recorded_at: Thu, 21 Nov 2013 14:32:35 GMT
51
+ recorded_with: VCR 2.6.0
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: http://platnosci-dev5.dc2/api/v2/order/28161ZT5TF131121GUEST000P01/status.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ! '{"OpenPayU":{"OrderStatusUpdateRequest":{"order_id":"28161ZT5TF131121GUEST000P01","order_status":"COMPLETED","OrderId":"28161ZT5TF131121GUEST000P01","OrderStatus":"COMPLETED"}}}'
9
+ headers:
10
+ accept:
11
+ - ! '*/*'
12
+ user-agent:
13
+ - Ruby
14
+ content-type:
15
+ - application/json
16
+ openpayu-signature:
17
+ - sender=45654;signature=a9ead1b49004e2225a7560a57e341a2f;algorithm=MD5
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ date:
24
+ - Thu, 21 Nov 2013 14:32:35 GMT
25
+ server:
26
+ - Apache/2.2.17 (Unix) DAV/2 mod_ssl/2.2.17 OpenSSL/1.0.0c mod_jk/1.2.31 PHP/5.3.5
27
+ mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
28
+ openpayu-signature:
29
+ - signature=530f2a4d86abaf8d1cbf0acb54b6effc;algorithm=MD5;sender=checkout;content=DOCUMENT;
30
+ x-openpayu-signature:
31
+ - signature=530f2a4d86abaf8d1cbf0acb54b6effc;algorithm=MD5;sender=checkout;content=DOCUMENT;
32
+ content-language:
33
+ - pl
34
+ content-length:
35
+ - '112'
36
+ set-cookie:
37
+ - payu_persistent=mobile_agent-false#; Expires=Sun, 16-Nov-2014 14:32:35 GMT;
38
+ Path=/
39
+ - CSESSIONID=723904F9CDF2061578920378B4955910.01; Path=/pl/standard/co
40
+ connection:
41
+ - close
42
+ content-type:
43
+ - application/json;charset=UTF-8
44
+ body:
45
+ encoding: US-ASCII
46
+ string: ! '{"OpenPayU":{"OrderStatusUpdateResponse":{"Status":{"StatusCode":"SUCCESS","StatusDesc":"Request
47
+ successful"}}}}'
48
+ http_version: '1.1'
49
+ recorded_at: Thu, 21 Nov 2013 14:32:35 GMT
50
+ recorded_with: VCR 2.6.0
@@ -0,0 +1,103 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe 'Create transparent order' do
5
+ %w(json xml).each do |data_format|
6
+ OpenPayU::Configuration.data_format = data_format
7
+ context "run with data format #{OpenPayU::Configuration.data_format}" do
8
+ before(:all) do
9
+ order = TestObject::Order.valid_order
10
+ VCR.use_cassette('create_order') do
11
+ @response = OpenPayU::Order.create(order)
12
+ end
13
+ end
14
+ context 'create order' do
15
+ it { @response.response.code.should eq '200' }
16
+ it { @response.status['status_code'].should eq 'SUCCESS' }
17
+ it { @response.order_id.should_not be_empty }
18
+ end
19
+ context 'Retrieve order' do
20
+ before(:all) do
21
+ VCR.use_cassette('retrieve_order') do
22
+ @response = OpenPayU::Order.retrieve(@response.order_id)
23
+ end
24
+ end
25
+ it { @response.response.code.should eq '200' }
26
+ it { @response.status['status_code'].should eq 'SUCCESS' }
27
+ it { @response.orders.should_not be_empty }
28
+ end
29
+
30
+ context 'Consume order notification' do
31
+ before(:all) do
32
+ body =
33
+ if OpenPayU::Configuration.data_format == 'json'
34
+ TestObject::Order.notification_request.to_json
35
+ else
36
+ TestObject::Order.notification_request['OpenPayU'].to_xml(
37
+ root: 'OpenPayU',
38
+ skip_types: true,
39
+ skip_instruct: true
40
+ )
41
+ end
42
+ request = OpenPayU::Documents::Request.new(body)
43
+ @request = OpenPayU::Order.consume_notification(request)
44
+ end
45
+ it { @request.order.should_not be_empty }
46
+ end
47
+
48
+ context 'refund order' do
49
+ before(:all) do
50
+ VCR.use_cassette('refund_order') do
51
+ @refund = OpenPayU::Refund.create({
52
+ order_id: @response.order_id,
53
+ description: 'Money refund'
54
+ })
55
+ end
56
+ end
57
+ it { @refund.response.code.should eq '200' }
58
+ it { @refund.status['status_code'].should eq 'SUCCESS' }
59
+ it { @refund.order_id.should eq @response.order_id }
60
+ it { @refund.refund['status'].should eq 'INIT' }
61
+ end
62
+
63
+ context 'update order' do
64
+ before(:all) do
65
+ status_update = {
66
+ order_id: @response.order_id,
67
+ order_status: 'COMPLETED'
68
+ }
69
+ VCR.use_cassette('update_order') do
70
+ @response = OpenPayU::Order.status_update(status_update)
71
+ pp @retrieve_response
72
+ end
73
+ end
74
+ it { @response.response.code.should eq '200' }
75
+ it { @response.status['status_code'].should eq 'SUCCESS' }
76
+ it { @response.status['status_desc'].should eq 'Request successful' }
77
+ end
78
+
79
+ context 'cancel order' do
80
+ before(:all) do
81
+ VCR.use_cassette('cancel_order') do
82
+ @response = OpenPayU::Order.cancel(@response.order_id)
83
+ end
84
+ end
85
+ it { @response.response.code.should eq '200' }
86
+ it { @response.status['status_code'].should eq 'SUCCESS' }
87
+ it { @response.status['status_desc'].should eq 'Request successful' }
88
+ end
89
+
90
+ describe ' Generate OrderNotifyResponse' do
91
+ it do
92
+ OpenPayU::Order.build_notify_response(3_243_243_324_342)
93
+ .should include('SUCCESS')
94
+ end
95
+ end
96
+
97
+ end
98
+ end
99
+ end
100
+
101
+ describe 'Create hosted order' do
102
+
103
+ end