pagseguro_v2 0.0.1
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.
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +36 -0
- data/README.md +4 -0
- data/Rakefile +4 -0
- data/lib/pagseguro_v2.rb +31 -0
- data/lib/pagseguro_v2/address.rb +26 -0
- data/lib/pagseguro_v2/checkout.rb +132 -0
- data/lib/pagseguro_v2/client.rb +75 -0
- data/lib/pagseguro_v2/config.rb +12 -0
- data/lib/pagseguro_v2/errors/invalid_data.rb +12 -0
- data/lib/pagseguro_v2/errors/unauthorized.rb +9 -0
- data/lib/pagseguro_v2/errors/unknown_error.rb +9 -0
- data/lib/pagseguro_v2/item.rb +30 -0
- data/lib/pagseguro_v2/notification.rb +14 -0
- data/lib/pagseguro_v2/payment_method.rb +14 -0
- data/lib/pagseguro_v2/sender.rb +29 -0
- data/lib/pagseguro_v2/shipping.rb +17 -0
- data/lib/pagseguro_v2/transaction.rb +29 -0
- data/lib/pagseguro_v2/transaction/payment.rb +68 -0
- data/lib/pagseguro_v2/transaction/shipping.rb +19 -0
- data/lib/pagseguro_v2/transaction/types.rb +23 -0
- data/lib/pagseguro_v2/version.rb +3 -0
- data/pagseguro_v2.gemspec +27 -0
- data/spec/pagseguro_v2/checkout_spec.rb +13 -0
- data/spec/spec_helper.rb +7 -0
- metadata +127 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pagseguro_v2 (0.0.0)
|
5
|
+
builder
|
6
|
+
hashie (>= 1.2.0)
|
7
|
+
httparty
|
8
|
+
nokogiri
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
builder (3.0.0)
|
14
|
+
diff-lcs (1.1.3)
|
15
|
+
hashie (1.2.0)
|
16
|
+
httparty (0.8.3)
|
17
|
+
multi_json (~> 1.0)
|
18
|
+
multi_xml
|
19
|
+
multi_json (1.3.6)
|
20
|
+
multi_xml (0.5.1)
|
21
|
+
nokogiri (1.5.4)
|
22
|
+
rspec (2.10.0)
|
23
|
+
rspec-core (~> 2.10.0)
|
24
|
+
rspec-expectations (~> 2.10.0)
|
25
|
+
rspec-mocks (~> 2.10.0)
|
26
|
+
rspec-core (2.10.1)
|
27
|
+
rspec-expectations (2.10.0)
|
28
|
+
diff-lcs (~> 1.1.3)
|
29
|
+
rspec-mocks (2.10.1)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
pagseguro_v2!
|
36
|
+
rspec (~> 2.10.0)
|
data/README.md
ADDED
data/Rakefile
ADDED
data/lib/pagseguro_v2.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'hashie'
|
3
|
+
require 'builder'
|
4
|
+
require 'bigdecimal'
|
5
|
+
require 'bigdecimal/util'
|
6
|
+
require "nokogiri"
|
7
|
+
|
8
|
+
require "pagseguro_v2/version"
|
9
|
+
require "pagseguro_v2/client"
|
10
|
+
require "pagseguro_v2/config"
|
11
|
+
require "pagseguro_v2/checkout"
|
12
|
+
require "pagseguro_v2/item"
|
13
|
+
|
14
|
+
require 'pagseguro_v2/address'
|
15
|
+
|
16
|
+
require "pagseguro_v2/sender"
|
17
|
+
require "pagseguro_v2/shipping"
|
18
|
+
require "pagseguro_v2/notification"
|
19
|
+
require "pagseguro_v2/transaction"
|
20
|
+
|
21
|
+
require "pagseguro_v2/errors/invalid_data"
|
22
|
+
#require "pagseguro_v2/errors/unknown_error"
|
23
|
+
require "pagseguro_v2/errors/unauthorized"
|
24
|
+
|
25
|
+
# Error classes
|
26
|
+
#require "errors/unauthorized"
|
27
|
+
|
28
|
+
|
29
|
+
module PagseguroV2
|
30
|
+
# Your code goes here...
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module PagseguroV2
|
2
|
+
class Address < Hashie::Dash
|
3
|
+
property :street
|
4
|
+
property :number
|
5
|
+
property :complement
|
6
|
+
property :district
|
7
|
+
property :postal_code, :from => :postalCode
|
8
|
+
property :city
|
9
|
+
property :state
|
10
|
+
property :country
|
11
|
+
|
12
|
+
def to_xml(options = {})
|
13
|
+
builder = options[:builder] || Builder::XmlMarkup.new()
|
14
|
+
builder.address do |address|
|
15
|
+
address.country country if country
|
16
|
+
address.state state if state
|
17
|
+
address.city city if city
|
18
|
+
address.district district if district
|
19
|
+
address.postalCode postal_code if postal_code
|
20
|
+
address.street street if street
|
21
|
+
address.number number if number
|
22
|
+
address.complement complement if complement
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'pagseguro_v2/config'
|
2
|
+
|
3
|
+
module PagseguroV2
|
4
|
+
class Checkout < Hashie::Dash
|
5
|
+
attr_accessor :client
|
6
|
+
|
7
|
+
# Data from the buyer
|
8
|
+
property :sender
|
9
|
+
# Shipping informations
|
10
|
+
property :shipping
|
11
|
+
|
12
|
+
# The currency in which payment will be made
|
13
|
+
property :currency, :required => true, :default => PagseguroV2::Config::CURRENCY
|
14
|
+
# List of items contained in the payment
|
15
|
+
property :items, :required => true
|
16
|
+
# Code that reference the payment
|
17
|
+
property :reference
|
18
|
+
# Determines the URL to which the buyer will be redirected after the end
|
19
|
+
# of the payment stream
|
20
|
+
property :redirect_url
|
21
|
+
# Specifies an extra value to be added or subtracted from the total payment
|
22
|
+
property :extra_amount
|
23
|
+
# maximum number of times the code created by the Payment API calls can be used
|
24
|
+
property :max_uses
|
25
|
+
# Time (in seconds) during which the payment code created by
|
26
|
+
# the Payment API call can be used.
|
27
|
+
property :max_age
|
28
|
+
|
29
|
+
property :code
|
30
|
+
property :date
|
31
|
+
|
32
|
+
def initialize(options)
|
33
|
+
self.item = options[:item] if options[:item]
|
34
|
+
self.items = options[:items] if options[:items]
|
35
|
+
options.delete(:items)
|
36
|
+
options.delete(:item)
|
37
|
+
super(options)
|
38
|
+
end
|
39
|
+
|
40
|
+
def items=(items)
|
41
|
+
items = items.map{ |i| Item.new(i) } if items.is_a? Array
|
42
|
+
items = [Item.new(items)] if items.is_a? Hash
|
43
|
+
self[:items] = items
|
44
|
+
end
|
45
|
+
|
46
|
+
def item=(item)
|
47
|
+
self.items = [item]
|
48
|
+
end
|
49
|
+
|
50
|
+
def sender=(sender)
|
51
|
+
self[:sender] = Sender.new(sender) if sender.is_a? Hash
|
52
|
+
self[:sender] = sender if sender.is_a? Sender
|
53
|
+
end
|
54
|
+
|
55
|
+
def shipping=(shipping)
|
56
|
+
self[:shipping] = Shipping.new(shipping) if shipping.is_a? Hash
|
57
|
+
self[:shipping] = shipping if shipping.is_a? Shipping
|
58
|
+
end
|
59
|
+
|
60
|
+
def proceed!
|
61
|
+
response = self.client.proceed_checkout(self) # if code_blank
|
62
|
+
self.code = response['checkout']['code']
|
63
|
+
self.date = response['checkout']['date']
|
64
|
+
!self.code.nil? && !self.date.nil?
|
65
|
+
end
|
66
|
+
|
67
|
+
def max_uses
|
68
|
+
self[:max_uses].to_i if self[:max_uses]
|
69
|
+
end
|
70
|
+
|
71
|
+
def max_age
|
72
|
+
self[:max_age].to_i if self[:max_age]
|
73
|
+
end
|
74
|
+
|
75
|
+
def url
|
76
|
+
url = ""
|
77
|
+
url = PagseguroV2::Config::REDIRECT_URL + self.code if self.code
|
78
|
+
url
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_hash(options = {})
|
82
|
+
sender = self.delete "sender"
|
83
|
+
shipping = self.delete "shipping"
|
84
|
+
items = self.delete "items"
|
85
|
+
|
86
|
+
self[:sender] = sender.to_hash(options) unless sender.nil?
|
87
|
+
self[:shipping] = shipping.to_hash(options) unless shipping.nil?
|
88
|
+
self[:items] = items.map { |i| i.to_hash(options) }
|
89
|
+
|
90
|
+
hash = super(options)
|
91
|
+
|
92
|
+
self[:sender] = sender unless sender.nil?
|
93
|
+
self[:shipping] = shipping unless shipping.nil?
|
94
|
+
self[:items] = items
|
95
|
+
|
96
|
+
return hash
|
97
|
+
end
|
98
|
+
|
99
|
+
def to_xml(options={})
|
100
|
+
builder = Builder::XmlMarkup.new( )
|
101
|
+
builder.instruct! :xml, :encoding => "UTF-8"
|
102
|
+
builder.checkout do |checkout|
|
103
|
+
checkout.currency currency
|
104
|
+
|
105
|
+
checkout.reference reference if reference
|
106
|
+
checkout.redirectURL redirect_url if redirect_url
|
107
|
+
checkout.extraAmount extra_amount if extra_amount
|
108
|
+
checkout.maxUses max_uses if max_uses
|
109
|
+
checkout.maxAge max_age if max_age
|
110
|
+
|
111
|
+
checkout.items do |items|
|
112
|
+
self.items.each{ |i| i.to_xml(:builder => items) }
|
113
|
+
end
|
114
|
+
|
115
|
+
if self.shipping
|
116
|
+
checkout.shipping self.shipping.to_xml(:builder => checkout)
|
117
|
+
end
|
118
|
+
|
119
|
+
if self.sender
|
120
|
+
checkout.sender self.sender.to_xml(:builder => checkout)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
private
|
126
|
+
# melhorar
|
127
|
+
def convert_unit(number, unit)
|
128
|
+
number = (BigDecimal("#{number}") * unit).to_i unless number.nil? || number.kind_of?(Integer)
|
129
|
+
number
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'pagseguro_v2/config'
|
3
|
+
|
4
|
+
module PagseguroV2
|
5
|
+
class Client
|
6
|
+
include HTTParty
|
7
|
+
base_uri PagseguroV2::Config::API_HOST
|
8
|
+
format :xml
|
9
|
+
|
10
|
+
attr_accessor :email
|
11
|
+
attr_accessor :token
|
12
|
+
|
13
|
+
def initialize(email, token)
|
14
|
+
super()
|
15
|
+
self.email = email
|
16
|
+
self.token = token
|
17
|
+
end
|
18
|
+
|
19
|
+
def checkout(attributes)
|
20
|
+
checkout = Checkout.new(attributes)
|
21
|
+
checkout.client = self
|
22
|
+
checkout
|
23
|
+
end
|
24
|
+
|
25
|
+
def notification(attributes)
|
26
|
+
notification = Notification.new(attributes)
|
27
|
+
notification.client = self
|
28
|
+
notification
|
29
|
+
end
|
30
|
+
|
31
|
+
def proceed_checkout(checkout)
|
32
|
+
self.parse_post_response(PagseguroV2::Config::CHECKOUT_PATH, checkout)
|
33
|
+
end
|
34
|
+
|
35
|
+
def query_transaction(notification)
|
36
|
+
path = PagseguroV2::Config::NOTIFICATION_PATH.gsub 'ID', notification.code
|
37
|
+
options = { query: {email: email, token: token} }
|
38
|
+
parse_get_response(path, options)
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse_post_response(path, object)
|
42
|
+
response = post(path, object)
|
43
|
+
parse_response(response)
|
44
|
+
end
|
45
|
+
|
46
|
+
def parse_get_response(path, options)
|
47
|
+
response = get(path, options)
|
48
|
+
parse_response(response)
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_response(response)
|
52
|
+
if response.code == 200
|
53
|
+
response
|
54
|
+
elsif response.code == 401
|
55
|
+
raise PagseguroV2::Errors::Unauthorized
|
56
|
+
elsif response.code == 400
|
57
|
+
raise PagseguroV2::Errors::InvalidData.new(response.body)
|
58
|
+
else
|
59
|
+
raise PagseguroV2::Errors::UnknownError.new(response)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def get(path, options = {})
|
64
|
+
self.class.get(path, options)
|
65
|
+
end
|
66
|
+
|
67
|
+
def post(path, object)
|
68
|
+
object_xml = object.to_xml
|
69
|
+
header = {"Content-Type" => "application/xml; charset=UTF-8"}
|
70
|
+
query = { :email => self.email, :token => self.token }
|
71
|
+
options = {query: query, body: object_xml, headers: header}
|
72
|
+
self.class.post(path, options)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module PagseguroV2
|
2
|
+
module Config
|
3
|
+
API_HOST = "https://ws.pagseguro.uol.com.br/v2"
|
4
|
+
REDIRECT_URL = "https://pagseguro.uol.com.br/v2/checkout/payment.html?code="
|
5
|
+
|
6
|
+
CHECKOUT_PATH = '/checkout'
|
7
|
+
NOTIFICATION_PATH = '/transactions/notifications/ID'
|
8
|
+
|
9
|
+
CHARSET = "UTF-8"
|
10
|
+
CURRENCY = "BRL"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module PagseguroV2
|
2
|
+
module Errors
|
3
|
+
class InvalidData < Exception
|
4
|
+
def initialize(error_xml)
|
5
|
+
err_msg = Nokogiri::XML(error_xml).css("errors error").inject("") do |acc, node|
|
6
|
+
acc + "#{node.css('code').first.content}: #{node.css('message').first.content}\n"
|
7
|
+
end
|
8
|
+
super(err_msg)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module PagseguroV2
|
2
|
+
class Item < Hashie::Dash
|
3
|
+
property :id, required: true
|
4
|
+
property :description, required: true
|
5
|
+
property :amount, required: true
|
6
|
+
property :quantity, required: true, default: 1
|
7
|
+
property :shipping_cost
|
8
|
+
property :weight
|
9
|
+
|
10
|
+
def to_xml(options = {})
|
11
|
+
builder = options[:builder] || Builder::XmlMarkup.new()
|
12
|
+
builder.item do |item|
|
13
|
+
item.id id
|
14
|
+
item.description description
|
15
|
+
item.amount amount
|
16
|
+
item.quantity quantity
|
17
|
+
item.shippingCost shipping_cost if shipping_cost
|
18
|
+
item.weight weight if weight
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def quantity
|
23
|
+
self[:quantity].to_i
|
24
|
+
end
|
25
|
+
|
26
|
+
def weight
|
27
|
+
self[:weight].to_i if self[:weight]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module PagseguroV2
|
2
|
+
class Notification < Hashie::Trash
|
3
|
+
property :code, :from => :notificationCode
|
4
|
+
property :type, :from => :notificationType
|
5
|
+
|
6
|
+
attr_accessor :client
|
7
|
+
|
8
|
+
def transaction
|
9
|
+
response = self.client.query_transaction(self)
|
10
|
+
transaction = Transaction.new response['transaction']
|
11
|
+
transaction
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module PagseguroV2
|
2
|
+
class Sender < Hashie::Dash
|
3
|
+
property :email
|
4
|
+
property :name
|
5
|
+
property :phone_area_code
|
6
|
+
property :phone_number
|
7
|
+
|
8
|
+
def initialize(attributes)
|
9
|
+
phone = attributes.delete 'phone'
|
10
|
+
self.phone_area_code = phone['areaCode']
|
11
|
+
self.phone_number = phone['number']
|
12
|
+
super(attributes)
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_xml(options = {})
|
16
|
+
builder = options[:builder] || Builder::XmlMarkup.new()
|
17
|
+
builder.sender do |sender|
|
18
|
+
sender.email email if email
|
19
|
+
sender.name name if name
|
20
|
+
if phone_area_number && phone_number
|
21
|
+
sender.phone do |phone|
|
22
|
+
phone.areaCode
|
23
|
+
phone.number
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module PagseguroV2
|
2
|
+
class Shipping < Hashie::Dash
|
3
|
+
property :type, default: 3
|
4
|
+
property :address
|
5
|
+
property :cost
|
6
|
+
|
7
|
+
def to_xml(options = {})
|
8
|
+
builder = options[:builder] || Builder::XmlMarkup.new()
|
9
|
+
builder.shipping do |shipping|
|
10
|
+
shipping.type type
|
11
|
+
if self.address
|
12
|
+
shipping.address self.address.to_xml(:builder => shipping)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module PagseguroV2
|
2
|
+
class Transaction < Hashie::Trash
|
3
|
+
property :date
|
4
|
+
property :code
|
5
|
+
property :reference
|
6
|
+
property :type
|
7
|
+
property :status
|
8
|
+
|
9
|
+
property :payment_method, :from => :paymentMethod
|
10
|
+
|
11
|
+
property :gross_amount, :from => :grossAmount
|
12
|
+
property :discount_amount, :from => :discountAmount
|
13
|
+
property :fee_amount, :from => :feeAmount
|
14
|
+
property :net_amount, :from => :netAmount
|
15
|
+
property :extra_amount, :from => :extraAmount
|
16
|
+
property :installment_count, :from => :installmentCount
|
17
|
+
|
18
|
+
property :item_count, :from => :itemCount
|
19
|
+
property :items
|
20
|
+
property :sender
|
21
|
+
property :shipping
|
22
|
+
property :last_event_date, :from => :lastEventDate
|
23
|
+
property :escrow_end_date, :from => :escrowEndDate
|
24
|
+
|
25
|
+
def status
|
26
|
+
Transaction::Payment::Status[self.status]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module PagseguroV2
|
4
|
+
module Transaction
|
5
|
+
module Payment
|
6
|
+
CODES = {
|
7
|
+
101 => "Cartão de crédito Visa",
|
8
|
+
102 => "Cartão de crédito MasterCard",
|
9
|
+
103 => "Cartão de crédito American Express",
|
10
|
+
104 => "Cartão de crédito Diners",
|
11
|
+
105 => "Cartão de crédito Hipercard",
|
12
|
+
106 => "Cartão de crédito Aura",
|
13
|
+
107 => "Cartão de crédito Elo",
|
14
|
+
108 => 'Cartão de crédito PLENOCard',
|
15
|
+
109 => 'Cartão de crédito PersonalCard',
|
16
|
+
110 => 'Cartão de crédito JCB',
|
17
|
+
111 => 'Cartão de crédito Discover',
|
18
|
+
112 => 'Cartão de crédito BrasilCard',
|
19
|
+
113 => 'Cartão de crédito FORTBRASIL',
|
20
|
+
201 => "Boleto Bradesco",
|
21
|
+
202 => "Boleto Santander",
|
22
|
+
301 => "Débito online Bradesco",
|
23
|
+
302 => "Débito online Itaú",
|
24
|
+
303 => "Débito online Unibanco",
|
25
|
+
304 => "Débito online Banco do Brasil",
|
26
|
+
305 => "Débito online Banco Real",
|
27
|
+
306 => "Débito online Banrisul",
|
28
|
+
307 => 'Débito online HSBC',
|
29
|
+
401 => "Saldo PagSeguro",
|
30
|
+
501 => "Oi Paggo"
|
31
|
+
}
|
32
|
+
|
33
|
+
TYPES = {
|
34
|
+
1 => :credit_card,
|
35
|
+
2 => :invoice,
|
36
|
+
3 => :online_transfer,
|
37
|
+
4 => :pagseguro,
|
38
|
+
5 => :oi_paggo
|
39
|
+
}
|
40
|
+
|
41
|
+
TYPES_STRINGS = {
|
42
|
+
credit_card: 'Cartão de crédito',
|
43
|
+
invoice: 'Boleto',
|
44
|
+
online_transfer: 'Débito online (TEF)',
|
45
|
+
pagseguro: 'Saldo PagSeguro',
|
46
|
+
oi_paggo: 'Oi Paggo',
|
47
|
+
}
|
48
|
+
|
49
|
+
STATUS = {
|
50
|
+
1 => :pending,
|
51
|
+
2 => :verifying,
|
52
|
+
3 => :approved,
|
53
|
+
4 => :completed,
|
54
|
+
5 => :completed,
|
55
|
+
6 => :dispute,
|
56
|
+
7 => :canceled
|
57
|
+
}
|
58
|
+
|
59
|
+
#1 Aguardando pagamento: o comprador iniciou a transação, mas até o momento o PagSeguro não recebeu nenhuma informação sobre o pagamento.
|
60
|
+
#2 Em análise: o comprador optou por pagar com um cartão de crédito e o PagSeguro está analisando o risco da transação.
|
61
|
+
#3 Paga: a transação foi paga pelo comprador e o PagSeguro já recebeu uma confirmação da instituição financeira responsável pelo processamento.
|
62
|
+
#4 Disponível: a transação foi paga e chegou ao final de seu prazo de liberação sem ter sido retornada e sem que haja nenhuma disputa aberta.
|
63
|
+
#5 Em disputa: o comprador, dentro do prazo de liberação da transação, abriu uma disputa.
|
64
|
+
#6 Devolvida: o valor da transação foi devolvido para o comprador.
|
65
|
+
#7 Cancelada: a transação foi cancelada sem ter sido finalizada.
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module PagseguroV2
|
3
|
+
module Transaction
|
4
|
+
module Shipping
|
5
|
+
TYPES = {
|
6
|
+
normal: 1 ,
|
7
|
+
express: 2,
|
8
|
+
other: 3
|
9
|
+
}
|
10
|
+
|
11
|
+
TYPES_STRINGS = {
|
12
|
+
normal: "Encomenda normal (PAC)",
|
13
|
+
express: "SEDEX",
|
14
|
+
other: "Tipo de frete não especificado"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module PagseguroV2
|
2
|
+
module Transaction
|
3
|
+
module Types
|
4
|
+
TYPES = {
|
5
|
+
payment: 1,
|
6
|
+
transfer: 2,
|
7
|
+
fund_addition: 3,
|
8
|
+
withdraw: 4,
|
9
|
+
charge: 5,
|
10
|
+
donation: 6,
|
11
|
+
bonus: 7,
|
12
|
+
bonus_repass: 8,
|
13
|
+
operational: 9,
|
14
|
+
political_donation: 10
|
15
|
+
}
|
16
|
+
|
17
|
+
TYPES_STRINGS = {
|
18
|
+
payment: 'Pagamento',
|
19
|
+
transfer: 'Tranferencia',
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "pagseguro_v2/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "pagseguro_v2"
|
7
|
+
s.version = PagseguroV2::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Cirdes Henrique", "Thiago Diniz"]
|
10
|
+
s.email = ["oi@eventick.com.br"]
|
11
|
+
s.homepage = "http://github.com/eventick/pagseguro_v2"
|
12
|
+
s.summary = %q{Ruby gem for interfacing with Pagseguro V2 API. By http://eventick.co}
|
13
|
+
s.description = %q{Ruby gem for interfacing with Pagseguro V2 API.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "pagseguro_v2"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency('nokogiri')
|
23
|
+
s.add_development_dependency "rspec", "~> 2.10.0"
|
24
|
+
s.add_runtime_dependency "hashie", '>= 1.2.0'
|
25
|
+
s.add_runtime_dependency "httparty"
|
26
|
+
s.add_runtime_dependency "builder"
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PagseguroV2::Checkout do
|
4
|
+
before do
|
5
|
+
@checkout = PagseguroV2::Checkout.new
|
6
|
+
@product = {:price => 9.90, :description => "Ruby 1.9 PDF", :id => 1}
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should set order id when instantiating object" do
|
10
|
+
@checkout = PagseguroV2::Checkout.new("ABCDEF")
|
11
|
+
@checkout.id.should == "ABCDEF"
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pagseguro_v2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Cirdes Henrique
|
9
|
+
- Thiago Diniz
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-06-12 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nokogiri
|
17
|
+
requirement: &87329740 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *87329740
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec
|
28
|
+
requirement: &87329220 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.10.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *87329220
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: hashie
|
39
|
+
requirement: &87328940 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.2.0
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *87328940
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: httparty
|
50
|
+
requirement: &87328720 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *87328720
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: builder
|
61
|
+
requirement: &87328370 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
type: :runtime
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *87328370
|
70
|
+
description: Ruby gem for interfacing with Pagseguro V2 API.
|
71
|
+
email:
|
72
|
+
- oi@eventick.com.br
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/pagseguro_v2.rb
|
83
|
+
- lib/pagseguro_v2/address.rb
|
84
|
+
- lib/pagseguro_v2/checkout.rb
|
85
|
+
- lib/pagseguro_v2/client.rb
|
86
|
+
- lib/pagseguro_v2/config.rb
|
87
|
+
- lib/pagseguro_v2/errors/invalid_data.rb
|
88
|
+
- lib/pagseguro_v2/errors/unauthorized.rb
|
89
|
+
- lib/pagseguro_v2/errors/unknown_error.rb
|
90
|
+
- lib/pagseguro_v2/item.rb
|
91
|
+
- lib/pagseguro_v2/notification.rb
|
92
|
+
- lib/pagseguro_v2/payment_method.rb
|
93
|
+
- lib/pagseguro_v2/sender.rb
|
94
|
+
- lib/pagseguro_v2/shipping.rb
|
95
|
+
- lib/pagseguro_v2/transaction.rb
|
96
|
+
- lib/pagseguro_v2/transaction/payment.rb
|
97
|
+
- lib/pagseguro_v2/transaction/shipping.rb
|
98
|
+
- lib/pagseguro_v2/transaction/types.rb
|
99
|
+
- lib/pagseguro_v2/version.rb
|
100
|
+
- pagseguro_v2.gemspec
|
101
|
+
- spec/pagseguro_v2/checkout_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
homepage: http://github.com/eventick/pagseguro_v2
|
104
|
+
licenses: []
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project: pagseguro_v2
|
123
|
+
rubygems_version: 1.8.10
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: Ruby gem for interfacing with Pagseguro V2 API. By http://eventick.co
|
127
|
+
test_files: []
|