braintree 2.101.0 → 3.0.1
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/configuration.rb +1 -1
- data/lib/braintree/credit_card.rb +5 -76
- data/lib/braintree/credit_card_gateway.rb +16 -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 +162 -157
- 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 +16 -8
- data/lib/braintree/payment_method_nonce.rb +2 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +13 -2
- 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/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/test/nonce.rb +19 -20
- data/lib/braintree/transaction.rb +8 -72
- 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 +2 -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 +3 -3
- data/lib/braintree/webhook_notification.rb +3 -10
- data/lib/braintree/webhook_testing_gateway.rb +243 -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 +100 -67
- data/spec/integration/braintree/credit_card_spec.rb +119 -467
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -0
- data/spec/integration/braintree/customer_spec.rb +135 -362
- data/spec/integration/braintree/dispute_search_spec.rb +2 -2
- data/spec/integration/braintree/dispute_spec.rb +1 -2
- data/spec/integration/braintree/document_upload_spec.rb +12 -0
- data/spec/integration/braintree/merchant_spec.rb +2 -2
- data/spec/integration/braintree/payment_method_nonce_spec.rb +77 -0
- data/spec/integration/braintree/payment_method_spec.rb +186 -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 +252 -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 +50 -23
- data/spec/unit/braintree/credit_card_verification_spec.rb +7 -0
- data/spec/unit/braintree/customer_spec.rb +26 -14
- 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 +57 -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 +49 -1
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- metadata +29 -31
- 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
|
@@ -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
|
@@ -46,6 +46,18 @@ describe Braintree::DocumentUploadGateway do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
it "returns file is empty error with empty file" do
|
50
|
+
filename = "#{File.dirname(__FILE__)}/../../fixtures/files/empty_file.png"
|
51
|
+
begin
|
52
|
+
File.open(filename, "w+") {}
|
53
|
+
file = File.new(filename, "r")
|
54
|
+
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
55
|
+
response.errors.for(:document_upload).first.code.should == Braintree::ErrorCodes::DocumentUpload::FileIsEmpty
|
56
|
+
ensure
|
57
|
+
File.delete(filename)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
49
61
|
it "returns file too long error with file over 50 pages" do
|
50
62
|
filename = "#{File.dirname(__FILE__)}/../../fixtures/files/too_long.pdf"
|
51
63
|
file = File.new(filename, "r")
|
@@ -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
|
|
@@ -239,5 +239,82 @@ describe Braintree::PaymentMethodNonce do
|
|
239
239
|
Braintree::PaymentMethodNonce.find("not_a_nonce")
|
240
240
|
end.to raise_error(Braintree::NotFoundError)
|
241
241
|
end
|
242
|
+
|
243
|
+
context "authentication insights" do
|
244
|
+
let(:indian_payment_token) { "india_visa_credit" }
|
245
|
+
let(:european_payment_token) { "european_visa_credit" }
|
246
|
+
let(:indian_merchant_token) { "india_three_d_secure_merchant_account" }
|
247
|
+
let(:european_merchant_token) { "european_three_d_secure_merchant_account" }
|
248
|
+
|
249
|
+
describe "self.create" do
|
250
|
+
it "raises an exception if hash includes an invalid key" do
|
251
|
+
expect do
|
252
|
+
Braintree::PaymentMethodNonce.create("european_visa_credit", :invalid_key => "foo")
|
253
|
+
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
context "regulation environments" do
|
258
|
+
it "can get unregulated" do
|
259
|
+
expect(
|
260
|
+
request_authentication_insights(european_merchant_token, indian_payment_token)[:regulation_environment]
|
261
|
+
).to eq "unregulated"
|
262
|
+
end
|
263
|
+
|
264
|
+
it "can get psd2" do
|
265
|
+
expect(
|
266
|
+
request_authentication_insights(european_merchant_token, european_payment_token)[:regulation_environment]
|
267
|
+
).to eq "psd2"
|
268
|
+
end
|
269
|
+
|
270
|
+
it "can get rbi" do
|
271
|
+
expect(
|
272
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token)[:regulation_environment]
|
273
|
+
).to eq "rbi"
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
context "sca_indicator" do
|
278
|
+
it "can get unavailable" do
|
279
|
+
expect(
|
280
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token)[:sca_indicator]
|
281
|
+
).to eq "unavailable"
|
282
|
+
end
|
283
|
+
|
284
|
+
it "can get sca_required" do
|
285
|
+
expect(
|
286
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2001})[:sca_indicator]
|
287
|
+
).to eq "sca_required"
|
288
|
+
end
|
289
|
+
|
290
|
+
it "can get sca_optional" do
|
291
|
+
expect(
|
292
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2000, recurring_customer_consent: true, recurring_max_amount: 2000})[:sca_indicator]
|
293
|
+
|
294
|
+
).to eq "sca_optional"
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
def request_authentication_insights(merchant_token, payment_method_token, options = {})
|
299
|
+
authentication_insight_options = {
|
300
|
+
amount: options[:amount],
|
301
|
+
recurring_customer_consent: options[:recurring_customer_consent],
|
302
|
+
recurring_max_amount: options[:recurring_max_amount],
|
303
|
+
}
|
304
|
+
nonce_request = {
|
305
|
+
merchant_account_id: merchant_token,
|
306
|
+
authentication_insight: true,
|
307
|
+
authentication_insight_options: authentication_insight_options,
|
308
|
+
}
|
309
|
+
|
310
|
+
result = Braintree::PaymentMethodNonce.create(
|
311
|
+
payment_method_token,
|
312
|
+
payment_method_nonce: nonce_request
|
313
|
+
)
|
314
|
+
result.should be_success
|
315
|
+
|
316
|
+
return result.payment_method_nonce.authentication_insight
|
317
|
+
end
|
318
|
+
end
|
242
319
|
end
|
243
320
|
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
|
@@ -300,6 +273,50 @@ describe Braintree::PaymentMethod do
|
|
300
273
|
result.credit_card_verification.amount.should == BigDecimal("100.00")
|
301
274
|
end
|
302
275
|
|
276
|
+
it "validates presence of three_d_secure_version in 3ds pass thru params" do
|
277
|
+
customer = Braintree::Customer.create!
|
278
|
+
result = Braintree::PaymentMethod.create(
|
279
|
+
:customer_id => customer.id,
|
280
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
281
|
+
:three_d_secure_pass_thru => {
|
282
|
+
:eci_flag => '02',
|
283
|
+
:cavv => 'some_cavv',
|
284
|
+
:xid => 'some_xid',
|
285
|
+
:three_d_secure_version => 'xx',
|
286
|
+
:authentication_response => 'Y',
|
287
|
+
:directory_response => 'Y',
|
288
|
+
:cavv_algorithm => '2',
|
289
|
+
:ds_transaction_id => 'some_ds_transaction_id',
|
290
|
+
},
|
291
|
+
:options => {:verify_card => true}
|
292
|
+
)
|
293
|
+
expect(result).not_to be_success
|
294
|
+
error = result.errors.for(:verification).first
|
295
|
+
expect(error.code).to eq(Braintree::ErrorCodes::Verification::ThreeDSecurePassThru::ThreeDSecureVersionIsInvalid)
|
296
|
+
expect(error.message).to eq("The version of 3D Secure authentication must be composed only of digits and separated by periods (e.g. `1.0.2`).")
|
297
|
+
end
|
298
|
+
|
299
|
+
it "accepts three_d_secure pass thru params in the request" do
|
300
|
+
customer = Braintree::Customer.create!
|
301
|
+
result = Braintree::PaymentMethod.create(
|
302
|
+
:customer_id => customer.id,
|
303
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
304
|
+
:three_d_secure_pass_thru => {
|
305
|
+
:eci_flag => '02',
|
306
|
+
:cavv => 'some_cavv',
|
307
|
+
:xid => 'some_xid',
|
308
|
+
:three_d_secure_version => '1.0.2',
|
309
|
+
:authentication_response => 'Y',
|
310
|
+
:directory_response => 'Y',
|
311
|
+
:cavv_algorithm => '2',
|
312
|
+
:ds_transaction_id => 'some_ds_transaction_id',
|
313
|
+
},
|
314
|
+
:options => {:verify_card => true}
|
315
|
+
)
|
316
|
+
|
317
|
+
expect(result).to be_success
|
318
|
+
end
|
319
|
+
|
303
320
|
it "returns 3DS info on cc verification" do
|
304
321
|
customer = Braintree::Customer.create.customer
|
305
322
|
result = Braintree::PaymentMethod.create(
|
@@ -980,61 +997,61 @@ describe Braintree::PaymentMethod do
|
|
980
997
|
end
|
981
998
|
end
|
982
999
|
|
983
|
-
context "
|
1000
|
+
context "google pay cards" do
|
984
1001
|
it "finds the proxy card payment method with the given token" do
|
985
1002
|
customer = Braintree::Customer.create!
|
986
1003
|
payment_method_token = make_token
|
987
1004
|
result = Braintree::PaymentMethod.create(
|
988
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1005
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
989
1006
|
:customer_id => customer.id,
|
990
1007
|
:token => payment_method_token
|
991
1008
|
)
|
992
1009
|
result.should be_success
|
993
1010
|
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
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
|
1010
1027
|
end
|
1011
1028
|
|
1012
1029
|
it "finds the network token payment method with the given token" do
|
1013
1030
|
customer = Braintree::Customer.create!
|
1014
1031
|
payment_method_token = make_token
|
1015
1032
|
result = Braintree::PaymentMethod.create(
|
1016
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1033
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
|
1017
1034
|
:customer_id => customer.id,
|
1018
1035
|
:token => payment_method_token
|
1019
1036
|
)
|
1020
1037
|
result.should be_success
|
1021
1038
|
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
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
|
1038
1055
|
end
|
1039
1056
|
end
|
1040
1057
|
|
@@ -1066,18 +1083,18 @@ describe Braintree::PaymentMethod do
|
|
1066
1083
|
end
|
1067
1084
|
|
1068
1085
|
describe "self.delete" do
|
1069
|
-
it "deletes an
|
1086
|
+
it "deletes an google pay card" do
|
1070
1087
|
customer = Braintree::Customer.create!
|
1071
1088
|
|
1072
1089
|
create_result = Braintree::PaymentMethod.create(
|
1073
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1090
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1074
1091
|
:customer_id => customer.id
|
1075
1092
|
)
|
1076
1093
|
|
1077
1094
|
token = create_result.payment_method.token
|
1078
1095
|
|
1079
|
-
|
1080
|
-
|
1096
|
+
google_card = Braintree::PaymentMethod.find(token)
|
1097
|
+
google_card.should be_a(Braintree::GooglePayCard)
|
1081
1098
|
|
1082
1099
|
delete_result = Braintree::PaymentMethod.delete(token)
|
1083
1100
|
delete_result.success?.should == true
|
@@ -1169,6 +1186,71 @@ describe Braintree::PaymentMethod do
|
|
1169
1186
|
|
1170
1187
|
describe "self.update" do
|
1171
1188
|
context "credit cards" do
|
1189
|
+
it "throws validation error when passing invalid pass thru params" do
|
1190
|
+
customer = Braintree::Customer.create!
|
1191
|
+
credit_card = Braintree::CreditCard.create!(
|
1192
|
+
:customer_id => customer.id,
|
1193
|
+
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1194
|
+
:options => {:verify_card => true},
|
1195
|
+
)
|
1196
|
+
|
1197
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1198
|
+
:cardholder_name => "New Holder",
|
1199
|
+
:cvv => "456",
|
1200
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1201
|
+
:expiration_date => "06/2013",
|
1202
|
+
:three_d_secure_pass_thru => {
|
1203
|
+
:eci_flag => '02',
|
1204
|
+
:cavv => 'some_cavv',
|
1205
|
+
:xid => 'some_xid',
|
1206
|
+
:three_d_secure_version => 'xx',
|
1207
|
+
:authentication_response => 'Y',
|
1208
|
+
:directory_response => 'Y',
|
1209
|
+
:cavv_algorithm => '2',
|
1210
|
+
:ds_transaction_id => 'some_ds_transaction_id',
|
1211
|
+
},
|
1212
|
+
:options => {:verify_card => true},
|
1213
|
+
)
|
1214
|
+
expect(update_result).to_not be_success
|
1215
|
+
error = update_result.errors.for(:verification).first
|
1216
|
+
expect(error.code).to eq(Braintree::ErrorCodes::Verification::ThreeDSecurePassThru::ThreeDSecureVersionIsInvalid)
|
1217
|
+
expect(error.message).to eq("The version of 3D Secure authentication must be composed only of digits and separated by periods (e.g. `1.0.2`).")
|
1218
|
+
end
|
1219
|
+
|
1220
|
+
it "updates the credit card with three_d_secure pass thru params" do
|
1221
|
+
customer = Braintree::Customer.create!
|
1222
|
+
credit_card = Braintree::CreditCard.create!(
|
1223
|
+
:customer_id => customer.id,
|
1224
|
+
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1225
|
+
:options => {:verify_card => true},
|
1226
|
+
)
|
1227
|
+
|
1228
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1229
|
+
:cardholder_name => "New Holder",
|
1230
|
+
:cvv => "456",
|
1231
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1232
|
+
:expiration_date => "06/2013",
|
1233
|
+
:three_d_secure_pass_thru => {
|
1234
|
+
:eci_flag => '02',
|
1235
|
+
:cavv => 'some_cavv',
|
1236
|
+
:xid => 'some_xid',
|
1237
|
+
:three_d_secure_version => '1.0.2',
|
1238
|
+
:authentication_response => 'Y',
|
1239
|
+
:directory_response => 'Y',
|
1240
|
+
:cavv_algorithm => '2',
|
1241
|
+
:ds_transaction_id => 'some_ds_transaction_id',
|
1242
|
+
},
|
1243
|
+
:options => {:verify_card => true},
|
1244
|
+
)
|
1245
|
+
update_result.success?.should == true
|
1246
|
+
update_result.payment_method.should == credit_card
|
1247
|
+
updated_credit_card = update_result.payment_method
|
1248
|
+
updated_credit_card.cardholder_name.should == "New Holder"
|
1249
|
+
updated_credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
1250
|
+
updated_credit_card.last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
1251
|
+
updated_credit_card.expiration_date.should == "06/2013"
|
1252
|
+
end
|
1253
|
+
|
1172
1254
|
it "updates the credit card" do
|
1173
1255
|
customer = Braintree::Customer.create!
|
1174
1256
|
credit_card = Braintree::CreditCard.create!(
|
@@ -1413,22 +1495,6 @@ describe Braintree::PaymentMethod do
|
|
1413
1495
|
end
|
1414
1496
|
end
|
1415
1497
|
|
1416
|
-
context "coinbase accounts" do
|
1417
|
-
it "cannot create a payment method token with Coinbase" do
|
1418
|
-
customer = Braintree::Customer.create!
|
1419
|
-
|
1420
|
-
nonce = Braintree::Test::Nonce::Coinbase
|
1421
|
-
result = Braintree::PaymentMethod.create(
|
1422
|
-
:payment_method_nonce => nonce,
|
1423
|
-
:customer_id => customer.id
|
1424
|
-
)
|
1425
|
-
|
1426
|
-
result.should_not be_success
|
1427
|
-
|
1428
|
-
result.errors.for(:coinbase_account).first.code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNoLongerSupported
|
1429
|
-
end
|
1430
|
-
end
|
1431
|
-
|
1432
1498
|
context "paypal accounts" do
|
1433
1499
|
it "updates a paypal account's token" do
|
1434
1500
|
customer = Braintree::Customer.create!
|
@@ -1630,7 +1696,7 @@ describe Braintree::PaymentMethod do
|
|
1630
1696
|
it "raises an error if the token isn't found" do
|
1631
1697
|
expect do
|
1632
1698
|
@granting_gateway.payment_method.grant("not_a_real_token", false)
|
1633
|
-
end.to raise_error
|
1699
|
+
end.to raise_error(Braintree::NotFoundError)
|
1634
1700
|
end
|
1635
1701
|
|
1636
1702
|
it "returns a valid nonce with no options set" do
|
@@ -1645,7 +1711,7 @@ describe Braintree::PaymentMethod do
|
|
1645
1711
|
it "raises an error if the token isn't found" do
|
1646
1712
|
expect do
|
1647
1713
|
@granting_gateway.payment_method.revoke("not_a_real_token")
|
1648
|
-
end.to raise_error
|
1714
|
+
end.to raise_error(Braintree::NotFoundError)
|
1649
1715
|
end
|
1650
1716
|
|
1651
1717
|
it "renders a granted nonce useless" do
|