pag_seguro 0.4.1 → 0.5.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 +1 -0
- data/Gemfile +5 -2
- data/README.md +71 -6
- data/lib/pag_seguro/checkout.xml.haml +24 -5
- data/lib/pag_seguro/convert_field_to_digit.rb +15 -0
- data/lib/pag_seguro/day_of_year.rb +35 -0
- data/lib/pag_seguro/item.rb +9 -11
- data/lib/pag_seguro/notification.rb +1 -1
- data/lib/pag_seguro/payment.rb +26 -19
- data/lib/pag_seguro/pre_approval.rb +84 -0
- data/lib/pag_seguro/query.rb +27 -1
- data/lib/pag_seguro/sender.rb +2 -2
- data/lib/pag_seguro/shipping.rb +2 -2
- data/lib/pag_seguro/transaction.rb +1 -1
- data/lib/pag_seguro/version.rb +1 -1
- data/lib/pag_seguro.rb +9 -1
- data/lib/pagseguro_decimal_validator.rb +9 -0
- data/pag_seguro.gemspec +1 -0
- data/spec/factories.rb +137 -0
- data/spec/fixtures/transaction_history.xml +40 -0
- data/spec/pag_seguro/checkout_xml_spec.rb +142 -159
- data/spec/pag_seguro/convert_field_to_digit_spec.rb +68 -0
- data/spec/pag_seguro/day_of_year_spec.rb +49 -0
- data/spec/pag_seguro/integration/checkout_spec.rb +34 -67
- data/spec/pag_seguro/integration/config.yml +4 -4
- data/spec/pag_seguro/integration/query_spec.rb +56 -34
- data/spec/pag_seguro/item_spec.rb +46 -72
- data/spec/pag_seguro/payment_method_spec.rb +58 -63
- data/spec/pag_seguro/payment_spec.rb +150 -123
- data/spec/pag_seguro/pre_approval_spec.rb +112 -0
- data/spec/pag_seguro/query_spec.rb +111 -4
- data/spec/pag_seguro/sender_spec.rb +50 -62
- data/spec/pag_seguro/shipping_spec.rb +36 -51
- data/spec/spec_helper.rb +11 -20
- data/spec/support/transaction_shared_examples.rb +7 -7
- metadata +32 -3
@@ -1,27 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
def create_valid_payment
|
5
|
-
payment = PagSeguro::Payment.new(EMAIL, TOKEN)
|
6
|
-
payment.items = [
|
7
|
-
PagSeguro::Item.new(id: 25, description: "A Bic Pen", amount: "1.50", quantity: "4", shipping_cost: "1.00", weight: 10),
|
8
|
-
PagSeguro::Item.new(id: 73, description: "A Book", amount: "38.23", quantity: "1", shipping_cost: "12.00", weight: 300),
|
9
|
-
PagSeguro::Item.new(id: 95, description: "A Towel", amount: "69.35", quantity: "2", weight: 400),
|
10
|
-
PagSeguro::Item.new(id: 17, description: "A pipe", amount: "3.00", quantity: "89")
|
11
|
-
]
|
12
|
-
payment.sender = PagSeguro::Sender.new(name: "María Isabel Andrade ", email: "stefano@heavenstudio.com.br", phone_ddd: "11", phone_number: "93430994")
|
13
|
-
payment.shipping = PagSeguro::Shipping.new(
|
14
|
-
type: PagSeguro::Shipping::SEDEX,
|
15
|
-
state: "SP",
|
16
|
-
city: "São Paulo",
|
17
|
-
postal_code: "05363000",
|
18
|
-
district: "Jd. PoliPoli",
|
19
|
-
street: "Av. Otacilio Tomanik",
|
20
|
-
number: "775",
|
21
|
-
complement: "apto. 92")
|
22
|
-
payment
|
23
|
-
end
|
24
|
-
|
25
4
|
describe PagSeguro::Payment do
|
26
5
|
before do
|
27
6
|
if EMAIL == "seu_email_cadastrado@nopagseguro.com.br"
|
@@ -31,63 +10,51 @@ describe PagSeguro::Payment do
|
|
31
10
|
end
|
32
11
|
end
|
33
12
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
payment = PagSeguro::Payment.new(EMAIL, TOKEN)
|
42
|
-
payment.items = [PagSeguro::Item.new(id: 17, description: "A pipe", amount: "3.00", quantity: "2")]
|
43
|
-
payment.code.size.should == 32
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should tell me when the email and token are invalid" do
|
47
|
-
payment = PagSeguro::Payment.new("not_a_user@not_an_email.com", "NOTATOKEN7F048A09A8AEFDD1E5A7B91")
|
48
|
-
lambda { payment.code }.should raise_error(PagSeguro::Errors::Unauthorized)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should list errors given by pagseguro" do
|
52
|
-
payment = PagSeguro::Payment.new(EMAIL, TOKEN)
|
53
|
-
lambda { payment.code }.should raise_error(PagSeguro::Errors::InvalidData)
|
54
|
-
end
|
55
|
-
|
13
|
+
context "with all fields" do
|
14
|
+
let(:payment){ build :payment_with_all_fields, email: EMAIL, token: TOKEN }
|
15
|
+
subject { payment }
|
16
|
+
|
17
|
+
its('code.size'){ should == 32 }
|
18
|
+
its(:date){ should be_an_instance_of(DateTime) }
|
19
|
+
|
56
20
|
it "should give a response code of 200 for the user pagseguro url" do
|
57
|
-
payment = create_valid_payment
|
58
21
|
RestClient.get(payment.checkout_payment_url).code.should == 200
|
59
22
|
end
|
60
23
|
end
|
61
24
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
25
|
+
context "with item and minimum pre approval" do
|
26
|
+
let(:payment){ build :payment_with_item, email: EMAIL, token: TOKEN, pre_approval: build(:minimum_pre_approval) }
|
27
|
+
subject { payment }
|
28
|
+
|
29
|
+
its('code.size'){ should == 32 }
|
30
|
+
its(:date){ should be_an_instance_of(DateTime) }
|
31
|
+
|
32
|
+
it "should give a response code of 200 for the user pagseguro url" do
|
33
|
+
RestClient.get(payment.checkout_payment_url).code.should == 200
|
66
34
|
end
|
67
35
|
end
|
68
36
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
@payment.stub(:parse_code)
|
73
|
-
@payment.stub(:parse_date)
|
74
|
-
@payment.stub(:parse_checkout_response){ "some response" }
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should not make a request to pagseguro more than once" do
|
78
|
-
@payment.should_receive(:parse_checkout_response).exactly(1).times
|
37
|
+
context "with items" do
|
38
|
+
let(:payment){ build :payment_with_items, email: EMAIL, token: TOKEN }
|
39
|
+
subject { payment }
|
79
40
|
|
80
|
-
|
81
|
-
|
82
|
-
|
41
|
+
its('code.size'){ should == 32 }
|
42
|
+
its(:date){ should be_an_instance_of(DateTime) }
|
43
|
+
|
44
|
+
it "should give a response code of 200 for the user pagseguro url" do
|
45
|
+
RestClient.get(payment.checkout_payment_url).code.should == 200
|
83
46
|
end
|
84
|
-
|
85
|
-
it "should make more than one request to pag seguro if the payment is reset" do
|
86
|
-
@payment.should_receive(:parse_checkout_response).exactly(2).times
|
47
|
+
end
|
87
48
|
|
88
|
-
|
89
|
-
|
90
|
-
|
49
|
+
context "without items" do
|
50
|
+
it "should raise error when fetching its code" do
|
51
|
+
payment = build :payment, email: EMAIL, token: TOKEN
|
52
|
+
expect { payment.code }.to raise_error(PagSeguro::Errors::InvalidData)
|
91
53
|
end
|
92
54
|
end
|
55
|
+
|
56
|
+
it "should raise unauthorized error if email and token do not match" do
|
57
|
+
payment = build :payment, email: "not_a_user@not_an_email.com", token: "NOTATOKEN7F048A09A8AEFDD1E5A7B91"
|
58
|
+
expect { payment.code }.to raise_error(PagSeguro::Errors::Unauthorized)
|
59
|
+
end
|
93
60
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
email:
|
2
|
-
token:
|
3
|
-
notification_code:
|
4
|
-
transaction_id:
|
1
|
+
email: belbraga@bobags.com.br
|
2
|
+
token: 4B5637E1C27C4304BFAF2C253C73D1FF
|
3
|
+
notification_code: DD9500-8AE8FAE8FAC8-7774B44F9384-4CA5DF
|
4
|
+
transaction_id: 84EFE527-E8FA-4116-8CA7-744530B1B45D
|
@@ -2,43 +2,65 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe PagSeguro::Query do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
describe "#new" do
|
6
|
+
before :all do
|
7
|
+
if EMAIL == "seu_email_cadastrado@nopagseguro.com.br"
|
8
|
+
pending "You need to set your email for your PagSeguro account in spec/pag_seguro/integration/config.yml in order to run this spec"
|
9
|
+
elsif TOKEN == "SEU_TOKEN_GERADO_NO_PAG_SEGURO"
|
10
|
+
pending "You need to set your token for your PagSeguro account in spec/pag_seguro/integration/config.yml in order to run this spec"
|
11
|
+
elsif TRANSACTION_ID == "UM_CODIGO_DE_TRANSACAO"
|
12
|
+
pending "You need to set one transaction id for your PagSeguro account in spec/pag_seguro/integration/config.yml in order to run this spec"
|
13
|
+
else
|
14
|
+
@query = PagSeguro::Query.new(EMAIL, TOKEN, TRANSACTION_ID)
|
15
|
+
end
|
14
16
|
end
|
17
|
+
|
18
|
+
it { @query.transaction_id.should be_present }
|
19
|
+
it { @query.date.should be_present }
|
20
|
+
it { @query.id.should be_present }
|
21
|
+
it { @query.type.should be_present }
|
22
|
+
it { @query.status.should be_present }
|
23
|
+
it { @query.payment_method.type.should be_present }
|
24
|
+
it { @query.payment_method.code.should be_present }
|
25
|
+
it { @query.gross_amount.should be_present }
|
26
|
+
it { @query.discount_amount.should be_present }
|
27
|
+
it { @query.fee_amount.should be_present }
|
28
|
+
it { @query.net_amount.should be_present }
|
29
|
+
it { @query.extra_amount.should be_present }
|
30
|
+
it { @query.installment_count.should be_present }
|
31
|
+
it { @query.item_count.should be_present }
|
32
|
+
it { @query.items.should be_present }
|
33
|
+
|
34
|
+
it "should have all required item attributes" do
|
35
|
+
@query.items.each do |item|
|
36
|
+
item.id.should be_present
|
37
|
+
item.description.should be_present
|
38
|
+
item.amount.should be_present
|
39
|
+
item.quantity.should be_present
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it { @query.sender.email.should be_present }
|
44
|
+
it { @query.shipping.type.should be_present }
|
15
45
|
end
|
16
|
-
|
17
|
-
it { @query.transaction_id.should be_present }
|
18
|
-
it { @query.date.should be_present }
|
19
|
-
it { @query.id.should be_present }
|
20
|
-
it { @query.type.should be_present }
|
21
|
-
it { @query.status.should be_present }
|
22
|
-
it { @query.payment_method.type.should be_present }
|
23
|
-
it { @query.payment_method.code.should be_present }
|
24
|
-
it { @query.gross_amount.should be_present }
|
25
|
-
it { @query.discount_amount.should be_present }
|
26
|
-
it { @query.fee_amount.should be_present }
|
27
|
-
it { @query.net_amount.should be_present }
|
28
|
-
it { @query.extra_amount.should be_present }
|
29
|
-
it { @query.installment_count.should be_present }
|
30
|
-
it { @query.item_count.should be_present }
|
31
|
-
it { @query.items.should be_present }
|
32
46
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
47
|
+
describe "::find" do
|
48
|
+
before :all do
|
49
|
+
if EMAIL == "seu_email_cadastrado@nopagseguro.com.br"
|
50
|
+
pending "You need to set your email for your PagSeguro account in spec/pag_seguro/integration/config.yml in order to run this spec"
|
51
|
+
elsif TOKEN == "SEU_TOKEN_GERADO_NO_PAG_SEGURO"
|
52
|
+
pending "You need to set your token for your PagSeguro account in spec/pag_seguro/integration/config.yml in order to run this spec"
|
53
|
+
else
|
54
|
+
@transactions = PagSeguro::Query.find(EMAIL, TOKEN, initial_date: 10.days.ago, final_date: Date.today)
|
55
|
+
pending "You do not have any active transaction with your account in the past 30 days" unless @transactions.present?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should return an array of Transactions" do
|
60
|
+
@transactions.each do |transaction|
|
61
|
+
transaction.should be_an_instance_of(PagSeguro::Transaction)
|
62
|
+
transaction.id.should be_present
|
63
|
+
end
|
39
64
|
end
|
40
65
|
end
|
41
|
-
|
42
|
-
it { @query.sender.email.should be_present }
|
43
|
-
it { @query.shipping.type.should be_present }
|
44
66
|
end
|
@@ -1,79 +1,53 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
valid_attributes = {
|
4
|
-
id: 1,
|
5
|
-
description: "descrevendo um item",
|
6
|
-
amount: "100.50",
|
7
|
-
quantity: 1,
|
8
|
-
shipping_cost: "10.50",
|
9
|
-
weight: 300
|
10
|
-
}
|
11
|
-
|
12
3
|
describe PagSeguro::Item do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
it "should be valid with valid attributes" do
|
24
|
-
PagSeguro::Item.new(valid_attributes).should be_valid
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should not be valid without an id" do
|
28
|
-
PagSeguro::Item.new(valid_attributes.except(:id)).should_not be_valid
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should not be valid without a description" do
|
32
|
-
PagSeguro::Item.new(valid_attributes.except(:description)).should_not be_valid
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should trim description to 100 characters if it has more than 100 characters" do
|
36
|
-
item = PagSeguro::Item.new(valid_attributes)
|
37
|
-
item.description = "-" * 100
|
38
|
-
item.description.size.should == 100
|
39
|
-
item.should be_valid
|
40
|
-
item.description = "-" * 101
|
41
|
-
item.description.size.should == 100
|
42
|
-
item.should be_valid
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should not be valid without an amount" do
|
46
|
-
PagSeguro::Item.new(valid_attributes.except(:amount)).should_not be_valid
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should not allow invalid amount formats" do
|
50
|
-
PagSeguro::Item.new(valid_attributes.merge(amount: "10")).should_not be_valid
|
51
|
-
PagSeguro::Item.new(valid_attributes.merge(amount: "10,50")).should_not be_valid
|
52
|
-
PagSeguro::Item.new(valid_attributes.merge(amount: "R$ 10.50")).should_not be_valid
|
53
|
-
PagSeguro::Item.new(valid_attributes.merge(amount: "-10.50")).should_not be_valid
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should not be valid without a quantity" do
|
57
|
-
PagSeguro::Item.new(valid_attributes.except(:quantity)).should_not be_valid
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should not allow invalid quantities" do
|
61
|
-
PagSeguro::Item.new(valid_attributes.merge(quantity: "1000")).should_not be_valid
|
62
|
-
PagSeguro::Item.new(valid_attributes.merge(quantity: "0")).should_not be_valid
|
63
|
-
PagSeguro::Item.new(valid_attributes.merge(quantity: "-1")).should_not be_valid
|
64
|
-
end
|
4
|
+
it { should have_attribute_accessor(:id) }
|
5
|
+
it { should have_attribute_accessor(:description) }
|
6
|
+
it { should have_attribute_accessor(:amount) }
|
7
|
+
it { should have_attribute_accessor(:quantity) }
|
8
|
+
it { should have_attribute_accessor(:shipping_cost) }
|
9
|
+
it { should have_attribute_accessor(:weight) }
|
10
|
+
|
11
|
+
it "should be valid with valid attributes" do
|
12
|
+
build(:item).should be_valid
|
13
|
+
end
|
65
14
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
15
|
+
it { should validate_presence_of :id }
|
16
|
+
it { should validate_presence_of :description }
|
17
|
+
it { should validate_presence_of :amount }
|
18
|
+
|
19
|
+
it { should_not allow_value(nil).for(:quantity) }
|
20
|
+
it { should_not allow_value(0).for(:quantity) }
|
21
|
+
it { should_not allow_value(1000).for(:quantity) }
|
22
|
+
it { should allow_value(1).for(:quantity) }
|
23
|
+
it { should allow_value(999).for(:quantity) }
|
24
|
+
|
25
|
+
it { should_not allow_value("10,50").for(:amount) }
|
26
|
+
it { should_not allow_value("R$ 10.50").for(:amount) }
|
27
|
+
it { should_not allow_value("-10.50").for(:amount) }
|
28
|
+
it { should allow_value("10.50").for(:amount) }
|
29
|
+
it { should allow_value(10).for(:amount) }
|
30
|
+
it { should allow_value(BigDecimal.new("10.5")).for(:amount) }
|
31
|
+
|
32
|
+
it { should_not allow_value("10,50").for(:shipping_cost) }
|
33
|
+
it { should_not allow_value("R$ 10.50").for(:shipping_cost) }
|
34
|
+
it { should_not allow_value("-10.50").for(:shipping_cost) }
|
35
|
+
it { should allow_value("10.50").for(:shipping_cost) }
|
36
|
+
it { should allow_value(10).for(:shipping_cost) }
|
37
|
+
it { should allow_value(BigDecimal.new("10.5")).for(:shipping_cost) }
|
38
|
+
it { should allow_value(nil).for(:shipping_cost) }
|
39
|
+
|
40
|
+
it { should_not allow_value("1000").for(:quantity) }
|
41
|
+
it { should_not allow_value("0").for(:quantity) }
|
42
|
+
it { should_not allow_value("-1").for(:quantity) }
|
43
|
+
it { should allow_value("1").for(:quantity) }
|
72
44
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
45
|
+
it { should_not allow_value("-10").for(:weight) }
|
46
|
+
it { should_not allow_value("10.5").for(:weight) }
|
47
|
+
it { should_not allow_value("10,5").for(:weight) }
|
48
|
+
it { should allow_value("3").for(:weight) }
|
49
|
+
|
50
|
+
it "should trim description to 100 characters if it has more than 100 characters" do
|
51
|
+
PagSeguro::Item.new(description: "-" * 101).description.size.should == 100
|
78
52
|
end
|
79
53
|
end
|
@@ -2,75 +2,70 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe PagSeguro::PaymentMethod do
|
5
|
-
|
6
|
-
|
7
|
-
before { @payment_method = PagSeguro::PaymentMethod.new }
|
8
|
-
|
9
|
-
it { @payment_method.should have_attribute_accessor(:code) }
|
10
|
-
it { @payment_method.should have_attribute_accessor(:type) }
|
11
|
-
end
|
5
|
+
it { should have_attribute_accessor(:code) }
|
6
|
+
it { should have_attribute_accessor(:type) }
|
12
7
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
context "initalized with code and type" do
|
9
|
+
subject { build :payment_method, code: "101", type: "1" }
|
10
|
+
|
11
|
+
its(:code){ should == 101 }
|
12
|
+
its(:type){ should == 1 }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "types" do
|
16
|
+
let(:payment_method){ PagSeguro::PaymentMethod.new }
|
17
|
+
|
18
|
+
context "with type 1" do
|
19
|
+
subject { build :payment_method, type: 1 }
|
20
|
+
it { should be_credit_card }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with if type 2" do
|
24
|
+
subject { build :payment_method, type: 2 }
|
25
|
+
it { should be_bank_bill }
|
17
26
|
end
|
18
27
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@payment_method.stub(:type){ 1 }
|
24
|
-
@payment_method.should be_credit_card
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should be bank bill if type is 2" do
|
28
|
-
@payment_method.stub(:type){ 2 }
|
29
|
-
@payment_method.should be_bank_bill
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should be online debit if type is 3" do
|
33
|
-
@payment_method.stub(:type){ 3 }
|
34
|
-
@payment_method.should be_online_debit
|
35
|
-
end
|
28
|
+
context "with if type 3" do
|
29
|
+
subject { build :payment_method, type: 3 }
|
30
|
+
it { should be_online_debit }
|
31
|
+
end
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should be oi paggo if type is 5" do
|
43
|
-
@payment_method.stub(:type){ 5 }
|
44
|
-
@payment_method.should be_oi_paggo
|
45
|
-
end
|
33
|
+
context "with if type 4" do
|
34
|
+
subject { build :payment_method, type: 4 }
|
35
|
+
it { should be_pag_seguro_balance }
|
46
36
|
end
|
47
37
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
it { should_have_meaning_for_code("Cartão de crédito Visa", 101) }
|
54
|
-
it { should_have_meaning_for_code("Cartão de crédito MasterCard", 102) }
|
55
|
-
it { should_have_meaning_for_code("Cartão de crédito American Express", 103) }
|
56
|
-
it { should_have_meaning_for_code("Cartão de crédito Diners", 104) }
|
57
|
-
it { should_have_meaning_for_code("Cartão de crédito Hipercard", 105) }
|
58
|
-
it { should_have_meaning_for_code("Cartão de crédito Aura", 106) }
|
59
|
-
it { should_have_meaning_for_code("Cartão de crédito Elo", 107) }
|
60
|
-
it { should_have_meaning_for_code("Cartão de crédito PLENOCard", 108) }
|
61
|
-
it { should_have_meaning_for_code("Cartão de crédito PersonalCard", 109) }
|
62
|
-
it { should_have_meaning_for_code("Boleto Bradesco", 201) }
|
63
|
-
it { should_have_meaning_for_code("Boleto Santander", 202) }
|
64
|
-
it { should_have_meaning_for_code("Débito online Bradesco", 301) }
|
65
|
-
it { should_have_meaning_for_code("Débito online Itaú", 302) }
|
66
|
-
it { should_have_meaning_for_code("Débito online Unibanco", 303) }
|
67
|
-
it { should_have_meaning_for_code("Débito online Banco do Brasil", 304) }
|
68
|
-
it { should_have_meaning_for_code("Débito online Banco Real", 305) }
|
69
|
-
it { should_have_meaning_for_code("Débito online Banrisul", 306) }
|
70
|
-
it { should_have_meaning_for_code("Débito online HSBC", 307) }
|
71
|
-
it { should_have_meaning_for_code("Saldo PagSeguro", 401) }
|
72
|
-
it { should_have_meaning_for_code("Oi Paggo", 501) }
|
73
|
-
it { should_have_meaning_for_code("Desconhecido", 0) }
|
38
|
+
context "with type 5" do
|
39
|
+
subject { build :payment_method, type: 5 }
|
40
|
+
it { should be_oi_paggo }
|
74
41
|
end
|
75
42
|
end
|
43
|
+
|
44
|
+
describe "codes" do
|
45
|
+
def should_have_meaning_for_code(meaning, code)
|
46
|
+
PagSeguro::PaymentMethod.new(code: code).name.should be == meaning
|
47
|
+
end
|
48
|
+
|
49
|
+
it { should_have_meaning_for_code("Cartão de crédito Visa", 101) }
|
50
|
+
it { should_have_meaning_for_code("Cartão de crédito MasterCard", 102) }
|
51
|
+
it { should_have_meaning_for_code("Cartão de crédito American Express", 103) }
|
52
|
+
it { should_have_meaning_for_code("Cartão de crédito Diners", 104) }
|
53
|
+
it { should_have_meaning_for_code("Cartão de crédito Hipercard", 105) }
|
54
|
+
it { should_have_meaning_for_code("Cartão de crédito Aura", 106) }
|
55
|
+
it { should_have_meaning_for_code("Cartão de crédito Elo", 107) }
|
56
|
+
it { should_have_meaning_for_code("Cartão de crédito PLENOCard", 108) }
|
57
|
+
it { should_have_meaning_for_code("Cartão de crédito PersonalCard", 109) }
|
58
|
+
it { should_have_meaning_for_code("Boleto Bradesco", 201) }
|
59
|
+
it { should_have_meaning_for_code("Boleto Santander", 202) }
|
60
|
+
it { should_have_meaning_for_code("Débito online Bradesco", 301) }
|
61
|
+
it { should_have_meaning_for_code("Débito online Itaú", 302) }
|
62
|
+
it { should_have_meaning_for_code("Débito online Unibanco", 303) }
|
63
|
+
it { should_have_meaning_for_code("Débito online Banco do Brasil", 304) }
|
64
|
+
it { should_have_meaning_for_code("Débito online Banco Real", 305) }
|
65
|
+
it { should_have_meaning_for_code("Débito online Banrisul", 306) }
|
66
|
+
it { should_have_meaning_for_code("Débito online HSBC", 307) }
|
67
|
+
it { should_have_meaning_for_code("Saldo PagSeguro", 401) }
|
68
|
+
it { should_have_meaning_for_code("Oi Paggo", 501) }
|
69
|
+
it { should_have_meaning_for_code("Desconhecido", 0) }
|
70
|
+
end
|
76
71
|
end
|