braintree 2.104.1 → 3.4.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 +7 -4
- data/lib/braintree.rb +7 -18
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +1 -23
- data/lib/braintree/apple_pay.rb +1 -1
- data/lib/braintree/apple_pay_card.rb +1 -1
- data/lib/braintree/apple_pay_options.rb +1 -1
- data/lib/braintree/authorization_adjustment.rb +1 -1
- data/lib/braintree/base_module.rb +6 -0
- data/lib/braintree/bin_data.rb +9 -2
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +12 -12
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +2 -77
- data/lib/braintree/credit_card_gateway.rb +7 -36
- data/lib/braintree/credit_card_verification.rb +18 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +5 -76
- data/lib/braintree/customer_gateway.rb +0 -23
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +2 -8
- data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
- data/lib/braintree/dispute_gateway.rb +4 -9
- data/lib/braintree/dispute_search.rb +2 -2
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/error_codes.rb +151 -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} +2 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +7 -7
- data/lib/braintree/http.rb +3 -3
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +1 -1
- data/lib/braintree/merchant_account.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +3 -1
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +1 -1
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/payment_instrument_type.rb +10 -14
- data/lib/braintree/payment_method_gateway.rb +8 -13
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/payment_method_parser.rb +1 -8
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +3 -1
- data/lib/braintree/samsung_pay_card.rb +1 -1
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/subscription.rb +11 -11
- data/lib/braintree/successful_result.rb +0 -1
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/test/nonce.rb +4 -23
- data/lib/braintree/three_d_secure_info.rb +22 -12
- data/lib/braintree/transaction.rb +44 -104
- 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/installment.rb +28 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/paypal_details.rb +1 -0
- data/lib/braintree/transaction/subscription_details.rb +2 -0
- data/lib/braintree/transaction_gateway.rb +37 -25
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_search.rb +3 -2
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +3 -3
- data/lib/braintree/us_bank_account_verification.rb +1 -1
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/util.rb +21 -6
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/version.rb +3 -3
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +28 -29
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +10 -43
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/libxml.rb +1 -0
- data/lib/braintree/xml/parser.rb +21 -44
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +26 -113
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +3 -3
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
- data/spec/integration/braintree/client_api/spec_helper.rb +5 -31
- data/spec/integration/braintree/credit_card_spec.rb +130 -593
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +336 -509
- data/spec/integration/braintree/dispute_search_spec.rb +6 -6
- data/spec/integration/braintree/dispute_spec.rb +6 -7
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +2 -2
- data/spec/integration/braintree/merchant_account_spec.rb +25 -26
- data/spec/integration/braintree/merchant_spec.rb +14 -14
- data/spec/integration/braintree/oauth_spec.rb +11 -11
- data/spec/integration/braintree/payment_method_nonce_spec.rb +12 -12
- data/spec/integration/braintree/payment_method_spec.rb +403 -269
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
- data/spec/integration/braintree/paypal_account_spec.rb +28 -28
- data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +144 -149
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +10 -10
- data/spec/integration/braintree/transaction_search_spec.rb +96 -70
- data/spec/integration/braintree/transaction_spec.rb +832 -904
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
- data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +10 -7
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +6 -14
- data/spec/unit/braintree/address_spec.rb +1 -9
- data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +42 -42
- data/spec/unit/braintree/credit_card_spec.rb +9 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
- data/spec/unit/braintree/customer_spec.rb +5 -16
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_spec.rb +9 -20
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/http_spec.rb +8 -8
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +30 -1
- data/spec/unit/braintree/risk_data_spec.rb +9 -5
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +3 -1
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +25 -51
- data/spec/unit/braintree/util_spec.rb +55 -21
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/webhook_notification_spec.rb +73 -57
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +30 -31
- data/lib/braintree/amex_express_checkout_card.rb +0 -40
- data/lib/braintree/coinbase_account.rb +0 -34
- data/lib/braintree/europe_bank_account.rb +0 -36
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -61
- data/lib/braintree/ideal_payment_gateway.rb +0 -19
- data/lib/braintree/masterpass_card.rb +0 -83
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
- data/lib/braintree/transaction/coinbase_details.rb +0 -16
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
- data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/lib/braintree/xml/rexml.rb +0 -71
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/integration/braintree/coinbase_spec.rb +0 -34
- data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
- data/spec/unit/braintree/xml/rexml_spec.rb +0 -51
@@ -12,12 +12,12 @@ describe Braintree::PaymentMethodNonce do
|
|
12
12
|
:number => "4111111111111111",
|
13
13
|
:expiration_month => "11",
|
14
14
|
:expiration_year => "2099",
|
15
|
-
}
|
15
|
+
},
|
16
16
|
)
|
17
17
|
|
18
18
|
result = Braintree::PaymentMethod.create(
|
19
19
|
:payment_method_nonce => nonce,
|
20
|
-
:customer_id => customer.id
|
20
|
+
:customer_id => customer.id,
|
21
21
|
)
|
22
22
|
|
23
23
|
result.should be_success
|
@@ -49,12 +49,12 @@ describe Braintree::PaymentMethodNonce do
|
|
49
49
|
:number => "4111111111111111",
|
50
50
|
:expiration_month => "11",
|
51
51
|
:expiration_year => "2099",
|
52
|
-
}
|
52
|
+
},
|
53
53
|
)
|
54
54
|
|
55
55
|
payment_method = Braintree::PaymentMethod.create!(
|
56
56
|
:payment_method_nonce => nonce,
|
57
|
-
:customer_id => customer.id
|
57
|
+
:customer_id => customer.id,
|
58
58
|
)
|
59
59
|
|
60
60
|
payment_method.should be_a(Braintree::CreditCard)
|
@@ -114,7 +114,7 @@ describe Braintree::PaymentMethodNonce do
|
|
114
114
|
:number => "4111111111111111",
|
115
115
|
:expiration_month => "11",
|
116
116
|
:expiration_year => "2099",
|
117
|
-
}
|
117
|
+
},
|
118
118
|
)
|
119
119
|
|
120
120
|
result = Braintree::PaymentMethodNonce.find(nonce)
|
@@ -257,19 +257,19 @@ describe Braintree::PaymentMethodNonce do
|
|
257
257
|
context "regulation environments" do
|
258
258
|
it "can get unregulated" do
|
259
259
|
expect(
|
260
|
-
request_authentication_insights(european_merchant_token, indian_payment_token)[:regulation_environment]
|
260
|
+
request_authentication_insights(european_merchant_token, indian_payment_token)[:regulation_environment],
|
261
261
|
).to eq "unregulated"
|
262
262
|
end
|
263
263
|
|
264
264
|
it "can get psd2" do
|
265
265
|
expect(
|
266
|
-
request_authentication_insights(european_merchant_token, european_payment_token)[:regulation_environment]
|
266
|
+
request_authentication_insights(european_merchant_token, european_payment_token)[:regulation_environment],
|
267
267
|
).to eq "psd2"
|
268
268
|
end
|
269
269
|
|
270
270
|
it "can get rbi" do
|
271
271
|
expect(
|
272
|
-
request_authentication_insights(indian_merchant_token, indian_payment_token)[:regulation_environment]
|
272
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token)[:regulation_environment],
|
273
273
|
).to eq "rbi"
|
274
274
|
end
|
275
275
|
end
|
@@ -277,19 +277,19 @@ describe Braintree::PaymentMethodNonce do
|
|
277
277
|
context "sca_indicator" do
|
278
278
|
it "can get unavailable" do
|
279
279
|
expect(
|
280
|
-
request_authentication_insights(indian_merchant_token, indian_payment_token)[:sca_indicator]
|
280
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token)[:sca_indicator],
|
281
281
|
).to eq "unavailable"
|
282
282
|
end
|
283
283
|
|
284
284
|
it "can get sca_required" do
|
285
285
|
expect(
|
286
|
-
request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2001})[:sca_indicator]
|
286
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2001})[:sca_indicator],
|
287
287
|
).to eq "sca_required"
|
288
288
|
end
|
289
289
|
|
290
290
|
it "can get sca_optional" do
|
291
291
|
expect(
|
292
|
-
request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2000, recurring_customer_consent: true, recurring_max_amount: 2000})[:sca_indicator]
|
292
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2000, recurring_customer_consent: true, recurring_max_amount: 2000})[:sca_indicator],
|
293
293
|
|
294
294
|
).to eq "sca_optional"
|
295
295
|
end
|
@@ -309,7 +309,7 @@ describe Braintree::PaymentMethodNonce do
|
|
309
309
|
|
310
310
|
result = Braintree::PaymentMethodNonce.create(
|
311
311
|
payment_method_token,
|
312
|
-
payment_method_nonce: nonce_request
|
312
|
+
payment_method_nonce: nonce_request,
|
313
313
|
)
|
314
314
|
result.should be_success
|
315
315
|
|
@@ -17,20 +17,20 @@ describe Braintree::PaymentMethod do
|
|
17
17
|
config,
|
18
18
|
:authorization_fingerprint => authorization_fingerprint,
|
19
19
|
:shared_customer_identifier => "fake_identifier",
|
20
|
-
:shared_customer_identifier_type => "testing"
|
20
|
+
:shared_customer_identifier_type => "testing",
|
21
21
|
)
|
22
22
|
|
23
23
|
response = http.create_credit_card(
|
24
24
|
:number => 4111111111111111,
|
25
25
|
:expirationMonth => 12,
|
26
|
-
:expirationYear => 2020
|
26
|
+
:expirationYear => 2020,
|
27
27
|
)
|
28
28
|
response.code.should == "201"
|
29
29
|
|
30
30
|
nonce = JSON.parse(response.body)["creditCards"].first["nonce"]
|
31
31
|
result = Braintree::PaymentMethod.create(
|
32
32
|
:payment_method_nonce => nonce,
|
33
|
-
:customer_id => customer.id
|
33
|
+
:customer_id => customer.id,
|
34
34
|
)
|
35
35
|
|
36
36
|
result.should be_success
|
@@ -51,21 +51,21 @@ describe Braintree::PaymentMethod do
|
|
51
51
|
config,
|
52
52
|
:authorization_fingerprint => authorization_fingerprint,
|
53
53
|
:shared_customer_identifier => "fake_identifier",
|
54
|
-
:shared_customer_identifier_type => "testing"
|
54
|
+
:shared_customer_identifier_type => "testing",
|
55
55
|
)
|
56
56
|
|
57
57
|
response = http.create_credit_card(
|
58
58
|
:number => "4111111111111111",
|
59
59
|
:expirationMonth => "12",
|
60
60
|
:expirationYear => "2020",
|
61
|
-
:options => {:validate => false}
|
61
|
+
:options => {:validate => false},
|
62
62
|
)
|
63
63
|
response.code.should == "202"
|
64
64
|
|
65
65
|
nonce = JSON.parse(response.body)["creditCards"].first["nonce"]
|
66
66
|
result = Braintree::PaymentMethod.create(
|
67
67
|
:payment_method_nonce => nonce,
|
68
|
-
:customer_id => customer.id
|
68
|
+
:customer_id => customer.id,
|
69
69
|
)
|
70
70
|
|
71
71
|
result.should be_success
|
@@ -82,7 +82,7 @@ describe Braintree::PaymentMethod do
|
|
82
82
|
result = Braintree::PaymentMethod.create(
|
83
83
|
:payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
|
84
84
|
:customer_id => customer.id,
|
85
|
-
:token => token
|
85
|
+
:token => token,
|
86
86
|
)
|
87
87
|
|
88
88
|
result.should be_success
|
@@ -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
|
105
|
-
customer = Braintree::Customer.create.customer
|
106
|
-
token = SecureRandom.hex(16)
|
107
|
-
result = Braintree::PaymentMethod.create(
|
108
|
-
:payment_method_nonce => Braintree::Test::Nonce::AndroidPayDiscover,
|
109
|
-
:customer_id => customer.id,
|
110
|
-
:token => token
|
111
|
-
)
|
112
|
-
|
113
|
-
result.should be_success
|
114
|
-
android_pay_card = result.payment_method
|
115
|
-
android_pay_card.should be_a(Braintree::AndroidPayCard)
|
116
|
-
android_pay_card.should_not be_nil
|
117
|
-
android_pay_card.token.should == token
|
118
|
-
android_pay_card.card_type.should == Braintree::CreditCard::CardType::Discover
|
119
|
-
android_pay_card.virtual_card_type.should == Braintree::CreditCard::CardType::Discover
|
120
|
-
android_pay_card.expiration_month.to_i.should > 0
|
121
|
-
android_pay_card.expiration_year.to_i.should > 0
|
122
|
-
android_pay_card.default.should == true
|
123
|
-
android_pay_card.image_url.should =~ /android_pay/
|
124
|
-
android_pay_card.is_network_tokenized?.should == false
|
125
|
-
android_pay_card.source_card_type.should == Braintree::CreditCard::CardType::Discover
|
126
|
-
android_pay_card.source_card_last_4.should == "1111"
|
127
|
-
android_pay_card.google_transaction_id.should == "google_transaction_id"
|
128
|
-
android_pay_card.source_description.should == "Discover 1111"
|
129
|
-
android_pay_card.customer_id.should == customer.id
|
130
|
-
end
|
131
|
-
|
132
|
-
it "creates a payment method from a android pay network token nonce" do
|
104
|
+
it "creates a payment method from a fake google pay proxy card nonce" do
|
133
105
|
customer = Braintree::Customer.create.customer
|
134
106
|
token = SecureRandom.hex(16)
|
135
107
|
result = Braintree::PaymentMethod.create(
|
136
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
108
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
137
109
|
:customer_id => customer.id,
|
138
|
-
:token => token
|
110
|
+
:token => token,
|
139
111
|
)
|
140
112
|
|
141
113
|
result.should be_success
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
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
|
158
130
|
end
|
159
131
|
|
160
|
-
it "creates a payment method from
|
132
|
+
it "creates a payment method from a google pay network token nonce" do
|
161
133
|
customer = Braintree::Customer.create.customer
|
162
134
|
token = SecureRandom.hex(16)
|
163
135
|
result = Braintree::PaymentMethod.create(
|
164
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
136
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
|
165
137
|
:customer_id => customer.id,
|
166
|
-
:token => token
|
138
|
+
:token => token,
|
167
139
|
)
|
168
140
|
|
169
141
|
result.should be_success
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
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
|
@@ -190,7 +163,7 @@ describe Braintree::PaymentMethod do
|
|
190
163
|
result = Braintree::PaymentMethod.create(
|
191
164
|
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
192
165
|
:customer_id => customer.id,
|
193
|
-
:token => token
|
166
|
+
:token => token,
|
194
167
|
)
|
195
168
|
|
196
169
|
result.should be_success
|
@@ -212,7 +185,7 @@ describe Braintree::PaymentMethod do
|
|
212
185
|
:customer_id => customer.id,
|
213
186
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
214
187
|
:expiration_date => "05/2009",
|
215
|
-
:cvv => "100"
|
188
|
+
:cvv => "100",
|
216
189
|
)
|
217
190
|
result.success?.should == true
|
218
191
|
original_payment_method = result.credit_card
|
@@ -222,7 +195,7 @@ describe Braintree::PaymentMethod do
|
|
222
195
|
result = Braintree::PaymentMethod.create(
|
223
196
|
:payment_method_nonce => nonce,
|
224
197
|
:customer_id => customer.id,
|
225
|
-
:options => {:make_default => true}
|
198
|
+
:options => {:make_default => true},
|
226
199
|
)
|
227
200
|
|
228
201
|
result.should be_success
|
@@ -237,12 +210,12 @@ describe Braintree::PaymentMethod do
|
|
237
210
|
second_token = make_token
|
238
211
|
nonce = nonce_for_paypal_account(
|
239
212
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
240
|
-
:token => first_token
|
213
|
+
:token => first_token,
|
241
214
|
)
|
242
215
|
result = Braintree::PaymentMethod.create(
|
243
216
|
:payment_method_nonce => nonce,
|
244
217
|
:customer_id => customer.id,
|
245
|
-
:token => second_token
|
218
|
+
:token => second_token,
|
246
219
|
)
|
247
220
|
|
248
221
|
result.should be_success
|
@@ -256,7 +229,7 @@ describe Braintree::PaymentMethod do
|
|
256
229
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
257
230
|
:expiration_month => "11",
|
258
231
|
:expiration_year => "2099",
|
259
|
-
}
|
232
|
+
},
|
260
233
|
)
|
261
234
|
customer = Braintree::Customer.create!
|
262
235
|
result = Braintree::PaymentMethod.create(
|
@@ -265,7 +238,7 @@ describe Braintree::PaymentMethod do
|
|
265
238
|
:options => {
|
266
239
|
:verify_card => true,
|
267
240
|
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
268
|
-
}
|
241
|
+
},
|
269
242
|
)
|
270
243
|
|
271
244
|
result.should_not be_success
|
@@ -281,7 +254,7 @@ describe Braintree::PaymentMethod do
|
|
281
254
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
282
255
|
:expiration_month => "11",
|
283
256
|
:expiration_year => "2099",
|
284
|
-
}
|
257
|
+
},
|
285
258
|
)
|
286
259
|
customer = Braintree::Customer.create!
|
287
260
|
result = Braintree::PaymentMethod.create(
|
@@ -290,7 +263,7 @@ describe Braintree::PaymentMethod do
|
|
290
263
|
:options => {
|
291
264
|
:verify_card => true,
|
292
265
|
:verification_amount => "100.00"
|
293
|
-
}
|
266
|
+
},
|
294
267
|
)
|
295
268
|
|
296
269
|
result.should_not be_success
|
@@ -306,16 +279,16 @@ describe Braintree::PaymentMethod do
|
|
306
279
|
:customer_id => customer.id,
|
307
280
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
308
281
|
:three_d_secure_pass_thru => {
|
309
|
-
:eci_flag =>
|
310
|
-
:cavv =>
|
311
|
-
:xid =>
|
312
|
-
:three_d_secure_version =>
|
313
|
-
:authentication_response =>
|
314
|
-
:directory_response =>
|
315
|
-
:cavv_algorithm =>
|
316
|
-
:ds_transaction_id =>
|
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",
|
317
290
|
},
|
318
|
-
:options => {:verify_card => true}
|
291
|
+
:options => {:verify_card => true},
|
319
292
|
)
|
320
293
|
expect(result).not_to be_success
|
321
294
|
error = result.errors.for(:verification).first
|
@@ -329,16 +302,16 @@ describe Braintree::PaymentMethod do
|
|
329
302
|
:customer_id => customer.id,
|
330
303
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
331
304
|
:three_d_secure_pass_thru => {
|
332
|
-
:eci_flag =>
|
333
|
-
:cavv =>
|
334
|
-
:xid =>
|
335
|
-
:three_d_secure_version =>
|
336
|
-
:authentication_response =>
|
337
|
-
:directory_response =>
|
338
|
-
:cavv_algorithm =>
|
339
|
-
:ds_transaction_id =>
|
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",
|
340
313
|
},
|
341
|
-
:options => {:verify_card => true}
|
314
|
+
:options => {:verify_card => true},
|
342
315
|
)
|
343
316
|
|
344
317
|
expect(result).to be_success
|
@@ -370,7 +343,7 @@ describe Braintree::PaymentMethod do
|
|
370
343
|
result = Braintree::CreditCard.create(
|
371
344
|
:customer_id => customer.id,
|
372
345
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
373
|
-
:expiration_date => "05/2012"
|
346
|
+
:expiration_date => "05/2012",
|
374
347
|
)
|
375
348
|
result.should be_success
|
376
349
|
|
@@ -378,14 +351,14 @@ describe Braintree::PaymentMethod do
|
|
378
351
|
:credit_card => {
|
379
352
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
380
353
|
:expiration_date => "05/2012"
|
381
|
-
}
|
354
|
+
},
|
382
355
|
)
|
383
356
|
result = Braintree::PaymentMethod.create(
|
384
357
|
:payment_method_nonce => nonce,
|
385
358
|
:customer_id => customer.id,
|
386
359
|
:options => {
|
387
360
|
:fail_on_duplicate_payment_method => true
|
388
|
-
}
|
361
|
+
},
|
389
362
|
)
|
390
363
|
|
391
364
|
result.should_not be_success
|
@@ -402,14 +375,14 @@ describe Braintree::PaymentMethod do
|
|
402
375
|
config,
|
403
376
|
:authorization_fingerprint => authorization_fingerprint,
|
404
377
|
:shared_customer_identifier => "fake_identifier",
|
405
|
-
:shared_customer_identifier_type => "testing"
|
378
|
+
:shared_customer_identifier_type => "testing",
|
406
379
|
)
|
407
380
|
|
408
381
|
response = http.create_credit_card(
|
409
382
|
:number => "4111111111111111",
|
410
383
|
:expirationMonth => "12",
|
411
384
|
:expirationYear => "2020",
|
412
|
-
:options => {:validate => false}
|
385
|
+
:options => {:validate => false},
|
413
386
|
)
|
414
387
|
response.code.should == "202"
|
415
388
|
|
@@ -419,7 +392,7 @@ describe Braintree::PaymentMethod do
|
|
419
392
|
:customer_id => customer.id,
|
420
393
|
:billing_address => {
|
421
394
|
:street_address => "123 Abc Way"
|
422
|
-
}
|
395
|
+
},
|
423
396
|
)
|
424
397
|
|
425
398
|
result.should be_success
|
@@ -441,14 +414,14 @@ describe Braintree::PaymentMethod do
|
|
441
414
|
config,
|
442
415
|
:authorization_fingerprint => authorization_fingerprint,
|
443
416
|
:shared_customer_identifier => "fake_identifier",
|
444
|
-
:shared_customer_identifier_type => "testing"
|
417
|
+
:shared_customer_identifier_type => "testing",
|
445
418
|
)
|
446
419
|
|
447
420
|
response = http.create_credit_card(
|
448
421
|
:number => "4111111111111111",
|
449
422
|
:expirationMonth => "12",
|
450
423
|
:expirationYear => "2020",
|
451
|
-
:options => {:validate => false}
|
424
|
+
:options => {:validate => false},
|
452
425
|
)
|
453
426
|
response.code.should == "202"
|
454
427
|
|
@@ -458,7 +431,7 @@ describe Braintree::PaymentMethod do
|
|
458
431
|
result = Braintree::PaymentMethod.create(
|
459
432
|
:payment_method_nonce => nonce,
|
460
433
|
:customer_id => customer.id,
|
461
|
-
:billing_address_id => address.id
|
434
|
+
:billing_address_id => address.id,
|
462
435
|
)
|
463
436
|
|
464
437
|
result.should be_success
|
@@ -481,7 +454,7 @@ describe Braintree::PaymentMethod do
|
|
481
454
|
config,
|
482
455
|
:authorization_fingerprint => authorization_fingerprint,
|
483
456
|
:shared_customer_identifier => "fake_identifier",
|
484
|
-
:shared_customer_identifier_type => "testing"
|
457
|
+
:shared_customer_identifier_type => "testing",
|
485
458
|
)
|
486
459
|
|
487
460
|
response = http.create_credit_card(
|
@@ -491,7 +464,7 @@ describe Braintree::PaymentMethod do
|
|
491
464
|
:options => {:validate => false},
|
492
465
|
:billing_address => {
|
493
466
|
:street_address => "456 Xyz Way"
|
494
|
-
}
|
467
|
+
},
|
495
468
|
)
|
496
469
|
response.code.should == "202"
|
497
470
|
|
@@ -501,7 +474,7 @@ describe Braintree::PaymentMethod do
|
|
501
474
|
:customer_id => customer.id,
|
502
475
|
:billing_address => {
|
503
476
|
:street_address => "123 Abc Way"
|
504
|
-
}
|
477
|
+
},
|
505
478
|
)
|
506
479
|
|
507
480
|
result.should be_success
|
@@ -523,7 +496,7 @@ describe Braintree::PaymentMethod do
|
|
523
496
|
config,
|
524
497
|
:authorization_fingerprint => authorization_fingerprint,
|
525
498
|
:shared_customer_identifier => "fake_identifier",
|
526
|
-
:shared_customer_identifier_type => "testing"
|
499
|
+
:shared_customer_identifier_type => "testing",
|
527
500
|
)
|
528
501
|
|
529
502
|
response = http.create_credit_card(
|
@@ -532,7 +505,7 @@ describe Braintree::PaymentMethod do
|
|
532
505
|
:expirationYear => 2020,
|
533
506
|
:billing_address => {
|
534
507
|
:street_address => "456 Xyz Way"
|
535
|
-
}
|
508
|
+
},
|
536
509
|
)
|
537
510
|
response.code.should == "201"
|
538
511
|
|
@@ -542,7 +515,7 @@ describe Braintree::PaymentMethod do
|
|
542
515
|
:customer_id => customer.id,
|
543
516
|
:billing_address => {
|
544
517
|
:street_address => "123 Abc Way"
|
545
|
-
}
|
518
|
+
},
|
546
519
|
)
|
547
520
|
|
548
521
|
result.should be_success
|
@@ -561,7 +534,7 @@ describe Braintree::PaymentMethod do
|
|
561
534
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
562
535
|
:expiration_month => "11",
|
563
536
|
:expiration_year => "2099",
|
564
|
-
}
|
537
|
+
},
|
565
538
|
)
|
566
539
|
customer = Braintree::Customer.create!
|
567
540
|
result = Braintree::PaymentMethod.create(
|
@@ -571,7 +544,7 @@ describe Braintree::PaymentMethod do
|
|
571
544
|
:verify_card => true,
|
572
545
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
573
546
|
:verification_account_type => "debit",
|
574
|
-
}
|
547
|
+
},
|
575
548
|
)
|
576
549
|
|
577
550
|
result.should be_success
|
@@ -584,7 +557,7 @@ describe Braintree::PaymentMethod do
|
|
584
557
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
585
558
|
:expiration_month => "11",
|
586
559
|
:expiration_year => "2099",
|
587
|
-
}
|
560
|
+
},
|
588
561
|
)
|
589
562
|
customer = Braintree::Customer.create!
|
590
563
|
result = Braintree::PaymentMethod.create(
|
@@ -594,7 +567,7 @@ describe Braintree::PaymentMethod do
|
|
594
567
|
:verify_card => true,
|
595
568
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
596
569
|
:verification_account_type => "credit",
|
597
|
-
}
|
570
|
+
},
|
598
571
|
)
|
599
572
|
|
600
573
|
result.should be_success
|
@@ -607,7 +580,7 @@ describe Braintree::PaymentMethod do
|
|
607
580
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
608
581
|
:expiration_month => "11",
|
609
582
|
:expiration_year => "2099",
|
610
|
-
}
|
583
|
+
},
|
611
584
|
)
|
612
585
|
customer = Braintree::Customer.create!
|
613
586
|
result = Braintree::PaymentMethod.create(
|
@@ -617,7 +590,7 @@ describe Braintree::PaymentMethod do
|
|
617
590
|
:verify_card => true,
|
618
591
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
619
592
|
:verification_account_type => "ach",
|
620
|
-
}
|
593
|
+
},
|
621
594
|
)
|
622
595
|
|
623
596
|
result.should_not be_success
|
@@ -630,7 +603,7 @@ describe Braintree::PaymentMethod do
|
|
630
603
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
631
604
|
:expiration_month => "11",
|
632
605
|
:expiration_year => "2099",
|
633
|
-
}
|
606
|
+
},
|
634
607
|
)
|
635
608
|
customer = Braintree::Customer.create!
|
636
609
|
result = Braintree::PaymentMethod.create(
|
@@ -639,7 +612,7 @@ describe Braintree::PaymentMethod do
|
|
639
612
|
:options => {
|
640
613
|
:verify_card => true,
|
641
614
|
:verification_account_type => "credit",
|
642
|
-
}
|
615
|
+
},
|
643
616
|
)
|
644
617
|
|
645
618
|
result.should_not be_success
|
@@ -653,7 +626,7 @@ describe Braintree::PaymentMethod do
|
|
653
626
|
:customer_id => customer.id,
|
654
627
|
:cvv => "123",
|
655
628
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
656
|
-
:expiration_date => "05/2012"
|
629
|
+
:expiration_date => "05/2012",
|
657
630
|
)
|
658
631
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
659
632
|
:cardholder_name => "New Holder",
|
@@ -677,7 +650,7 @@ describe Braintree::PaymentMethod do
|
|
677
650
|
:customer_id => customer.id,
|
678
651
|
:cvv => "123",
|
679
652
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
680
|
-
:expiration_date => "05/2012"
|
653
|
+
:expiration_date => "05/2012",
|
681
654
|
)
|
682
655
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
683
656
|
:cardholder_name => "New Holder",
|
@@ -701,7 +674,7 @@ describe Braintree::PaymentMethod do
|
|
701
674
|
customer = Braintree::Customer.create.customer
|
702
675
|
result = Braintree::PaymentMethod.create(
|
703
676
|
:payment_method_nonce => nonce,
|
704
|
-
:customer_id => customer.id
|
677
|
+
:customer_id => customer.id,
|
705
678
|
)
|
706
679
|
|
707
680
|
result.should be_success
|
@@ -778,7 +751,7 @@ describe Braintree::PaymentMethod do
|
|
778
751
|
nonce = nonce_for_paypal_account(:access_token => "PAYPAL_ACCESS_TOKEN")
|
779
752
|
result = Braintree::PaymentMethod.create(
|
780
753
|
:payment_method_nonce => nonce,
|
781
|
-
:customer_id => customer.id
|
754
|
+
:customer_id => customer.id,
|
782
755
|
)
|
783
756
|
|
784
757
|
result.should_not be_success
|
@@ -793,7 +766,7 @@ describe Braintree::PaymentMethod do
|
|
793
766
|
:customer_id => customer.id,
|
794
767
|
:billing_address => {
|
795
768
|
:street_address => "123 Abc Way"
|
796
|
-
}
|
769
|
+
},
|
797
770
|
)
|
798
771
|
|
799
772
|
result.should be_success
|
@@ -811,7 +784,7 @@ describe Braintree::PaymentMethod do
|
|
811
784
|
result = Braintree::PaymentMethod.create(
|
812
785
|
:payment_method_nonce => nonce,
|
813
786
|
:customer_id => customer.id,
|
814
|
-
:billing_address_id => "address_id"
|
787
|
+
:billing_address_id => "address_id",
|
815
788
|
)
|
816
789
|
|
817
790
|
result.should be_success
|
@@ -828,7 +801,7 @@ describe Braintree::PaymentMethod do
|
|
828
801
|
nonce = nonce_for_paypal_account(:token => "PAYPAL_TOKEN")
|
829
802
|
result = Braintree::PaymentMethod.create(
|
830
803
|
:payment_method_nonce => nonce,
|
831
|
-
:customer_id => customer.id
|
804
|
+
:customer_id => customer.id,
|
832
805
|
)
|
833
806
|
|
834
807
|
result.should_not be_success
|
@@ -842,7 +815,7 @@ describe Braintree::PaymentMethod do
|
|
842
815
|
original_token = random_payment_method_token
|
843
816
|
nonce = nonce_for_paypal_account(
|
844
817
|
:consent_code => "consent-code",
|
845
|
-
:token => original_token
|
818
|
+
:token => original_token,
|
846
819
|
)
|
847
820
|
|
848
821
|
result = Braintree::PaymentMethod.create(
|
@@ -852,7 +825,7 @@ describe Braintree::PaymentMethod do
|
|
852
825
|
:verify_card => true,
|
853
826
|
:fail_on_duplicate_payment_method => true,
|
854
827
|
:verification_merchant_account_id => "not_a_real_merchant_account_id"
|
855
|
-
}
|
828
|
+
},
|
856
829
|
)
|
857
830
|
|
858
831
|
result.should be_success
|
@@ -866,7 +839,7 @@ describe Braintree::PaymentMethod do
|
|
866
839
|
result = Braintree::PaymentMethod.create(
|
867
840
|
:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable,
|
868
841
|
:customer_id => customer.id,
|
869
|
-
:token => token
|
842
|
+
:token => token,
|
870
843
|
)
|
871
844
|
|
872
845
|
result.should be_success
|
@@ -876,6 +849,99 @@ describe Braintree::PaymentMethod do
|
|
876
849
|
payment_method.should be_a Braintree::UnknownPaymentMethod
|
877
850
|
end
|
878
851
|
end
|
852
|
+
|
853
|
+
context "verification_currency_iso_code" do
|
854
|
+
it "validates verification_currency_iso_code against currency configured in default merchant account" do
|
855
|
+
nonce = nonce_for_new_payment_method(
|
856
|
+
:credit_card => {
|
857
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
858
|
+
:expiration_month => "11",
|
859
|
+
:expiration_year => "2099",
|
860
|
+
},
|
861
|
+
)
|
862
|
+
customer = Braintree::Customer.create!
|
863
|
+
result = Braintree::PaymentMethod.create(
|
864
|
+
:payment_method_nonce => nonce,
|
865
|
+
:customer_id => customer.id,
|
866
|
+
:options => {
|
867
|
+
:verify_card => true,
|
868
|
+
:verification_currency_iso_code => "USD"
|
869
|
+
},
|
870
|
+
)
|
871
|
+
|
872
|
+
result.should be_success
|
873
|
+
result.payment_method.verification.currency_iso_code == "USD"
|
874
|
+
end
|
875
|
+
|
876
|
+
it "validates verification_currency_iso_code against currency configured in verification_merchant_account_id" do
|
877
|
+
nonce = nonce_for_new_payment_method(
|
878
|
+
:credit_card => {
|
879
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
880
|
+
:expiration_month => "11",
|
881
|
+
:expiration_year => "2099",
|
882
|
+
},
|
883
|
+
)
|
884
|
+
customer = Braintree::Customer.create!
|
885
|
+
result = Braintree::PaymentMethod.create(
|
886
|
+
:payment_method_nonce => nonce,
|
887
|
+
:customer_id => customer.id,
|
888
|
+
:options => {
|
889
|
+
:verify_card => true,
|
890
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
891
|
+
:verification_currency_iso_code => "USD"
|
892
|
+
},
|
893
|
+
)
|
894
|
+
|
895
|
+
result.should be_success
|
896
|
+
result.payment_method.verification.currency_iso_code == "USD"
|
897
|
+
result.payment_method.verification.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
|
898
|
+
end
|
899
|
+
|
900
|
+
|
901
|
+
it "errors with invalid presentment currency due to verification_currency_iso_code not matching with currency configured in default merchant account" do
|
902
|
+
nonce = nonce_for_new_payment_method(
|
903
|
+
:credit_card => {
|
904
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
905
|
+
:expiration_month => "11",
|
906
|
+
:expiration_year => "2099",
|
907
|
+
},
|
908
|
+
)
|
909
|
+
customer = Braintree::Customer.create!
|
910
|
+
result = Braintree::PaymentMethod.create(
|
911
|
+
:payment_method_nonce => nonce,
|
912
|
+
:customer_id => customer.id,
|
913
|
+
:options => {
|
914
|
+
:verify_card => true,
|
915
|
+
:verification_currency_iso_code => "GBP"
|
916
|
+
},
|
917
|
+
)
|
918
|
+
result.should_not be_success
|
919
|
+
result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
920
|
+
end
|
921
|
+
|
922
|
+
it "errors with invalid presentment currency due to verification_currency_iso_code not matching with currency configured in verification_merchant_account_id" do
|
923
|
+
nonce = nonce_for_new_payment_method(
|
924
|
+
:credit_card => {
|
925
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
926
|
+
:expiration_month => "11",
|
927
|
+
:expiration_year => "2099",
|
928
|
+
},
|
929
|
+
)
|
930
|
+
customer = Braintree::Customer.create!
|
931
|
+
result = Braintree::PaymentMethod.create(
|
932
|
+
:payment_method_nonce => nonce,
|
933
|
+
:customer_id => customer.id,
|
934
|
+
:options => {
|
935
|
+
:verify_card => true,
|
936
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
937
|
+
:verification_currency_iso_code => "GBP"
|
938
|
+
},
|
939
|
+
)
|
940
|
+
|
941
|
+
result.should_not be_success
|
942
|
+
result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
943
|
+
end
|
944
|
+
end
|
879
945
|
end
|
880
946
|
|
881
947
|
describe "self.create!" do
|
@@ -889,20 +955,20 @@ describe Braintree::PaymentMethod do
|
|
889
955
|
config,
|
890
956
|
:authorization_fingerprint => authorization_fingerprint,
|
891
957
|
:shared_customer_identifier => "fake_identifier",
|
892
|
-
:shared_customer_identifier_type => "testing"
|
958
|
+
:shared_customer_identifier_type => "testing",
|
893
959
|
)
|
894
960
|
|
895
961
|
response = http.create_credit_card(
|
896
962
|
:number => 4111111111111111,
|
897
963
|
:expirationMonth => 12,
|
898
|
-
:expirationYear => 2020
|
964
|
+
:expirationYear => 2020,
|
899
965
|
)
|
900
966
|
response.code.should == "201"
|
901
967
|
|
902
968
|
nonce = JSON.parse(response.body)["creditCards"].first["nonce"]
|
903
969
|
payment_method = Braintree::PaymentMethod.create!(
|
904
970
|
:payment_method_nonce => nonce,
|
905
|
-
:customer_id => customer.id
|
971
|
+
:customer_id => customer.id,
|
906
972
|
)
|
907
973
|
|
908
974
|
payment_method.should be_a(Braintree::CreditCard)
|
@@ -920,7 +986,7 @@ describe Braintree::PaymentMethod do
|
|
920
986
|
result = Braintree::CreditCard.create(
|
921
987
|
:customer_id => customer.id,
|
922
988
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
923
|
-
:expiration_date => "05/2012"
|
989
|
+
:expiration_date => "05/2012",
|
924
990
|
)
|
925
991
|
result.success?.should == true
|
926
992
|
|
@@ -936,13 +1002,13 @@ describe Braintree::PaymentMethod do
|
|
936
1002
|
credit_card = Braintree::CreditCard.create(
|
937
1003
|
:customer_id => customer.id,
|
938
1004
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
939
|
-
:expiration_date => "05/2012"
|
1005
|
+
:expiration_date => "05/2012",
|
940
1006
|
).credit_card
|
941
1007
|
|
942
1008
|
subscription = Braintree::Subscription.create(
|
943
1009
|
:payment_method_token => credit_card.token,
|
944
1010
|
:plan_id => "integration_trialless_plan",
|
945
|
-
:price => "1.00"
|
1011
|
+
:price => "1.00",
|
946
1012
|
).subscription
|
947
1013
|
|
948
1014
|
found_card = Braintree::PaymentMethod.find(credit_card.token)
|
@@ -959,11 +1025,11 @@ describe Braintree::PaymentMethod do
|
|
959
1025
|
payment_method_token = make_token
|
960
1026
|
nonce = nonce_for_paypal_account(
|
961
1027
|
:consent_code => "consent-code",
|
962
|
-
:token => payment_method_token
|
1028
|
+
:token => payment_method_token,
|
963
1029
|
)
|
964
1030
|
result = Braintree::PaymentMethod.create(
|
965
1031
|
:payment_method_nonce => nonce,
|
966
|
-
:customer_id => customer.id
|
1032
|
+
:customer_id => customer.id,
|
967
1033
|
)
|
968
1034
|
result.should be_success
|
969
1035
|
|
@@ -982,7 +1048,7 @@ describe Braintree::PaymentMethod do
|
|
982
1048
|
result = Braintree::PaymentMethod.create(
|
983
1049
|
:payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
|
984
1050
|
:customer_id => customer.id,
|
985
|
-
:token => payment_method_token
|
1051
|
+
:token => payment_method_token,
|
986
1052
|
)
|
987
1053
|
result.should be_success
|
988
1054
|
|
@@ -1007,7 +1073,7 @@ describe Braintree::PaymentMethod do
|
|
1007
1073
|
result = Braintree::PaymentMethod.create(
|
1008
1074
|
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
1009
1075
|
:customer_id => customer.id,
|
1010
|
-
:token => payment_method_token
|
1076
|
+
:token => payment_method_token,
|
1011
1077
|
)
|
1012
1078
|
result.should be_success
|
1013
1079
|
|
@@ -1017,68 +1083,68 @@ describe Braintree::PaymentMethod do
|
|
1017
1083
|
venmo_account.token.should == payment_method_token
|
1018
1084
|
venmo_account.default.should == true
|
1019
1085
|
venmo_account.image_url.should =~ /venmo/
|
1020
|
-
venmo_account.username.should ==
|
1021
|
-
venmo_account.venmo_user_id.should ==
|
1086
|
+
venmo_account.username.should == "venmojoe"
|
1087
|
+
venmo_account.venmo_user_id.should == "Venmo-Joe-1"
|
1022
1088
|
venmo_account.source_description.should == "Venmo Account: venmojoe"
|
1023
1089
|
venmo_account.customer_id.should == customer.id
|
1024
1090
|
end
|
1025
1091
|
end
|
1026
1092
|
|
1027
|
-
context "
|
1093
|
+
context "google pay cards" do
|
1028
1094
|
it "finds the proxy card payment method with the given token" do
|
1029
1095
|
customer = Braintree::Customer.create!
|
1030
1096
|
payment_method_token = make_token
|
1031
1097
|
result = Braintree::PaymentMethod.create(
|
1032
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1098
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1033
1099
|
:customer_id => customer.id,
|
1034
|
-
:token => payment_method_token
|
1100
|
+
:token => payment_method_token,
|
1035
1101
|
)
|
1036
1102
|
result.should be_success
|
1037
1103
|
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1104
|
+
google_pay_card = Braintree::PaymentMethod.find(payment_method_token)
|
1105
|
+
google_pay_card.should be_a(Braintree::GooglePayCard)
|
1106
|
+
google_pay_card.should_not be_nil
|
1107
|
+
google_pay_card.token.should == payment_method_token
|
1108
|
+
google_pay_card.card_type.should == Braintree::CreditCard::CardType::Discover
|
1109
|
+
google_pay_card.virtual_card_type.should == Braintree::CreditCard::CardType::Discover
|
1110
|
+
google_pay_card.expiration_month.to_i.should > 0
|
1111
|
+
google_pay_card.expiration_year.to_i.should > 0
|
1112
|
+
google_pay_card.default.should == true
|
1113
|
+
google_pay_card.image_url.should =~ /android_pay/
|
1114
|
+
google_pay_card.is_network_tokenized?.should == false
|
1115
|
+
google_pay_card.source_card_type.should == Braintree::CreditCard::CardType::Discover
|
1116
|
+
google_pay_card.source_card_last_4.should == "1111"
|
1117
|
+
google_pay_card.google_transaction_id.should == "google_transaction_id"
|
1118
|
+
google_pay_card.source_description.should == "Discover 1111"
|
1119
|
+
google_pay_card.customer_id.should == customer.id
|
1054
1120
|
end
|
1055
1121
|
|
1056
1122
|
it "finds the network token payment method with the given token" do
|
1057
1123
|
customer = Braintree::Customer.create!
|
1058
1124
|
payment_method_token = make_token
|
1059
1125
|
result = Braintree::PaymentMethod.create(
|
1060
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1126
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
|
1061
1127
|
:customer_id => customer.id,
|
1062
|
-
:token => payment_method_token
|
1128
|
+
:token => payment_method_token,
|
1063
1129
|
)
|
1064
1130
|
result.should be_success
|
1065
1131
|
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1132
|
+
google_pay_card = Braintree::PaymentMethod.find(payment_method_token)
|
1133
|
+
google_pay_card.should be_a(Braintree::GooglePayCard)
|
1134
|
+
google_pay_card.should_not be_nil
|
1135
|
+
google_pay_card.token.should == payment_method_token
|
1136
|
+
google_pay_card.card_type.should == Braintree::CreditCard::CardType::MasterCard
|
1137
|
+
google_pay_card.virtual_card_type.should == Braintree::CreditCard::CardType::MasterCard
|
1138
|
+
google_pay_card.expiration_month.to_i.should > 0
|
1139
|
+
google_pay_card.expiration_year.to_i.should > 0
|
1140
|
+
google_pay_card.default.should == true
|
1141
|
+
google_pay_card.image_url.should =~ /android_pay/
|
1142
|
+
google_pay_card.is_network_tokenized?.should == true
|
1143
|
+
google_pay_card.source_card_type.should == Braintree::CreditCard::CardType::MasterCard
|
1144
|
+
google_pay_card.source_card_last_4.should == "4444"
|
1145
|
+
google_pay_card.google_transaction_id.should == "google_transaction_id"
|
1146
|
+
google_pay_card.source_description.should == "MasterCard 4444"
|
1147
|
+
google_pay_card.customer_id.should == customer.id
|
1082
1148
|
end
|
1083
1149
|
end
|
1084
1150
|
|
@@ -1089,7 +1155,7 @@ describe Braintree::PaymentMethod do
|
|
1089
1155
|
result = Braintree::PaymentMethod.create(
|
1090
1156
|
:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable,
|
1091
1157
|
:customer_id => customer.id,
|
1092
|
-
:token => payment_method_token
|
1158
|
+
:token => payment_method_token,
|
1093
1159
|
)
|
1094
1160
|
result.should be_success
|
1095
1161
|
|
@@ -1110,18 +1176,18 @@ describe Braintree::PaymentMethod do
|
|
1110
1176
|
end
|
1111
1177
|
|
1112
1178
|
describe "self.delete" do
|
1113
|
-
it "deletes an
|
1179
|
+
it "deletes an google pay card" do
|
1114
1180
|
customer = Braintree::Customer.create!
|
1115
1181
|
|
1116
1182
|
create_result = Braintree::PaymentMethod.create(
|
1117
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
1118
|
-
:customer_id => customer.id
|
1183
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1184
|
+
:customer_id => customer.id,
|
1119
1185
|
)
|
1120
1186
|
|
1121
1187
|
token = create_result.payment_method.token
|
1122
1188
|
|
1123
|
-
|
1124
|
-
|
1189
|
+
google_card = Braintree::PaymentMethod.find(token)
|
1190
|
+
google_card.should be_a(Braintree::GooglePayCard)
|
1125
1191
|
|
1126
1192
|
delete_result = Braintree::PaymentMethod.delete(token)
|
1127
1193
|
delete_result.success?.should == true
|
@@ -1136,7 +1202,7 @@ describe Braintree::PaymentMethod do
|
|
1136
1202
|
|
1137
1203
|
create_result = Braintree::PaymentMethod.create(
|
1138
1204
|
:payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
|
1139
|
-
:customer_id => customer.id
|
1205
|
+
:customer_id => customer.id,
|
1140
1206
|
)
|
1141
1207
|
token = create_result.payment_method.token
|
1142
1208
|
|
@@ -1157,11 +1223,11 @@ describe Braintree::PaymentMethod do
|
|
1157
1223
|
|
1158
1224
|
nonce = nonce_for_paypal_account(
|
1159
1225
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
1160
|
-
:token => paypal_account_token
|
1226
|
+
:token => paypal_account_token,
|
1161
1227
|
)
|
1162
1228
|
Braintree::PaymentMethod.create(
|
1163
1229
|
:payment_method_nonce => nonce,
|
1164
|
-
:customer_id => customer.id
|
1230
|
+
:customer_id => customer.id,
|
1165
1231
|
)
|
1166
1232
|
|
1167
1233
|
paypal_account = Braintree::PaymentMethod.find(paypal_account_token)
|
@@ -1190,7 +1256,7 @@ describe Braintree::PaymentMethod do
|
|
1190
1256
|
|
1191
1257
|
Braintree::PaymentMethod.create(
|
1192
1258
|
:payment_method_nonce => nonce,
|
1193
|
-
:customer_id => customer.id
|
1259
|
+
:customer_id => customer.id,
|
1194
1260
|
)
|
1195
1261
|
|
1196
1262
|
result = Braintree::PaymentMethod.delete(token)
|
@@ -1227,14 +1293,14 @@ describe Braintree::PaymentMethod do
|
|
1227
1293
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1228
1294
|
:expiration_date => "06/2013",
|
1229
1295
|
:three_d_secure_pass_thru => {
|
1230
|
-
:eci_flag =>
|
1231
|
-
:cavv =>
|
1232
|
-
:xid =>
|
1233
|
-
:three_d_secure_version =>
|
1234
|
-
:authentication_response =>
|
1235
|
-
:directory_response =>
|
1236
|
-
:cavv_algorithm =>
|
1237
|
-
:ds_transaction_id =>
|
1296
|
+
:eci_flag => "02",
|
1297
|
+
:cavv => "some_cavv",
|
1298
|
+
:xid => "some_xid",
|
1299
|
+
:three_d_secure_version => "xx",
|
1300
|
+
:authentication_response => "Y",
|
1301
|
+
:directory_response => "Y",
|
1302
|
+
:cavv_algorithm => "2",
|
1303
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
1238
1304
|
},
|
1239
1305
|
:options => {:verify_card => true},
|
1240
1306
|
)
|
@@ -1258,14 +1324,14 @@ describe Braintree::PaymentMethod do
|
|
1258
1324
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1259
1325
|
:expiration_date => "06/2013",
|
1260
1326
|
:three_d_secure_pass_thru => {
|
1261
|
-
:eci_flag =>
|
1262
|
-
:cavv =>
|
1263
|
-
:xid =>
|
1264
|
-
:three_d_secure_version =>
|
1265
|
-
:authentication_response =>
|
1266
|
-
:directory_response =>
|
1267
|
-
:cavv_algorithm =>
|
1268
|
-
:ds_transaction_id =>
|
1327
|
+
:eci_flag => "02",
|
1328
|
+
:cavv => "some_cavv",
|
1329
|
+
:xid => "some_xid",
|
1330
|
+
:three_d_secure_version => "1.0.2",
|
1331
|
+
:authentication_response => "Y",
|
1332
|
+
:directory_response => "Y",
|
1333
|
+
:cavv_algorithm => "2",
|
1334
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
1269
1335
|
},
|
1270
1336
|
:options => {:verify_card => true},
|
1271
1337
|
)
|
@@ -1285,13 +1351,13 @@ describe Braintree::PaymentMethod do
|
|
1285
1351
|
:customer_id => customer.id,
|
1286
1352
|
:cvv => "123",
|
1287
1353
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1288
|
-
:expiration_date => "05/2012"
|
1354
|
+
:expiration_date => "05/2012",
|
1289
1355
|
)
|
1290
1356
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1291
1357
|
:cardholder_name => "New Holder",
|
1292
1358
|
:cvv => "456",
|
1293
1359
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1294
|
-
:expiration_date => "06/2013"
|
1360
|
+
:expiration_date => "06/2013",
|
1295
1361
|
)
|
1296
1362
|
update_result.success?.should == true
|
1297
1363
|
update_result.payment_method.should == credit_card
|
@@ -1302,6 +1368,90 @@ describe Braintree::PaymentMethod do
|
|
1302
1368
|
updated_credit_card.expiration_date.should == "06/2013"
|
1303
1369
|
end
|
1304
1370
|
|
1371
|
+
context "verification_currency_iso_code" do
|
1372
|
+
it "validates verification_currency_iso_code and updates the credit card " do
|
1373
|
+
customer = Braintree::Customer.create!
|
1374
|
+
credit_card = Braintree::CreditCard.create!(
|
1375
|
+
:cardholder_name => "Original Holder",
|
1376
|
+
:customer_id => customer.id,
|
1377
|
+
:cvv => "123",
|
1378
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1379
|
+
:expiration_date => "05/2012",
|
1380
|
+
)
|
1381
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1382
|
+
:cardholder_name => "New Holder",
|
1383
|
+
:cvv => "456",
|
1384
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1385
|
+
:expiration_date => "06/2013",
|
1386
|
+
:options => {:verify_card => true, :verification_currency_iso_code => "USD"},
|
1387
|
+
)
|
1388
|
+
update_result.success?.should == true
|
1389
|
+
update_result.payment_method.verification.currency_iso_code == "USD"
|
1390
|
+
end
|
1391
|
+
|
1392
|
+
it "validates verification_currency_iso_code against the given verification_merchant_account_id and updates the credit card " do
|
1393
|
+
customer = Braintree::Customer.create!
|
1394
|
+
credit_card = Braintree::CreditCard.create!(
|
1395
|
+
:cardholder_name => "Original Holder",
|
1396
|
+
:customer_id => customer.id,
|
1397
|
+
:cvv => "123",
|
1398
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1399
|
+
:expiration_date => "05/2012",
|
1400
|
+
)
|
1401
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1402
|
+
:cardholder_name => "New Holder",
|
1403
|
+
:cvv => "456",
|
1404
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1405
|
+
:expiration_date => "06/2013",
|
1406
|
+
:options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "USD"},
|
1407
|
+
)
|
1408
|
+
update_result.success?.should == true
|
1409
|
+
update_result.payment_method.verification.currency_iso_code == "USD"
|
1410
|
+
update_result.payment_method.verification.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
|
1411
|
+
end
|
1412
|
+
|
1413
|
+
it "throws validation error when passing invalid verification_currency_iso_code" do
|
1414
|
+
customer = Braintree::Customer.create!
|
1415
|
+
credit_card = Braintree::CreditCard.create!(
|
1416
|
+
:cardholder_name => "Original Holder",
|
1417
|
+
:customer_id => customer.id,
|
1418
|
+
:cvv => "123",
|
1419
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1420
|
+
:expiration_date => "05/2012",
|
1421
|
+
)
|
1422
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1423
|
+
:cardholder_name => "New Holder",
|
1424
|
+
:cvv => "456",
|
1425
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1426
|
+
:expiration_date => "06/2013",
|
1427
|
+
:options => {:verify_card => true, :verification_currency_iso_code => "GBP"},
|
1428
|
+
)
|
1429
|
+
expect(update_result).to_not be_success
|
1430
|
+
update_result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1431
|
+
end
|
1432
|
+
|
1433
|
+
it "throws validation error when passing invalid verification_currency_iso_code of the given verification merchant account id" do
|
1434
|
+
customer = Braintree::Customer.create!
|
1435
|
+
credit_card = Braintree::CreditCard.create!(
|
1436
|
+
:cardholder_name => "Original Holder",
|
1437
|
+
:customer_id => customer.id,
|
1438
|
+
:cvv => "123",
|
1439
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1440
|
+
:expiration_date => "05/2012",
|
1441
|
+
)
|
1442
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1443
|
+
:cardholder_name => "New Holder",
|
1444
|
+
:cvv => "456",
|
1445
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1446
|
+
:expiration_date => "06/2013",
|
1447
|
+
:options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "GBP"},
|
1448
|
+
)
|
1449
|
+
expect(update_result).to_not be_success
|
1450
|
+
update_result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1451
|
+
end
|
1452
|
+
end
|
1453
|
+
|
1454
|
+
|
1305
1455
|
context "billing address" do
|
1306
1456
|
it "creates a new billing address by default" do
|
1307
1457
|
customer = Braintree::Customer.create!
|
@@ -1311,12 +1461,12 @@ describe Braintree::PaymentMethod do
|
|
1311
1461
|
:expiration_date => "05/2012",
|
1312
1462
|
:billing_address => {
|
1313
1463
|
:street_address => "123 Nigeria Ave"
|
1314
|
-
}
|
1464
|
+
},
|
1315
1465
|
)
|
1316
1466
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1317
1467
|
:billing_address => {
|
1318
1468
|
:region => "IL"
|
1319
|
-
}
|
1469
|
+
},
|
1320
1470
|
)
|
1321
1471
|
update_result.success?.should == true
|
1322
1472
|
updated_credit_card = update_result.payment_method
|
@@ -1333,13 +1483,13 @@ describe Braintree::PaymentMethod do
|
|
1333
1483
|
:expiration_date => "05/2012",
|
1334
1484
|
:billing_address => {
|
1335
1485
|
:street_address => "123 Nigeria Ave"
|
1336
|
-
}
|
1486
|
+
},
|
1337
1487
|
)
|
1338
1488
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1339
1489
|
:billing_address => {
|
1340
1490
|
:region => "IL",
|
1341
1491
|
:options => {:update_existing => true}
|
1342
|
-
}
|
1492
|
+
},
|
1343
1493
|
)
|
1344
1494
|
update_result.success?.should == true
|
1345
1495
|
updated_credit_card = update_result.payment_method
|
@@ -1356,7 +1506,7 @@ describe Braintree::PaymentMethod do
|
|
1356
1506
|
:expiration_date => "05/2012",
|
1357
1507
|
:billing_address => {
|
1358
1508
|
:street_address => "123 Nigeria Ave"
|
1359
|
-
}
|
1509
|
+
},
|
1360
1510
|
)
|
1361
1511
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1362
1512
|
:billing_address => {
|
@@ -1365,7 +1515,7 @@ describe Braintree::PaymentMethod do
|
|
1365
1515
|
:country_code_alpha3 => "ASM",
|
1366
1516
|
:country_code_numeric => "016",
|
1367
1517
|
:options => {:update_existing => true}
|
1368
|
-
}
|
1518
|
+
},
|
1369
1519
|
)
|
1370
1520
|
update_result.success?.should == true
|
1371
1521
|
updated_credit_card = update_result.payment_method
|
@@ -1381,12 +1531,12 @@ describe Braintree::PaymentMethod do
|
|
1381
1531
|
credit_card = Braintree::CreditCard.create!(
|
1382
1532
|
:customer_id => customer.id,
|
1383
1533
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1384
|
-
:expiration_date => "05/2012"
|
1534
|
+
:expiration_date => "05/2012",
|
1385
1535
|
)
|
1386
1536
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1387
1537
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1388
1538
|
:expiration_month => "07",
|
1389
|
-
:expiration_year => "2011"
|
1539
|
+
:expiration_year => "2011",
|
1390
1540
|
)
|
1391
1541
|
update_result.success?.should == true
|
1392
1542
|
update_result.payment_method.should == credit_card
|
@@ -1402,14 +1552,14 @@ describe Braintree::PaymentMethod do
|
|
1402
1552
|
:customer_id => customer.id,
|
1403
1553
|
:cvv => "123",
|
1404
1554
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1405
|
-
:expiration_date => "05/2012"
|
1555
|
+
:expiration_date => "05/2012",
|
1406
1556
|
)
|
1407
1557
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1408
1558
|
:cardholder_name => "New Holder",
|
1409
1559
|
:cvv => "456",
|
1410
1560
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
|
1411
1561
|
:expiration_date => "06/2013",
|
1412
|
-
:options => {:verify_card => true}
|
1562
|
+
:options => {:verify_card => true},
|
1413
1563
|
)
|
1414
1564
|
update_result.success?.should == false
|
1415
1565
|
update_result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
@@ -1423,11 +1573,11 @@ describe Braintree::PaymentMethod do
|
|
1423
1573
|
:customer_id => customer.id,
|
1424
1574
|
:cvv => "123",
|
1425
1575
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1426
|
-
:expiration_date => "05/2020"
|
1576
|
+
:expiration_date => "05/2020",
|
1427
1577
|
)
|
1428
1578
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1429
1579
|
:payment_method_nonce => Braintree::Test::Nonce::ProcessorDeclinedMasterCard,
|
1430
|
-
:options => {:verify_card => true, :verification_amount => "2.34"}
|
1580
|
+
:options => {:verify_card => true, :verification_amount => "2.34"},
|
1431
1581
|
)
|
1432
1582
|
update_result.success?.should == false
|
1433
1583
|
update_result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
@@ -1453,7 +1603,7 @@ describe Braintree::PaymentMethod do
|
|
1453
1603
|
:region => "Old State",
|
1454
1604
|
:postal_code => "12345",
|
1455
1605
|
:country_name => "Canada"
|
1456
|
-
}
|
1606
|
+
},
|
1457
1607
|
)
|
1458
1608
|
result = Braintree::PaymentMethod.update(credit_card.token,
|
1459
1609
|
:options => {:verify_card => false},
|
@@ -1467,7 +1617,7 @@ describe Braintree::PaymentMethod do
|
|
1467
1617
|
:region => "New State",
|
1468
1618
|
:postal_code => "56789",
|
1469
1619
|
:country_name => "United States of America"
|
1470
|
-
}
|
1620
|
+
},
|
1471
1621
|
)
|
1472
1622
|
result.success?.should == true
|
1473
1623
|
address = result.payment_method.billing_address
|
@@ -1488,12 +1638,12 @@ describe Braintree::PaymentMethod do
|
|
1488
1638
|
:cardholder_name => "Original Holder",
|
1489
1639
|
:customer_id => customer.id,
|
1490
1640
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1491
|
-
:expiration_date => "05/2012"
|
1641
|
+
:expiration_date => "05/2012",
|
1492
1642
|
)
|
1493
1643
|
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1494
1644
|
:cardholder_name => "New Holder",
|
1495
1645
|
:number => "invalid",
|
1496
|
-
:expiration_date => "05/2014"
|
1646
|
+
:expiration_date => "05/2014",
|
1497
1647
|
)
|
1498
1648
|
update_result.success?.should == false
|
1499
1649
|
update_result.errors.for(:credit_card).on(:number)[0].message.should == "Credit card number must be 12-19 digits."
|
@@ -1504,12 +1654,12 @@ describe Braintree::PaymentMethod do
|
|
1504
1654
|
card1 = Braintree::CreditCard.create(
|
1505
1655
|
:customer_id => customer.id,
|
1506
1656
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1507
|
-
:expiration_date => "05/2009"
|
1657
|
+
:expiration_date => "05/2009",
|
1508
1658
|
).credit_card
|
1509
1659
|
card2 = Braintree::CreditCard.create(
|
1510
1660
|
:customer_id => customer.id,
|
1511
1661
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1512
|
-
:expiration_date => "05/2009"
|
1662
|
+
:expiration_date => "05/2009",
|
1513
1663
|
).credit_card
|
1514
1664
|
|
1515
1665
|
card1.should be_default
|
@@ -1522,39 +1672,23 @@ describe Braintree::PaymentMethod do
|
|
1522
1672
|
end
|
1523
1673
|
end
|
1524
1674
|
|
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
1675
|
context "paypal accounts" do
|
1542
1676
|
it "updates a paypal account's token" do
|
1543
1677
|
customer = Braintree::Customer.create!
|
1544
1678
|
original_token = random_payment_method_token
|
1545
1679
|
nonce = nonce_for_paypal_account(
|
1546
1680
|
:consent_code => "consent-code",
|
1547
|
-
:token => original_token
|
1681
|
+
:token => original_token,
|
1548
1682
|
)
|
1549
1683
|
original_result = Braintree::PaymentMethod.create(
|
1550
1684
|
:payment_method_nonce => nonce,
|
1551
|
-
:customer_id => customer.id
|
1685
|
+
:customer_id => customer.id,
|
1552
1686
|
)
|
1553
1687
|
|
1554
1688
|
updated_token = make_token
|
1555
1689
|
updated_result = Braintree::PaymentMethod.update(
|
1556
1690
|
original_token,
|
1557
|
-
:token => updated_token
|
1691
|
+
:token => updated_token,
|
1558
1692
|
)
|
1559
1693
|
|
1560
1694
|
updated_paypal_account = Braintree::PayPalAccount.find(updated_token)
|
@@ -1571,19 +1705,19 @@ describe Braintree::PaymentMethod do
|
|
1571
1705
|
:customer_id => customer.id,
|
1572
1706
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1573
1707
|
:expiration_date => "05/2009",
|
1574
|
-
:options => {:make_default => true}
|
1708
|
+
:options => {:make_default => true},
|
1575
1709
|
)
|
1576
1710
|
result.should be_success
|
1577
1711
|
|
1578
1712
|
nonce = nonce_for_paypal_account(:consent_code => "consent-code")
|
1579
1713
|
original_token = Braintree::PaymentMethod.create(
|
1580
1714
|
:payment_method_nonce => nonce,
|
1581
|
-
:customer_id => customer.id
|
1715
|
+
:customer_id => customer.id,
|
1582
1716
|
).payment_method.token
|
1583
1717
|
|
1584
1718
|
updated_result = Braintree::PaymentMethod.update(
|
1585
1719
|
original_token,
|
1586
|
-
:options => {:make_default => true}
|
1720
|
+
:options => {:make_default => true},
|
1587
1721
|
)
|
1588
1722
|
|
1589
1723
|
updated_paypal_account = Braintree::PayPalAccount.find(original_token)
|
@@ -1597,25 +1731,25 @@ describe Braintree::PaymentMethod do
|
|
1597
1731
|
|
1598
1732
|
first_nonce = nonce_for_paypal_account(
|
1599
1733
|
:consent_code => "consent-code",
|
1600
|
-
:token => first_token
|
1734
|
+
:token => first_token,
|
1601
1735
|
)
|
1602
1736
|
first_result = Braintree::PaymentMethod.create(
|
1603
1737
|
:payment_method_nonce => first_nonce,
|
1604
|
-
:customer_id => customer.id
|
1738
|
+
:customer_id => customer.id,
|
1605
1739
|
)
|
1606
1740
|
|
1607
1741
|
second_nonce = nonce_for_paypal_account(
|
1608
1742
|
:consent_code => "consent-code",
|
1609
|
-
:token => second_token
|
1743
|
+
:token => second_token,
|
1610
1744
|
)
|
1611
1745
|
second_result = Braintree::PaymentMethod.create(
|
1612
1746
|
:payment_method_nonce => second_nonce,
|
1613
|
-
:customer_id => customer.id
|
1747
|
+
:customer_id => customer.id,
|
1614
1748
|
)
|
1615
1749
|
|
1616
1750
|
updated_result = Braintree::PaymentMethod.update(
|
1617
1751
|
first_token,
|
1618
|
-
:token => second_token
|
1752
|
+
:token => second_token,
|
1619
1753
|
)
|
1620
1754
|
|
1621
1755
|
updated_result.should_not be_success
|
@@ -1632,13 +1766,13 @@ describe Braintree::PaymentMethod do
|
|
1632
1766
|
:customer_id => customer.id,
|
1633
1767
|
:cvv => "123",
|
1634
1768
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1635
|
-
:expiration_date => "05/2012"
|
1769
|
+
:expiration_date => "05/2012",
|
1636
1770
|
)
|
1637
1771
|
payment_method = Braintree::PaymentMethod.update!(credit_card.token,
|
1638
1772
|
:cardholder_name => "New Holder",
|
1639
1773
|
:cvv => "456",
|
1640
1774
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1641
|
-
:expiration_date => "06/2013"
|
1775
|
+
:expiration_date => "06/2013",
|
1642
1776
|
)
|
1643
1777
|
payment_method.should == credit_card
|
1644
1778
|
payment_method.cardholder_name.should == "New Holder"
|
@@ -1655,7 +1789,7 @@ describe Braintree::PaymentMethod do
|
|
1655
1789
|
:public_key => "oauth_app_partner_user_public_key",
|
1656
1790
|
:private_key => "oauth_app_partner_user_private_key",
|
1657
1791
|
:environment => Braintree::Configuration.environment,
|
1658
|
-
:logger => Logger.new("/dev/null")
|
1792
|
+
:logger => Logger.new("/dev/null"),
|
1659
1793
|
)
|
1660
1794
|
customer = @partner_merchant_gateway.customer.create(
|
1661
1795
|
:first_name => "Joe",
|
@@ -1664,19 +1798,19 @@ describe Braintree::PaymentMethod do
|
|
1664
1798
|
:email => "joe@example.com",
|
1665
1799
|
:phone => "312.555.1234",
|
1666
1800
|
:fax => "614.555.5678",
|
1667
|
-
:website => "www.example.com"
|
1801
|
+
:website => "www.example.com",
|
1668
1802
|
).customer
|
1669
1803
|
@credit_card = @partner_merchant_gateway.credit_card.create(
|
1670
1804
|
:customer_id => customer.id,
|
1671
1805
|
:cardholder_name => "Adam Davis",
|
1672
1806
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1673
|
-
:expiration_date => "05/2009"
|
1807
|
+
:expiration_date => "05/2009",
|
1674
1808
|
).credit_card
|
1675
1809
|
|
1676
1810
|
@oauth_gateway = Braintree::Gateway.new(
|
1677
1811
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
1678
1812
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
1679
|
-
:logger => Logger.new("/dev/null")
|
1813
|
+
:logger => Logger.new("/dev/null"),
|
1680
1814
|
)
|
1681
1815
|
access_token = Braintree::OAuthTestHelper.create_token(@oauth_gateway, {
|
1682
1816
|
:merchant_public_id => "integration_merchant_id",
|
@@ -1685,7 +1819,7 @@ describe Braintree::PaymentMethod do
|
|
1685
1819
|
|
1686
1820
|
@granting_gateway = Braintree::Gateway.new(
|
1687
1821
|
:access_token => access_token,
|
1688
|
-
:logger => Logger.new("/dev/null")
|
1822
|
+
:logger => Logger.new("/dev/null"),
|
1689
1823
|
)
|
1690
1824
|
end
|
1691
1825
|
|
@@ -1701,13 +1835,13 @@ describe Braintree::PaymentMethod do
|
|
1701
1835
|
|
1702
1836
|
result = Braintree::Transaction.sale(
|
1703
1837
|
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
|
1704
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
1838
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1705
1839
|
)
|
1706
1840
|
result.should be_success
|
1707
1841
|
|
1708
1842
|
result2 = Braintree::Transaction.sale(
|
1709
1843
|
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
|
1710
|
-
:amount => Braintree::Test::TransactionAmounts::Authorize
|
1844
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1711
1845
|
)
|
1712
1846
|
result2.should_not be_success
|
1713
1847
|
end
|
@@ -1719,7 +1853,7 @@ describe Braintree::PaymentMethod do
|
|
1719
1853
|
|
1720
1854
|
result = Braintree::PaymentMethod.create(
|
1721
1855
|
:customer_id => customer_result.customer.id,
|
1722
|
-
:payment_method_nonce => grant_result.payment_method_nonce.nonce
|
1856
|
+
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
|
1723
1857
|
)
|
1724
1858
|
result.should_not be_success
|
1725
1859
|
end
|
@@ -1731,7 +1865,7 @@ describe Braintree::PaymentMethod do
|
|
1731
1865
|
|
1732
1866
|
result = Braintree::PaymentMethod.create(
|
1733
1867
|
:customer_id => customer_result.customer.id,
|
1734
|
-
:payment_method_nonce => grant_result.payment_method_nonce.nonce
|
1868
|
+
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
|
1735
1869
|
)
|
1736
1870
|
result.should be_success
|
1737
1871
|
end
|
@@ -1739,7 +1873,7 @@ describe Braintree::PaymentMethod do
|
|
1739
1873
|
it "raises an error if the token isn't found" do
|
1740
1874
|
expect do
|
1741
1875
|
@granting_gateway.payment_method.grant("not_a_real_token", false)
|
1742
|
-
end.to raise_error
|
1876
|
+
end.to raise_error(Braintree::NotFoundError)
|
1743
1877
|
end
|
1744
1878
|
|
1745
1879
|
it "returns a valid nonce with no options set" do
|
@@ -1754,7 +1888,7 @@ describe Braintree::PaymentMethod do
|
|
1754
1888
|
it "raises an error if the token isn't found" do
|
1755
1889
|
expect do
|
1756
1890
|
@granting_gateway.payment_method.revoke("not_a_real_token")
|
1757
|
-
end.to raise_error
|
1891
|
+
end.to raise_error(Braintree::NotFoundError)
|
1758
1892
|
end
|
1759
1893
|
|
1760
1894
|
it "renders a granted nonce useless" do
|
@@ -1766,7 +1900,7 @@ describe Braintree::PaymentMethod do
|
|
1766
1900
|
|
1767
1901
|
result = Braintree::PaymentMethod.create(
|
1768
1902
|
:customer_id => customer_result.customer.id,
|
1769
|
-
:payment_method_nonce => grant_result.payment_method_nonce.nonce
|
1903
|
+
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
|
1770
1904
|
)
|
1771
1905
|
result.should_not be_success
|
1772
1906
|
end
|
@@ -1780,7 +1914,7 @@ describe Braintree::PaymentMethod do
|
|
1780
1914
|
|
1781
1915
|
result = Braintree::PaymentMethod.create(
|
1782
1916
|
:customer_id => customer_result.customer.id,
|
1783
|
-
:payment_method_nonce => grant_result.payment_method_nonce.nonce
|
1917
|
+
:payment_method_nonce => grant_result.payment_method_nonce.nonce,
|
1784
1918
|
)
|
1785
1919
|
result.should_not be_success
|
1786
1920
|
end
|