hipay 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7da65605f6e47e28f69a2adb6dabc444e50f8236
4
+ data.tar.gz: abf998d4cdbaddff6e0f64e028f2d7ee597850e9
5
+ SHA512:
6
+ metadata.gz: c77ecf3f306caf172d4d4ad0c2e2acda8ff424abdd585f4fd8d6c07ae779b7032fafb8f6edb221a1dcf446b537c70640ae43a22ca4ad9a211a3da109ba941e24
7
+ data.tar.gz: 38267c174ec16f02b5d27e6028ccb6a187079b79a0731861676184143e57d3367485616c9c97549e7c8abf8e341d2bcda76bb680f64e12ce84c3dce28f46d065
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hipay.gemspec
4
+ gemspec
5
+
6
+ gem 'savon', '~> 2.8.0'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 UgoMare
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.
@@ -0,0 +1,108 @@
1
+ # Hipay
2
+
3
+ This gem works with an Hipay webservice account
4
+ https://www.hipaywallet.com/
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'hipay'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install hipay
21
+
22
+ The gem consists of the following functionality:
23
+ * `Payment`
24
+ * `Refund`
25
+ * `Transaction`
26
+ * `BusinessLines`
27
+ * `WebTopics`
28
+
29
+ The main module is called `Hipay`
30
+
31
+ ##`Payment` module
32
+
33
+ An instance of the `Payment` class needs to be initialized before it can be used.
34
+
35
+ Constructor params:
36
+
37
+ ```
38
+ wsLogin: string
39
+ wsPassword: string
40
+ websiteId: string
41
+ categoryId: string
42
+ test: boolean
43
+ ```
44
+
45
+ `test` boolean is to perform operations on test platform, default is false
46
+
47
+ Usage:
48
+ ```ruby
49
+ require 'hipay'
50
+
51
+ payment = Hipay::Payment.new(wsLogin, wsPassword, websiteId, categoryId)
52
+ ```
53
+
54
+ to get the category id please visit
55
+ Production platform:
56
+ https://payment.hipay.com/order/list-categories/id/[production websiteID]
57
+ Stage platform:
58
+ https://test-payment.hipay.com/order/list-categories/id/[stage websiteID]
59
+
60
+ ####`generate`
61
+ Generate a new payment url. Returns a payment url, code status and message.
62
+
63
+ Params:
64
+ ```
65
+ amount: int - The total order amount. Sum of the items purchased, +shipping fee (if present) +tax fee (if present).
66
+ customerIpAddress: string - The IP address of your customer making a purchase.
67
+ urlCallback: string - The URL to send back information update database.
68
+ currency: string - 3 chars ISO 4217, default EUR
69
+ rating: string - Age category of your order ("+12", "+16", "+18", "ALL"), default "ALL"
70
+ locale: string - Locale for displaying information in payment page, default "en_GB"
71
+ manualCapture: int - How you want to process the payment, default 0
72
+ * 0: indicates transaction is sent for authorization, and if approved, is automatically submitted for capture.
73
+ * 1: indicates this transaction is sent for authorization only. The transaction will not be sent for settlement until the Merchant submits the transaction for capture manually.
74
+ executionDate: string - Date and time of execution of the payment (Y-m-dTH:i:s)
75
+ description: string - The order short description
76
+ customerEmail: string - (optional) The customer's e-mail address
77
+ urlAccept: string - (optional)
78
+ urlDecline: string - (optional)
79
+ urlCancel: string - (optional)
80
+ urlLogo: string - (optional) This URL of your logo for the payment page (HTTPS)
81
+ merchantReference: string - (optional) Merchants’ order reference
82
+ merchantComment: string - (optional) Merchants’ comment concerning the order
83
+ emailCallback: string - (optional) Email used by HiPay Wallet to post operation notifications
84
+ freedata: string - (optional) Custom data
85
+ <freeData>
86
+ <item>
87
+ <key>keyOne</key>
88
+ <value>ValueOne</value>
89
+ </item>
90
+ <item>
91
+ <key>keyTwo</key>
92
+ <value>ValueTwo</value>
93
+ </item>
94
+ </freeData>
95
+ ```
96
+
97
+ Usage:
98
+ ```ruby
99
+ payment.generate(100, "192.168.1.1", "http://www.site.com/callback", "2014-12-25T10:57:55", "order#123 - books")
100
+ ```
101
+
102
+ ## Contributing
103
+
104
+ 1. Fork it ( https://github.com/UgoMare/hipay/fork )
105
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
106
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
107
+ 4. Push to the branch (`git push origin my-new-feature`)
108
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hipay/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hipay"
8
+ spec.version = Hipay::VERSION
9
+ spec.authors = ["UgoMare"]
10
+ spec.email = ["ugo.mare.epitech@gmail.com"]
11
+ spec.summary = %q{Hipay gem for hipay webservice}
12
+ spec.description = %q{This gem works with an Hipay webservice account https://www.hipaywallet.com}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,194 @@
1
+ #require "hipay/version"
2
+ require 'savon'
3
+
4
+ module Hipay
5
+
6
+ TEST_PLATFORM = "test-"
7
+
8
+ def self.call_api(ressource, operation, test, message = nil)
9
+ test_url = (test ? TEST_PLATFORM : "")
10
+ client = Savon.client(wsdl: "https://#{test_url}ws.hipay.com/soap/#{ressource}?wsdl", ssl_version: :TLSv1)
11
+ response = client.call(operation, message: message)
12
+ return response.body
13
+ end
14
+
15
+ class Payment
16
+
17
+ def initialize(wsLogin, wsPassword, websiteId, categoryId, test: false)
18
+ @wsLogin = wsLogin
19
+ @wsPassword = wsPassword
20
+ @websiteId = websiteId
21
+ @categoryId = categoryId
22
+ @test = test
23
+ end
24
+
25
+ def generate(amount, customerIpAddress, urlCallback, executionDate, description, currency: "EUR",
26
+ rating: "ALL", locale: "en_GB", manualCapture: 0, customerEmail: nil,
27
+ urlAccept: nil, urlDecline: nil, urlCancel: nil, urlLogo: nil,
28
+ merchantReference: nil, merchantComment: nil, emailCallback: nil, freedata: nil)
29
+
30
+ operation = :generate
31
+ parameters = build_basic_request
32
+ parameters[:currency] = currency
33
+ parameters[:amount] = amount
34
+ parameters[:rating] = rating
35
+ parameters[:locale] = locale
36
+ parameters[:customerIpAddress] = customerIpAddress
37
+ parameters[:manualCapture] = manualCapture
38
+ parameters[:executionDate] = executionDate
39
+ parameters[:description] = description
40
+ parameters[:urlCallback] = urlCallback
41
+
42
+ if !customerEmail.nil?
43
+ parameters[:customerEmail] = customerEmail
44
+ end
45
+ if !urlAccept.nil?
46
+ parameters[:urlAccept] = urlAccept
47
+ end
48
+ if !urlCancel.nil?
49
+ parameters[:urlCancel] = urlCancel
50
+ end
51
+ if !urlDecline.nil?
52
+ parameters[:urlDecline] = urlDecline
53
+ end
54
+ if !urlLogo.nil?
55
+ parameters[:urlLogo] = urlLogo
56
+ end
57
+ if !merchantReference.nil?
58
+ parameters[:merchantReference] = merchantReference
59
+ end
60
+ if !merchantComment.nil?
61
+ parameters[:merchantComment] = merchantComment
62
+ end
63
+ if !emailCallback.nil?
64
+ parameters[:emailCallback] = emailCallback
65
+ end
66
+ if !freedata.nil?
67
+ parameters[:freedata] = freedata
68
+ end
69
+
70
+ Hipay::call_api("payment-v2", operation, @test, {parameters: parameters})[:generate_response][:generate_result]
71
+ end
72
+
73
+ def build_basic_request()
74
+ { wsLogin: @wsLogin, wsPassword: @wsPassword, websiteId: @websiteId, categoryId: @categoryId }
75
+ end
76
+
77
+ end
78
+
79
+ class Refund
80
+
81
+ def initialize(wsLogin, wsPassword, websiteId, test: false)
82
+ @wsLogin = wsLogin
83
+ @wsPassword = wsPassword
84
+ @websiteId = websiteId
85
+ @test = test
86
+ end
87
+
88
+ def card(transactionPublicId, currency, amount)
89
+ @transactionPublicId = transactionPublicId
90
+ operation = :card
91
+ parameters = build_basic_request
92
+
93
+ if !amount.nil?
94
+ parameters[:amount] = amount
95
+ end
96
+ if !currency.nil?
97
+ parameters[:currency] = currency
98
+ end
99
+ Hipay::call_api("refund-v2", operation, @test, {parameters: parameters})[:card_response][:card_result]
100
+ end
101
+
102
+ def account(transactionPublicId, currency, amount)
103
+ @transactionPublicId = transactionPublicId
104
+ operation = :account
105
+ parameters = build_basic_request
106
+
107
+ if !amount.nil?
108
+ parameters[:amount] = amount
109
+ end
110
+ if !currency.nil?
111
+ parameters[:currency] = currency
112
+ end
113
+ Hipay::call_api("refund-v2", operation, @test, { parameters: parameters })[:account_response][:account_result]
114
+ end
115
+
116
+ def build_basic_request()
117
+ { wsLogin: @wsLogin, wsPassword: @wsPassword, websiteId: @websiteId, transactionPublicId: @transactionPublicId }
118
+ end
119
+
120
+ end
121
+
122
+ class Transaction
123
+
124
+ def initialize(wsLogin, wsPassword, test: false)
125
+ @wsLogin = wsLogin
126
+ @wsPassword = wsPassword
127
+ @test = test
128
+ end
129
+
130
+ def confirm(transactionPublicId)
131
+ @transactionPublicId = transactionPublicId
132
+ operation = :confirm
133
+ parameters = build_basic_request
134
+ Hipay::call_api("transaction-v2", operation, @test, { parameters: parameters })[:confirm_response][:confirm_result]
135
+ end
136
+
137
+ def cancel(transactionPublicId)
138
+ @transactionPublicId = transactionPublicId
139
+ operation = :cancel
140
+ parameters = build_basic_request
141
+ Hipay::call_api("transaction-v2", operation, @test, { parameters: parameters })[:cancel_response][:cancel_result]
142
+ end
143
+
144
+ def build_basic_request
145
+ { wsLogin: @wsLogin, wsPassword: @wsPassword, transactionPublicId: @transactionPublicId }
146
+ end
147
+
148
+ end
149
+
150
+ class BusinessLines
151
+
152
+ def initialize(wsLogin, wsPassword, test: false)
153
+ @wsLogin = wsLogin
154
+ @wsPassword = wsPassword
155
+ @test = test
156
+ end
157
+
158
+ def get(locale)
159
+ @locale = locale
160
+ operation = :get
161
+ parameters = build_basic_request
162
+ Hipay::call_api("business-lines-v2", operation, @test, { parameters: parameters })[:get_response][:get_result]
163
+ end
164
+
165
+ def build_basic_request
166
+ { wsLogin: @wsLogin, wsPassword: @wsPassword, locale: @locale }
167
+ end
168
+ end
169
+
170
+ class WebsiteTopics
171
+
172
+ def initialize(wsLogin, wsPassword, test: false)
173
+ @wsLogin = wsLogin
174
+ @wsPassword = wsPassword
175
+ @test = test
176
+ end
177
+
178
+ def get(locale, businessLineId)
179
+ @locale = locale
180
+ @businessLineId = businessLineId
181
+ operation = :get
182
+ parameters = build_basic_request
183
+ Hipay::call_api("website-topics-v2", operation, @test, { parameters: parameters })[:get_response][:get_result]
184
+ end
185
+
186
+ def build_basic_request
187
+ { wsLogin: @wsLogin, wsPassword: @wsPassword, locale: @locale, businessLineId: @businessLineId }
188
+ end
189
+ end
190
+
191
+ end
192
+
193
+ #payment = Hipay::Payment.new("XXXXXXXXX", "XXXXXXXXXXXX", "XXXX", "XXX", true)
194
+ #payment.generate(10, "192.168.1.1", "http://www.site.fr/callback.php"
@@ -0,0 +1,3 @@
1
+ module Hipay
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hipay
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - UgoMare
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: This gem works with an Hipay webservice account https://www.hipaywallet.com
42
+ email:
43
+ - ugo.mare.epitech@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - hipay.gemspec
54
+ - lib/hipay.rb
55
+ - lib/hipay/version.rb
56
+ homepage: ''
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.2.2
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Hipay gem for hipay webservice
80
+ test_files: []