active_merchant_payline 0.2.14 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,7 +11,8 @@ begin
11
11
  gem.homepage = "http://github.com/scrumers/active_merchant_payline"
12
12
  gem.authors = ["Ludovic Galabru"]
13
13
  gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
- gem.add_dependency 'activemerchant', '>= 1.9.0'
14
+ gem.add_dependency 'activemerchant', '1.9.0'
15
+ gem.add_dependency 'typhoeus', '0.1.31'
15
16
  gem.add_dependency 'builder'
16
17
  end
17
18
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.14
1
+ 0.3.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active_merchant_payline}
8
- s.version = "0.2.14"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ludovic Galabru"]
12
- s.date = %q{2010-11-08}
12
+ s.date = %q{2010-11-09}
13
13
  s.description = %q{A plugin for Payline support in Active Merchant.}
14
14
  s.email = %q{ludovic@scrumers.com}
15
15
  s.extra_rdoc_files = [
@@ -28,8 +28,10 @@ Gem::Specification.new do |s|
28
28
  "lib/active_merchant_payline.rb",
29
29
  "lib/active_merchant_payline/gateway/payline.rb",
30
30
  "lib/active_merchant_payline/integration/lib/notification.rb",
31
+ "lib/active_merchant_payline/integration/lib/request.rb",
32
+ "lib/active_merchant_payline/integration/lib/response.rb",
31
33
  "lib/active_merchant_payline/integration/lib/return.rb",
32
- "lib/active_merchant_payline/integration/lib/web_payment.rb",
34
+ "lib/active_merchant_payline/integration/lib/web_payment_request.rb",
33
35
  "lib/active_merchant_payline/integration/lib/web_payment_response.rb",
34
36
  "lib/active_merchant_payline/integration/payline.rb",
35
37
  "test/helper.rb",
@@ -51,16 +53,19 @@ Gem::Specification.new do |s|
51
53
 
52
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
55
  s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
- s.add_runtime_dependency(%q<activemerchant>, [">= 1.9.0"])
56
+ s.add_runtime_dependency(%q<activemerchant>, ["= 1.9.0"])
57
+ s.add_runtime_dependency(%q<typhoeus>, ["= 0.1.31"])
55
58
  s.add_runtime_dependency(%q<builder>, [">= 0"])
56
59
  else
57
60
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
58
- s.add_dependency(%q<activemerchant>, [">= 1.9.0"])
61
+ s.add_dependency(%q<activemerchant>, ["= 1.9.0"])
62
+ s.add_dependency(%q<typhoeus>, ["= 0.1.31"])
59
63
  s.add_dependency(%q<builder>, [">= 0"])
60
64
  end
61
65
  else
62
66
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
63
- s.add_dependency(%q<activemerchant>, [">= 1.9.0"])
67
+ s.add_dependency(%q<activemerchant>, ["= 1.9.0"])
68
+ s.add_dependency(%q<typhoeus>, ["= 0.1.31"])
64
69
  s.add_dependency(%q<builder>, [">= 0"])
65
70
  end
66
71
  end
@@ -0,0 +1,13 @@
1
+ module ActiveMerchant
2
+ module Billing
3
+ module Integrations
4
+ module Payline
5
+ class Request
6
+ attr_accessor :body
7
+
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,15 @@
1
+ require 'hpricot'
2
+
3
+ module ActiveMerchant
4
+ module Billing
5
+ module Integrations
6
+ module Payline
7
+ class Response
8
+
9
+
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,125 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Payline
5
+ class WebPaymentRequest
6
+ #merchant_id, merchant_key, contract, return_url, amount
7
+ attr_accessor :options
8
+
9
+ def initialize(options = {})
10
+ self.options= options
11
+ end
12
+
13
+ def to_xml
14
+ xml= Builder::XmlMarkup.new
15
+ xml.instruct!
16
+ xmlns= {
17
+ 'xmlns:soapenv' => 'http://schemas.xmlsoap.org/soap/envelope/',
18
+ 'xmlns:impl' => 'http://impl.ws.payline.experian.com',
19
+ 'xmlns:obj' => 'http://obj.ws.payline.experian.com'
20
+ }
21
+
22
+ xml.soapenv :Envelope, xmlns do
23
+ xml.soapenv :Header do
24
+ end
25
+ xml.soapenv :Body do
26
+ do_web_payment_envelope xml
27
+ end
28
+ end
29
+
30
+ xml.target!
31
+ end
32
+
33
+ private
34
+ def do_web_payment_envelope(xml)
35
+ xml.impl :doWebPaymentRequest do
36
+ xml.impl :securityMode, 'SSL'
37
+ xml.impl :languageCode
38
+ xml.impl :customPaymentPageCode
39
+
40
+ add_urls_to xml
41
+ add_payment_to xml
42
+ add_order_to xml
43
+ add_contract_to xml
44
+ add_buyer_to xml
45
+ end
46
+ xml
47
+ end
48
+
49
+ private
50
+ def add_urls_to(xml)
51
+ xml.impl :returnURL, ''
52
+ xml.impl :cancelURL, ''
53
+ xml.impl :notificationURL, ''
54
+ xml.impl :customPaymentTemplateURL, ''
55
+ xml
56
+ end
57
+
58
+ private
59
+ def add_payment_to(xml)
60
+ xml.impl :payment do
61
+ xml.obj :amount, ''
62
+ xml.obj :currency, ''
63
+ xml.obj :action, ''
64
+ xml.obj :mode, ''
65
+ xml.obj :contractNumber, ''
66
+ xml.obj :differedActionDate, ''
67
+ end
68
+ end
69
+
70
+ private
71
+ def add_order_to(xml)
72
+ xml.impl :order do
73
+ xml.obj :ref, ''
74
+ xml.obj :origin, ''
75
+ xml.obj :country, ''
76
+ xml.obj :taxes, ''
77
+ xml.obj :amount, ''
78
+ xml.obj :currency, ''
79
+ xml.obj :date, ''
80
+ xml.obj :details do
81
+ xml.obj :details do
82
+ xml.obj :ref, ''
83
+ xml.obj :price, ''
84
+ xml.obj :quantity, ''
85
+ xml.obj :comment, ''
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ private
92
+ def add_contract_to(xml)
93
+ xml.impl :selectedContractList do
94
+ xml.obj :selectedContract, ''
95
+ end
96
+ end
97
+
98
+ private
99
+ def add_buyer_to(xml)
100
+ xml.impl :buyer do
101
+ xml.obj :lastName, ''
102
+ xml.obj :firstName, ''
103
+ xml.obj :email, ''
104
+ xml.obj :accountCreateDate, ''
105
+ xml.obj :accountAverageAmount, ''
106
+ xml.obj :accountOrderCount, ''
107
+ xml.obj :ip, ''
108
+ xml.obj :shippingAdress do
109
+ xml.obj :name, ''
110
+ xml.obj :street1, ''
111
+ xml.obj :street2, ''
112
+ xml.obj :cityName, ''
113
+ xml.obj :zipCode, ''
114
+ xml.obj :country, ''
115
+ xml.obj :phone, ''
116
+ end
117
+ end
118
+ end
119
+
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+
@@ -1,8 +1,6 @@
1
- require 'hpricot'
2
-
3
- module ActiveMerchant
4
- module Billing
5
- module Integrations
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
6
4
  module Payline
7
5
  class WebPaymentResponse
8
6
 
@@ -1,12 +1,14 @@
1
+ require 'typhoeus'
2
+
1
3
  module ActiveMerchant
2
4
  module Billing
3
5
  module Integrations
4
6
  module Payline
5
7
  autoload :Return, File.dirname(__FILE__) + '/lib/return.rb'
6
8
  autoload :Notification, File.dirname(__FILE__) + '/lib/notification.rb'
7
- autoload :WebPayment, File.dirname(__FILE__) + '/lib/web_payment.rb'
9
+ autoload :WebPaymentRequest, File.dirname(__FILE__) + '/lib/web_payment_request.rb'
8
10
  autoload :WebPaymentResponse, File.dirname(__FILE__) + '/lib/web_payment_response.rb'
9
-
11
+
10
12
  # Overwrite this if you want to change the Payline homologation url
11
13
  mattr_accessor :homologation_url
12
14
  self.homologation_url= 'homologation.payline.com'
@@ -14,15 +16,18 @@ module ActiveMerchant
14
16
  # Overwrite this if you want to change the Payline production url
15
17
  mattr_accessor :production_url
16
18
  self.production_url= 'services.payline.com'
17
-
18
- mattr_accessor :path
19
- self.path= '/V4/services/DirectPaymentAPI'
19
+
20
+ mattr_accessor :service_path
21
+ self.service_path= '/V4/services/WebPaymentAPI'
22
+
23
+ mattr_accessor :config
24
+ self.config= {}
20
25
 
21
26
  def self.service_url
22
27
  mode = ActiveMerchant::Billing::Base.integration_mode
23
28
  case mode
24
29
  when :production
25
- self.production_url
30
+ self.production_url
26
31
  when :test
27
32
  self.homologation_url
28
33
  else
@@ -35,9 +40,32 @@ module ActiveMerchant
35
40
  end
36
41
 
37
42
  def self.authorize(options = {})
43
+ soap_request= WebPaymentRequest.new(options)
44
+
45
+ merchant= self.config[:merchant]
46
+ unless merchant == nil
47
+ merchant_id= merchant[:id]
48
+ merchant_access_key= merchant[:access_key]
49
+ end
50
+
51
+ #Typhoeus can be replaced by 'net/https', but literraly 10x faster.
52
+ response = Typhoeus::Request.post(
53
+ "https://#{self.homologation_url}#{self.service_path}",
54
+ :headers => {
55
+ 'Content-Type' => nil,
56
+ 'Accept-Encoding' => nil
57
+ },
58
+ :username => merchant_id,
59
+ :password => merchant_access_key,
60
+ :method => :basic,
61
+ :user_agent => 'Scrumers - Authorization',
62
+ :body => soap_request.to_xml,
63
+ :verbose => 1
64
+ )
38
65
  WebPaymentResponse.new(
39
- WebPayment.authorize(options)
66
+ response.body
40
67
  )
68
+ response
41
69
  end
42
70
 
43
71
  def self.payment_details
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 14
9
- version: 0.2.14
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ludovic Galabru
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-08 00:00:00 +01:00
17
+ date: 2010-11-09 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -36,7 +36,7 @@ dependencies:
36
36
  requirement: &id002 !ruby/object:Gem::Requirement
37
37
  none: false
38
38
  requirements:
39
- - - ">="
39
+ - - "="
40
40
  - !ruby/object:Gem::Version
41
41
  segments:
42
42
  - 1
@@ -46,9 +46,24 @@ dependencies:
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
48
  - !ruby/object:Gem::Dependency
49
- name: builder
49
+ name: typhoeus
50
50
  prerelease: false
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - "="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ - 1
59
+ - 31
60
+ version: 0.1.31
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: builder
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
52
67
  none: false
53
68
  requirements:
54
69
  - - ">="
@@ -57,7 +72,7 @@ dependencies:
57
72
  - 0
58
73
  version: "0"
59
74
  type: :runtime
60
- version_requirements: *id003
75
+ version_requirements: *id004
61
76
  description: A plugin for Payline support in Active Merchant.
62
77
  email: ludovic@scrumers.com
63
78
  executables: []
@@ -79,8 +94,10 @@ files:
79
94
  - lib/active_merchant_payline.rb
80
95
  - lib/active_merchant_payline/gateway/payline.rb
81
96
  - lib/active_merchant_payline/integration/lib/notification.rb
97
+ - lib/active_merchant_payline/integration/lib/request.rb
98
+ - lib/active_merchant_payline/integration/lib/response.rb
82
99
  - lib/active_merchant_payline/integration/lib/return.rb
83
- - lib/active_merchant_payline/integration/lib/web_payment.rb
100
+ - lib/active_merchant_payline/integration/lib/web_payment_request.rb
84
101
  - lib/active_merchant_payline/integration/lib/web_payment_response.rb
85
102
  - lib/active_merchant_payline/integration/payline.rb
86
103
  - test/helper.rb
@@ -1,104 +0,0 @@
1
- require 'net/http'
2
- require 'net/https'
3
-
4
- module ActiveMerchant #:nodoc:
5
- module Billing #:nodoc:
6
- module Integrations #:nodoc:
7
- module Payline
8
- class WebPayment
9
- #merchant_id, merchant_key, contract, return_url, amount
10
-
11
- def self.authorize(options = {})
12
- xml= Builder::XmlMarkup.new
13
- xml.instruct!
14
- xmlns= {
15
- 'xmlns:soapenv' => 'http://schemas.xmlsoap.org/soap/envelope/',
16
- 'xmlns:impl' => 'http://impl.ws.payline.experian.com',
17
- 'xmlns:obj' => 'http://obj.ws.payline.experian.com'
18
- }
19
- xml.tag! "soapenv:Envelope", xmlns do
20
- xml.tag! "soapenv:Header"
21
- xml.tag! "soapenv:Body" do
22
- do_web_payment_envelope(xml)
23
- end
24
- end
25
-
26
- Net::HTTP.start('homologation.payline.com', 443) do |http|
27
- http.use_ssl= true
28
- path= 'V4/services/DirectPaymentAPI'
29
- data= xml.target!
30
- response = http.post(path, data)
31
- end
32
- response
33
- end
34
-
35
- private
36
- def do_web_payment_envelope(xml, options = {})
37
- xml.tag! 'impl:doWebPaymentRequest' do
38
- xml.tag! 'impl:securityMode' do
39
- xml.text! 'SSL'
40
- end
41
- xml.tag! 'impl:languageCode'
42
- xml.tag! 'impl:customPaymentPageCode' do
43
-
44
- end
45
- add_urls(xml)
46
- add_payment(xml)
47
- add_order(xml)
48
- add_contract(xml)
49
- add_buyer(xml)
50
- end
51
- xml
52
- end
53
-
54
- private
55
- def add_urls(xml, options = {})
56
- xml.tag! 'impl:returnURL' do
57
-
58
- end
59
- xml.tag! 'impl:cancelURL' do
60
-
61
- end
62
- xml.tag! 'impl:notificationURL' do
63
-
64
- end
65
- xml.tag! 'impl:customPaymentTemplateURL' do
66
-
67
- end
68
- xml
69
- end
70
-
71
- private
72
- def add_payment(xml, options = {})
73
- xml.tag! 'impl:payment' do
74
-
75
- end
76
- end
77
-
78
- private
79
- def add_order(xml, options = {})
80
- xml.tag! 'impl:order' do
81
-
82
- end
83
- end
84
-
85
- private
86
- def add_contract(xml, options = {})
87
- xml.tag! 'impl:contract' do
88
-
89
- end
90
- end
91
-
92
- private
93
- def add_buyer(xml, options = {})
94
- xml.tag! 'impl:buyer' do
95
-
96
- end
97
- end
98
-
99
- end
100
- end
101
- end
102
- end
103
- end
104
-