pag_seguro 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +3 -2
- data/README.md +16 -0
- data/lib/pag_seguro.rb +1 -0
- data/lib/pag_seguro/checkout.xml.haml +2 -0
- data/lib/pag_seguro/notification.rb +1 -1
- data/lib/pag_seguro/payment.rb +14 -6
- data/lib/pag_seguro/query.rb +2 -2
- data/lib/pag_seguro/transaction.rb +4 -2
- data/lib/pag_seguro/url.rb +36 -0
- data/lib/pag_seguro/version.rb +1 -1
- data/spec/pag_seguro/checkout_xml_spec.rb +77 -72
- data/spec/pag_seguro/day_of_year_spec.rb +9 -9
- data/spec/pag_seguro/errors/invalid_data_spec.rb +1 -1
- data/spec/pag_seguro/errors/unauthorized_spec.rb +1 -1
- data/spec/pag_seguro/errors/unknown_error_spec.rb +1 -1
- data/spec/pag_seguro/integration/checkout_spec.rb +9 -9
- data/spec/pag_seguro/integration/config.yml +4 -4
- data/spec/pag_seguro/integration/notification_spec.rb +21 -21
- data/spec/pag_seguro/integration/query_spec.rb +23 -23
- data/spec/pag_seguro/item_spec.rb +44 -44
- data/spec/pag_seguro/notification_spec.rb +1 -1
- data/spec/pag_seguro/payment_method_spec.rb +8 -8
- data/spec/pag_seguro/payment_spec.rb +177 -160
- data/spec/pag_seguro/pre_approval_spec.rb +56 -56
- data/spec/pag_seguro/query_spec.rb +26 -24
- data/spec/pag_seguro/sender_spec.rb +10 -10
- data/spec/pag_seguro/shipping_spec.rb +13 -13
- data/spec/pag_seguro/url_spec.rb +53 -0
- data/spec/pag_seguro/version_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -3
- data/spec/support/transaction_shared_examples.rb +186 -167
- metadata +20 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 855e564031122d7fe066c2b9534ace226afecca7
|
4
|
+
data.tar.gz: e126b017a4e8b23b51889425aa5256e24c102dd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9233c304b25d2e8400889df6e00f1722670a187cafd8ebc6b6d117bb227e161dc1d924af51b6392156e57db612bb761d64b1253f156eecc6adb7364bedf9b8f6
|
7
|
+
data.tar.gz: 52c1a877692781c255057f0ebe8fdb8ff12222b62d0c12220f8dd067980d66ecbf4cbc4d05d8f2e928b014c46c751e13580c8b5ab5cda85c9dfcf91c0d8fee92
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -5,9 +5,10 @@ gemspec
|
|
5
5
|
|
6
6
|
# test or development gems
|
7
7
|
gem 'rspec'
|
8
|
+
gem 'rspec-its'
|
8
9
|
gem 'simplecov', require: false
|
9
10
|
gem 'guard-rspec'
|
10
|
-
gem 'shoulda-matchers'
|
11
|
+
gem 'shoulda-matchers', '2.5.0'
|
11
12
|
gem "factory_girl", "~> 4.0"
|
12
13
|
gem 'growl'
|
13
|
-
gem 'pry'
|
14
|
+
gem 'pry'
|
data/README.md
CHANGED
@@ -18,6 +18,22 @@ Além disso, é necessário que tenha uma conta no pag seguro, e que habilite as
|
|
18
18
|
Em [Integrações -> Pagamentos via API](https://pagseguro.uol.com.br/integracao/pagamentos-via-api.jhtml) é necessário ativar a opção "Quero receber somente pagamentos via API."
|
19
19
|
Em [Integrações -> Notificação de transações](https://pagseguro.uol.com.br/integracao/notificacao-de-transacoes.jhtml) é necessário ativar a notificação de transações e definir a url de retorno
|
20
20
|
|
21
|
+
### Sandbox
|
22
|
+
|
23
|
+
Altere o ambiente para `sandbox`:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
# config/initializers/pagseguro.rb
|
27
|
+
|
28
|
+
PagSeguro::Url.environment = :sandbox # default: :production
|
29
|
+
```
|
30
|
+
Você pode alterar o ambiente a qualquer momento para `:production`
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
PagSeguro::Url.environment = :production
|
34
|
+
```
|
35
|
+
Acesse a página de [Sandbox](https://sandbox.pagseguro.uol.com.br/) no pag seguro para obter seus [dados de teste](https://sandbox.pagseguro.uol.com.br/dados-de-teste.html).
|
36
|
+
|
21
37
|
## Documentação
|
22
38
|
|
23
39
|
### Classes e Atributos
|
data/lib/pag_seguro.rb
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
%extraAmount= payment.extra_amount
|
7
7
|
- if payment.redirect_url.present?
|
8
8
|
%redirectURL= payment.redirect_url
|
9
|
+
- if payment.notification_url.present?
|
10
|
+
%notificationURL= payment.notification_url
|
9
11
|
- if payment.max_uses.present?
|
10
12
|
%maxUses= payment.max_uses
|
11
13
|
- if payment.max_age.present?
|
@@ -10,7 +10,7 @@ module PagSeguro
|
|
10
10
|
|
11
11
|
private
|
12
12
|
def transaction_data(email, token, notification_code)
|
13
|
-
notification_url = "#{
|
13
|
+
notification_url = "#{Transaction.transactions_url}/notifications/#{notification_code}"
|
14
14
|
super RestClient.get notification_url, params: {email: email, token: token}
|
15
15
|
end
|
16
16
|
end
|
data/lib/pag_seguro/payment.rb
CHANGED
@@ -3,10 +3,8 @@ module PagSeguro
|
|
3
3
|
include ActiveModel::Validations
|
4
4
|
extend PagSeguro::ConvertFieldToDigit
|
5
5
|
|
6
|
-
CHECKOUT_URL = "https://ws.pagseguro.uol.com.br/v2/checkout"
|
7
|
-
|
8
6
|
attr_accessor :id, :email, :token, :items, :sender, :shipping,
|
9
|
-
:extra_amount, :redirect_url, :max_uses, :max_age,
|
7
|
+
:extra_amount, :redirect_url, :notification_url, :max_uses, :max_age,
|
10
8
|
:response, :pre_approval
|
11
9
|
alias :reference :id
|
12
10
|
alias :reference= :id=
|
@@ -16,6 +14,7 @@ module PagSeguro
|
|
16
14
|
validates_presence_of :email, :token
|
17
15
|
validates :extra_amount, pagseguro_decimal: true
|
18
16
|
validates_format_of :redirect_url, with: URI::regexp(%w(http https)), message: " must give a correct url for redirection", allow_blank: true
|
17
|
+
validates_format_of :notification_url, with: URI::regexp(%w(http https)), message: " must give a correct url for notification", allow_blank: true
|
19
18
|
validate :max_uses_number, :max_age_number, :valid_pre_approval, :valid_items
|
20
19
|
|
21
20
|
def initialize(email = nil, token = nil, options = {})
|
@@ -27,13 +26,18 @@ module PagSeguro
|
|
27
26
|
@items = options[:items] || []
|
28
27
|
@extra_amount = options[:extra_amount]
|
29
28
|
@redirect_url = options[:redirect_url]
|
29
|
+
@notification_url = options[:notification_url]
|
30
30
|
@max_uses = options[:max_uses]
|
31
31
|
@max_age = options[:max_age]
|
32
32
|
@pre_approval = options[:pre_approval]
|
33
33
|
end
|
34
34
|
|
35
|
+
def self.checkout_url
|
36
|
+
PagSeguro::Url.api_url("/checkout")
|
37
|
+
end
|
38
|
+
|
35
39
|
def self.checkout_payment_url(code)
|
36
|
-
"
|
40
|
+
PagSeguro::Url.site_url("/checkout/payment.html?code=#{code}")
|
37
41
|
end
|
38
42
|
|
39
43
|
def checkout_xml
|
@@ -52,6 +56,10 @@ module PagSeguro
|
|
52
56
|
self.class.checkout_payment_url(code)
|
53
57
|
end
|
54
58
|
|
59
|
+
def checkout_url
|
60
|
+
self.class.checkout_url
|
61
|
+
end
|
62
|
+
|
55
63
|
def code
|
56
64
|
response || parse_checkout_response
|
57
65
|
parse_code
|
@@ -92,8 +100,8 @@ module PagSeguro
|
|
92
100
|
end
|
93
101
|
|
94
102
|
def send_checkout
|
95
|
-
params = { email: @email, token: @token }
|
96
|
-
RestClient.post(
|
103
|
+
params = { email: @email, token: @token, ssl_version: :SSLv3 }
|
104
|
+
RestClient.post(checkout_url, checkout_xml,
|
97
105
|
params: params,
|
98
106
|
content_type: "application/xml"){|resp, request, result| resp }
|
99
107
|
end
|
data/lib/pag_seguro/query.rb
CHANGED
@@ -9,7 +9,7 @@ module PagSeguro
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.find(email, token, options={})
|
12
|
-
url = Transaction
|
12
|
+
url = Transaction.transactions_url
|
13
13
|
url += "/abandoned" if options[:abandoned]
|
14
14
|
|
15
15
|
transactions_data = Nokogiri::XML(RestClient.get url, params: search_params(email, token, options))
|
@@ -40,7 +40,7 @@ module PagSeguro
|
|
40
40
|
|
41
41
|
private
|
42
42
|
def transaction_data(email, token, transaction_code)
|
43
|
-
transaction_url = "#{
|
43
|
+
transaction_url = "#{Transaction.transactions_url}/#{transaction_code}"
|
44
44
|
super RestClient.get transaction_url, params: {email: email, token: token}
|
45
45
|
end
|
46
46
|
end
|
@@ -5,8 +5,6 @@ module PagSeguro
|
|
5
5
|
class Transaction
|
6
6
|
attr_accessor :data
|
7
7
|
|
8
|
-
PAGSEGURO_TRANSACTIONS_URL = "https://ws.pagseguro.uol.com.br/v2/transactions"
|
9
|
-
|
10
8
|
# possible status values
|
11
9
|
PAGSEGURO_PROCESSING = 1
|
12
10
|
PAGSEGURO_IN_ANALYSIS = 2
|
@@ -35,6 +33,10 @@ module PagSeguro
|
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
36
|
+
def self.transactions_url
|
37
|
+
PagSeguro::Url.api_url("/transactions")
|
38
|
+
end
|
39
|
+
|
38
40
|
def initialize(transaction_xml)
|
39
41
|
@data = transaction_data(transaction_xml)
|
40
42
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module PagSeguro
|
2
|
+
class Url
|
3
|
+
class << self
|
4
|
+
attr_accessor :environment
|
5
|
+
end
|
6
|
+
|
7
|
+
self.environment = :production
|
8
|
+
|
9
|
+
def self.uris
|
10
|
+
@uris ||= {
|
11
|
+
production: {
|
12
|
+
api: "https://ws.pagseguro.uol.com.br/v2",
|
13
|
+
site: "https://pagseguro.uol.com.br/v2"
|
14
|
+
},
|
15
|
+
sandbox: {
|
16
|
+
api: "https://ws.sandbox.pagseguro.uol.com.br/v2",
|
17
|
+
site: "https://sandbox.pagseguro.uol.com.br/v2"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.root_uri(type)
|
23
|
+
root = uris.fetch(environment.to_sym) { raise InvalidEnvironmentError }
|
24
|
+
root[type.to_sym]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.api_url(path)
|
28
|
+
File.join(root_uri(:api), path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.site_url(path)
|
32
|
+
File.join(root_uri(:site), path)
|
33
|
+
end
|
34
|
+
InvalidEnvironmentError = Class.new(StandardError)
|
35
|
+
end
|
36
|
+
end
|
data/lib/pag_seguro/version.rb
CHANGED
@@ -22,154 +22,159 @@ describe PagSeguro::Payment do
|
|
22
22
|
its(:checkout_xml){ should match(/^<\?xml.+encoding="UTF-8".+\?>$/) }
|
23
23
|
|
24
24
|
describe 'settings' do
|
25
|
-
it { xml_content('checkout reference').
|
26
|
-
it { xml_content('checkout extraAmount').
|
27
|
-
it { xml_content('checkout redirectURL').
|
28
|
-
it { xml_content('checkout maxUses').
|
29
|
-
it { xml_content('checkout maxAge').
|
30
|
-
it { xml_content('checkout currency').
|
25
|
+
it { expect(xml_content('checkout reference')).to be_empty }
|
26
|
+
it { expect(xml_content('checkout extraAmount')).to be_empty }
|
27
|
+
it { expect(xml_content('checkout redirectURL')).to be_empty }
|
28
|
+
it { expect(xml_content('checkout maxUses')).to be_empty }
|
29
|
+
it { expect(xml_content('checkout maxAge')).to be_empty }
|
30
|
+
it { expect(xml_content('checkout currency')).to eq('BRL') }
|
31
31
|
|
32
32
|
context 'with id' do
|
33
33
|
before{ payment.id = 305 }
|
34
|
-
it { xml_content('checkout reference').
|
34
|
+
it { expect(xml_content('checkout reference')).to eq('305') }
|
35
35
|
end
|
36
36
|
|
37
37
|
context 'with extra amount' do
|
38
38
|
before{ payment.extra_amount = '10.50' }
|
39
|
-
it { xml_content('checkout extraAmount').
|
39
|
+
it { expect(xml_content('checkout extraAmount')).to eq('10.50') }
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'with redirect url' do
|
43
43
|
before{ payment.redirect_url = 'http://heavenstudio.com.br' }
|
44
|
-
it { xml_content('checkout redirectURL').
|
44
|
+
it { expect(xml_content('checkout redirectURL')).to eq('http://heavenstudio.com.br') }
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with notification url' do
|
48
|
+
before{ payment.notification_url = 'http://heavenstudio.com.br/notification' }
|
49
|
+
it { expect(xml_content('checkout notificationURL')).to eq('http://heavenstudio.com.br/notification') }
|
45
50
|
end
|
46
51
|
|
47
52
|
context 'with max uses' do
|
48
53
|
before{ payment.max_uses = '10' }
|
49
|
-
it { xml_content('checkout maxUses').
|
54
|
+
it { expect(xml_content('checkout maxUses')).to eq('10') }
|
50
55
|
end
|
51
56
|
|
52
57
|
context 'with max age' do
|
53
58
|
before{ payment.max_age = '5000' }
|
54
|
-
it { xml_content('checkout maxAge').
|
59
|
+
it { expect(xml_content('checkout maxAge')).to eq('5000') }
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
58
63
|
describe 'items' do
|
59
64
|
let(:payment){ build :payment_with_items }
|
60
65
|
|
61
|
-
it { xml_collection('checkout items item').size.
|
62
|
-
it { xml_collection('checkout items item id').
|
63
|
-
it { xml_collection('checkout items item description').
|
64
|
-
it { xml_collection('checkout items item amount').
|
65
|
-
it { xml_collection('checkout items item quantity').
|
66
|
-
it { xml_collection('checkout items item shippingCost').
|
67
|
-
it { xml_collection('checkout items item weight').
|
66
|
+
it { expect(xml_collection('checkout items item').size).to eq(4) }
|
67
|
+
it { expect(xml_collection('checkout items item id')).to eq(['25', '73', '95', '17']) }
|
68
|
+
it { expect(xml_collection('checkout items item description')).to eq(['A Bic Pen', 'A Book & Cover', 'A Towel', 'A pipe']) }
|
69
|
+
it { expect(xml_collection('checkout items item amount')).to eq(['1.50', '38.23', '69.35', '3.00']) }
|
70
|
+
it { expect(xml_collection('checkout items item quantity')).to eq(['4', '1', '2', '89']) }
|
71
|
+
it { expect(xml_collection('checkout items item shippingCost')).to eq(['1.00', '12.00']) }
|
72
|
+
it { expect(xml_collection('checkout items item weight')).to eq(['10', '300', '400']) }
|
68
73
|
|
69
74
|
it 'should escape html in item description' do
|
70
|
-
payment.checkout_xml.
|
75
|
+
expect(payment.checkout_xml).to include('A Book & Cover')
|
71
76
|
end
|
72
77
|
end
|
73
78
|
|
74
79
|
describe 'sender info' do
|
75
80
|
context 'without sender' do
|
76
|
-
it { xml_content('checkout sender name').
|
77
|
-
it { xml_content('checkout sender email').
|
78
|
-
it { xml_content('checkout sender phone areaCode').
|
79
|
-
it { xml_content('checkout sender phone number').
|
81
|
+
it { expect(xml_content('checkout sender name')).to be_empty }
|
82
|
+
it { expect(xml_content('checkout sender email')).to be_empty }
|
83
|
+
it { expect(xml_content('checkout sender phone areaCode')).to be_empty }
|
84
|
+
it { expect(xml_content('checkout sender phone number')).to be_empty }
|
80
85
|
end
|
81
86
|
|
82
87
|
context 'with sender' do
|
83
88
|
let(:payment){ build :payment_with_sender }
|
84
89
|
|
85
|
-
it { xml_content('checkout sender name').
|
86
|
-
it { xml_content('checkout sender email').
|
87
|
-
it { xml_content('checkout sender phone areaCode').
|
88
|
-
it { xml_content('checkout sender phone number').
|
90
|
+
it { expect(xml_content('checkout sender name')).to eq('Stefano Diem Benatti') }
|
91
|
+
it { expect(xml_content('checkout sender email')).to eq('stefano@heavenstudio.com.br') }
|
92
|
+
it { expect(xml_content('checkout sender phone areaCode')).to eq('11') }
|
93
|
+
it { expect(xml_content('checkout sender phone number')).to eq('993430994') }
|
89
94
|
end
|
90
95
|
end
|
91
96
|
|
92
97
|
describe 'shipping info' do
|
93
98
|
context 'without shipping' do
|
94
|
-
it { xml_content('checkout shipping').
|
95
|
-
it { xml_content('checkout shipping address').
|
99
|
+
it { expect(xml_content('checkout shipping')).to be_empty }
|
100
|
+
it { expect(xml_content('checkout shipping address')).to be_empty }
|
96
101
|
end
|
97
102
|
|
98
103
|
context 'with empty shipping' do
|
99
104
|
before{ payment.shipping = PagSeguro::Shipping.new }
|
100
105
|
|
101
|
-
it { xml_content('checkout shipping').
|
102
|
-
it { xml_content('checkout shipping address').
|
103
|
-
it { xml_content('checkout shipping address state').
|
104
|
-
it { xml_content('checkout shipping address city').
|
105
|
-
it { xml_content('checkout shipping address postalCode').
|
106
|
-
it { xml_content('checkout shipping address district').
|
107
|
-
it { xml_content('checkout shipping address street').
|
108
|
-
it { xml_content('checkout shipping address number').
|
109
|
-
it { xml_content('checkout shipping address complement').
|
110
|
-
it { xml_content('checkout shipping type').to_i.
|
106
|
+
it { expect(xml_content('checkout shipping')).not_to be_empty }
|
107
|
+
it { expect(xml_content('checkout shipping address')).not_to be_empty }
|
108
|
+
it { expect(xml_content('checkout shipping address state')).to be_empty }
|
109
|
+
it { expect(xml_content('checkout shipping address city')).to be_empty }
|
110
|
+
it { expect(xml_content('checkout shipping address postalCode')).to be_empty }
|
111
|
+
it { expect(xml_content('checkout shipping address district')).to be_empty }
|
112
|
+
it { expect(xml_content('checkout shipping address street')).to be_empty }
|
113
|
+
it { expect(xml_content('checkout shipping address number')).to be_empty }
|
114
|
+
it { expect(xml_content('checkout shipping address complement')).to be_empty }
|
115
|
+
it { expect(xml_content('checkout shipping type').to_i).to eq(PagSeguro::Shipping::UNIDENTIFIED) }
|
111
116
|
end
|
112
117
|
|
113
118
|
context 'with shipping' do
|
114
119
|
let(:payment){ build :payment_with_shipping }
|
115
120
|
|
116
|
-
it { xml_content('checkout shipping').
|
117
|
-
it { xml_content('checkout shipping address').
|
118
|
-
it { xml_content('checkout shipping type').to_i.
|
119
|
-
it { xml_content('checkout shipping cost').
|
120
|
-
it { xml_content('checkout shipping address state').
|
121
|
-
it { xml_content('checkout shipping address city').
|
122
|
-
it { xml_content('checkout shipping address postalCode').
|
123
|
-
it { xml_content('checkout shipping address district').
|
124
|
-
it { xml_content('checkout shipping address street').
|
125
|
-
it { xml_content('checkout shipping address number').
|
126
|
-
it { xml_content('checkout shipping address complement').
|
121
|
+
it { expect(xml_content('checkout shipping')).not_to be_empty }
|
122
|
+
it { expect(xml_content('checkout shipping address')).not_to be_empty }
|
123
|
+
it { expect(xml_content('checkout shipping type').to_i).to eq(PagSeguro::Shipping::SEDEX) }
|
124
|
+
it { expect(xml_content('checkout shipping cost')).to eq('12.13') }
|
125
|
+
it { expect(xml_content('checkout shipping address state')).to eq('SP') }
|
126
|
+
it { expect(xml_content('checkout shipping address city')).to eq('São Paulo') }
|
127
|
+
it { expect(xml_content('checkout shipping address postalCode')).to eq('05363000') }
|
128
|
+
it { expect(xml_content('checkout shipping address district')).to eq('Jd. PoliPoli') }
|
129
|
+
it { expect(xml_content('checkout shipping address street')).to eq('Av. Otacilio Tomanik') }
|
130
|
+
it { expect(xml_content('checkout shipping address number')).to eq('775') }
|
131
|
+
it { expect(xml_content('checkout shipping address complement')).to eq('apto. 92') }
|
127
132
|
end
|
128
133
|
end
|
129
134
|
|
130
135
|
describe 'pre approval info' do
|
131
136
|
context 'without pre approval' do
|
132
|
-
it { xml_content('checkout preApproval').
|
137
|
+
it { expect(xml_content('checkout preApproval')).to be_empty }
|
133
138
|
end
|
134
139
|
|
135
140
|
context 'with pre_approval' do
|
136
141
|
let(:payment){ build :payment_with_pre_approval }
|
137
142
|
|
138
|
-
it { xml_content('checkout preApproval').
|
139
|
-
it { xml_content('checkout preApproval name').
|
140
|
-
it { xml_content('checkout preApproval details').
|
141
|
-
it { xml_content('checkout preApproval amountPerPayment').
|
142
|
-
it { xml_content('checkout preApproval initialDate').
|
143
|
-
it { xml_content('checkout preApproval finalDate').
|
144
|
-
it { xml_content('checkout preApproval maxAmountPerPeriod').
|
145
|
-
it { xml_content('checkout preApproval maxTotalAmount').
|
146
|
-
it { xml_content('checkout preApproval reviewURL').
|
143
|
+
it { expect(xml_content('checkout preApproval')).not_to be_empty }
|
144
|
+
it { expect(xml_content('checkout preApproval name')).to eq('Super seguro para notebook') }
|
145
|
+
it { expect(xml_content('checkout preApproval details')).to eq('Toda segunda feira será cobrado o valor de R$150,00 para o seguro do notebook') }
|
146
|
+
it { expect(xml_content('checkout preApproval amountPerPayment')).to eq('150.00') }
|
147
|
+
it { expect(xml_content('checkout preApproval initialDate')).to eq('2015-01-17T00:00:00+00:00') }
|
148
|
+
it { expect(xml_content('checkout preApproval finalDate')).to eq('2017-01-17T00:00:00+00:00') }
|
149
|
+
it { expect(xml_content('checkout preApproval maxAmountPerPeriod')).to eq('200.00') }
|
150
|
+
it { expect(xml_content('checkout preApproval maxTotalAmount')).to eq('900.00') }
|
151
|
+
it { expect(xml_content('checkout preApproval reviewURL')).to eq('http://sounoob.com.br/produto1') }
|
147
152
|
|
148
153
|
context 'weekly' do
|
149
154
|
let(:payment){ build :payment_with_weekly_pre_approval }
|
150
155
|
|
151
|
-
it { xml_content('checkout preApproval period').
|
152
|
-
it { xml_content('checkout preApproval dayOfWeek').
|
153
|
-
it { xml_content('checkout preApproval dayOfMonth').
|
154
|
-
it { xml_content('checkout preApproval dayOfYear').
|
156
|
+
it { expect(xml_content('checkout preApproval period')).to eq('weekly') }
|
157
|
+
it { expect(xml_content('checkout preApproval dayOfWeek')).to eq('monday') }
|
158
|
+
it { expect(xml_content('checkout preApproval dayOfMonth')).to be_empty }
|
159
|
+
it { expect(xml_content('checkout preApproval dayOfYear')).to be_empty }
|
155
160
|
end
|
156
161
|
|
157
162
|
context 'monthly' do
|
158
163
|
let(:payment){ build :payment_with_monthly_pre_approval }
|
159
164
|
|
160
|
-
it { xml_content('checkout preApproval period').
|
161
|
-
it { xml_content('checkout preApproval dayOfWeek').
|
162
|
-
it { xml_content('checkout preApproval dayOfMonth').
|
163
|
-
it { xml_content('checkout preApproval dayOfYear').
|
165
|
+
it { expect(xml_content('checkout preApproval period')).to eq('monthly') }
|
166
|
+
it { expect(xml_content('checkout preApproval dayOfWeek')).to be_empty }
|
167
|
+
it { expect(xml_content('checkout preApproval dayOfMonth')).to eq('3') }
|
168
|
+
it { expect(xml_content('checkout preApproval dayOfYear')).to be_empty }
|
164
169
|
end
|
165
170
|
|
166
171
|
context 'yearly' do
|
167
172
|
let(:payment){ build :payment_with_yearly_pre_approval }
|
168
173
|
|
169
|
-
it { xml_content('checkout preApproval period').
|
170
|
-
it { xml_content('checkout preApproval dayOfWeek').
|
171
|
-
it { xml_content('checkout preApproval dayOfMonth').
|
172
|
-
it { xml_content('checkout preApproval dayOfYear').
|
174
|
+
it { expect(xml_content('checkout preApproval period')).to eq('yearly') }
|
175
|
+
it { expect(xml_content('checkout preApproval dayOfWeek')).to be_empty }
|
176
|
+
it { expect(xml_content('checkout preApproval dayOfMonth')).to be_empty }
|
177
|
+
it { expect(xml_content('checkout preApproval dayOfYear')).to eq('03-01') }
|
173
178
|
end
|
174
179
|
end
|
175
180
|
end
|