braintree 2.104.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/braintree.gemspec +6 -3
- data/lib/braintree.rb +3 -17
- data/lib/braintree/address.rb +0 -22
- data/lib/braintree/base_module.rb +6 -0
- data/lib/braintree/bin_data.rb +9 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card.rb +0 -75
- data/lib/braintree/credit_card_gateway.rb +3 -32
- data/lib/braintree/credit_card_verification.rb +13 -0
- data/lib/braintree/customer.rb +3 -74
- data/lib/braintree/customer_gateway.rb +0 -23
- data/lib/braintree/dispute.rb +1 -7
- data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
- data/lib/braintree/dispute_gateway.rb +2 -7
- data/lib/braintree/error_codes.rb +139 -170
- data/lib/braintree/exceptions.rb +5 -3
- data/lib/braintree/gateway.rb +0 -14
- data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +1 -2
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +2 -0
- data/lib/braintree/payment_instrument_type.rb +1 -5
- data/lib/braintree/payment_method_gateway.rb +4 -9
- data/lib/braintree/payment_method_parser.rb +1 -8
- data/lib/braintree/subscription.rb +5 -5
- data/lib/braintree/successful_result.rb +0 -1
- data/lib/braintree/test/nonce.rb +4 -23
- data/lib/braintree/transaction.rb +4 -80
- data/lib/braintree/transaction/disbursement_details.rb +1 -0
- data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
- data/lib/braintree/transaction/paypal_details.rb +1 -0
- data/lib/braintree/transaction/subscription_details.rb +2 -0
- data/lib/braintree/transaction_gateway.rb +12 -21
- data/lib/braintree/transaction_search.rb +0 -1
- data/lib/braintree/util.rb +17 -2
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/webhook_notification.rb +0 -10
- data/lib/braintree/webhook_testing_gateway.rb +0 -43
- data/lib/braintree/xml/libxml.rb +1 -0
- data/lib/braintree/xml/parser.rb +11 -34
- data/spec/integration/braintree/address_spec.rb +2 -89
- data/spec/integration/braintree/client_api/spec_helper.rb +0 -26
- data/spec/integration/braintree/credit_card_spec.rb +6 -471
- data/spec/integration/braintree/customer_spec.rb +22 -362
- data/spec/integration/braintree/dispute_search_spec.rb +3 -3
- data/spec/integration/braintree/dispute_spec.rb +1 -2
- data/spec/integration/braintree/payment_method_spec.rb +77 -120
- data/spec/integration/braintree/subscription_spec.rb +11 -16
- data/spec/integration/braintree/transaction_search_spec.rb +3 -3
- data/spec/integration/braintree/transaction_spec.rb +106 -511
- data/spec/integration/spec_helper.rb +1 -4
- data/spec/spec_helper.rb +1 -11
- data/spec/unit/braintree/address_spec.rb +0 -8
- data/spec/unit/braintree/credit_card_spec.rb +1 -20
- data/spec/unit/braintree/customer_spec.rb +0 -12
- data/spec/unit/braintree/dispute_spec.rb +1 -12
- data/spec/unit/braintree/http_spec.rb +3 -3
- data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +2 -0
- data/spec/unit/braintree/transaction_spec.rb +1 -35
- data/spec/unit/braintree/util_spec.rb +37 -3
- data/spec/unit/braintree/webhook_notification_spec.rb +1 -1
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- metadata +26 -30
- data/lib/braintree/amex_express_checkout_card.rb +0 -40
- data/lib/braintree/coinbase_account.rb +0 -34
- data/lib/braintree/europe_bank_account.rb +0 -36
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -61
- data/lib/braintree/ideal_payment_gateway.rb +0 -19
- data/lib/braintree/masterpass_card.rb +0 -83
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
- data/lib/braintree/transaction/coinbase_details.rb +0 -16
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
- data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/lib/braintree/xml/rexml.rb +0 -71
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/integration/braintree/coinbase_spec.rb +0 -34
- data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
- data/spec/unit/braintree/xml/rexml_spec.rb +0 -51
@@ -82,7 +82,7 @@ describe Braintree::Dispute, "search" do
|
|
82
82
|
effective_date = transaction.disputes.first.status_history.first.effective_date
|
83
83
|
|
84
84
|
collection = Braintree::Dispute.search do |search|
|
85
|
-
search.effective_date.between(effective_date,
|
85
|
+
search.effective_date.between(effective_date, effective_date.next_day)
|
86
86
|
end
|
87
87
|
|
88
88
|
expect(collection.disputes.count).to be >= 1
|
@@ -95,7 +95,7 @@ describe Braintree::Dispute, "search" do
|
|
95
95
|
disbursement_date = transaction.disputes.first.status_history.first.disbursement_date
|
96
96
|
|
97
97
|
collection = Braintree::Dispute.search do |search|
|
98
|
-
search.disbursement_date.between(disbursement_date,
|
98
|
+
search.disbursement_date.between(disbursement_date, disbursement_date.next_day)
|
99
99
|
end
|
100
100
|
|
101
101
|
expect(collection.disputes.count).to be >= 1
|
@@ -109,7 +109,7 @@ describe Braintree::Dispute, "search" do
|
|
109
109
|
search.received_date.between("03/03/2014", "03/05/2014")
|
110
110
|
end
|
111
111
|
|
112
|
-
expect(collection.disputes.count).to
|
112
|
+
expect(collection.disputes.count).to be >= 1
|
113
113
|
dispute = collection.disputes.first
|
114
114
|
|
115
115
|
expect(dispute.received_date).to eq(Date.new(2014, 3, 4))
|
@@ -141,7 +141,7 @@ describe Braintree::Dispute do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
it "creates text evidence for the dispute with optional parameters" do
|
144
|
-
result = Braintree::Dispute.add_text_evidence(dispute.id, { content: "123456789",
|
144
|
+
result = Braintree::Dispute.add_text_evidence(dispute.id, { content: "123456789", category: "REFUND_ID", sequence_number: 7 })
|
145
145
|
|
146
146
|
result.success?.should == true
|
147
147
|
result.evidence.category.should == "REFUND_ID"
|
@@ -149,7 +149,6 @@ describe Braintree::Dispute do
|
|
149
149
|
result.evidence.created_at.between?(Time.now - 10, Time.now).should == true
|
150
150
|
result.evidence.id.should =~ /^\w{16,}$/
|
151
151
|
result.evidence.sent_to_processor_at.should == nil
|
152
|
-
result.evidence.tag.should == "REFUND_ID"
|
153
152
|
result.evidence.sequence_number.should == 7
|
154
153
|
end
|
155
154
|
end
|
@@ -101,87 +101,60 @@ describe Braintree::PaymentMethod do
|
|
101
101
|
apple_pay_card.customer_id.should == customer.id
|
102
102
|
end
|
103
103
|
|
104
|
-
it "creates a payment method from a fake
|
104
|
+
it "creates a payment method from a fake google pay proxy card nonce" do
|
105
105
|
customer = Braintree::Customer.create.customer
|
106
106
|
token = SecureRandom.hex(16)
|
107
107
|
result = Braintree::PaymentMethod.create(
|
108
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
108
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
109
109
|
:customer_id => customer.id,
|
110
110
|
:token => token
|
111
111
|
)
|
112
112
|
|
113
113
|
result.should be_success
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
114
|
+
google_pay_card = result.payment_method
|
115
|
+
google_pay_card.should be_a(Braintree::GooglePayCard)
|
116
|
+
google_pay_card.should_not be_nil
|
117
|
+
google_pay_card.token.should == token
|
118
|
+
google_pay_card.card_type.should == Braintree::CreditCard::CardType::Discover
|
119
|
+
google_pay_card.virtual_card_type.should == Braintree::CreditCard::CardType::Discover
|
120
|
+
google_pay_card.expiration_month.to_i.should > 0
|
121
|
+
google_pay_card.expiration_year.to_i.should > 0
|
122
|
+
google_pay_card.default.should == true
|
123
|
+
google_pay_card.image_url.should =~ /android_pay/
|
124
|
+
google_pay_card.is_network_tokenized?.should == false
|
125
|
+
google_pay_card.source_card_type.should == Braintree::CreditCard::CardType::Discover
|
126
|
+
google_pay_card.source_card_last_4.should == "1111"
|
127
|
+
google_pay_card.google_transaction_id.should == "google_transaction_id"
|
128
|
+
google_pay_card.source_description.should == "Discover 1111"
|
129
|
+
google_pay_card.customer_id.should == customer.id
|
130
130
|
end
|
131
131
|
|
132
|
-
it "creates a payment method from a
|
132
|
+
it "creates a payment method from a google pay network token nonce" do
|
133
133
|
customer = Braintree::Customer.create.customer
|
134
134
|
token = SecureRandom.hex(16)
|
135
135
|
result = Braintree::PaymentMethod.create(
|
136
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
136
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
|
137
137
|
:customer_id => customer.id,
|
138
138
|
:token => token
|
139
139
|
)
|
140
140
|
|
141
141
|
result.should be_success
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
end
|
159
|
-
|
160
|
-
it "creates a payment method from an amex express checkout card nonce" do
|
161
|
-
customer = Braintree::Customer.create.customer
|
162
|
-
token = SecureRandom.hex(16)
|
163
|
-
result = Braintree::PaymentMethod.create(
|
164
|
-
:payment_method_nonce => Braintree::Test::Nonce::AmexExpressCheckout,
|
165
|
-
:customer_id => customer.id,
|
166
|
-
:token => token
|
167
|
-
)
|
168
|
-
|
169
|
-
result.should be_success
|
170
|
-
amex_express_checkout_card = result.payment_method
|
171
|
-
amex_express_checkout_card.should be_a(Braintree::AmexExpressCheckoutCard)
|
172
|
-
amex_express_checkout_card.should_not be_nil
|
173
|
-
|
174
|
-
amex_express_checkout_card.default.should == true
|
175
|
-
amex_express_checkout_card.card_type.should == "American Express"
|
176
|
-
amex_express_checkout_card.token.should == token
|
177
|
-
amex_express_checkout_card.bin.should =~ /\A\d{6}\z/
|
178
|
-
amex_express_checkout_card.expiration_month.should =~ /\A\d{2}\z/
|
179
|
-
amex_express_checkout_card.expiration_year.should =~ /\A\d{4}\z/
|
180
|
-
amex_express_checkout_card.card_member_number.should =~ /\A\d{4}\z/
|
181
|
-
amex_express_checkout_card.card_member_expiry_date.should =~ /\A\d{2}\/\d{2}\z/
|
182
|
-
amex_express_checkout_card.image_url.should include(".png")
|
183
|
-
amex_express_checkout_card.source_description.should =~ /\AAmEx \d{4}\z/
|
184
|
-
amex_express_checkout_card.customer_id.should == customer.id
|
142
|
+
google_pay_card = result.payment_method
|
143
|
+
google_pay_card.should be_a(Braintree::GooglePayCard)
|
144
|
+
google_pay_card.should_not be_nil
|
145
|
+
google_pay_card.token.should == token
|
146
|
+
google_pay_card.card_type.should == Braintree::CreditCard::CardType::MasterCard
|
147
|
+
google_pay_card.virtual_card_type.should == Braintree::CreditCard::CardType::MasterCard
|
148
|
+
google_pay_card.expiration_month.to_i.should > 0
|
149
|
+
google_pay_card.expiration_year.to_i.should > 0
|
150
|
+
google_pay_card.default.should == true
|
151
|
+
google_pay_card.image_url.should =~ /android_pay/
|
152
|
+
google_pay_card.is_network_tokenized?.should == true
|
153
|
+
google_pay_card.source_card_type.should == Braintree::CreditCard::CardType::MasterCard
|
154
|
+
google_pay_card.source_card_last_4.should == "4444"
|
155
|
+
google_pay_card.google_transaction_id.should == "google_transaction_id"
|
156
|
+
google_pay_card.source_description.should == "MasterCard 4444"
|
157
|
+
google_pay_card.customer_id.should == customer.id
|
185
158
|
end
|
186
159
|
|
187
160
|
it "creates a payment method from venmo account nonce" do
|
@@ -1024,61 +997,61 @@ describe Braintree::PaymentMethod do
|
|
1024
997
|
end
|
1025
998
|
end
|
1026
999
|
|
1027
|
-
context "
|
1000
|
+
context "google pay cards" do
|
1028
1001
|
it "finds the proxy card payment method with the given token" do
|
1029
1002
|
customer = Braintree::Customer.create!
|
1030
1003
|
payment_method_token = make_token
|
1031
1004
|
result = Braintree::PaymentMethod.create(
|
1032
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1005
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1033
1006
|
:customer_id => customer.id,
|
1034
1007
|
:token => payment_method_token
|
1035
1008
|
)
|
1036
1009
|
result.should be_success
|
1037
1010
|
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1011
|
+
google_pay_card = Braintree::PaymentMethod.find(payment_method_token)
|
1012
|
+
google_pay_card.should be_a(Braintree::GooglePayCard)
|
1013
|
+
google_pay_card.should_not be_nil
|
1014
|
+
google_pay_card.token.should == payment_method_token
|
1015
|
+
google_pay_card.card_type.should == Braintree::CreditCard::CardType::Discover
|
1016
|
+
google_pay_card.virtual_card_type.should == Braintree::CreditCard::CardType::Discover
|
1017
|
+
google_pay_card.expiration_month.to_i.should > 0
|
1018
|
+
google_pay_card.expiration_year.to_i.should > 0
|
1019
|
+
google_pay_card.default.should == true
|
1020
|
+
google_pay_card.image_url.should =~ /android_pay/
|
1021
|
+
google_pay_card.is_network_tokenized?.should == false
|
1022
|
+
google_pay_card.source_card_type.should == Braintree::CreditCard::CardType::Discover
|
1023
|
+
google_pay_card.source_card_last_4.should == "1111"
|
1024
|
+
google_pay_card.google_transaction_id.should == "google_transaction_id"
|
1025
|
+
google_pay_card.source_description.should == "Discover 1111"
|
1026
|
+
google_pay_card.customer_id.should == customer.id
|
1054
1027
|
end
|
1055
1028
|
|
1056
1029
|
it "finds the network token payment method with the given token" do
|
1057
1030
|
customer = Braintree::Customer.create!
|
1058
1031
|
payment_method_token = make_token
|
1059
1032
|
result = Braintree::PaymentMethod.create(
|
1060
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1033
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
|
1061
1034
|
:customer_id => customer.id,
|
1062
1035
|
:token => payment_method_token
|
1063
1036
|
)
|
1064
1037
|
result.should be_success
|
1065
1038
|
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1039
|
+
google_pay_card = Braintree::PaymentMethod.find(payment_method_token)
|
1040
|
+
google_pay_card.should be_a(Braintree::GooglePayCard)
|
1041
|
+
google_pay_card.should_not be_nil
|
1042
|
+
google_pay_card.token.should == payment_method_token
|
1043
|
+
google_pay_card.card_type.should == Braintree::CreditCard::CardType::MasterCard
|
1044
|
+
google_pay_card.virtual_card_type.should == Braintree::CreditCard::CardType::MasterCard
|
1045
|
+
google_pay_card.expiration_month.to_i.should > 0
|
1046
|
+
google_pay_card.expiration_year.to_i.should > 0
|
1047
|
+
google_pay_card.default.should == true
|
1048
|
+
google_pay_card.image_url.should =~ /android_pay/
|
1049
|
+
google_pay_card.is_network_tokenized?.should == true
|
1050
|
+
google_pay_card.source_card_type.should == Braintree::CreditCard::CardType::MasterCard
|
1051
|
+
google_pay_card.source_card_last_4.should == "4444"
|
1052
|
+
google_pay_card.google_transaction_id.should == "google_transaction_id"
|
1053
|
+
google_pay_card.source_description.should == "MasterCard 4444"
|
1054
|
+
google_pay_card.customer_id.should == customer.id
|
1082
1055
|
end
|
1083
1056
|
end
|
1084
1057
|
|
@@ -1110,18 +1083,18 @@ describe Braintree::PaymentMethod do
|
|
1110
1083
|
end
|
1111
1084
|
|
1112
1085
|
describe "self.delete" do
|
1113
|
-
it "deletes an
|
1086
|
+
it "deletes an google pay card" do
|
1114
1087
|
customer = Braintree::Customer.create!
|
1115
1088
|
|
1116
1089
|
create_result = Braintree::PaymentMethod.create(
|
1117
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1090
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1118
1091
|
:customer_id => customer.id
|
1119
1092
|
)
|
1120
1093
|
|
1121
1094
|
token = create_result.payment_method.token
|
1122
1095
|
|
1123
|
-
|
1124
|
-
|
1096
|
+
google_card = Braintree::PaymentMethod.find(token)
|
1097
|
+
google_card.should be_a(Braintree::GooglePayCard)
|
1125
1098
|
|
1126
1099
|
delete_result = Braintree::PaymentMethod.delete(token)
|
1127
1100
|
delete_result.success?.should == true
|
@@ -1522,22 +1495,6 @@ describe Braintree::PaymentMethod do
|
|
1522
1495
|
end
|
1523
1496
|
end
|
1524
1497
|
|
1525
|
-
context "coinbase accounts" do
|
1526
|
-
it "cannot create a payment method token with Coinbase" do
|
1527
|
-
customer = Braintree::Customer.create!
|
1528
|
-
|
1529
|
-
nonce = Braintree::Test::Nonce::Coinbase
|
1530
|
-
result = Braintree::PaymentMethod.create(
|
1531
|
-
:payment_method_nonce => nonce,
|
1532
|
-
:customer_id => customer.id
|
1533
|
-
)
|
1534
|
-
|
1535
|
-
result.should_not be_success
|
1536
|
-
|
1537
|
-
result.errors.for(:coinbase_account).first.code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNoLongerSupported
|
1538
|
-
end
|
1539
|
-
end
|
1540
|
-
|
1541
1498
|
context "paypal accounts" do
|
1542
1499
|
it "updates a paypal account's token" do
|
1543
1500
|
customer = Braintree::Customer.create!
|
@@ -1739,7 +1696,7 @@ describe Braintree::PaymentMethod do
|
|
1739
1696
|
it "raises an error if the token isn't found" do
|
1740
1697
|
expect do
|
1741
1698
|
@granting_gateway.payment_method.grant("not_a_real_token", false)
|
1742
|
-
end.to raise_error
|
1699
|
+
end.to raise_error(Braintree::NotFoundError)
|
1743
1700
|
end
|
1744
1701
|
|
1745
1702
|
it "returns a valid nonce with no options set" do
|
@@ -1754,7 +1711,7 @@ describe Braintree::PaymentMethod do
|
|
1754
1711
|
it "raises an error if the token isn't found" do
|
1755
1712
|
expect do
|
1756
1713
|
@granting_gateway.payment_method.revoke("not_a_real_token")
|
1757
|
-
end.to raise_error
|
1714
|
+
end.to raise_error(Braintree::NotFoundError)
|
1758
1715
|
end
|
1759
1716
|
|
1760
1717
|
it "renders a granted nonce useless" do
|
@@ -19,23 +19,21 @@ describe Braintree::Subscription do
|
|
19
19
|
:plan_id => SpecHelper::TriallessPlan[:id]
|
20
20
|
)
|
21
21
|
|
22
|
-
date_format = /^\d{4}\D\d{1,2}\D\d{1,2}$/
|
23
22
|
result.success?.should == true
|
24
23
|
result.subscription.id.should =~ /^\w{6}$/
|
25
24
|
result.subscription.status.should == Braintree::Subscription::Status::Active
|
26
25
|
result.subscription.plan_id.should == "integration_trialless_plan"
|
27
26
|
|
28
|
-
result.subscription.first_billing_date.
|
29
|
-
result.subscription.next_billing_date.
|
30
|
-
result.subscription.billing_period_start_date.
|
31
|
-
result.subscription.billing_period_end_date.
|
32
|
-
result.subscription.paid_through_date.
|
27
|
+
expect(result.subscription.first_billing_date).to be_a Date
|
28
|
+
expect(result.subscription.next_billing_date).to be_a Date
|
29
|
+
expect(result.subscription.billing_period_start_date).to be_a Date
|
30
|
+
expect(result.subscription.billing_period_end_date).to be_a Date
|
31
|
+
expect(result.subscription.paid_through_date).to be_a Date
|
33
32
|
|
34
33
|
result.subscription.created_at.between?(Time.now - 60, Time.now).should == true
|
35
34
|
result.subscription.updated_at.between?(Time.now - 60, Time.now).should == true
|
36
35
|
|
37
36
|
result.subscription.failure_count.should == 0
|
38
|
-
result.subscription.next_bill_amount.should == "12.34"
|
39
37
|
result.subscription.next_billing_period_amount.should == "12.34"
|
40
38
|
result.subscription.payment_method_token.should == @credit_card.token
|
41
39
|
|
@@ -68,7 +66,6 @@ describe Braintree::Subscription do
|
|
68
66
|
:id => new_id
|
69
67
|
)
|
70
68
|
|
71
|
-
date_format = /^\d{4}\D\d{1,2}\D\d{1,2}$/
|
72
69
|
result.success?.should == true
|
73
70
|
result.subscription.id.should == new_id
|
74
71
|
end
|
@@ -195,7 +192,7 @@ describe Braintree::Subscription do
|
|
195
192
|
)
|
196
193
|
|
197
194
|
result.success?.should == true
|
198
|
-
result.subscription.first_billing_date.should ==
|
195
|
+
result.subscription.first_billing_date.should == Date.today + 3
|
199
196
|
result.subscription.status.should == Braintree::Subscription::Status::Pending
|
200
197
|
end
|
201
198
|
|
@@ -678,20 +675,18 @@ describe Braintree::Subscription do
|
|
678
675
|
:plan_id => SpecHelper::TriallessPlan[:id]
|
679
676
|
)
|
680
677
|
|
681
|
-
date_format = /^\d{4}\D\d{1,2}\D\d{1,2}$/
|
682
678
|
subscription.id.should =~ /^\w{6}$/
|
683
679
|
subscription.status.should == Braintree::Subscription::Status::Active
|
684
680
|
subscription.plan_id.should == "integration_trialless_plan"
|
685
681
|
|
686
|
-
subscription.first_billing_date.
|
687
|
-
subscription.next_billing_date.
|
688
|
-
subscription.billing_period_start_date.
|
689
|
-
subscription.billing_period_end_date.
|
690
|
-
subscription.paid_through_date.
|
682
|
+
expect(subscription.first_billing_date).to be_a Date
|
683
|
+
expect(subscription.next_billing_date).to be_a Date
|
684
|
+
expect(subscription.billing_period_start_date).to be_a Date
|
685
|
+
expect(subscription.billing_period_end_date).to be_a Date
|
686
|
+
expect(subscription.paid_through_date).to be_a Date
|
691
687
|
|
692
688
|
subscription.failure_count.should == 0
|
693
689
|
subscription.current_billing_cycle.should == 1
|
694
|
-
subscription.next_bill_amount.should == "12.34"
|
695
690
|
subscription.next_billing_period_amount.should == "12.34"
|
696
691
|
subscription.payment_method_token.should == @credit_card.token
|
697
692
|
end
|
@@ -468,7 +468,7 @@ describe Braintree::Transaction, "search" do
|
|
468
468
|
)
|
469
469
|
SpecHelper.settle_transaction transaction.id
|
470
470
|
|
471
|
-
refund_transaction =
|
471
|
+
refund_transaction = Braintree::Transaction.refund(transaction.id).transaction
|
472
472
|
|
473
473
|
collection = Braintree::Transaction.search do |search|
|
474
474
|
search.credit_card_cardholder_name.is cardholder_name
|
@@ -1316,12 +1316,12 @@ describe Braintree::Transaction, "search" do
|
|
1316
1316
|
end
|
1317
1317
|
|
1318
1318
|
context "when the search times out" do
|
1319
|
-
it "raises a
|
1319
|
+
it "raises a UnexpectedError" do
|
1320
1320
|
expect {
|
1321
1321
|
collection = Braintree::Transaction.search do |search|
|
1322
1322
|
search.amount.is -10
|
1323
1323
|
end
|
1324
|
-
}.to raise_error(Braintree::
|
1324
|
+
}.to raise_error(Braintree::UnexpectedError)
|
1325
1325
|
end
|
1326
1326
|
end
|
1327
1327
|
end
|
@@ -445,6 +445,7 @@ describe Braintree::Transaction do
|
|
445
445
|
result.transaction.credit_card_details.expiration_date.should == "05/2009"
|
446
446
|
result.transaction.credit_card_details.customer_location.should == "US"
|
447
447
|
result.transaction.retrieval_reference_number.should_not be_nil
|
448
|
+
result.transaction.acquirer_reference_number.should be_nil
|
448
449
|
end
|
449
450
|
|
450
451
|
it "returns a successful network response code if successful" do
|
@@ -509,7 +510,7 @@ describe Braintree::Transaction do
|
|
509
510
|
result.transaction.credit_card_details.customer_location.should == "US"
|
510
511
|
end
|
511
512
|
|
512
|
-
it "accepts additional security parameters:
|
513
|
+
it "accepts additional security parameters: device_data" do
|
513
514
|
result = Braintree::Transaction.create(
|
514
515
|
:type => "sale",
|
515
516
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -517,8 +518,7 @@ describe Braintree::Transaction do
|
|
517
518
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
518
519
|
:expiration_date => "05/2009"
|
519
520
|
},
|
520
|
-
:
|
521
|
-
:fraud_merchant_id => "7"
|
521
|
+
:device_data => "device_data",
|
522
522
|
)
|
523
523
|
|
524
524
|
result.success?.should == true
|
@@ -1372,22 +1372,6 @@ describe Braintree::Transaction do
|
|
1372
1372
|
end
|
1373
1373
|
end
|
1374
1374
|
|
1375
|
-
context "recurring" do
|
1376
|
-
it "marks a transaction as recurring" do
|
1377
|
-
result = Braintree::Transaction.create(
|
1378
|
-
:type => "sale",
|
1379
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1380
|
-
:credit_card => {
|
1381
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1382
|
-
:expiration_date => "12/12",
|
1383
|
-
},
|
1384
|
-
:recurring => true
|
1385
|
-
)
|
1386
|
-
result.success?.should == true
|
1387
|
-
result.transaction.recurring.should == true
|
1388
|
-
end
|
1389
|
-
end
|
1390
|
-
|
1391
1375
|
context "transaction_source" do
|
1392
1376
|
it "marks a transactions as recurring_first" do
|
1393
1377
|
result = Braintree::Transaction.create(
|
@@ -1804,106 +1788,83 @@ describe Braintree::Transaction do
|
|
1804
1788
|
apple_pay_details.token.should_not be_nil
|
1805
1789
|
end
|
1806
1790
|
|
1807
|
-
it "can create a transaction with a fake
|
1791
|
+
it "can create a transaction with a fake google pay proxy card nonce" do
|
1808
1792
|
customer = Braintree::Customer.create!
|
1809
1793
|
result = Braintree::Transaction.create(
|
1810
1794
|
:type => "sale",
|
1811
1795
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1812
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1796
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover
|
1813
1797
|
)
|
1814
1798
|
result.success?.should == true
|
1815
1799
|
result.transaction.should_not be_nil
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
end
|
1838
|
-
|
1839
|
-
it "can create a vaulted transaction with a fake
|
1800
|
+
google_pay_details = result.transaction.google_pay_details
|
1801
|
+
google_pay_details.should_not be_nil
|
1802
|
+
google_pay_details.bin.should_not be_nil
|
1803
|
+
google_pay_details.card_type.should == Braintree::CreditCard::CardType::Discover
|
1804
|
+
google_pay_details.virtual_card_type.should == Braintree::CreditCard::CardType::Discover
|
1805
|
+
google_pay_details.last_4.should == "1117"
|
1806
|
+
google_pay_details.virtual_card_last_4.should == "1117"
|
1807
|
+
google_pay_details.source_description.should == "Discover 1111"
|
1808
|
+
google_pay_details.expiration_month.to_i.should > 0
|
1809
|
+
google_pay_details.expiration_year.to_i.should > 0
|
1810
|
+
google_pay_details.google_transaction_id.should == "google_transaction_id"
|
1811
|
+
google_pay_details.image_url.should_not be_nil
|
1812
|
+
google_pay_details.is_network_tokenized?.should == false
|
1813
|
+
google_pay_details.token.should be_nil
|
1814
|
+
google_pay_details.prepaid.should_not be_nil
|
1815
|
+
google_pay_details.healthcare.should_not be_nil
|
1816
|
+
google_pay_details.debit.should_not be_nil
|
1817
|
+
google_pay_details.durbin_regulated.should_not be_nil
|
1818
|
+
google_pay_details.commercial.should_not be_nil
|
1819
|
+
google_pay_details.payroll.should_not be_nil
|
1820
|
+
google_pay_details.product_id.should_not be_nil
|
1821
|
+
end
|
1822
|
+
|
1823
|
+
it "can create a vaulted transaction with a fake google pay proxy card nonce" do
|
1840
1824
|
customer = Braintree::Customer.create!
|
1841
1825
|
result = Braintree::Transaction.create(
|
1842
1826
|
:type => "sale",
|
1843
1827
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1844
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1828
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1845
1829
|
:options => { :store_in_vault_on_success => true }
|
1846
1830
|
)
|
1847
1831
|
result.success?.should == true
|
1848
1832
|
result.transaction.should_not be_nil
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
end
|
1863
|
-
|
1864
|
-
it "can create a transaction with a fake
|
1833
|
+
google_pay_details = result.transaction.google_pay_details
|
1834
|
+
google_pay_details.should_not be_nil
|
1835
|
+
google_pay_details.card_type.should == Braintree::CreditCard::CardType::Discover
|
1836
|
+
google_pay_details.virtual_card_type.should == Braintree::CreditCard::CardType::Discover
|
1837
|
+
google_pay_details.last_4.should == "1117"
|
1838
|
+
google_pay_details.virtual_card_last_4.should == "1117"
|
1839
|
+
google_pay_details.source_description.should == "Discover 1111"
|
1840
|
+
google_pay_details.expiration_month.to_i.should > 0
|
1841
|
+
google_pay_details.expiration_year.to_i.should > 0
|
1842
|
+
google_pay_details.google_transaction_id.should == "google_transaction_id"
|
1843
|
+
google_pay_details.image_url.should_not be_nil
|
1844
|
+
google_pay_details.is_network_tokenized?.should == false
|
1845
|
+
google_pay_details.token.should_not be_nil
|
1846
|
+
end
|
1847
|
+
|
1848
|
+
it "can create a transaction with a fake google pay network token nonce" do
|
1865
1849
|
customer = Braintree::Customer.create!
|
1866
1850
|
result = Braintree::Transaction.create(
|
1867
1851
|
:type => "sale",
|
1868
1852
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1869
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1870
|
-
)
|
1871
|
-
result.success?.should == true
|
1872
|
-
result.transaction.should_not be_nil
|
1873
|
-
android_pay_details = result.transaction.android_pay_details
|
1874
|
-
android_pay_details.should_not be_nil
|
1875
|
-
android_pay_details.card_type.should == Braintree::CreditCard::CardType::MasterCard
|
1876
|
-
android_pay_details.virtual_card_type.should == Braintree::CreditCard::CardType::MasterCard
|
1877
|
-
android_pay_details.last_4.should == "4444"
|
1878
|
-
android_pay_details.virtual_card_last_4.should == "4444"
|
1879
|
-
android_pay_details.source_description.should == "MasterCard 4444"
|
1880
|
-
android_pay_details.expiration_month.to_i.should > 0
|
1881
|
-
android_pay_details.expiration_year.to_i.should > 0
|
1882
|
-
android_pay_details.google_transaction_id.should == "google_transaction_id"
|
1883
|
-
android_pay_details.is_network_tokenized?.should == true
|
1884
|
-
end
|
1885
|
-
|
1886
|
-
it "can create a transaction with a fake amex express checkout card nonce" do
|
1887
|
-
result = Braintree::Transaction.create(
|
1888
|
-
:type => "sale",
|
1889
|
-
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
1890
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1891
|
-
:payment_method_nonce => Braintree::Test::Nonce::AmexExpressCheckout,
|
1892
|
-
:options => {:store_in_vault => true}
|
1853
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard
|
1893
1854
|
)
|
1894
1855
|
result.success?.should == true
|
1895
1856
|
result.transaction.should_not be_nil
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1857
|
+
google_pay_details = result.transaction.google_pay_details
|
1858
|
+
google_pay_details.should_not be_nil
|
1859
|
+
google_pay_details.card_type.should == Braintree::CreditCard::CardType::MasterCard
|
1860
|
+
google_pay_details.virtual_card_type.should == Braintree::CreditCard::CardType::MasterCard
|
1861
|
+
google_pay_details.last_4.should == "4444"
|
1862
|
+
google_pay_details.virtual_card_last_4.should == "4444"
|
1863
|
+
google_pay_details.source_description.should == "MasterCard 4444"
|
1864
|
+
google_pay_details.expiration_month.to_i.should > 0
|
1865
|
+
google_pay_details.expiration_year.to_i.should > 0
|
1866
|
+
google_pay_details.google_transaction_id.should == "google_transaction_id"
|
1867
|
+
google_pay_details.is_network_tokenized?.should == true
|
1907
1868
|
end
|
1908
1869
|
|
1909
1870
|
it "can create a transaction with a fake venmo account nonce" do
|
@@ -2703,6 +2664,22 @@ describe Braintree::Transaction do
|
|
2703
2664
|
end
|
2704
2665
|
end
|
2705
2666
|
|
2667
|
+
context "billing agreement" do
|
2668
|
+
it "can create a paypal billing agreement" do
|
2669
|
+
result = Braintree::Transaction.create(
|
2670
|
+
:type => "sale",
|
2671
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2672
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
2673
|
+
:options => {:store_in_vault => true}
|
2674
|
+
)
|
2675
|
+
|
2676
|
+
result.should be_success
|
2677
|
+
result.transaction.paypal_details.should_not be_nil
|
2678
|
+
result.transaction.paypal_details.debug_id.should_not be_nil
|
2679
|
+
result.transaction.paypal_details.billing_agreement_id.should_not be_nil
|
2680
|
+
end
|
2681
|
+
end
|
2682
|
+
|
2706
2683
|
context "local payments" do
|
2707
2684
|
it "can create a local payment transaction with a nonce" do
|
2708
2685
|
result = Braintree::Transaction.create(
|
@@ -2865,14 +2842,6 @@ describe Braintree::Transaction do
|
|
2865
2842
|
}.to raise_error(ArgumentError)
|
2866
2843
|
end
|
2867
2844
|
|
2868
|
-
it "assigns the refund_id on the original transaction" do
|
2869
|
-
transaction = create_paypal_transaction_for_refund
|
2870
|
-
refund_transaction = Braintree::Transaction.refund(transaction.id).transaction
|
2871
|
-
transaction = Braintree::Transaction.find(transaction.id)
|
2872
|
-
|
2873
|
-
transaction.refund_id.should == refund_transaction.id
|
2874
|
-
end
|
2875
|
-
|
2876
2845
|
it "assigns the refunded_transaction_id to the original transaction" do
|
2877
2846
|
transaction = create_paypal_transaction_for_refund
|
2878
2847
|
refund_transaction = Braintree::Transaction.refund(transaction.id).transaction
|
@@ -2902,7 +2871,13 @@ describe Braintree::Transaction do
|
|
2902
2871
|
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
2903
2872
|
result = Braintree::Transaction.refund(transaction.id, :amount => "2046.00")
|
2904
2873
|
result.success?.should == false
|
2905
|
-
result.
|
2874
|
+
result.transaction.id.should =~ /^\w{6,}$/
|
2875
|
+
result.transaction.type.should == "credit"
|
2876
|
+
result.transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
2877
|
+
result.transaction.processor_response_code.should == "2046"
|
2878
|
+
result.transaction.processor_response_text.should == "Declined"
|
2879
|
+
result.transaction.processor_response_type.should == Braintree::ProcessorResponseTypes::SoftDeclined
|
2880
|
+
result.transaction.additional_processor_response.should == "2046 : Declined"
|
2906
2881
|
end
|
2907
2882
|
|
2908
2883
|
it "handles hard declined refund authorizations" do
|
@@ -2917,7 +2892,13 @@ describe Braintree::Transaction do
|
|
2917
2892
|
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
2918
2893
|
result = Braintree::Transaction.refund(transaction.id, :amount => "2009.00")
|
2919
2894
|
result.success?.should == false
|
2920
|
-
result.
|
2895
|
+
result.transaction.id.should =~ /^\w{6,}$/
|
2896
|
+
result.transaction.type.should == "credit"
|
2897
|
+
result.transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
2898
|
+
result.transaction.processor_response_code.should == "2009"
|
2899
|
+
result.transaction.processor_response_text.should == "No Such Issuer"
|
2900
|
+
result.transaction.processor_response_type.should == Braintree::ProcessorResponseTypes::HardDeclined
|
2901
|
+
result.transaction.additional_processor_response.should == "2009 : No Such Issuer"
|
2921
2902
|
end
|
2922
2903
|
end
|
2923
2904
|
|
@@ -4571,14 +4552,6 @@ describe Braintree::Transaction do
|
|
4571
4552
|
result.transaction.type.should == "credit"
|
4572
4553
|
end
|
4573
4554
|
|
4574
|
-
it "assigns the refund_id on the original transaction" do
|
4575
|
-
transaction = create_transaction_to_refund
|
4576
|
-
refund_transaction = Braintree::Transaction.refund(transaction.id).transaction
|
4577
|
-
transaction = Braintree::Transaction.find(transaction.id)
|
4578
|
-
|
4579
|
-
transaction.refund_id.should == refund_transaction.id
|
4580
|
-
end
|
4581
|
-
|
4582
4555
|
it "assigns the refunded_transaction_id to the original transaction" do
|
4583
4556
|
transaction = create_transaction_to_refund
|
4584
4557
|
refund_transaction = Braintree::Transaction.refund(transaction.id).transaction
|
@@ -5020,11 +4993,11 @@ describe Braintree::Transaction do
|
|
5020
4993
|
result.transaction.status.should == Braintree::Transaction::Status::Authorized
|
5021
4994
|
end
|
5022
4995
|
|
5023
|
-
context "
|
4996
|
+
context "Google Pay params" do
|
5024
4997
|
it "works with full params" do
|
5025
4998
|
params = {
|
5026
4999
|
:amount => "3.12",
|
5027
|
-
:
|
5000
|
+
:google_pay_card => {
|
5028
5001
|
:number => "4012888888881881",
|
5029
5002
|
:cryptogram => "AAAAAAAA/COBt84dnIEcwAA3gAAGhgEDoLABAAhAgAABAAAALnNCLw==",
|
5030
5003
|
:google_transaction_id => "25469d622c1dd37cb1a403c6d438e850",
|
@@ -5043,7 +5016,7 @@ describe Braintree::Transaction do
|
|
5043
5016
|
it "works with only number, cryptogram, expiration and transaction ID (network tokenized card)" do
|
5044
5017
|
params = {
|
5045
5018
|
:amount => "3.12",
|
5046
|
-
:
|
5019
|
+
:google_pay_card => {
|
5047
5020
|
:number => "4012888888881881",
|
5048
5021
|
:cryptogram => "AAAAAAAA/COBt84dnIEcwAA3gAAGhgEDoLABAAhAgAABAAAALnNCLw==",
|
5049
5022
|
:google_transaction_id => "25469d622c1dd37cb1a403c6d438e850",
|
@@ -5059,7 +5032,7 @@ describe Braintree::Transaction do
|
|
5059
5032
|
it "works with only number, expiration and transaction ID (non-tokenized card)" do
|
5060
5033
|
params = {
|
5061
5034
|
:amount => "3.12",
|
5062
|
-
:
|
5035
|
+
:google_pay_card => {
|
5063
5036
|
:number => "4012888888881881",
|
5064
5037
|
:google_transaction_id => "25469d622c1dd37cb1a403c6d438e850",
|
5065
5038
|
:expiration_month => "10",
|
@@ -6048,184 +6021,6 @@ describe Braintree::Transaction do
|
|
6048
6021
|
end
|
6049
6022
|
end
|
6050
6023
|
|
6051
|
-
describe "self.create_from_transparent_redirect" do
|
6052
|
-
it "returns a successful result if successful" do
|
6053
|
-
params = {
|
6054
|
-
:transaction => {
|
6055
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6056
|
-
:credit_card => {
|
6057
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6058
|
-
:expiration_date => "05/2009"
|
6059
|
-
}
|
6060
|
-
}
|
6061
|
-
}
|
6062
|
-
tr_data_params = {
|
6063
|
-
:transaction => {
|
6064
|
-
:type => "sale"
|
6065
|
-
}
|
6066
|
-
}
|
6067
|
-
tr_data = Braintree::TransparentRedirect.transaction_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
6068
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::Transaction.create_transaction_url)
|
6069
|
-
result = Braintree::Transaction.create_from_transparent_redirect(query_string_response)
|
6070
|
-
|
6071
|
-
result.success?.should == true
|
6072
|
-
transaction = result.transaction
|
6073
|
-
transaction.type.should == "sale"
|
6074
|
-
transaction.amount.should == BigDecimal("1000.00")
|
6075
|
-
transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
6076
|
-
transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
6077
|
-
transaction.credit_card_details.expiration_date.should == "05/2009"
|
6078
|
-
end
|
6079
|
-
|
6080
|
-
it "raises an error with a message if given invalid params" do
|
6081
|
-
params = {
|
6082
|
-
:transaction => {
|
6083
|
-
:bad => "value",
|
6084
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6085
|
-
:credit_card => {
|
6086
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6087
|
-
:expiration_date => "05/2009"
|
6088
|
-
}
|
6089
|
-
}
|
6090
|
-
}
|
6091
|
-
tr_data_params = {
|
6092
|
-
:transaction => {
|
6093
|
-
:type => "sale"
|
6094
|
-
}
|
6095
|
-
}
|
6096
|
-
tr_data = Braintree::TransparentRedirect.transaction_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
6097
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::Transaction.create_transaction_url)
|
6098
|
-
|
6099
|
-
expect do
|
6100
|
-
Braintree::Transaction.create_from_transparent_redirect(query_string_response)
|
6101
|
-
end.to raise_error(Braintree::AuthorizationError, "Invalid params: transaction[bad]")
|
6102
|
-
end
|
6103
|
-
|
6104
|
-
it "can put any param in tr_data" do
|
6105
|
-
params = {
|
6106
|
-
|
6107
|
-
}
|
6108
|
-
tr_data_params = {
|
6109
|
-
:transaction => {
|
6110
|
-
:amount => "100.00",
|
6111
|
-
:order_id => "123",
|
6112
|
-
:channel => "MyShoppingCartProvider",
|
6113
|
-
:type => "sale",
|
6114
|
-
:credit_card => {
|
6115
|
-
:cardholder_name => "The Cardholder",
|
6116
|
-
:number => "5105105105105100",
|
6117
|
-
:expiration_date => "05/2011",
|
6118
|
-
:cvv => "123"
|
6119
|
-
},
|
6120
|
-
:customer => {
|
6121
|
-
:first_name => "Dan",
|
6122
|
-
:last_name => "Smith",
|
6123
|
-
:company => "Braintree",
|
6124
|
-
:email => "dan@example.com",
|
6125
|
-
:phone => "419-555-1234",
|
6126
|
-
:fax => "419-555-1235",
|
6127
|
-
:website => "http://braintreepayments.com"
|
6128
|
-
},
|
6129
|
-
:billing => {
|
6130
|
-
:first_name => "Carl",
|
6131
|
-
:last_name => "Jones",
|
6132
|
-
:company => "Braintree",
|
6133
|
-
:street_address => "123 E Main St",
|
6134
|
-
:extended_address => "Suite 403",
|
6135
|
-
:locality => "Chicago",
|
6136
|
-
:region => "IL",
|
6137
|
-
:postal_code => "60622",
|
6138
|
-
:country_name => "United States of America"
|
6139
|
-
},
|
6140
|
-
:shipping => {
|
6141
|
-
:first_name => "Andrew",
|
6142
|
-
:last_name => "Mason",
|
6143
|
-
:company => "Braintree",
|
6144
|
-
:street_address => "456 W Main St",
|
6145
|
-
:extended_address => "Apt 2F",
|
6146
|
-
:locality => "Bartlett",
|
6147
|
-
:region => "IL",
|
6148
|
-
:postal_code => "60103",
|
6149
|
-
:country_name => "United States of America"
|
6150
|
-
}
|
6151
|
-
}
|
6152
|
-
}
|
6153
|
-
tr_data = Braintree::TransparentRedirect.transaction_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
6154
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::Transaction.create_transaction_url)
|
6155
|
-
result = Braintree::Transaction.create_from_transparent_redirect(query_string_response)
|
6156
|
-
|
6157
|
-
transaction = result.transaction
|
6158
|
-
transaction.id.should =~ /\A\w{6,}\z/
|
6159
|
-
transaction.type.should == "sale"
|
6160
|
-
transaction.status.should == Braintree::Transaction::Status::Authorized
|
6161
|
-
transaction.amount.should == BigDecimal("100.00")
|
6162
|
-
transaction.order_id.should == "123"
|
6163
|
-
transaction.channel.should == "MyShoppingCartProvider"
|
6164
|
-
transaction.processor_response_code.should == "1000"
|
6165
|
-
transaction.authorization_expires_at.between?(Time.now, Time.now + (60 * 60 * 24 * 60)).should == true
|
6166
|
-
transaction.created_at.between?(Time.now - 60, Time.now).should == true
|
6167
|
-
transaction.updated_at.between?(Time.now - 60, Time.now).should == true
|
6168
|
-
transaction.credit_card_details.bin.should == "510510"
|
6169
|
-
transaction.credit_card_details.last_4.should == "5100"
|
6170
|
-
transaction.credit_card_details.cardholder_name.should == "The Cardholder"
|
6171
|
-
transaction.credit_card_details.masked_number.should == "510510******5100"
|
6172
|
-
transaction.credit_card_details.card_type.should == "MasterCard"
|
6173
|
-
transaction.avs_error_response_code.should == nil
|
6174
|
-
transaction.avs_postal_code_response_code.should == "M"
|
6175
|
-
transaction.avs_street_address_response_code.should == "M"
|
6176
|
-
transaction.cvv_response_code.should == "M"
|
6177
|
-
transaction.customer_details.first_name.should == "Dan"
|
6178
|
-
transaction.customer_details.last_name.should == "Smith"
|
6179
|
-
transaction.customer_details.company.should == "Braintree"
|
6180
|
-
transaction.customer_details.email.should == "dan@example.com"
|
6181
|
-
transaction.customer_details.phone.should == "419-555-1234"
|
6182
|
-
transaction.customer_details.fax.should == "419-555-1235"
|
6183
|
-
transaction.customer_details.website.should == "http://braintreepayments.com"
|
6184
|
-
transaction.billing_details.first_name.should == "Carl"
|
6185
|
-
transaction.billing_details.last_name.should == "Jones"
|
6186
|
-
transaction.billing_details.company.should == "Braintree"
|
6187
|
-
transaction.billing_details.street_address.should == "123 E Main St"
|
6188
|
-
transaction.billing_details.extended_address.should == "Suite 403"
|
6189
|
-
transaction.billing_details.locality.should == "Chicago"
|
6190
|
-
transaction.billing_details.region.should == "IL"
|
6191
|
-
transaction.billing_details.postal_code.should == "60622"
|
6192
|
-
transaction.billing_details.country_name.should == "United States of America"
|
6193
|
-
transaction.shipping_details.first_name.should == "Andrew"
|
6194
|
-
transaction.shipping_details.last_name.should == "Mason"
|
6195
|
-
transaction.shipping_details.company.should == "Braintree"
|
6196
|
-
transaction.shipping_details.street_address.should == "456 W Main St"
|
6197
|
-
transaction.shipping_details.extended_address.should == "Apt 2F"
|
6198
|
-
transaction.shipping_details.locality.should == "Bartlett"
|
6199
|
-
transaction.shipping_details.region.should == "IL"
|
6200
|
-
transaction.shipping_details.postal_code.should == "60103"
|
6201
|
-
transaction.shipping_details.country_name.should == "United States of America"
|
6202
|
-
end
|
6203
|
-
|
6204
|
-
it "returns an error result if validations fail" do
|
6205
|
-
params = {
|
6206
|
-
:transaction => {
|
6207
|
-
:amount => "",
|
6208
|
-
:credit_card => {
|
6209
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6210
|
-
:expiration_date => "05/2009"
|
6211
|
-
}
|
6212
|
-
}
|
6213
|
-
}
|
6214
|
-
tr_data_params = {
|
6215
|
-
:transaction => {
|
6216
|
-
:type => "sale"
|
6217
|
-
}
|
6218
|
-
}
|
6219
|
-
tr_data = Braintree::TransparentRedirect.transaction_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
6220
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::Transaction.create_transaction_url)
|
6221
|
-
result = Braintree::Transaction.create_from_transparent_redirect(query_string_response)
|
6222
|
-
|
6223
|
-
result.success?.should == false
|
6224
|
-
result.params[:transaction].should == {:amount => "", :type => "sale", :credit_card => {:expiration_date => "05/2009"}}
|
6225
|
-
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
|
6226
|
-
end
|
6227
|
-
end
|
6228
|
-
|
6229
6024
|
describe "self.find" do
|
6230
6025
|
it "finds the transaction with the given id" do
|
6231
6026
|
result = Braintree::Transaction.create(
|
@@ -6267,6 +6062,12 @@ describe Braintree::Transaction do
|
|
6267
6062
|
end.to raise_error(Braintree::NotFoundError, 'transaction with id "invalid-id" not found')
|
6268
6063
|
end
|
6269
6064
|
|
6065
|
+
it "finds a transaction and returns an acquirer_reference_number if the transaction has one" do
|
6066
|
+
transaction = Braintree::Transaction.find("transactionwithacquirerreferencenumber")
|
6067
|
+
|
6068
|
+
transaction.acquirer_reference_number.should == "123456789 091019"
|
6069
|
+
end
|
6070
|
+
|
6270
6071
|
context "disbursement_details" do
|
6271
6072
|
it "includes disbursement_details on found transactions" do
|
6272
6073
|
found_transaction = Braintree::Transaction.find("deposittransaction")
|
@@ -6274,7 +6075,8 @@ describe Braintree::Transaction do
|
|
6274
6075
|
found_transaction.disbursed?.should == true
|
6275
6076
|
disbursement = found_transaction.disbursement_details
|
6276
6077
|
|
6277
|
-
disbursement.disbursement_date.
|
6078
|
+
expect(disbursement.disbursement_date).to be_a Date
|
6079
|
+
expect(disbursement.disbursement_date).to eq Date.parse("2013-04-10")
|
6278
6080
|
disbursement.settlement_amount.should == "100.00"
|
6279
6081
|
disbursement.settlement_currency_iso_code.should == "USD"
|
6280
6082
|
disbursement.settlement_currency_exchange_rate.should == "1"
|
@@ -6519,151 +6321,6 @@ describe Braintree::Transaction do
|
|
6519
6321
|
end
|
6520
6322
|
end
|
6521
6323
|
|
6522
|
-
describe "refund" do
|
6523
|
-
context "partial refunds" do
|
6524
|
-
it "allows partial refunds" do
|
6525
|
-
transaction = create_transaction_to_refund
|
6526
|
-
result = transaction.refund(transaction.amount / 2)
|
6527
|
-
result.success?.should == true
|
6528
|
-
result.new_transaction.type.should == "credit"
|
6529
|
-
end
|
6530
|
-
end
|
6531
|
-
|
6532
|
-
it "returns a successful result if successful" do
|
6533
|
-
transaction = create_transaction_to_refund
|
6534
|
-
transaction.status.should == Braintree::Transaction::Status::Settled
|
6535
|
-
result = transaction.refund
|
6536
|
-
result.success?.should == true
|
6537
|
-
result.new_transaction.type.should == "credit"
|
6538
|
-
end
|
6539
|
-
|
6540
|
-
it "assigns the refund_id on the original transaction" do
|
6541
|
-
transaction = create_transaction_to_refund
|
6542
|
-
refund_transaction = transaction.refund.new_transaction
|
6543
|
-
transaction = Braintree::Transaction.find(transaction.id)
|
6544
|
-
|
6545
|
-
transaction.refund_id.should == refund_transaction.id
|
6546
|
-
end
|
6547
|
-
|
6548
|
-
it "assigns the refunded_transaction_id to the original transaction" do
|
6549
|
-
transaction = create_transaction_to_refund
|
6550
|
-
refund_transaction = transaction.refund.new_transaction
|
6551
|
-
|
6552
|
-
refund_transaction.refunded_transaction_id.should == transaction.id
|
6553
|
-
end
|
6554
|
-
|
6555
|
-
it "returns an error if already refunded" do
|
6556
|
-
transaction = create_transaction_to_refund
|
6557
|
-
result = transaction.refund
|
6558
|
-
result.success?.should == true
|
6559
|
-
result = transaction.refund
|
6560
|
-
result.success?.should == false
|
6561
|
-
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::HasAlreadyBeenRefunded
|
6562
|
-
end
|
6563
|
-
|
6564
|
-
it "returns an error result if unsettled" do
|
6565
|
-
transaction = Braintree::Transaction.create!(
|
6566
|
-
:type => "sale",
|
6567
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6568
|
-
:credit_card => {
|
6569
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6570
|
-
:expiration_date => "05/2009"
|
6571
|
-
}
|
6572
|
-
)
|
6573
|
-
result = transaction.refund
|
6574
|
-
result.success?.should == false
|
6575
|
-
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotRefundUnlessSettled
|
6576
|
-
end
|
6577
|
-
end
|
6578
|
-
|
6579
|
-
describe "submit_for_settlement" do
|
6580
|
-
it "returns a successful result if successful" do
|
6581
|
-
transaction = Braintree::Transaction.sale!(
|
6582
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6583
|
-
:credit_card => {
|
6584
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6585
|
-
:expiration_date => "06/2009"
|
6586
|
-
}
|
6587
|
-
)
|
6588
|
-
result = transaction.submit_for_settlement
|
6589
|
-
result.success?.should == true
|
6590
|
-
end
|
6591
|
-
|
6592
|
-
it "can submit a specific amount for settlement" do
|
6593
|
-
transaction = Braintree::Transaction.sale!(
|
6594
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6595
|
-
:credit_card => {
|
6596
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6597
|
-
:expiration_date => "06/2009"
|
6598
|
-
}
|
6599
|
-
)
|
6600
|
-
transaction.amount.should == BigDecimal("1000.00")
|
6601
|
-
result = transaction.submit_for_settlement("999.99")
|
6602
|
-
result.success?.should == true
|
6603
|
-
transaction.amount.should == BigDecimal("999.99")
|
6604
|
-
end
|
6605
|
-
|
6606
|
-
it "updates the transaction attributes" do
|
6607
|
-
transaction = Braintree::Transaction.sale!(
|
6608
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6609
|
-
:credit_card => {
|
6610
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6611
|
-
:expiration_date => "06/2009"
|
6612
|
-
}
|
6613
|
-
)
|
6614
|
-
transaction.amount.should == BigDecimal("1000.00")
|
6615
|
-
result = transaction.submit_for_settlement("999.99")
|
6616
|
-
result.success?.should == true
|
6617
|
-
transaction.amount.should == BigDecimal("999.99")
|
6618
|
-
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
6619
|
-
transaction.updated_at.between?(Time.now - 60, Time.now).should == true
|
6620
|
-
end
|
6621
|
-
|
6622
|
-
it "returns an error result if unsuccessful" do
|
6623
|
-
transaction = Braintree::Transaction.sale!(
|
6624
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6625
|
-
:credit_card => {
|
6626
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6627
|
-
:expiration_date => "06/2009"
|
6628
|
-
}
|
6629
|
-
)
|
6630
|
-
transaction.amount.should == BigDecimal("1000.00")
|
6631
|
-
result = transaction.submit_for_settlement("1000.01")
|
6632
|
-
result.success?.should == false
|
6633
|
-
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::SettlementAmountIsTooLarge
|
6634
|
-
result.params[:transaction][:amount].should == "1000.01"
|
6635
|
-
end
|
6636
|
-
end
|
6637
|
-
|
6638
|
-
describe "submit_for_settlement!" do
|
6639
|
-
it "returns the transaction if successful" do
|
6640
|
-
original_transaction = Braintree::Transaction.sale!(
|
6641
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6642
|
-
:credit_card => {
|
6643
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6644
|
-
:expiration_date => "06/2009"
|
6645
|
-
}
|
6646
|
-
)
|
6647
|
-
transaction = original_transaction.submit_for_settlement!
|
6648
|
-
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
6649
|
-
transaction.id.should == original_transaction.id
|
6650
|
-
end
|
6651
|
-
|
6652
|
-
it "raises a ValidationsFailed if unsuccessful" do
|
6653
|
-
transaction = Braintree::Transaction.sale!(
|
6654
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6655
|
-
:credit_card => {
|
6656
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6657
|
-
:expiration_date => "06/2009"
|
6658
|
-
}
|
6659
|
-
)
|
6660
|
-
transaction.amount.should == BigDecimal("1000.00")
|
6661
|
-
expect do
|
6662
|
-
transaction.submit_for_settlement!("1000.01")
|
6663
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
6664
|
-
end
|
6665
|
-
end
|
6666
|
-
|
6667
6324
|
describe "status_history" do
|
6668
6325
|
it "returns an array of StatusDetail" do
|
6669
6326
|
transaction = Braintree::Transaction.sale!(
|
@@ -6673,10 +6330,10 @@ describe Braintree::Transaction do
|
|
6673
6330
|
:expiration_date => "05/2009"
|
6674
6331
|
}
|
6675
6332
|
)
|
6676
|
-
|
6677
|
-
|
6678
|
-
|
6679
|
-
|
6333
|
+
result = Braintree::Transaction.submit_for_settlement!(transaction.id)
|
6334
|
+
result.status_history.size.should == 2
|
6335
|
+
result.status_history[0].status.should == Braintree::Transaction::Status::Authorized
|
6336
|
+
result.status_history[1].status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
6680
6337
|
end
|
6681
6338
|
end
|
6682
6339
|
|
@@ -6731,7 +6388,7 @@ describe Braintree::Transaction do
|
|
6731
6388
|
:expiration_date => "05/2010"
|
6732
6389
|
}
|
6733
6390
|
)
|
6734
|
-
transaction = customer.credit_cards[0].
|
6391
|
+
transaction = Braintree::CreditCard.sale(customer.credit_cards[0].token, {:amount => "100.00"}).transaction
|
6735
6392
|
transaction.vault_credit_card.should == customer.credit_cards[0]
|
6736
6393
|
end
|
6737
6394
|
|
@@ -6756,7 +6413,7 @@ describe Braintree::Transaction do
|
|
6756
6413
|
:expiration_date => "05/2010"
|
6757
6414
|
}
|
6758
6415
|
)
|
6759
|
-
transaction = customer.credit_cards[0].
|
6416
|
+
transaction = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00").transaction
|
6760
6417
|
transaction.vault_customer.should == customer
|
6761
6418
|
end
|
6762
6419
|
|
@@ -6773,68 +6430,6 @@ describe Braintree::Transaction do
|
|
6773
6430
|
end
|
6774
6431
|
end
|
6775
6432
|
|
6776
|
-
describe "void" do
|
6777
|
-
it "returns a successful result if successful" do
|
6778
|
-
result = Braintree::Transaction.create(
|
6779
|
-
:type => "sale",
|
6780
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6781
|
-
:credit_card => {
|
6782
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6783
|
-
:expiration_date => "05/2009"
|
6784
|
-
}
|
6785
|
-
)
|
6786
|
-
result.success?.should == true
|
6787
|
-
transaction = result.transaction
|
6788
|
-
transaction.status.should == Braintree::Transaction::Status::Authorized
|
6789
|
-
void_result = transaction.void
|
6790
|
-
void_result.success?.should == true
|
6791
|
-
void_result.transaction.should == transaction
|
6792
|
-
transaction.status.should == void_result.transaction.status
|
6793
|
-
end
|
6794
|
-
|
6795
|
-
it "returns an error result if unsuccessful" do
|
6796
|
-
transaction = Braintree::Transaction.sale(
|
6797
|
-
:amount => Braintree::Test::TransactionAmounts::Decline,
|
6798
|
-
:credit_card => {
|
6799
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6800
|
-
:expiration_date => "05/2009"
|
6801
|
-
}
|
6802
|
-
).transaction
|
6803
|
-
transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
6804
|
-
result = transaction.void
|
6805
|
-
result.success?.should == false
|
6806
|
-
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotBeVoided
|
6807
|
-
end
|
6808
|
-
end
|
6809
|
-
|
6810
|
-
describe "void!" do
|
6811
|
-
it "returns the transaction if successful" do
|
6812
|
-
transaction = Braintree::Transaction.sale!(
|
6813
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6814
|
-
:credit_card => {
|
6815
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6816
|
-
:expiration_date => "05/2009"
|
6817
|
-
}
|
6818
|
-
)
|
6819
|
-
transaction.void!.should == transaction
|
6820
|
-
transaction.status.should == Braintree::Transaction::Status::Voided
|
6821
|
-
end
|
6822
|
-
|
6823
|
-
it "raises a ValidationsFailed if unsuccessful" do
|
6824
|
-
transaction = Braintree::Transaction.sale(
|
6825
|
-
:amount => Braintree::Test::TransactionAmounts::Decline,
|
6826
|
-
:credit_card => {
|
6827
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6828
|
-
:expiration_date => "05/2009"
|
6829
|
-
}
|
6830
|
-
).transaction
|
6831
|
-
transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
6832
|
-
expect do
|
6833
|
-
transaction.void!
|
6834
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
6835
|
-
end
|
6836
|
-
end
|
6837
|
-
|
6838
6433
|
def create_transaction_to_refund
|
6839
6434
|
transaction = Braintree::Transaction.sale!(
|
6840
6435
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|