braintree 2.102.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/address_gateway.rb +2 -2
- 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 +5 -76
- data/lib/braintree/credit_card_gateway.rb +3 -32
- data/lib/braintree/credit_card_verification.rb +14 -0
- data/lib/braintree/customer.rb +3 -72
- 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/transaction.rb +2 -0
- data/lib/braintree/dispute_gateway.rb +2 -7
- data/lib/braintree/error_codes.rb +152 -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 -1
- 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 -4
- data/lib/braintree/payment_method_gateway.rb +4 -8
- data/lib/braintree/payment_method_parser.rb +1 -7
- data/lib/braintree/risk_data.rb +4 -1
- data/lib/braintree/subscription.rb +5 -5
- data/lib/braintree/successful_result.rb +0 -1
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/test/nonce.rb +5 -20
- data/lib/braintree/transaction.rb +9 -73
- data/lib/braintree/transaction/address_details.rb +11 -0
- 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 +3 -0
- data/lib/braintree/transaction/subscription_details.rb +2 -0
- data/lib/braintree/transaction_gateway.rb +14 -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 +92 -66
- data/spec/integration/braintree/credit_card_spec.rb +20 -467
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -0
- 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/merchant_spec.rb +2 -2
- data/spec/integration/braintree/payment_method_spec.rb +77 -120
- data/spec/integration/braintree/paypal_account_spec.rb +1 -1
- 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 +274 -524
- 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 +28 -21
- data/spec/unit/braintree/credit_card_verification_spec.rb +7 -0
- data/spec/unit/braintree/customer_spec.rb +4 -12
- data/spec/unit/braintree/dispute_spec.rb +4 -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 +59 -0
- data/spec/unit/braintree/transaction_spec.rb +17 -37
- 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 +28 -32
- data/lib/braintree/amex_express_checkout_card.rb +0 -38
- 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 -81
- 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 -47
- 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
|
@@ -305,7 +305,7 @@ describe Braintree::MerchantGateway do
|
|
305
305
|
it "succeeds" do
|
306
306
|
result = Braintree::Merchant.provision_raw_apple_pay
|
307
307
|
result.should be_success
|
308
|
-
result.supported_networks.should == ["visa", "mastercard", "amex", "discover"]
|
308
|
+
result.supported_networks.should == ["visa", "mastercard", "amex", "discover", "maestro"]
|
309
309
|
end
|
310
310
|
|
311
311
|
it "is repeatable" do
|
@@ -313,7 +313,7 @@ describe Braintree::MerchantGateway do
|
|
313
313
|
result.should be_success
|
314
314
|
result = Braintree::Merchant.provision_raw_apple_pay
|
315
315
|
result.should be_success
|
316
|
-
result.supported_networks.should == ["visa", "mastercard", "amex", "discover"]
|
316
|
+
result.supported_networks.should == ["visa", "mastercard", "amex", "discover", "maestro"]
|
317
317
|
end
|
318
318
|
end
|
319
319
|
|
@@ -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
|
@@ -140,6 +140,31 @@ describe Braintree::Transaction do
|
|
140
140
|
result.transaction.risk_data.should respond_to(:fraud_service_provider)
|
141
141
|
end
|
142
142
|
end
|
143
|
+
|
144
|
+
it "handles validation errors for invalid risk data attributes" do
|
145
|
+
with_advanced_fraud_integration_merchant do
|
146
|
+
result = Braintree::Transaction.create(
|
147
|
+
:type => "sale",
|
148
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
149
|
+
:credit_card => {
|
150
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
151
|
+
:expiration_date => "05/2009"
|
152
|
+
},
|
153
|
+
:risk_data => {
|
154
|
+
:customer_browser => "#{"1" * 300}",
|
155
|
+
:customer_device_id => "customer_device_id_0#{"1" * 300}",
|
156
|
+
:customer_ip => "192.168.0.1",
|
157
|
+
:customer_location_zip => "not-a-$#phone",
|
158
|
+
:customer_tenure => "20#{"0" * 500}"
|
159
|
+
}
|
160
|
+
)
|
161
|
+
result.success?.should == false
|
162
|
+
result.errors.for(:transaction).for(:risk_data).on(:customer_browser).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerBrowserIsTooLong
|
163
|
+
result.errors.for(:transaction).for(:risk_data).on(:customer_device_id).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerDeviceIdIsTooLong
|
164
|
+
result.errors.for(:transaction).for(:risk_data).on(:customer_location_zip).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerLocationZipInvalidCharacters
|
165
|
+
result.errors.for(:transaction).for(:risk_data).on(:customer_tenure).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerTenureIsTooLong
|
166
|
+
end
|
167
|
+
end
|
143
168
|
end
|
144
169
|
|
145
170
|
describe "card type indicators" do
|
@@ -420,6 +445,7 @@ describe Braintree::Transaction do
|
|
420
445
|
result.transaction.credit_card_details.expiration_date.should == "05/2009"
|
421
446
|
result.transaction.credit_card_details.customer_location.should == "US"
|
422
447
|
result.transaction.retrieval_reference_number.should_not be_nil
|
448
|
+
result.transaction.acquirer_reference_number.should be_nil
|
423
449
|
end
|
424
450
|
|
425
451
|
it "returns a successful network response code if successful" do
|
@@ -484,7 +510,7 @@ describe Braintree::Transaction do
|
|
484
510
|
result.transaction.credit_card_details.customer_location.should == "US"
|
485
511
|
end
|
486
512
|
|
487
|
-
it "accepts additional security parameters:
|
513
|
+
it "accepts additional security parameters: device_data" do
|
488
514
|
result = Braintree::Transaction.create(
|
489
515
|
:type => "sale",
|
490
516
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -492,14 +518,13 @@ describe Braintree::Transaction do
|
|
492
518
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
493
519
|
:expiration_date => "05/2009"
|
494
520
|
},
|
495
|
-
:
|
496
|
-
:fraud_merchant_id => "7"
|
521
|
+
:device_data => "device_data",
|
497
522
|
)
|
498
523
|
|
499
524
|
result.success?.should == true
|
500
525
|
end
|
501
526
|
|
502
|
-
it "accepts additional security parameters: risk data
|
527
|
+
it "accepts additional security parameters: risk data" do
|
503
528
|
result = Braintree::Transaction.create(
|
504
529
|
:type => "sale",
|
505
530
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -509,7 +534,10 @@ describe Braintree::Transaction do
|
|
509
534
|
},
|
510
535
|
:risk_data => {
|
511
536
|
:customer_browser => "IE6",
|
512
|
-
:
|
537
|
+
:customer_device_id => "customer_device_id_012",
|
538
|
+
:customer_ip => "192.168.0.1",
|
539
|
+
:customer_location_zip => "91244",
|
540
|
+
:customer_tenure => "20",
|
513
541
|
}
|
514
542
|
)
|
515
543
|
|
@@ -688,6 +716,68 @@ describe Braintree::Transaction do
|
|
688
716
|
codes.should include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
|
689
717
|
end
|
690
718
|
|
719
|
+
it "returns an error if provided product sku is invalid" do
|
720
|
+
result = Braintree::Transaction.sale(
|
721
|
+
:amount => "100",
|
722
|
+
:credit_card => {
|
723
|
+
:number => "5105105105105100",
|
724
|
+
:expiration_date => "05/2012"
|
725
|
+
},
|
726
|
+
:product_sku => "product$ku!",
|
727
|
+
)
|
728
|
+
|
729
|
+
result.success?.should == false
|
730
|
+
result.errors.for(:transaction).on(:product_sku).map { |e| e.code }.should include(Braintree::ErrorCodes::Transaction::ProductSkuIsInvalid)
|
731
|
+
end
|
732
|
+
|
733
|
+
it "returns an error if provided shipping phone number is invalid" do
|
734
|
+
result = Braintree::Transaction.sale(
|
735
|
+
:amount => "100",
|
736
|
+
:credit_card => {
|
737
|
+
:number => "5105105105105100",
|
738
|
+
:expiration_date => "05/2012"
|
739
|
+
},
|
740
|
+
:shipping => {
|
741
|
+
:phone_number => "123-234-3456=098765"
|
742
|
+
}
|
743
|
+
)
|
744
|
+
|
745
|
+
result.success?.should == false
|
746
|
+
result.errors.for(:transaction).for(:shipping).on(:phone_number).map { |e| e.code }.should include(Braintree::ErrorCodes::Transaction::ShippingPhoneNumberIsInvalid)
|
747
|
+
end
|
748
|
+
|
749
|
+
it "returns an error if provided shipping method is invalid" do
|
750
|
+
result = Braintree::Transaction.sale(
|
751
|
+
:amount => "100",
|
752
|
+
:credit_card => {
|
753
|
+
:number => "5105105105105100",
|
754
|
+
:expiration_date => "05/2012"
|
755
|
+
},
|
756
|
+
:shipping => {
|
757
|
+
:shipping_method => "urgent"
|
758
|
+
}
|
759
|
+
)
|
760
|
+
|
761
|
+
result.success?.should == false
|
762
|
+
result.errors.for(:transaction).for(:shipping).on(:shipping_method).map { |e| e.code }.should include(Braintree::ErrorCodes::Transaction::ShippingMethodIsInvalid)
|
763
|
+
end
|
764
|
+
|
765
|
+
it "returns an error if provided billing phone number is invalid" do
|
766
|
+
result = Braintree::Transaction.sale(
|
767
|
+
:amount => "100",
|
768
|
+
:credit_card => {
|
769
|
+
:number => "5105105105105100",
|
770
|
+
:expiration_date => "05/2012"
|
771
|
+
},
|
772
|
+
:billing => {
|
773
|
+
:phone_number => "123-234-3456=098765"
|
774
|
+
}
|
775
|
+
)
|
776
|
+
|
777
|
+
result.success?.should == false
|
778
|
+
result.errors.for(:transaction).for(:billing).on(:phone_number).map { |e| e.code }.should include(Braintree::ErrorCodes::Transaction::BillingPhoneNumberIsInvalid)
|
779
|
+
end
|
780
|
+
|
691
781
|
context "gateway rejection reason" do
|
692
782
|
it "exposes the cvv gateway rejection reason" do
|
693
783
|
old_merchant = Braintree::Configuration.merchant_id
|
@@ -805,16 +895,44 @@ describe Braintree::Transaction do
|
|
805
895
|
end
|
806
896
|
|
807
897
|
it "exposes the fraud gateway rejection reason" do
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
:
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
898
|
+
with_advanced_fraud_integration_merchant do
|
899
|
+
result = Braintree::Transaction.sale(
|
900
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
901
|
+
:credit_card => {
|
902
|
+
:number => Braintree::Test::CreditCardNumbers::Fraud,
|
903
|
+
:expiration_date => "05/2017",
|
904
|
+
:cvv => "333"
|
905
|
+
}
|
906
|
+
)
|
907
|
+
result.success?.should == false
|
908
|
+
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::Fraud
|
909
|
+
end
|
910
|
+
end
|
911
|
+
|
912
|
+
it "exposes the risk_threshold gateway rejection reason (via test cc num)" do
|
913
|
+
with_advanced_fraud_integration_merchant do
|
914
|
+
result = Braintree::Transaction.sale(
|
915
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
916
|
+
:credit_card => {
|
917
|
+
:number => Braintree::Test::CreditCardNumbers::RiskThreshold,
|
918
|
+
:expiration_date => "05/2017",
|
919
|
+
:cvv => "333"
|
920
|
+
}
|
921
|
+
)
|
922
|
+
result.success?.should == false
|
923
|
+
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::RiskThreshold
|
924
|
+
end
|
925
|
+
end
|
926
|
+
|
927
|
+
it "exposes the risk_threshold gateway rejection reason (via test test nonce)" do
|
928
|
+
with_advanced_fraud_integration_merchant do
|
929
|
+
result = Braintree::Transaction.sale(
|
930
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
931
|
+
:payment_method_nonce => Braintree::Test::Nonce::GatewayRejectedRiskThresholds,
|
932
|
+
)
|
933
|
+
result.success?.should == false
|
934
|
+
result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::RiskThreshold
|
935
|
+
end
|
818
936
|
end
|
819
937
|
|
820
938
|
it "exposes the token issuance gateway rejection reason" do
|
@@ -1254,22 +1372,6 @@ describe Braintree::Transaction do
|
|
1254
1372
|
end
|
1255
1373
|
end
|
1256
1374
|
|
1257
|
-
context "recurring" do
|
1258
|
-
it "marks a transaction as recurring" do
|
1259
|
-
result = Braintree::Transaction.create(
|
1260
|
-
:type => "sale",
|
1261
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1262
|
-
:credit_card => {
|
1263
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1264
|
-
:expiration_date => "12/12",
|
1265
|
-
},
|
1266
|
-
:recurring => true
|
1267
|
-
)
|
1268
|
-
result.success?.should == true
|
1269
|
-
result.transaction.recurring.should == true
|
1270
|
-
end
|
1271
|
-
end
|
1272
|
-
|
1273
1375
|
context "transaction_source" do
|
1274
1376
|
it "marks a transactions as recurring_first" do
|
1275
1377
|
result = Braintree::Transaction.create(
|
@@ -1686,106 +1788,83 @@ describe Braintree::Transaction do
|
|
1686
1788
|
apple_pay_details.token.should_not be_nil
|
1687
1789
|
end
|
1688
1790
|
|
1689
|
-
it "can create a transaction with a fake
|
1791
|
+
it "can create a transaction with a fake google pay proxy card nonce" do
|
1690
1792
|
customer = Braintree::Customer.create!
|
1691
1793
|
result = Braintree::Transaction.create(
|
1692
1794
|
:type => "sale",
|
1693
1795
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1694
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1796
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover
|
1695
1797
|
)
|
1696
1798
|
result.success?.should == true
|
1697
1799
|
result.transaction.should_not be_nil
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
end
|
1720
|
-
|
1721
|
-
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
|
1722
1824
|
customer = Braintree::Customer.create!
|
1723
1825
|
result = Braintree::Transaction.create(
|
1724
1826
|
:type => "sale",
|
1725
1827
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1726
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1828
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1727
1829
|
:options => { :store_in_vault_on_success => true }
|
1728
1830
|
)
|
1729
1831
|
result.success?.should == true
|
1730
1832
|
result.transaction.should_not be_nil
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
end
|
1745
|
-
|
1746
|
-
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
|
1747
1849
|
customer = Braintree::Customer.create!
|
1748
1850
|
result = Braintree::Transaction.create(
|
1749
1851
|
:type => "sale",
|
1750
1852
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1751
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1853
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard
|
1752
1854
|
)
|
1753
1855
|
result.success?.should == true
|
1754
1856
|
result.transaction.should_not be_nil
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
end
|
1767
|
-
|
1768
|
-
it "can create a transaction with a fake amex express checkout card nonce" do
|
1769
|
-
result = Braintree::Transaction.create(
|
1770
|
-
:type => "sale",
|
1771
|
-
:merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
|
1772
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1773
|
-
:payment_method_nonce => Braintree::Test::Nonce::AmexExpressCheckout,
|
1774
|
-
:options => {:store_in_vault => true}
|
1775
|
-
)
|
1776
|
-
result.success?.should == true
|
1777
|
-
result.transaction.should_not be_nil
|
1778
|
-
checkout_details = result.transaction.amex_express_checkout_details
|
1779
|
-
checkout_details.should_not be_nil
|
1780
|
-
checkout_details.card_type.should == "American Express"
|
1781
|
-
checkout_details.token.should respond_to(:to_str)
|
1782
|
-
checkout_details.bin.should =~ /\A\d{6}\z/
|
1783
|
-
checkout_details.expiration_month.should =~ /\A\d{2}\z/
|
1784
|
-
checkout_details.expiration_year.should =~ /\A\d{4}\z/
|
1785
|
-
checkout_details.card_member_number.should =~ /\A\d{4}\z/
|
1786
|
-
checkout_details.card_member_expiry_date.should =~ /\A\d{2}\/\d{2}\z/
|
1787
|
-
checkout_details.image_url.should include(".png")
|
1788
|
-
checkout_details.source_description.should =~ /\AAmEx \d{4}\z/
|
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
|
1789
1868
|
end
|
1790
1869
|
|
1791
1870
|
it "can create a transaction with a fake venmo account nonce" do
|
@@ -2585,6 +2664,22 @@ describe Braintree::Transaction do
|
|
2585
2664
|
end
|
2586
2665
|
end
|
2587
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
|
+
|
2588
2683
|
context "local payments" do
|
2589
2684
|
it "can create a local payment transaction with a nonce" do
|
2590
2685
|
result = Braintree::Transaction.create(
|
@@ -2747,14 +2842,6 @@ describe Braintree::Transaction do
|
|
2747
2842
|
}.to raise_error(ArgumentError)
|
2748
2843
|
end
|
2749
2844
|
|
2750
|
-
it "assigns the refund_id on the original transaction" do
|
2751
|
-
transaction = create_paypal_transaction_for_refund
|
2752
|
-
refund_transaction = Braintree::Transaction.refund(transaction.id).transaction
|
2753
|
-
transaction = Braintree::Transaction.find(transaction.id)
|
2754
|
-
|
2755
|
-
transaction.refund_id.should == refund_transaction.id
|
2756
|
-
end
|
2757
|
-
|
2758
2845
|
it "assigns the refunded_transaction_id to the original transaction" do
|
2759
2846
|
transaction = create_paypal_transaction_for_refund
|
2760
2847
|
refund_transaction = Braintree::Transaction.refund(transaction.id).transaction
|
@@ -2784,7 +2871,13 @@ describe Braintree::Transaction do
|
|
2784
2871
|
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
2785
2872
|
result = Braintree::Transaction.refund(transaction.id, :amount => "2046.00")
|
2786
2873
|
result.success?.should == false
|
2787
|
-
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"
|
2788
2881
|
end
|
2789
2882
|
|
2790
2883
|
it "handles hard declined refund authorizations" do
|
@@ -2799,7 +2892,13 @@ describe Braintree::Transaction do
|
|
2799
2892
|
response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
|
2800
2893
|
result = Braintree::Transaction.refund(transaction.id, :amount => "2009.00")
|
2801
2894
|
result.success?.should == false
|
2802
|
-
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"
|
2803
2902
|
end
|
2804
2903
|
end
|
2805
2904
|
|
@@ -4453,14 +4552,6 @@ describe Braintree::Transaction do
|
|
4453
4552
|
result.transaction.type.should == "credit"
|
4454
4553
|
end
|
4455
4554
|
|
4456
|
-
it "assigns the refund_id on the original transaction" do
|
4457
|
-
transaction = create_transaction_to_refund
|
4458
|
-
refund_transaction = Braintree::Transaction.refund(transaction.id).transaction
|
4459
|
-
transaction = Braintree::Transaction.find(transaction.id)
|
4460
|
-
|
4461
|
-
transaction.refund_id.should == refund_transaction.id
|
4462
|
-
end
|
4463
|
-
|
4464
4555
|
it "assigns the refunded_transaction_id to the original transaction" do
|
4465
4556
|
transaction = create_transaction_to_refund
|
4466
4557
|
refund_transaction = Braintree::Transaction.refund(transaction.id).transaction
|
@@ -4536,6 +4627,7 @@ describe Braintree::Transaction do
|
|
4536
4627
|
result = Braintree::Transaction.sale(
|
4537
4628
|
:amount => "100.00",
|
4538
4629
|
:order_id => "123",
|
4630
|
+
:product_sku => "productsku01",
|
4539
4631
|
:channel => "MyShoppingCartProvider",
|
4540
4632
|
:credit_card => {
|
4541
4633
|
:cardholder_name => "The Cardholder",
|
@@ -4560,6 +4652,7 @@ describe Braintree::Transaction do
|
|
4560
4652
|
:extended_address => "Suite 403",
|
4561
4653
|
:locality => "Chicago",
|
4562
4654
|
:region => "IL",
|
4655
|
+
:phone_number => "122-555-1237",
|
4563
4656
|
:postal_code => "60622",
|
4564
4657
|
:country_name => "United States of America"
|
4565
4658
|
},
|
@@ -4571,8 +4664,10 @@ describe Braintree::Transaction do
|
|
4571
4664
|
:extended_address => "Apt 2F",
|
4572
4665
|
:locality => "Bartlett",
|
4573
4666
|
:region => "IL",
|
4667
|
+
:phone_number => "122-555-1236",
|
4574
4668
|
:postal_code => "60103",
|
4575
|
-
:country_name => "United States of America"
|
4669
|
+
:country_name => "United States of America",
|
4670
|
+
:shipping_method => Braintree::Transaction::AddressDetails::ShippingMethod::Electronic
|
4576
4671
|
}
|
4577
4672
|
)
|
4578
4673
|
result.success?.should == true
|
@@ -4898,11 +4993,11 @@ describe Braintree::Transaction do
|
|
4898
4993
|
result.transaction.status.should == Braintree::Transaction::Status::Authorized
|
4899
4994
|
end
|
4900
4995
|
|
4901
|
-
context "
|
4996
|
+
context "Google Pay params" do
|
4902
4997
|
it "works with full params" do
|
4903
4998
|
params = {
|
4904
4999
|
:amount => "3.12",
|
4905
|
-
:
|
5000
|
+
:google_pay_card => {
|
4906
5001
|
:number => "4012888888881881",
|
4907
5002
|
:cryptogram => "AAAAAAAA/COBt84dnIEcwAA3gAAGhgEDoLABAAhAgAABAAAALnNCLw==",
|
4908
5003
|
:google_transaction_id => "25469d622c1dd37cb1a403c6d438e850",
|
@@ -4921,7 +5016,7 @@ describe Braintree::Transaction do
|
|
4921
5016
|
it "works with only number, cryptogram, expiration and transaction ID (network tokenized card)" do
|
4922
5017
|
params = {
|
4923
5018
|
:amount => "3.12",
|
4924
|
-
:
|
5019
|
+
:google_pay_card => {
|
4925
5020
|
:number => "4012888888881881",
|
4926
5021
|
:cryptogram => "AAAAAAAA/COBt84dnIEcwAA3gAAGhgEDoLABAAhAgAABAAAALnNCLw==",
|
4927
5022
|
:google_transaction_id => "25469d622c1dd37cb1a403c6d438e850",
|
@@ -4937,7 +5032,7 @@ describe Braintree::Transaction do
|
|
4937
5032
|
it "works with only number, expiration and transaction ID (non-tokenized card)" do
|
4938
5033
|
params = {
|
4939
5034
|
:amount => "3.12",
|
4940
|
-
:
|
5035
|
+
:google_pay_card => {
|
4941
5036
|
:number => "4012888888881881",
|
4942
5037
|
:google_transaction_id => "25469d622c1dd37cb1a403c6d438e850",
|
4943
5038
|
:expiration_month => "10",
|
@@ -5926,184 +6021,6 @@ describe Braintree::Transaction do
|
|
5926
6021
|
end
|
5927
6022
|
end
|
5928
6023
|
|
5929
|
-
describe "self.create_from_transparent_redirect" do
|
5930
|
-
it "returns a successful result if successful" do
|
5931
|
-
params = {
|
5932
|
-
:transaction => {
|
5933
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5934
|
-
:credit_card => {
|
5935
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5936
|
-
:expiration_date => "05/2009"
|
5937
|
-
}
|
5938
|
-
}
|
5939
|
-
}
|
5940
|
-
tr_data_params = {
|
5941
|
-
:transaction => {
|
5942
|
-
:type => "sale"
|
5943
|
-
}
|
5944
|
-
}
|
5945
|
-
tr_data = Braintree::TransparentRedirect.transaction_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
5946
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::Transaction.create_transaction_url)
|
5947
|
-
result = Braintree::Transaction.create_from_transparent_redirect(query_string_response)
|
5948
|
-
|
5949
|
-
result.success?.should == true
|
5950
|
-
transaction = result.transaction
|
5951
|
-
transaction.type.should == "sale"
|
5952
|
-
transaction.amount.should == BigDecimal("1000.00")
|
5953
|
-
transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
5954
|
-
transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
5955
|
-
transaction.credit_card_details.expiration_date.should == "05/2009"
|
5956
|
-
end
|
5957
|
-
|
5958
|
-
it "raises an error with a message if given invalid params" do
|
5959
|
-
params = {
|
5960
|
-
:transaction => {
|
5961
|
-
:bad => "value",
|
5962
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5963
|
-
:credit_card => {
|
5964
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
5965
|
-
:expiration_date => "05/2009"
|
5966
|
-
}
|
5967
|
-
}
|
5968
|
-
}
|
5969
|
-
tr_data_params = {
|
5970
|
-
:transaction => {
|
5971
|
-
:type => "sale"
|
5972
|
-
}
|
5973
|
-
}
|
5974
|
-
tr_data = Braintree::TransparentRedirect.transaction_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
5975
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::Transaction.create_transaction_url)
|
5976
|
-
|
5977
|
-
expect do
|
5978
|
-
Braintree::Transaction.create_from_transparent_redirect(query_string_response)
|
5979
|
-
end.to raise_error(Braintree::AuthorizationError, "Invalid params: transaction[bad]")
|
5980
|
-
end
|
5981
|
-
|
5982
|
-
it "can put any param in tr_data" do
|
5983
|
-
params = {
|
5984
|
-
|
5985
|
-
}
|
5986
|
-
tr_data_params = {
|
5987
|
-
:transaction => {
|
5988
|
-
:amount => "100.00",
|
5989
|
-
:order_id => "123",
|
5990
|
-
:channel => "MyShoppingCartProvider",
|
5991
|
-
:type => "sale",
|
5992
|
-
:credit_card => {
|
5993
|
-
:cardholder_name => "The Cardholder",
|
5994
|
-
:number => "5105105105105100",
|
5995
|
-
:expiration_date => "05/2011",
|
5996
|
-
:cvv => "123"
|
5997
|
-
},
|
5998
|
-
:customer => {
|
5999
|
-
:first_name => "Dan",
|
6000
|
-
:last_name => "Smith",
|
6001
|
-
:company => "Braintree",
|
6002
|
-
:email => "dan@example.com",
|
6003
|
-
:phone => "419-555-1234",
|
6004
|
-
:fax => "419-555-1235",
|
6005
|
-
:website => "http://braintreepayments.com"
|
6006
|
-
},
|
6007
|
-
:billing => {
|
6008
|
-
:first_name => "Carl",
|
6009
|
-
:last_name => "Jones",
|
6010
|
-
:company => "Braintree",
|
6011
|
-
:street_address => "123 E Main St",
|
6012
|
-
:extended_address => "Suite 403",
|
6013
|
-
:locality => "Chicago",
|
6014
|
-
:region => "IL",
|
6015
|
-
:postal_code => "60622",
|
6016
|
-
:country_name => "United States of America"
|
6017
|
-
},
|
6018
|
-
:shipping => {
|
6019
|
-
:first_name => "Andrew",
|
6020
|
-
:last_name => "Mason",
|
6021
|
-
:company => "Braintree",
|
6022
|
-
:street_address => "456 W Main St",
|
6023
|
-
:extended_address => "Apt 2F",
|
6024
|
-
:locality => "Bartlett",
|
6025
|
-
:region => "IL",
|
6026
|
-
:postal_code => "60103",
|
6027
|
-
:country_name => "United States of America"
|
6028
|
-
}
|
6029
|
-
}
|
6030
|
-
}
|
6031
|
-
tr_data = Braintree::TransparentRedirect.transaction_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
6032
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::Transaction.create_transaction_url)
|
6033
|
-
result = Braintree::Transaction.create_from_transparent_redirect(query_string_response)
|
6034
|
-
|
6035
|
-
transaction = result.transaction
|
6036
|
-
transaction.id.should =~ /\A\w{6,}\z/
|
6037
|
-
transaction.type.should == "sale"
|
6038
|
-
transaction.status.should == Braintree::Transaction::Status::Authorized
|
6039
|
-
transaction.amount.should == BigDecimal("100.00")
|
6040
|
-
transaction.order_id.should == "123"
|
6041
|
-
transaction.channel.should == "MyShoppingCartProvider"
|
6042
|
-
transaction.processor_response_code.should == "1000"
|
6043
|
-
transaction.authorization_expires_at.between?(Time.now, Time.now + (60 * 60 * 24 * 60)).should == true
|
6044
|
-
transaction.created_at.between?(Time.now - 60, Time.now).should == true
|
6045
|
-
transaction.updated_at.between?(Time.now - 60, Time.now).should == true
|
6046
|
-
transaction.credit_card_details.bin.should == "510510"
|
6047
|
-
transaction.credit_card_details.last_4.should == "5100"
|
6048
|
-
transaction.credit_card_details.cardholder_name.should == "The Cardholder"
|
6049
|
-
transaction.credit_card_details.masked_number.should == "510510******5100"
|
6050
|
-
transaction.credit_card_details.card_type.should == "MasterCard"
|
6051
|
-
transaction.avs_error_response_code.should == nil
|
6052
|
-
transaction.avs_postal_code_response_code.should == "M"
|
6053
|
-
transaction.avs_street_address_response_code.should == "M"
|
6054
|
-
transaction.cvv_response_code.should == "M"
|
6055
|
-
transaction.customer_details.first_name.should == "Dan"
|
6056
|
-
transaction.customer_details.last_name.should == "Smith"
|
6057
|
-
transaction.customer_details.company.should == "Braintree"
|
6058
|
-
transaction.customer_details.email.should == "dan@example.com"
|
6059
|
-
transaction.customer_details.phone.should == "419-555-1234"
|
6060
|
-
transaction.customer_details.fax.should == "419-555-1235"
|
6061
|
-
transaction.customer_details.website.should == "http://braintreepayments.com"
|
6062
|
-
transaction.billing_details.first_name.should == "Carl"
|
6063
|
-
transaction.billing_details.last_name.should == "Jones"
|
6064
|
-
transaction.billing_details.company.should == "Braintree"
|
6065
|
-
transaction.billing_details.street_address.should == "123 E Main St"
|
6066
|
-
transaction.billing_details.extended_address.should == "Suite 403"
|
6067
|
-
transaction.billing_details.locality.should == "Chicago"
|
6068
|
-
transaction.billing_details.region.should == "IL"
|
6069
|
-
transaction.billing_details.postal_code.should == "60622"
|
6070
|
-
transaction.billing_details.country_name.should == "United States of America"
|
6071
|
-
transaction.shipping_details.first_name.should == "Andrew"
|
6072
|
-
transaction.shipping_details.last_name.should == "Mason"
|
6073
|
-
transaction.shipping_details.company.should == "Braintree"
|
6074
|
-
transaction.shipping_details.street_address.should == "456 W Main St"
|
6075
|
-
transaction.shipping_details.extended_address.should == "Apt 2F"
|
6076
|
-
transaction.shipping_details.locality.should == "Bartlett"
|
6077
|
-
transaction.shipping_details.region.should == "IL"
|
6078
|
-
transaction.shipping_details.postal_code.should == "60103"
|
6079
|
-
transaction.shipping_details.country_name.should == "United States of America"
|
6080
|
-
end
|
6081
|
-
|
6082
|
-
it "returns an error result if validations fail" do
|
6083
|
-
params = {
|
6084
|
-
:transaction => {
|
6085
|
-
:amount => "",
|
6086
|
-
:credit_card => {
|
6087
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6088
|
-
:expiration_date => "05/2009"
|
6089
|
-
}
|
6090
|
-
}
|
6091
|
-
}
|
6092
|
-
tr_data_params = {
|
6093
|
-
:transaction => {
|
6094
|
-
:type => "sale"
|
6095
|
-
}
|
6096
|
-
}
|
6097
|
-
tr_data = Braintree::TransparentRedirect.transaction_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
6098
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::Transaction.create_transaction_url)
|
6099
|
-
result = Braintree::Transaction.create_from_transparent_redirect(query_string_response)
|
6100
|
-
|
6101
|
-
result.success?.should == false
|
6102
|
-
result.params[:transaction].should == {:amount => "", :type => "sale", :credit_card => {:expiration_date => "05/2009"}}
|
6103
|
-
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
|
6104
|
-
end
|
6105
|
-
end
|
6106
|
-
|
6107
6024
|
describe "self.find" do
|
6108
6025
|
it "finds the transaction with the given id" do
|
6109
6026
|
result = Braintree::Transaction.create(
|
@@ -6145,6 +6062,12 @@ describe Braintree::Transaction do
|
|
6145
6062
|
end.to raise_error(Braintree::NotFoundError, 'transaction with id "invalid-id" not found')
|
6146
6063
|
end
|
6147
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
|
+
|
6148
6071
|
context "disbursement_details" do
|
6149
6072
|
it "includes disbursement_details on found transactions" do
|
6150
6073
|
found_transaction = Braintree::Transaction.find("deposittransaction")
|
@@ -6152,7 +6075,8 @@ describe Braintree::Transaction do
|
|
6152
6075
|
found_transaction.disbursed?.should == true
|
6153
6076
|
disbursement = found_transaction.disbursement_details
|
6154
6077
|
|
6155
|
-
disbursement.disbursement_date.
|
6078
|
+
expect(disbursement.disbursement_date).to be_a Date
|
6079
|
+
expect(disbursement.disbursement_date).to eq Date.parse("2013-04-10")
|
6156
6080
|
disbursement.settlement_amount.should == "100.00"
|
6157
6081
|
disbursement.settlement_currency_iso_code.should == "USD"
|
6158
6082
|
disbursement.settlement_currency_exchange_rate.should == "1"
|
@@ -6397,151 +6321,6 @@ describe Braintree::Transaction do
|
|
6397
6321
|
end
|
6398
6322
|
end
|
6399
6323
|
|
6400
|
-
describe "refund" do
|
6401
|
-
context "partial refunds" do
|
6402
|
-
it "allows partial refunds" do
|
6403
|
-
transaction = create_transaction_to_refund
|
6404
|
-
result = transaction.refund(transaction.amount / 2)
|
6405
|
-
result.success?.should == true
|
6406
|
-
result.new_transaction.type.should == "credit"
|
6407
|
-
end
|
6408
|
-
end
|
6409
|
-
|
6410
|
-
it "returns a successful result if successful" do
|
6411
|
-
transaction = create_transaction_to_refund
|
6412
|
-
transaction.status.should == Braintree::Transaction::Status::Settled
|
6413
|
-
result = transaction.refund
|
6414
|
-
result.success?.should == true
|
6415
|
-
result.new_transaction.type.should == "credit"
|
6416
|
-
end
|
6417
|
-
|
6418
|
-
it "assigns the refund_id on the original transaction" do
|
6419
|
-
transaction = create_transaction_to_refund
|
6420
|
-
refund_transaction = transaction.refund.new_transaction
|
6421
|
-
transaction = Braintree::Transaction.find(transaction.id)
|
6422
|
-
|
6423
|
-
transaction.refund_id.should == refund_transaction.id
|
6424
|
-
end
|
6425
|
-
|
6426
|
-
it "assigns the refunded_transaction_id to the original transaction" do
|
6427
|
-
transaction = create_transaction_to_refund
|
6428
|
-
refund_transaction = transaction.refund.new_transaction
|
6429
|
-
|
6430
|
-
refund_transaction.refunded_transaction_id.should == transaction.id
|
6431
|
-
end
|
6432
|
-
|
6433
|
-
it "returns an error if already refunded" do
|
6434
|
-
transaction = create_transaction_to_refund
|
6435
|
-
result = transaction.refund
|
6436
|
-
result.success?.should == true
|
6437
|
-
result = transaction.refund
|
6438
|
-
result.success?.should == false
|
6439
|
-
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::HasAlreadyBeenRefunded
|
6440
|
-
end
|
6441
|
-
|
6442
|
-
it "returns an error result if unsettled" do
|
6443
|
-
transaction = Braintree::Transaction.create!(
|
6444
|
-
:type => "sale",
|
6445
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6446
|
-
:credit_card => {
|
6447
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6448
|
-
:expiration_date => "05/2009"
|
6449
|
-
}
|
6450
|
-
)
|
6451
|
-
result = transaction.refund
|
6452
|
-
result.success?.should == false
|
6453
|
-
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotRefundUnlessSettled
|
6454
|
-
end
|
6455
|
-
end
|
6456
|
-
|
6457
|
-
describe "submit_for_settlement" do
|
6458
|
-
it "returns a successful result if successful" do
|
6459
|
-
transaction = Braintree::Transaction.sale!(
|
6460
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6461
|
-
:credit_card => {
|
6462
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6463
|
-
:expiration_date => "06/2009"
|
6464
|
-
}
|
6465
|
-
)
|
6466
|
-
result = transaction.submit_for_settlement
|
6467
|
-
result.success?.should == true
|
6468
|
-
end
|
6469
|
-
|
6470
|
-
it "can submit a specific amount for settlement" do
|
6471
|
-
transaction = Braintree::Transaction.sale!(
|
6472
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6473
|
-
:credit_card => {
|
6474
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6475
|
-
:expiration_date => "06/2009"
|
6476
|
-
}
|
6477
|
-
)
|
6478
|
-
transaction.amount.should == BigDecimal("1000.00")
|
6479
|
-
result = transaction.submit_for_settlement("999.99")
|
6480
|
-
result.success?.should == true
|
6481
|
-
transaction.amount.should == BigDecimal("999.99")
|
6482
|
-
end
|
6483
|
-
|
6484
|
-
it "updates the transaction attributes" do
|
6485
|
-
transaction = Braintree::Transaction.sale!(
|
6486
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6487
|
-
:credit_card => {
|
6488
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6489
|
-
:expiration_date => "06/2009"
|
6490
|
-
}
|
6491
|
-
)
|
6492
|
-
transaction.amount.should == BigDecimal("1000.00")
|
6493
|
-
result = transaction.submit_for_settlement("999.99")
|
6494
|
-
result.success?.should == true
|
6495
|
-
transaction.amount.should == BigDecimal("999.99")
|
6496
|
-
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
6497
|
-
transaction.updated_at.between?(Time.now - 60, Time.now).should == true
|
6498
|
-
end
|
6499
|
-
|
6500
|
-
it "returns an error result if unsuccessful" do
|
6501
|
-
transaction = Braintree::Transaction.sale!(
|
6502
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6503
|
-
:credit_card => {
|
6504
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6505
|
-
:expiration_date => "06/2009"
|
6506
|
-
}
|
6507
|
-
)
|
6508
|
-
transaction.amount.should == BigDecimal("1000.00")
|
6509
|
-
result = transaction.submit_for_settlement("1000.01")
|
6510
|
-
result.success?.should == false
|
6511
|
-
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::SettlementAmountIsTooLarge
|
6512
|
-
result.params[:transaction][:amount].should == "1000.01"
|
6513
|
-
end
|
6514
|
-
end
|
6515
|
-
|
6516
|
-
describe "submit_for_settlement!" do
|
6517
|
-
it "returns the transaction if successful" do
|
6518
|
-
original_transaction = Braintree::Transaction.sale!(
|
6519
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6520
|
-
:credit_card => {
|
6521
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6522
|
-
:expiration_date => "06/2009"
|
6523
|
-
}
|
6524
|
-
)
|
6525
|
-
transaction = original_transaction.submit_for_settlement!
|
6526
|
-
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
6527
|
-
transaction.id.should == original_transaction.id
|
6528
|
-
end
|
6529
|
-
|
6530
|
-
it "raises a ValidationsFailed if unsuccessful" do
|
6531
|
-
transaction = Braintree::Transaction.sale!(
|
6532
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6533
|
-
:credit_card => {
|
6534
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6535
|
-
:expiration_date => "06/2009"
|
6536
|
-
}
|
6537
|
-
)
|
6538
|
-
transaction.amount.should == BigDecimal("1000.00")
|
6539
|
-
expect do
|
6540
|
-
transaction.submit_for_settlement!("1000.01")
|
6541
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
6542
|
-
end
|
6543
|
-
end
|
6544
|
-
|
6545
6324
|
describe "status_history" do
|
6546
6325
|
it "returns an array of StatusDetail" do
|
6547
6326
|
transaction = Braintree::Transaction.sale!(
|
@@ -6551,10 +6330,10 @@ describe Braintree::Transaction do
|
|
6551
6330
|
:expiration_date => "05/2009"
|
6552
6331
|
}
|
6553
6332
|
)
|
6554
|
-
|
6555
|
-
|
6556
|
-
|
6557
|
-
|
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
|
6558
6337
|
end
|
6559
6338
|
end
|
6560
6339
|
|
@@ -6609,7 +6388,7 @@ describe Braintree::Transaction do
|
|
6609
6388
|
:expiration_date => "05/2010"
|
6610
6389
|
}
|
6611
6390
|
)
|
6612
|
-
transaction = customer.credit_cards[0].
|
6391
|
+
transaction = Braintree::CreditCard.sale(customer.credit_cards[0].token, {:amount => "100.00"}).transaction
|
6613
6392
|
transaction.vault_credit_card.should == customer.credit_cards[0]
|
6614
6393
|
end
|
6615
6394
|
|
@@ -6634,7 +6413,7 @@ describe Braintree::Transaction do
|
|
6634
6413
|
:expiration_date => "05/2010"
|
6635
6414
|
}
|
6636
6415
|
)
|
6637
|
-
transaction = customer.credit_cards[0].
|
6416
|
+
transaction = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00").transaction
|
6638
6417
|
transaction.vault_customer.should == customer
|
6639
6418
|
end
|
6640
6419
|
|
@@ -6651,68 +6430,6 @@ describe Braintree::Transaction do
|
|
6651
6430
|
end
|
6652
6431
|
end
|
6653
6432
|
|
6654
|
-
describe "void" do
|
6655
|
-
it "returns a successful result if successful" do
|
6656
|
-
result = Braintree::Transaction.create(
|
6657
|
-
:type => "sale",
|
6658
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6659
|
-
:credit_card => {
|
6660
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6661
|
-
:expiration_date => "05/2009"
|
6662
|
-
}
|
6663
|
-
)
|
6664
|
-
result.success?.should == true
|
6665
|
-
transaction = result.transaction
|
6666
|
-
transaction.status.should == Braintree::Transaction::Status::Authorized
|
6667
|
-
void_result = transaction.void
|
6668
|
-
void_result.success?.should == true
|
6669
|
-
void_result.transaction.should == transaction
|
6670
|
-
transaction.status.should == void_result.transaction.status
|
6671
|
-
end
|
6672
|
-
|
6673
|
-
it "returns an error result if unsuccessful" do
|
6674
|
-
transaction = Braintree::Transaction.sale(
|
6675
|
-
:amount => Braintree::Test::TransactionAmounts::Decline,
|
6676
|
-
:credit_card => {
|
6677
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6678
|
-
:expiration_date => "05/2009"
|
6679
|
-
}
|
6680
|
-
).transaction
|
6681
|
-
transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
6682
|
-
result = transaction.void
|
6683
|
-
result.success?.should == false
|
6684
|
-
result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotBeVoided
|
6685
|
-
end
|
6686
|
-
end
|
6687
|
-
|
6688
|
-
describe "void!" do
|
6689
|
-
it "returns the transaction if successful" do
|
6690
|
-
transaction = Braintree::Transaction.sale!(
|
6691
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6692
|
-
:credit_card => {
|
6693
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6694
|
-
:expiration_date => "05/2009"
|
6695
|
-
}
|
6696
|
-
)
|
6697
|
-
transaction.void!.should == transaction
|
6698
|
-
transaction.status.should == Braintree::Transaction::Status::Voided
|
6699
|
-
end
|
6700
|
-
|
6701
|
-
it "raises a ValidationsFailed if unsuccessful" do
|
6702
|
-
transaction = Braintree::Transaction.sale(
|
6703
|
-
:amount => Braintree::Test::TransactionAmounts::Decline,
|
6704
|
-
:credit_card => {
|
6705
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
6706
|
-
:expiration_date => "05/2009"
|
6707
|
-
}
|
6708
|
-
).transaction
|
6709
|
-
transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
6710
|
-
expect do
|
6711
|
-
transaction.void!
|
6712
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
6713
|
-
end
|
6714
|
-
end
|
6715
|
-
|
6716
6433
|
def create_transaction_to_refund
|
6717
6434
|
transaction = Braintree::Transaction.sale!(
|
6718
6435
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -7039,4 +6756,37 @@ describe Braintree::Transaction do
|
|
7039
6756
|
details.refund_id.should_not be_nil
|
7040
6757
|
end
|
7041
6758
|
end
|
6759
|
+
|
6760
|
+
describe "card on file network tokenization" do
|
6761
|
+
it "creates a transaction with a vaulted, tokenized credit card" do
|
6762
|
+
result = Braintree::Transaction.sale(
|
6763
|
+
:amount => "112.44",
|
6764
|
+
:payment_method_token => "network_tokenized_credit_card",
|
6765
|
+
)
|
6766
|
+
result.success?.should == true
|
6767
|
+
transaction = result.transaction
|
6768
|
+
|
6769
|
+
transaction.amount.should == BigDecimal("112.44")
|
6770
|
+
transaction.processed_with_network_token?.should == true
|
6771
|
+
end
|
6772
|
+
|
6773
|
+
it "creates a transaction with a vaulted, non-tokenized credit card" do
|
6774
|
+
customer = Braintree::Customer.create!
|
6775
|
+
result = Braintree::PaymentMethod.create(
|
6776
|
+
:payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
|
6777
|
+
:customer_id => customer.id
|
6778
|
+
)
|
6779
|
+
payment_method_token = result.payment_method.token
|
6780
|
+
|
6781
|
+
result = Braintree::Transaction.sale(
|
6782
|
+
:amount => "112.44",
|
6783
|
+
:payment_method_token => payment_method_token,
|
6784
|
+
)
|
6785
|
+
result.success?.should == true
|
6786
|
+
transaction = result.transaction
|
6787
|
+
|
6788
|
+
transaction.amount.should == BigDecimal("112.44")
|
6789
|
+
transaction.processed_with_network_token?.should == false
|
6790
|
+
end
|
6791
|
+
end
|
7042
6792
|
end
|