activemerchant 1.42.9 → 1.43.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG +14 -1
- data/CONTRIBUTORS +4 -0
- data/README.md +2 -1
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +14 -9
- data/lib/active_merchant/billing/gateways/iats_payments.rb +199 -16
- data/lib/active_merchant/billing/gateways/network_merchants.rb +239 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +5 -1
- data/lib/active_merchant/billing/gateways/sage_pay.rb +1 -1
- data/lib/active_merchant/billing/gateways/transnational.rb +1 -231
- data/lib/active_merchant/billing/integrations/pag_seguro.rb +53 -0
- data/lib/active_merchant/billing/integrations/pag_seguro/helper.rb +121 -0
- data/lib/active_merchant/billing/integrations/pag_seguro/notification.rb +104 -0
- data/lib/active_merchant/billing/integrations/pxpay/helper.rb +5 -4
- data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +1 -1
- data/lib/active_merchant/version.rb +1 -1
- metadata +7 -2
- metadata.gz.sig +0 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module PagSeguro
|
5
|
+
|
6
|
+
autoload :Helper, 'active_merchant/billing/integrations/pag_seguro/helper.rb'
|
7
|
+
autoload :Notification, 'active_merchant/billing/integrations/pag_seguro/notification.rb'
|
8
|
+
|
9
|
+
mattr_accessor :service_production_url
|
10
|
+
self.service_production_url = 'https://pagseguro.uol.com.br/v2/checkout/payment.html'
|
11
|
+
|
12
|
+
mattr_accessor :service_test_url
|
13
|
+
self.service_test_url = 'https://sandbox.pagseguro.uol.com.br/v2/checkout/payment.html'
|
14
|
+
|
15
|
+
mattr_accessor :invoicing_production_url
|
16
|
+
self.invoicing_production_url = 'https://ws.pagseguro.uol.com.br/v2/checkout/'
|
17
|
+
|
18
|
+
mattr_accessor :invoicing_test_url
|
19
|
+
self.invoicing_test_url = 'https://ws.sandbox.pagseguro.uol.com.br/v2/checkout/'
|
20
|
+
|
21
|
+
mattr_accessor :notification_production_url
|
22
|
+
self.notification_production_url = 'https://ws.pagseguro.uol.com.br/v2/transactions/notifications/'
|
23
|
+
|
24
|
+
mattr_accessor :notification_test_url
|
25
|
+
self.notification_test_url = 'https://ws.sandbox.pagseguro.uol.com.br/v2/transactions/notifications/'
|
26
|
+
|
27
|
+
def self.service_url
|
28
|
+
test? ? service_test_url : service_production_url
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.invoicing_url
|
32
|
+
test? ? invoicing_test_url : invoicing_production_url
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.notification_url
|
36
|
+
test? ? notification_test_url : notification_production_url
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.notification(query_string, options = {})
|
40
|
+
Notification.new(query_string, options)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.return(query_string, options = {})
|
44
|
+
Return.new(query_string, options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.test?
|
48
|
+
ActiveMerchant::Billing::Base.integration_mode == :test
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
module Integrations #:nodoc:
|
7
|
+
module PagSeguro
|
8
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
9
|
+
def initialize(order_id, account, options)
|
10
|
+
super
|
11
|
+
@account = account
|
12
|
+
|
13
|
+
add_field('itemAmount1', sprintf("%0.02f", options[:amount]))
|
14
|
+
add_field('itemId1', '1')
|
15
|
+
add_field('itemQuantity1', '1')
|
16
|
+
add_field('shippingType', '3')
|
17
|
+
add_field('currency', 'BRL')
|
18
|
+
end
|
19
|
+
|
20
|
+
mapping :account, 'email'
|
21
|
+
mapping :credential2, 'token'
|
22
|
+
|
23
|
+
mapping :order, 'reference'
|
24
|
+
|
25
|
+
mapping :billing_address, :city => 'shippingAddressCity',
|
26
|
+
:address1 => 'shippingAddressStreet',
|
27
|
+
:address2 => 'shippingAddressNumber',
|
28
|
+
:state => 'shippingAddressState',
|
29
|
+
:zip => 'shippingAddressPostalCode',
|
30
|
+
:country => 'shippingAddressCountry'
|
31
|
+
|
32
|
+
mapping :notify_url, 'notificationURL'
|
33
|
+
mapping :return_url, 'redirectURL'
|
34
|
+
mapping :description, 'itemDescription1'
|
35
|
+
|
36
|
+
def form_fields
|
37
|
+
invoice_id = fetch_token
|
38
|
+
|
39
|
+
{"code" => invoice_id}
|
40
|
+
end
|
41
|
+
|
42
|
+
def shipping(value)
|
43
|
+
add_field("shippingCost", sprintf("%0.02f", value))
|
44
|
+
end
|
45
|
+
|
46
|
+
def customer(params = {})
|
47
|
+
phone = area_code_and_number(params[:phone])
|
48
|
+
|
49
|
+
add_field("senderAreaCode", phone[0])
|
50
|
+
add_field("senderPhone", phone[1])
|
51
|
+
add_field("senderEmail", params[:email])
|
52
|
+
add_field('senderName', "#{params[:first_name]} #{params[:last_name]}")
|
53
|
+
end
|
54
|
+
|
55
|
+
def fetch_token
|
56
|
+
uri = URI.parse(PagSeguro.invoicing_url)
|
57
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
58
|
+
http.use_ssl = true
|
59
|
+
|
60
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
61
|
+
request.content_type = "application/x-www-form-urlencoded"
|
62
|
+
request.set_form_data @fields
|
63
|
+
|
64
|
+
response = http.request(request)
|
65
|
+
xml = Nokogiri::XML.parse(response.body)
|
66
|
+
|
67
|
+
check_for_errors(response, xml)
|
68
|
+
|
69
|
+
extract_token(xml)
|
70
|
+
rescue Timeout::Error => e
|
71
|
+
raise StandardError, "Erro ao se conectar ao PagSeguro."
|
72
|
+
end
|
73
|
+
|
74
|
+
def area_code_and_number(phone)
|
75
|
+
phone.gsub!(/[^\d]/, '')
|
76
|
+
|
77
|
+
ddd = phone.slice(0..1)
|
78
|
+
number = phone.slice(2..12)
|
79
|
+
|
80
|
+
[ddd, number]
|
81
|
+
end
|
82
|
+
|
83
|
+
def check_for_errors(response, xml)
|
84
|
+
return if response.code == "200"
|
85
|
+
|
86
|
+
case response.code
|
87
|
+
when "400"
|
88
|
+
raise StandardError, humanize_errors(xml)
|
89
|
+
when "401"
|
90
|
+
raise StandardError, "Token do PagSeguro inválido."
|
91
|
+
else
|
92
|
+
raise ActiveMerchant::ResponseError, response
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def extract_token(xml)
|
97
|
+
xml.css("code").text
|
98
|
+
end
|
99
|
+
|
100
|
+
def humanize_errors(xml)
|
101
|
+
# reference: https://pagseguro.uol.com.br/v2/guia-de-integracao/codigos-de-erro.html
|
102
|
+
|
103
|
+
xml.css("errors").children.map do |error|
|
104
|
+
case error.css('code').text
|
105
|
+
when "11013"
|
106
|
+
"Código de área inválido"
|
107
|
+
when "11014"
|
108
|
+
"Número de telefone inválido. Formato esperado: (DD) XXXX-XXXX"
|
109
|
+
when "11017"
|
110
|
+
"Código postal (CEP) inválido."
|
111
|
+
else
|
112
|
+
error.css('message').text
|
113
|
+
end
|
114
|
+
end.join(", ")
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
module Integrations #:nodoc:
|
7
|
+
module PagSeguro
|
8
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
9
|
+
|
10
|
+
def initialize(post, options = {})
|
11
|
+
notify_code = parse_http_query(post)["notificationCode"]
|
12
|
+
email = options[:credential1]
|
13
|
+
token = options[:credential2]
|
14
|
+
|
15
|
+
uri = URI.join(PagSeguro.notification_url, notify_code)
|
16
|
+
parse_xml(web_get(uri, email: email, token: token))
|
17
|
+
end
|
18
|
+
|
19
|
+
def complete?
|
20
|
+
status == "Completed"
|
21
|
+
end
|
22
|
+
|
23
|
+
def item_id
|
24
|
+
params["transaction"]["reference"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def transaction_id
|
28
|
+
params["transaction"]["code"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def received_at
|
32
|
+
params["transaction"]["date"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def payer_email
|
36
|
+
params["sender"]["email"]
|
37
|
+
end
|
38
|
+
|
39
|
+
def gross
|
40
|
+
params["transaction"]["grossAmount"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def currency
|
44
|
+
"BRL"
|
45
|
+
end
|
46
|
+
|
47
|
+
def payment_method_type
|
48
|
+
params["transaction"]["paymentMethod"]["type"]
|
49
|
+
end
|
50
|
+
|
51
|
+
def payment_method_code
|
52
|
+
params["transaction"]["paymentMethod"]["code"]
|
53
|
+
end
|
54
|
+
|
55
|
+
def status
|
56
|
+
case params["transaction"]["status"]
|
57
|
+
when "1", "2"
|
58
|
+
"Pending"
|
59
|
+
when "3"
|
60
|
+
"Completed"
|
61
|
+
when "4"
|
62
|
+
"Available"
|
63
|
+
when "5"
|
64
|
+
"Dispute"
|
65
|
+
when "6"
|
66
|
+
"Reversed"
|
67
|
+
when "7"
|
68
|
+
"Failed"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# There's no acknowledge for PagSeguro
|
73
|
+
def acknowledge
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def web_get(uri, params)
|
80
|
+
uri.query = URI.encode_www_form(params)
|
81
|
+
|
82
|
+
response = Net::HTTP.get_response(uri)
|
83
|
+
response.body
|
84
|
+
end
|
85
|
+
|
86
|
+
# Take the posted data and move the relevant data into a hash
|
87
|
+
def parse_xml(post)
|
88
|
+
@params = Hash.from_xml(post)
|
89
|
+
end
|
90
|
+
|
91
|
+
def parse_http_query(post)
|
92
|
+
@raw = post
|
93
|
+
params = {}
|
94
|
+
for line in post.split('&')
|
95
|
+
key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
|
96
|
+
params[key] = value
|
97
|
+
end
|
98
|
+
params
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -90,17 +90,18 @@ module ActiveMerchant #:nodoc:
|
|
90
90
|
|
91
91
|
def request_secure_redirect
|
92
92
|
request = generate_request
|
93
|
-
|
94
93
|
response = ssl_post(Pxpay.token_url, request)
|
95
94
|
xml = REXML::Document.new(response)
|
96
95
|
root = REXML::XPath.first(xml, "//Request")
|
97
96
|
valid = root.attributes["valid"]
|
98
|
-
redirect = root.elements["URI"].text
|
97
|
+
redirect = root.elements["URI"].try(:text)
|
98
|
+
valid, redirect = "0", root.elements["ResponseText"].try(:text) unless redirect
|
99
99
|
|
100
|
-
# example
|
100
|
+
# example valid response:
|
101
101
|
# <Request valid="1"><URI>https://sec.paymentexpress.com/pxpay/pxpay.aspx?userid=PxpayUser&request=REQUEST_TOKEN</URI></Request>
|
102
|
+
# <Request valid='1'><Reco>IP</Reco><ResponseText>Invalid Access Info</ResponseText></Request>
|
102
103
|
|
103
|
-
# example
|
104
|
+
# example invalid response:
|
104
105
|
# <Request valid="0"><URI>Invalid TxnType</URI></Request>
|
105
106
|
|
106
107
|
{:valid => valid, :redirect => redirect}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemerchant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.43.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
ZJB9YPQZG+vWBdDSca3sUMtvFxpLUFwdKF5APSPOVnhbFJ3vSXY1ulP/R6XW9vnw
|
31
31
|
6kkQi2fHhU20ugMzp881Eixr+TjC0RvUerLG7g==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2014-04-
|
33
|
+
date: 2014-04-24 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: activesupport
|
@@ -248,6 +248,7 @@ files:
|
|
248
248
|
- lib/active_merchant/billing/gateways/braintree/braintree_common.rb
|
249
249
|
- lib/active_merchant/billing/gateways/braintree_blue.rb
|
250
250
|
- lib/active_merchant/billing/gateways/braintree_orange.rb
|
251
|
+
- lib/active_merchant/billing/gateways/bridge_pay.rb
|
251
252
|
- lib/active_merchant/billing/gateways/card_save.rb
|
252
253
|
- lib/active_merchant/billing/gateways/card_stream.rb
|
253
254
|
- lib/active_merchant/billing/gateways/cc5.rb
|
@@ -304,6 +305,7 @@ files:
|
|
304
305
|
- lib/active_merchant/billing/gateways/netaxept.rb
|
305
306
|
- lib/active_merchant/billing/gateways/netbilling.rb
|
306
307
|
- lib/active_merchant/billing/gateways/netpay.rb
|
308
|
+
- lib/active_merchant/billing/gateways/network_merchants.rb
|
307
309
|
- lib/active_merchant/billing/gateways/nmi.rb
|
308
310
|
- lib/active_merchant/billing/gateways/ogone.rb
|
309
311
|
- lib/active_merchant/billing/gateways/openpay.rb
|
@@ -472,6 +474,9 @@ files:
|
|
472
474
|
- lib/active_merchant/billing/integrations/nochex/notification.rb
|
473
475
|
- lib/active_merchant/billing/integrations/nochex/return.rb
|
474
476
|
- lib/active_merchant/billing/integrations/notification.rb
|
477
|
+
- lib/active_merchant/billing/integrations/pag_seguro.rb
|
478
|
+
- lib/active_merchant/billing/integrations/pag_seguro/helper.rb
|
479
|
+
- lib/active_merchant/billing/integrations/pag_seguro/notification.rb
|
475
480
|
- lib/active_merchant/billing/integrations/paxum.rb
|
476
481
|
- lib/active_merchant/billing/integrations/paxum/common.rb
|
477
482
|
- lib/active_merchant/billing/integrations/paxum/helper.rb
|
metadata.gz.sig
CHANGED
Binary file
|