braintree 4.14.0 → 4.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/account_updater_daily_report.rb +3 -3
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +4 -4
- data/lib/braintree/address_gateway.rb +5 -5
- data/lib/braintree/advanced_search.rb +10 -10
- data/lib/braintree/apple_pay.rb +3 -3
- data/lib/braintree/apple_pay_card.rb +3 -3
- data/lib/braintree/apple_pay_options.rb +3 -3
- data/lib/braintree/authorization_adjustment.rb +3 -3
- data/lib/braintree/base_module.rb +1 -1
- data/lib/braintree/bin_data.rb +2 -2
- data/lib/braintree/client_token_gateway.rb +1 -1
- data/lib/braintree/configuration.rb +22 -22
- 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 +22 -9
- data/lib/braintree/credit_card_gateway.rb +23 -11
- data/lib/braintree/credit_card_verification.rb +3 -3
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +5 -9
- data/lib/braintree/customer_gateway.rb +7 -7
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +5 -5
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/dispute/paypal_message.rb +1 -1
- data/lib/braintree/dispute/status_history.rb +1 -1
- data/lib/braintree/dispute/transaction.rb +1 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +3 -3
- data/lib/braintree/dispute_gateway.rb +1 -1
- data/lib/braintree/dispute_search.rb +1 -1
- data/lib/braintree/document_upload.rb +2 -2
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +2 -2
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +1 -2
- data/lib/braintree/exchange_rate.rb +2 -2
- data/lib/braintree/exchange_rate_quote.rb +3 -3
- data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
- data/lib/braintree/exchange_rate_quote_input.rb +3 -3
- data/lib/braintree/exchange_rate_quote_request.rb +3 -3
- data/lib/braintree/exchange_rate_quote_response.rb +3 -3
- data/lib/braintree/facilitated_details.rb +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/google_pay_card.rb +3 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +1 -1
- data/lib/braintree/http.rb +1 -1
- data/lib/braintree/local_payment_completed.rb +2 -2
- data/lib/braintree/local_payment_expired.rb +2 -2
- data/lib/braintree/local_payment_funded.rb +2 -2
- data/lib/braintree/local_payment_reversed.rb +2 -2
- data/lib/braintree/merchant.rb +3 -3
- data/lib/braintree/merchant_account.rb +2 -2
- data/lib/braintree/merchant_account_gateway.rb +9 -9
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +3 -3
- data/lib/braintree/oauth_credentials.rb +3 -3
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +2 -0
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
- data/lib/braintree/payment_method_gateway.rb +23 -10
- data/lib/braintree/payment_method_nonce.rb +4 -4
- data/lib/braintree/payment_method_nonce_details.rb +1 -1
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/paypal_account.rb +1 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/plan_gateway.rb +2 -2
- data/lib/braintree/resource_collection.rb +2 -2
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +1 -1
- data/lib/braintree/samsung_pay_card.rb +5 -5
- data/lib/braintree/sepa_direct_debit_account.rb +2 -2
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
- data/lib/braintree/sha256_digest.rb +1 -1
- data/lib/braintree/subscription/status_details.rb +1 -1
- data/lib/braintree/subscription.rb +2 -2
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +2 -2
- data/lib/braintree/test/credit_card.rb +7 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +4 -0
- data/lib/braintree/test/transaction_amounts.rb +2 -3
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/testing_gateway.rb +1 -1
- data/lib/braintree/three_d_secure_info.rb +1 -1
- data/lib/braintree/transaction/address_details.rb +1 -1
- data/lib/braintree/transaction/credit_card_details.rb +4 -1
- data/lib/braintree/transaction/customer_details.rb +1 -1
- data/lib/braintree/transaction/disbursement_details.rb +1 -1
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +1 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +27 -20
- data/lib/braintree/transaction_gateway.rb +23 -12
- data/lib/braintree/transaction_line_item.rb +2 -2
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +1 -1
- data/lib/braintree/transaction_search.rb +7 -6
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +2 -2
- data/lib/braintree/us_bank_account_verification.rb +23 -15
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +3 -3
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +3 -3
- data/lib/braintree/venmo_profile_data.rb +6 -4
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +7 -7
- data/lib/braintree/webhook_notification.rb +3 -2
- data/lib/braintree/webhook_notification_gateway.rb +3 -3
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +18 -1
- data/lib/braintree/xml/generator.rb +1 -1
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +2 -2
- data/lib/braintree/xml/rexml.rb +2 -2
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +4 -1
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/credit_card_spec.rb +223 -223
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +313 -313
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_search_spec.rb +0 -1
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/payment_method_nonce_spec.rb +89 -69
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +150 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
- data/spec/integration/braintree/transaction_search_spec.rb +225 -165
- data/spec/integration/braintree/transaction_spec.rb +1502 -1210
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +11 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +9 -9
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- 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/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +39 -7
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +12 -7
- data/spec/unit/braintree/util_spec.rb +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +16 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +11 -2
@@ -17,15 +17,15 @@ describe Braintree::CreditCard do
|
|
17
17
|
:expiration_date => "05/2009",
|
18
18
|
:cvv => "100",
|
19
19
|
)
|
20
|
-
result.success
|
20
|
+
expect(result.success?).to eq(true)
|
21
21
|
credit_card = result.credit_card
|
22
|
-
credit_card.token.
|
23
|
-
credit_card.bin.
|
24
|
-
credit_card.last_4.
|
25
|
-
credit_card.expiration_date.
|
26
|
-
credit_card.unique_number_identifier.
|
27
|
-
credit_card.venmo_sdk
|
28
|
-
credit_card.image_url.
|
22
|
+
expect(credit_card.token).to match(/\A\w{4,}\z/)
|
23
|
+
expect(credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
24
|
+
expect(credit_card.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
25
|
+
expect(credit_card.expiration_date).to eq("05/2009")
|
26
|
+
expect(credit_card.unique_number_identifier).to match(/\A\w{32}\z/)
|
27
|
+
expect(credit_card.venmo_sdk?).to eq(false)
|
28
|
+
expect(credit_card.image_url).not_to be_nil
|
29
29
|
end
|
30
30
|
|
31
31
|
it "supports creation of cards with security params" do
|
@@ -37,7 +37,7 @@ describe Braintree::CreditCard do
|
|
37
37
|
:cvv => "100",
|
38
38
|
:device_data => "device_data",
|
39
39
|
)
|
40
|
-
result.success
|
40
|
+
expect(result.success?).to eq(true)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "can provide expiration month and year separately" do
|
@@ -48,11 +48,11 @@ describe Braintree::CreditCard do
|
|
48
48
|
:expiration_month => "05",
|
49
49
|
:expiration_year => "2012",
|
50
50
|
)
|
51
|
-
result.success
|
51
|
+
expect(result.success?).to eq(true)
|
52
52
|
credit_card = result.credit_card
|
53
|
-
credit_card.expiration_month.
|
54
|
-
credit_card.expiration_year.
|
55
|
-
credit_card.expiration_date.
|
53
|
+
expect(credit_card.expiration_month).to eq("05")
|
54
|
+
expect(credit_card.expiration_year).to eq("2012")
|
55
|
+
expect(credit_card.expiration_date).to eq("05/2012")
|
56
56
|
end
|
57
57
|
|
58
58
|
it "can specify the desired token" do
|
@@ -65,12 +65,12 @@ describe Braintree::CreditCard do
|
|
65
65
|
:cvv => "100",
|
66
66
|
:token => token,
|
67
67
|
)
|
68
|
-
result.success
|
68
|
+
expect(result.success?).to eq(true)
|
69
69
|
credit_card = result.credit_card
|
70
|
-
credit_card.token.
|
71
|
-
credit_card.bin.
|
72
|
-
credit_card.last_4.
|
73
|
-
credit_card.expiration_date.
|
70
|
+
expect(credit_card.token).to eq(token)
|
71
|
+
expect(credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
72
|
+
expect(credit_card.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
73
|
+
expect(credit_card.expiration_date).to eq("05/2009")
|
74
74
|
end
|
75
75
|
|
76
76
|
it "accepts billing_address_id" do
|
@@ -84,9 +84,9 @@ describe Braintree::CreditCard do
|
|
84
84
|
:billing_address_id => address.id,
|
85
85
|
).credit_card
|
86
86
|
|
87
|
-
credit_card.billing_address.id.
|
88
|
-
credit_card.billing_address.first_name.
|
89
|
-
credit_card.billing_address.last_name.
|
87
|
+
expect(credit_card.billing_address.id).to eq(address.id)
|
88
|
+
expect(credit_card.billing_address.first_name).to eq("Bobby")
|
89
|
+
expect(credit_card.billing_address.last_name).to eq("Tables")
|
90
90
|
end
|
91
91
|
|
92
92
|
it "accepts empty options hash" do
|
@@ -97,7 +97,7 @@ describe Braintree::CreditCard do
|
|
97
97
|
:expiration_date => "05/2009",
|
98
98
|
:options => {},
|
99
99
|
)
|
100
|
-
result.success
|
100
|
+
expect(result.success?).to eq(true)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "verifies the credit card if options[verify_card]=true" do
|
@@ -108,14 +108,14 @@ describe Braintree::CreditCard do
|
|
108
108
|
:expiration_date => "05/2009",
|
109
109
|
:options => {:verify_card => true},
|
110
110
|
)
|
111
|
-
result.success
|
112
|
-
result.credit_card_verification.status.
|
113
|
-
result.credit_card_verification.processor_response_code.
|
114
|
-
result.credit_card_verification.processor_response_text.
|
115
|
-
result.credit_card_verification.cvv_response_code.
|
116
|
-
result.credit_card_verification.avs_error_response_code.
|
117
|
-
result.credit_card_verification.avs_postal_code_response_code.
|
118
|
-
result.credit_card_verification.avs_street_address_response_code.
|
111
|
+
expect(result.success?).to eq(false)
|
112
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::ProcessorDeclined)
|
113
|
+
expect(result.credit_card_verification.processor_response_code).to eq("2000")
|
114
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Do Not Honor")
|
115
|
+
expect(result.credit_card_verification.cvv_response_code).to eq("I")
|
116
|
+
expect(result.credit_card_verification.avs_error_response_code).to eq(nil)
|
117
|
+
expect(result.credit_card_verification.avs_postal_code_response_code).to eq("I")
|
118
|
+
expect(result.credit_card_verification.avs_street_address_response_code).to eq("I")
|
119
119
|
end
|
120
120
|
|
121
121
|
it "allows passing a specific verification amount" do
|
@@ -126,14 +126,14 @@ describe Braintree::CreditCard do
|
|
126
126
|
:expiration_date => "05/2009",
|
127
127
|
:options => {:verify_card => true, :verification_amount => "100.00"},
|
128
128
|
)
|
129
|
-
result.success
|
130
|
-
result.credit_card_verification.status.
|
131
|
-
result.credit_card_verification.processor_response_code.
|
132
|
-
result.credit_card_verification.processor_response_text.
|
133
|
-
result.credit_card_verification.cvv_response_code.
|
134
|
-
result.credit_card_verification.avs_error_response_code.
|
135
|
-
result.credit_card_verification.avs_postal_code_response_code.
|
136
|
-
result.credit_card_verification.avs_street_address_response_code.
|
129
|
+
expect(result.success?).to eq(false)
|
130
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::ProcessorDeclined)
|
131
|
+
expect(result.credit_card_verification.processor_response_code).to eq("2000")
|
132
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Do Not Honor")
|
133
|
+
expect(result.credit_card_verification.cvv_response_code).to eq("I")
|
134
|
+
expect(result.credit_card_verification.avs_error_response_code).to eq(nil)
|
135
|
+
expect(result.credit_card_verification.avs_postal_code_response_code).to eq("I")
|
136
|
+
expect(result.credit_card_verification.avs_street_address_response_code).to eq("I")
|
137
137
|
end
|
138
138
|
|
139
139
|
it "returns risk data on verification on credit_card create" do
|
@@ -148,9 +148,9 @@ describe Braintree::CreditCard do
|
|
148
148
|
:options => {:verify_card => true},
|
149
149
|
)
|
150
150
|
verification = credit_card.verification
|
151
|
-
verification.risk_data.id.
|
152
|
-
verification.risk_data.decision.
|
153
|
-
verification.risk_data.decision_reasons.
|
151
|
+
expect(verification.risk_data.id).not_to be_nil
|
152
|
+
expect(verification.risk_data.decision).not_to be_nil
|
153
|
+
expect(verification.risk_data.decision_reasons).not_to be_nil
|
154
154
|
expect(verification.risk_data).to respond_to(:device_data_captured)
|
155
155
|
expect(verification.risk_data).to respond_to(:fraud_service_provider)
|
156
156
|
expect(verification.risk_data).to respond_to(:transaction_risk_score)
|
@@ -217,8 +217,8 @@ describe Braintree::CreditCard do
|
|
217
217
|
:cvv => "200",
|
218
218
|
:options => {:verify_card => true},
|
219
219
|
)
|
220
|
-
result.success
|
221
|
-
result.credit_card_verification.gateway_rejection_reason.
|
220
|
+
expect(result.success?).to eq(false)
|
221
|
+
expect(result.credit_card_verification.gateway_rejection_reason).to eq(Braintree::CreditCardVerification::GatewayRejectionReason::CVV)
|
222
222
|
ensure
|
223
223
|
Braintree::Configuration.merchant_id = old_merchant
|
224
224
|
Braintree::Configuration.public_key = old_public_key
|
@@ -234,14 +234,14 @@ describe Braintree::CreditCard do
|
|
234
234
|
:expiration_date => "05/2009",
|
235
235
|
:options => {:verify_card => true, :verification_amount => "1.01"},
|
236
236
|
)
|
237
|
-
result.success
|
238
|
-
result.credit_card_verification.status.
|
239
|
-
result.credit_card_verification.processor_response_code.
|
240
|
-
result.credit_card_verification.processor_response_text.
|
241
|
-
result.credit_card_verification.cvv_response_code.
|
242
|
-
result.credit_card_verification.avs_error_response_code.
|
243
|
-
result.credit_card_verification.avs_postal_code_response_code.
|
244
|
-
result.credit_card_verification.avs_street_address_response_code.
|
237
|
+
expect(result.success?).to eq(false)
|
238
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::ProcessorDeclined)
|
239
|
+
expect(result.credit_card_verification.processor_response_code).to eq("2000")
|
240
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Do Not Honor")
|
241
|
+
expect(result.credit_card_verification.cvv_response_code).to eq("I")
|
242
|
+
expect(result.credit_card_verification.avs_error_response_code).to eq(nil)
|
243
|
+
expect(result.credit_card_verification.avs_postal_code_response_code).to eq("I")
|
244
|
+
expect(result.credit_card_verification.avs_street_address_response_code).to eq("I")
|
245
245
|
end
|
246
246
|
|
247
247
|
it "allows user to specify merchant account for verification" do
|
@@ -255,8 +255,8 @@ describe Braintree::CreditCard do
|
|
255
255
|
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
256
256
|
},
|
257
257
|
)
|
258
|
-
result.success
|
259
|
-
result.credit_card_verification.merchant_account_id.
|
258
|
+
expect(result.success?).to eq(false)
|
259
|
+
expect(result.credit_card_verification.merchant_account_id).to eq(SpecHelper::NonDefaultMerchantAccountId)
|
260
260
|
end
|
261
261
|
|
262
262
|
it "does not verify the card if options[verify_card]=false" do
|
@@ -267,7 +267,7 @@ describe Braintree::CreditCard do
|
|
267
267
|
:expiration_date => "05/2009",
|
268
268
|
:options => {:verify_card => false},
|
269
269
|
)
|
270
|
-
result.success
|
270
|
+
expect(result.success?).to eq(true)
|
271
271
|
end
|
272
272
|
|
273
273
|
it "validates presence of three_d_secure_version in 3ds pass thru params" do
|
@@ -309,7 +309,7 @@ describe Braintree::CreditCard do
|
|
309
309
|
},
|
310
310
|
:options => {:verify_card => true},
|
311
311
|
)
|
312
|
-
result.success
|
312
|
+
expect(result.success?).to eq(true)
|
313
313
|
|
314
314
|
end
|
315
315
|
|
@@ -320,19 +320,19 @@ describe Braintree::CreditCard do
|
|
320
320
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
321
321
|
:options => {:verify_card => true},
|
322
322
|
)
|
323
|
-
result.success
|
323
|
+
expect(result.success?).to eq(true)
|
324
324
|
|
325
325
|
three_d_secure_info = result.credit_card.verification.three_d_secure_info
|
326
|
-
three_d_secure_info.enrolled.
|
327
|
-
three_d_secure_info.
|
328
|
-
three_d_secure_info.
|
329
|
-
three_d_secure_info.status.
|
330
|
-
three_d_secure_info.cavv.
|
331
|
-
three_d_secure_info.xid.
|
332
|
-
three_d_secure_info.eci_flag.
|
333
|
-
three_d_secure_info.three_d_secure_version.
|
334
|
-
three_d_secure_info.ds_transaction_id.
|
335
|
-
three_d_secure_info.three_d_secure_authentication_id.
|
326
|
+
expect(three_d_secure_info.enrolled).to eq("Y")
|
327
|
+
expect(three_d_secure_info).to be_liability_shifted
|
328
|
+
expect(three_d_secure_info).to be_liability_shift_possible
|
329
|
+
expect(three_d_secure_info.status).to eq("authenticate_successful")
|
330
|
+
expect(three_d_secure_info.cavv).to eq("cavv_value")
|
331
|
+
expect(three_d_secure_info.xid).to eq("xid_value")
|
332
|
+
expect(three_d_secure_info.eci_flag).to eq("05")
|
333
|
+
expect(three_d_secure_info.three_d_secure_version).to eq("1.0.2")
|
334
|
+
expect(three_d_secure_info.ds_transaction_id).to eq(nil)
|
335
|
+
expect(three_d_secure_info.three_d_secure_authentication_id).not_to be_nil
|
336
336
|
end
|
337
337
|
|
338
338
|
it "adds credit card with billing address to customer" do
|
@@ -348,10 +348,10 @@ describe Braintree::CreditCard do
|
|
348
348
|
:postal_code => "60622"
|
349
349
|
},
|
350
350
|
)
|
351
|
-
result.success
|
351
|
+
expect(result.success?).to eq(true)
|
352
352
|
credit_card = result.credit_card
|
353
|
-
credit_card.bin.
|
354
|
-
credit_card.billing_address.street_address.
|
353
|
+
expect(credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::MasterCard[0, 6])
|
354
|
+
expect(credit_card.billing_address.street_address).to eq("123 Abc Way")
|
355
355
|
end
|
356
356
|
|
357
357
|
it "adds credit card with billing using country_code" do
|
@@ -367,12 +367,12 @@ describe Braintree::CreditCard do
|
|
367
367
|
:country_code_numeric => "840"
|
368
368
|
},
|
369
369
|
)
|
370
|
-
result.success
|
370
|
+
expect(result.success?).to eq(true)
|
371
371
|
credit_card = result.credit_card
|
372
|
-
credit_card.billing_address.country_name.
|
373
|
-
credit_card.billing_address.country_code_alpha2.
|
374
|
-
credit_card.billing_address.country_code_alpha3.
|
375
|
-
credit_card.billing_address.country_code_numeric.
|
372
|
+
expect(credit_card.billing_address.country_name).to eq("United States of America")
|
373
|
+
expect(credit_card.billing_address.country_code_alpha2).to eq("US")
|
374
|
+
expect(credit_card.billing_address.country_code_alpha3).to eq("USA")
|
375
|
+
expect(credit_card.billing_address.country_code_numeric).to eq("840")
|
376
376
|
end
|
377
377
|
|
378
378
|
it "returns an error when given inconsistent country information" do
|
@@ -386,8 +386,8 @@ describe Braintree::CreditCard do
|
|
386
386
|
:country_code_alpha2 => "US"
|
387
387
|
},
|
388
388
|
)
|
389
|
-
result.success
|
390
|
-
result.errors.for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }.
|
389
|
+
expect(result.success?).to eq(false)
|
390
|
+
expect(result.errors.for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::InconsistentCountry)
|
391
391
|
end
|
392
392
|
|
393
393
|
it "returns an error response if unsuccessful" do
|
@@ -397,8 +397,8 @@ describe Braintree::CreditCard do
|
|
397
397
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
398
398
|
:expiration_date => "invalid_date",
|
399
399
|
)
|
400
|
-
result.success
|
401
|
-
result.errors.for(:credit_card).on(:expiration_date)[0].message.
|
400
|
+
expect(result.success?).to eq(false)
|
401
|
+
expect(result.errors.for(:credit_card).on(:expiration_date)[0].message).to eq("Expiration date is invalid.")
|
402
402
|
end
|
403
403
|
|
404
404
|
it "can set the default flag" do
|
@@ -408,7 +408,7 @@ describe Braintree::CreditCard do
|
|
408
408
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
409
409
|
:expiration_date => "05/2009",
|
410
410
|
).credit_card
|
411
|
-
card1.
|
411
|
+
expect(card1).to be_default
|
412
412
|
|
413
413
|
card2 = Braintree::CreditCard.create(
|
414
414
|
:customer_id => customer.id,
|
@@ -418,9 +418,9 @@ describe Braintree::CreditCard do
|
|
418
418
|
:make_default => true
|
419
419
|
},
|
420
420
|
).credit_card
|
421
|
-
card2.
|
421
|
+
expect(card2).to be_default
|
422
422
|
|
423
|
-
Braintree::CreditCard.find(card1.token).
|
423
|
+
expect(Braintree::CreditCard.find(card1.token)).not_to be_default
|
424
424
|
end
|
425
425
|
|
426
426
|
it "can set the network transaction identifier when creating a credit card" do
|
@@ -448,7 +448,7 @@ describe Braintree::CreditCard do
|
|
448
448
|
:options => {:verify_card => true},
|
449
449
|
)
|
450
450
|
credit_card = result.credit_card
|
451
|
-
credit_card.prepaid.
|
451
|
+
expect(credit_card.prepaid).to eq(Braintree::CreditCard::Prepaid::Yes)
|
452
452
|
end
|
453
453
|
|
454
454
|
it "sets the healthcare field if the card is healthcare" do
|
@@ -460,8 +460,8 @@ describe Braintree::CreditCard do
|
|
460
460
|
:options => {:verify_card => true},
|
461
461
|
)
|
462
462
|
credit_card = result.credit_card
|
463
|
-
credit_card.healthcare.
|
464
|
-
credit_card.product_id.
|
463
|
+
expect(credit_card.healthcare).to eq(Braintree::CreditCard::Healthcare::Yes)
|
464
|
+
expect(credit_card.product_id).to eq("J3")
|
465
465
|
end
|
466
466
|
|
467
467
|
it "sets the durbin regulated field if the card is durbin regulated" do
|
@@ -473,7 +473,7 @@ describe Braintree::CreditCard do
|
|
473
473
|
:options => {:verify_card => true},
|
474
474
|
)
|
475
475
|
credit_card = result.credit_card
|
476
|
-
credit_card.durbin_regulated.
|
476
|
+
expect(credit_card.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Yes)
|
477
477
|
end
|
478
478
|
|
479
479
|
it "sets the country of issuance field" do
|
@@ -485,7 +485,7 @@ describe Braintree::CreditCard do
|
|
485
485
|
:options => {:verify_card => true},
|
486
486
|
)
|
487
487
|
credit_card = result.credit_card
|
488
|
-
credit_card.country_of_issuance.
|
488
|
+
expect(credit_card.country_of_issuance).to eq(Braintree::Test::CreditCardDefaults::CountryOfIssuance)
|
489
489
|
end
|
490
490
|
|
491
491
|
it "sets the issuing bank field" do
|
@@ -497,7 +497,7 @@ describe Braintree::CreditCard do
|
|
497
497
|
:options => {:verify_card => true},
|
498
498
|
)
|
499
499
|
credit_card = result.credit_card
|
500
|
-
credit_card.issuing_bank.
|
500
|
+
expect(credit_card.issuing_bank).to eq(Braintree::Test::CreditCardDefaults::IssuingBank)
|
501
501
|
end
|
502
502
|
|
503
503
|
it "sets the payroll field if the card is payroll" do
|
@@ -509,8 +509,8 @@ describe Braintree::CreditCard do
|
|
509
509
|
:options => {:verify_card => true},
|
510
510
|
)
|
511
511
|
credit_card = result.credit_card
|
512
|
-
credit_card.payroll.
|
513
|
-
credit_card.product_id.
|
512
|
+
expect(credit_card.payroll).to eq(Braintree::CreditCard::Payroll::Yes)
|
513
|
+
expect(credit_card.product_id).to eq("MSA")
|
514
514
|
end
|
515
515
|
|
516
516
|
it "sets the debit field if the card is debit" do
|
@@ -522,7 +522,7 @@ describe Braintree::CreditCard do
|
|
522
522
|
:options => {:verify_card => true},
|
523
523
|
)
|
524
524
|
credit_card = result.credit_card
|
525
|
-
credit_card.debit.
|
525
|
+
expect(credit_card.debit).to eq(Braintree::CreditCard::Debit::Yes)
|
526
526
|
end
|
527
527
|
|
528
528
|
it "sets the commercial field if the card is commercial" do
|
@@ -534,7 +534,7 @@ describe Braintree::CreditCard do
|
|
534
534
|
:options => {:verify_card => true},
|
535
535
|
)
|
536
536
|
credit_card = result.credit_card
|
537
|
-
credit_card.commercial.
|
537
|
+
expect(credit_card.commercial).to eq(Braintree::CreditCard::Commercial::Yes)
|
538
538
|
end
|
539
539
|
|
540
540
|
it "sets negative card type identifiers" do
|
@@ -546,13 +546,13 @@ describe Braintree::CreditCard do
|
|
546
546
|
:options => {:verify_card => true},
|
547
547
|
)
|
548
548
|
credit_card = result.credit_card
|
549
|
-
credit_card.prepaid.
|
550
|
-
credit_card.commercial.
|
551
|
-
credit_card.payroll.
|
552
|
-
credit_card.debit.
|
553
|
-
credit_card.durbin_regulated.
|
554
|
-
credit_card.healthcare.
|
555
|
-
credit_card.product_id.
|
549
|
+
expect(credit_card.prepaid).to eq(Braintree::CreditCard::Prepaid::No)
|
550
|
+
expect(credit_card.commercial).to eq(Braintree::CreditCard::Prepaid::No)
|
551
|
+
expect(credit_card.payroll).to eq(Braintree::CreditCard::Prepaid::No)
|
552
|
+
expect(credit_card.debit).to eq(Braintree::CreditCard::Prepaid::No)
|
553
|
+
expect(credit_card.durbin_regulated).to eq(Braintree::CreditCard::Prepaid::No)
|
554
|
+
expect(credit_card.healthcare).to eq(Braintree::CreditCard::Prepaid::No)
|
555
|
+
expect(credit_card.product_id).to eq("MSB")
|
556
556
|
end
|
557
557
|
|
558
558
|
it "doesn't set the card type identifiers for an un-identified card" do
|
@@ -564,12 +564,12 @@ describe Braintree::CreditCard do
|
|
564
564
|
:options => {:verify_card => true},
|
565
565
|
)
|
566
566
|
credit_card = result.credit_card
|
567
|
-
credit_card.prepaid.
|
568
|
-
credit_card.commercial.
|
569
|
-
credit_card.payroll.
|
570
|
-
credit_card.debit.
|
571
|
-
credit_card.durbin_regulated.
|
572
|
-
credit_card.healthcare.
|
567
|
+
expect(credit_card.prepaid).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
568
|
+
expect(credit_card.commercial).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
569
|
+
expect(credit_card.payroll).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
570
|
+
expect(credit_card.debit).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
571
|
+
expect(credit_card.durbin_regulated).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
572
|
+
expect(credit_card.healthcare).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
573
573
|
credit_card.country_of_issuance == Braintree::CreditCard::CountryOfIssuance::Unknown
|
574
574
|
credit_card.issuing_bank == Braintree::CreditCard::IssuingBank::Unknown
|
575
575
|
credit_card.product_id == Braintree::CreditCard::ProductId::Unknown
|
@@ -592,11 +592,11 @@ describe Braintree::CreditCard do
|
|
592
592
|
:payment_method_nonce => nonce,
|
593
593
|
)
|
594
594
|
|
595
|
-
result.success
|
595
|
+
expect(result.success?).to eq(true)
|
596
596
|
credit_card = result.credit_card
|
597
|
-
credit_card.bin.
|
598
|
-
credit_card.last_4.
|
599
|
-
credit_card.expiration_date.
|
597
|
+
expect(credit_card.bin).to eq("411111")
|
598
|
+
expect(credit_card.last_4).to eq("1111")
|
599
|
+
expect(credit_card.expiration_date).to eq("11/2099")
|
600
600
|
end
|
601
601
|
end
|
602
602
|
|
@@ -608,9 +608,9 @@ describe Braintree::CreditCard do
|
|
608
608
|
:number => Braintree::Test::CreditCardNumbers::Elo,
|
609
609
|
:expiration_date => "10/2020",
|
610
610
|
)
|
611
|
-
result.success
|
611
|
+
expect(result.success?).to eq(true)
|
612
612
|
credit_card = result.credit_card
|
613
|
-
credit_card.card_type.
|
613
|
+
expect(credit_card.card_type).to eq(Braintree::CreditCard::CardType::Elo)
|
614
614
|
end
|
615
615
|
end
|
616
616
|
|
@@ -693,10 +693,10 @@ describe Braintree::CreditCard do
|
|
693
693
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
694
694
|
:expiration_date => "05/2009",
|
695
695
|
)
|
696
|
-
credit_card.bin.
|
697
|
-
credit_card.cardholder_name.
|
698
|
-
credit_card.last_4.
|
699
|
-
credit_card.expiration_date.
|
696
|
+
expect(credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
697
|
+
expect(credit_card.cardholder_name).to eq("Adam Davis")
|
698
|
+
expect(credit_card.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
699
|
+
expect(credit_card.expiration_date).to eq("05/2009")
|
700
700
|
end
|
701
701
|
|
702
702
|
it "raises a ValidationsFailed if unsuccessful" do
|
@@ -723,14 +723,14 @@ describe Braintree::CreditCard do
|
|
723
723
|
customer.credit_cards[0].token,
|
724
724
|
:amount => "100.00",
|
725
725
|
)
|
726
|
-
result.success
|
727
|
-
result.transaction.amount.
|
728
|
-
result.transaction.type.
|
729
|
-
result.transaction.customer_details.id.
|
730
|
-
result.transaction.credit_card_details.token.
|
731
|
-
result.transaction.credit_card_details.bin.
|
732
|
-
result.transaction.credit_card_details.last_4.
|
733
|
-
result.transaction.credit_card_details.expiration_date.
|
726
|
+
expect(result.success?).to eq(true)
|
727
|
+
expect(result.transaction.amount).to eq(BigDecimal("100.00"))
|
728
|
+
expect(result.transaction.type).to eq("credit")
|
729
|
+
expect(result.transaction.customer_details.id).to eq(customer.id)
|
730
|
+
expect(result.transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
731
|
+
expect(result.transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
732
|
+
expect(result.transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
733
|
+
expect(result.transaction.credit_card_details.expiration_date).to eq("05/2010")
|
734
734
|
end
|
735
735
|
end
|
736
736
|
|
@@ -746,13 +746,13 @@ describe Braintree::CreditCard do
|
|
746
746
|
customer.credit_cards[0].token,
|
747
747
|
:amount => "100.00",
|
748
748
|
)
|
749
|
-
transaction.amount.
|
750
|
-
transaction.type.
|
751
|
-
transaction.customer_details.id.
|
752
|
-
transaction.credit_card_details.token.
|
753
|
-
transaction.credit_card_details.bin.
|
754
|
-
transaction.credit_card_details.last_4.
|
755
|
-
transaction.credit_card_details.expiration_date.
|
749
|
+
expect(transaction.amount).to eq(BigDecimal("100.00"))
|
750
|
+
expect(transaction.type).to eq("credit")
|
751
|
+
expect(transaction.customer_details.id).to eq(customer.id)
|
752
|
+
expect(transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
753
|
+
expect(transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
754
|
+
expect(transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
755
|
+
expect(transaction.credit_card_details.expiration_date).to eq("05/2010")
|
756
756
|
end
|
757
757
|
end
|
758
758
|
|
@@ -772,13 +772,13 @@ describe Braintree::CreditCard do
|
|
772
772
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
773
773
|
:expiration_date => "06/2013",
|
774
774
|
)
|
775
|
-
update_result.success
|
776
|
-
update_result.credit_card.
|
775
|
+
expect(update_result.success?).to eq(true)
|
776
|
+
expect(update_result.credit_card).to eq(credit_card)
|
777
777
|
updated_credit_card = update_result.credit_card
|
778
|
-
updated_credit_card.bin.
|
779
|
-
updated_credit_card.last_4.
|
780
|
-
updated_credit_card.expiration_date.
|
781
|
-
updated_credit_card.cardholder_name.
|
778
|
+
expect(updated_credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::MasterCard[0, 6])
|
779
|
+
expect(updated_credit_card.last_4).to eq(Braintree::Test::CreditCardNumbers::MasterCard[-4..-1])
|
780
|
+
expect(updated_credit_card.expiration_date).to eq("06/2013")
|
781
|
+
expect(updated_credit_card.cardholder_name).to eq("New Holder")
|
782
782
|
end
|
783
783
|
|
784
784
|
it "validates presence of three_d_secure_version in 3ds pass thru params" do
|
@@ -833,7 +833,7 @@ describe Braintree::CreditCard do
|
|
833
833
|
:options => {:verify_card => true},
|
834
834
|
)
|
835
835
|
|
836
|
-
result.success
|
836
|
+
expect(result.success?).to eq(true)
|
837
837
|
end
|
838
838
|
|
839
839
|
it "includes risk data when skip_advanced_fraud_checking is false" do
|
@@ -900,11 +900,11 @@ describe Braintree::CreditCard do
|
|
900
900
|
:region => "IL"
|
901
901
|
},
|
902
902
|
)
|
903
|
-
update_result.success
|
903
|
+
expect(update_result.success?).to eq(true)
|
904
904
|
updated_credit_card = update_result.credit_card
|
905
|
-
updated_credit_card.billing_address.region.
|
906
|
-
updated_credit_card.billing_address.street_address.
|
907
|
-
updated_credit_card.billing_address.id.
|
905
|
+
expect(updated_credit_card.billing_address.region).to eq("IL")
|
906
|
+
expect(updated_credit_card.billing_address.street_address).to eq(nil)
|
907
|
+
expect(updated_credit_card.billing_address.id).not_to eq(credit_card.billing_address.id)
|
908
908
|
end
|
909
909
|
|
910
910
|
it "updates the billing address if option is specified" do
|
@@ -923,11 +923,11 @@ describe Braintree::CreditCard do
|
|
923
923
|
:options => {:update_existing => true}
|
924
924
|
},
|
925
925
|
)
|
926
|
-
update_result.success
|
926
|
+
expect(update_result.success?).to eq(true)
|
927
927
|
updated_credit_card = update_result.credit_card
|
928
|
-
updated_credit_card.billing_address.region.
|
929
|
-
updated_credit_card.billing_address.street_address.
|
930
|
-
updated_credit_card.billing_address.id.
|
928
|
+
expect(updated_credit_card.billing_address.region).to eq("IL")
|
929
|
+
expect(updated_credit_card.billing_address.street_address).to eq("123 Nigeria Ave")
|
930
|
+
expect(updated_credit_card.billing_address.id).to eq(credit_card.billing_address.id)
|
931
931
|
end
|
932
932
|
|
933
933
|
it "updates the country via codes" do
|
@@ -949,12 +949,12 @@ describe Braintree::CreditCard do
|
|
949
949
|
:options => {:update_existing => true}
|
950
950
|
},
|
951
951
|
)
|
952
|
-
update_result.success
|
952
|
+
expect(update_result.success?).to eq(true)
|
953
953
|
updated_credit_card = update_result.credit_card
|
954
|
-
updated_credit_card.billing_address.country_name.
|
955
|
-
updated_credit_card.billing_address.country_code_alpha2.
|
956
|
-
updated_credit_card.billing_address.country_code_alpha3.
|
957
|
-
updated_credit_card.billing_address.country_code_numeric.
|
954
|
+
expect(updated_credit_card.billing_address.country_name).to eq("American Samoa")
|
955
|
+
expect(updated_credit_card.billing_address.country_code_alpha2).to eq("AS")
|
956
|
+
expect(updated_credit_card.billing_address.country_code_alpha3).to eq("ASM")
|
957
|
+
expect(updated_credit_card.billing_address.country_code_numeric).to eq("016")
|
958
958
|
end
|
959
959
|
end
|
960
960
|
|
@@ -970,11 +970,11 @@ describe Braintree::CreditCard do
|
|
970
970
|
:expiration_month => "07",
|
971
971
|
:expiration_year => "2011",
|
972
972
|
)
|
973
|
-
update_result.success
|
974
|
-
update_result.credit_card.
|
975
|
-
update_result.credit_card.expiration_month.
|
976
|
-
update_result.credit_card.expiration_year.
|
977
|
-
update_result.credit_card.expiration_date.
|
973
|
+
expect(update_result.success?).to eq(true)
|
974
|
+
expect(update_result.credit_card).to eq(credit_card)
|
975
|
+
expect(update_result.credit_card.expiration_month).to eq("07")
|
976
|
+
expect(update_result.credit_card.expiration_year).to eq("2011")
|
977
|
+
expect(update_result.credit_card.expiration_date).to eq("07/2011")
|
978
978
|
end
|
979
979
|
|
980
980
|
it "verifies the update if options[verify_card]=true" do
|
@@ -993,9 +993,9 @@ describe Braintree::CreditCard do
|
|
993
993
|
:expiration_date => "06/2013",
|
994
994
|
:options => {:verify_card => true},
|
995
995
|
)
|
996
|
-
update_result.success
|
997
|
-
update_result.credit_card_verification.status.
|
998
|
-
update_result.credit_card_verification.gateway_rejection_reason.
|
996
|
+
expect(update_result.success?).to eq(false)
|
997
|
+
expect(update_result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::ProcessorDeclined)
|
998
|
+
expect(update_result.credit_card_verification.gateway_rejection_reason).to be_nil
|
999
999
|
end
|
1000
1000
|
|
1001
1001
|
it "can update the billing address" do
|
@@ -1032,17 +1032,17 @@ describe Braintree::CreditCard do
|
|
1032
1032
|
:country_name => "United States of America"
|
1033
1033
|
},
|
1034
1034
|
)
|
1035
|
-
result.success
|
1035
|
+
expect(result.success?).to eq(true)
|
1036
1036
|
address = result.credit_card.billing_address
|
1037
|
-
address.first_name.
|
1038
|
-
address.last_name.
|
1039
|
-
address.company.
|
1040
|
-
address.street_address.
|
1041
|
-
address.extended_address.
|
1042
|
-
address.locality.
|
1043
|
-
address.region.
|
1044
|
-
address.postal_code.
|
1045
|
-
address.country_name.
|
1037
|
+
expect(address.first_name).to eq("New First Name")
|
1038
|
+
expect(address.last_name).to eq("New Last Name")
|
1039
|
+
expect(address.company).to eq("New Company")
|
1040
|
+
expect(address.street_address).to eq("123 New St")
|
1041
|
+
expect(address.extended_address).to eq("Apt New")
|
1042
|
+
expect(address.locality).to eq("New City")
|
1043
|
+
expect(address.region).to eq("New State")
|
1044
|
+
expect(address.postal_code).to eq("56789")
|
1045
|
+
expect(address.country_name).to eq("United States of America")
|
1046
1046
|
end
|
1047
1047
|
|
1048
1048
|
it "returns an error response if invalid" do
|
@@ -1058,8 +1058,8 @@ describe Braintree::CreditCard do
|
|
1058
1058
|
:number => "invalid",
|
1059
1059
|
:expiration_date => "05/2014",
|
1060
1060
|
)
|
1061
|
-
update_result.success
|
1062
|
-
update_result.errors.for(:credit_card).on(:number)[0].message.
|
1061
|
+
expect(update_result.success?).to eq(false)
|
1062
|
+
expect(update_result.errors.for(:credit_card).on(:number)[0].message).to eq("Credit card number must be 12-19 digits.")
|
1063
1063
|
end
|
1064
1064
|
|
1065
1065
|
it "can update the default" do
|
@@ -1075,13 +1075,13 @@ describe Braintree::CreditCard do
|
|
1075
1075
|
:expiration_date => "05/2009",
|
1076
1076
|
).credit_card
|
1077
1077
|
|
1078
|
-
card1.
|
1079
|
-
card2.
|
1078
|
+
expect(card1).to be_default
|
1079
|
+
expect(card2).not_to be_default
|
1080
1080
|
|
1081
1081
|
Braintree::CreditCard.update(card2.token, :options => {:make_default => true})
|
1082
1082
|
|
1083
|
-
Braintree::CreditCard.find(card1.token).
|
1084
|
-
Braintree::CreditCard.find(card2.token).
|
1083
|
+
expect(Braintree::CreditCard.find(card1.token)).not_to be_default
|
1084
|
+
expect(Braintree::CreditCard.find(card2.token)).to be_default
|
1085
1085
|
end
|
1086
1086
|
|
1087
1087
|
context "verification_account_type" do
|
@@ -1137,12 +1137,12 @@ describe Braintree::CreditCard do
|
|
1137
1137
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1138
1138
|
:expiration_date => "06/2013",
|
1139
1139
|
)
|
1140
|
-
updated_credit_card.token.
|
1141
|
-
updated_credit_card.bin.
|
1142
|
-
updated_credit_card.last_4.
|
1143
|
-
updated_credit_card.expiration_date.
|
1144
|
-
updated_credit_card.cardholder_name.
|
1145
|
-
updated_credit_card.updated_at.between?(Time.now - 60, Time.now).
|
1140
|
+
expect(updated_credit_card.token).to eq(credit_card.token)
|
1141
|
+
expect(updated_credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::MasterCard[0, 6])
|
1142
|
+
expect(updated_credit_card.last_4).to eq(Braintree::Test::CreditCardNumbers::MasterCard[-4..-1])
|
1143
|
+
expect(updated_credit_card.expiration_date).to eq("06/2013")
|
1144
|
+
expect(updated_credit_card.cardholder_name).to eq("New Holder")
|
1145
|
+
expect(updated_credit_card.updated_at.between?(Time.now - 60, Time.now)).to eq(true)
|
1146
1146
|
end
|
1147
1147
|
|
1148
1148
|
it "raises a ValidationsFailed if invalid" do
|
@@ -1172,9 +1172,9 @@ describe Braintree::CreditCard do
|
|
1172
1172
|
:expiration_date => "05/2012",
|
1173
1173
|
)
|
1174
1174
|
|
1175
|
-
result.success
|
1175
|
+
expect(result.success?).to eq(true)
|
1176
1176
|
credit_card = result.credit_card
|
1177
|
-
Braintree::CreditCard.delete(credit_card.token).
|
1177
|
+
expect(Braintree::CreditCard.delete(credit_card.token)).to eq(true)
|
1178
1178
|
expect do
|
1179
1179
|
Braintree::CreditCard.find(credit_card.token)
|
1180
1180
|
end.to raise_error(Braintree::NotFoundError)
|
@@ -1194,13 +1194,13 @@ describe Braintree::CreditCard do
|
|
1194
1194
|
end
|
1195
1195
|
|
1196
1196
|
collection = Braintree::CreditCard.expired
|
1197
|
-
collection.maximum_size.
|
1197
|
+
expect(collection.maximum_size).to be > 100
|
1198
1198
|
|
1199
1199
|
credit_card_ids = collection.map do |c|
|
1200
|
-
c.expired
|
1200
|
+
expect(c.expired?).to eq(true)
|
1201
1201
|
c.token
|
1202
1202
|
end.uniq.compact
|
1203
|
-
credit_card_ids.size.
|
1203
|
+
expect(credit_card_ids.size).to eq(collection.maximum_size)
|
1204
1204
|
end
|
1205
1205
|
end
|
1206
1206
|
|
@@ -1208,9 +1208,9 @@ describe Braintree::CreditCard do
|
|
1208
1208
|
it "finds payment methods expiring between the given dates" do
|
1209
1209
|
next_year = Time.now.year + 1
|
1210
1210
|
collection = Braintree::CreditCard.expiring_between(Time.mktime(next_year, 1), Time.mktime(next_year, 12))
|
1211
|
-
collection.maximum_size.
|
1212
|
-
collection.all? { |pm| pm.expired
|
1213
|
-
collection.all? { |pm| pm.expiration_year.
|
1211
|
+
expect(collection.maximum_size).to be > 0
|
1212
|
+
collection.all? { |pm| expect(pm.expired?).to eq(false) }
|
1213
|
+
collection.all? { |pm| expect(pm.expiration_year).to eq(next_year.to_s) }
|
1214
1214
|
end
|
1215
1215
|
|
1216
1216
|
it "can iterate over all items" do
|
@@ -1225,10 +1225,10 @@ describe Braintree::CreditCard do
|
|
1225
1225
|
end
|
1226
1226
|
|
1227
1227
|
collection = Braintree::CreditCard.expiring_between(Time.mktime(2010, 1, 1), Time.mktime(2010,3, 1))
|
1228
|
-
collection.maximum_size.
|
1228
|
+
expect(collection.maximum_size).to be > 100
|
1229
1229
|
|
1230
1230
|
credit_card_ids = collection.map { |c| c.token }.uniq.compact
|
1231
|
-
credit_card_ids.size.
|
1231
|
+
expect(credit_card_ids.size).to eq(collection.maximum_size)
|
1232
1232
|
end
|
1233
1233
|
end
|
1234
1234
|
|
@@ -1240,12 +1240,12 @@ describe Braintree::CreditCard do
|
|
1240
1240
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1241
1241
|
:expiration_date => "05/2012",
|
1242
1242
|
)
|
1243
|
-
result.success
|
1243
|
+
expect(result.success?).to eq(true)
|
1244
1244
|
credit_card = Braintree::CreditCard.find(result.credit_card.token)
|
1245
|
-
credit_card.bin.
|
1246
|
-
credit_card.last_4.
|
1247
|
-
credit_card.token.
|
1248
|
-
credit_card.expiration_date.
|
1245
|
+
expect(credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
1246
|
+
expect(credit_card.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
1247
|
+
expect(credit_card.token).to eq(result.credit_card.token)
|
1248
|
+
expect(credit_card.expiration_date).to eq("05/2012")
|
1249
1249
|
end
|
1250
1250
|
|
1251
1251
|
it "returns associated subscriptions with the credit card" do
|
@@ -1263,10 +1263,10 @@ describe Braintree::CreditCard do
|
|
1263
1263
|
).subscription
|
1264
1264
|
|
1265
1265
|
found_card = Braintree::CreditCard.find(credit_card.token)
|
1266
|
-
found_card.subscriptions.first.id.
|
1267
|
-
found_card.subscriptions.first.plan_id.
|
1268
|
-
found_card.subscriptions.first.payment_method_token.
|
1269
|
-
found_card.subscriptions.first.price.
|
1266
|
+
expect(found_card.subscriptions.first.id).to eq(subscription.id)
|
1267
|
+
expect(found_card.subscriptions.first.plan_id).to eq("integration_trialless_plan")
|
1268
|
+
expect(found_card.subscriptions.first.payment_method_token).to eq(credit_card.token)
|
1269
|
+
expect(found_card.subscriptions.first.price).to eq(BigDecimal("1.00"))
|
1270
1270
|
end
|
1271
1271
|
|
1272
1272
|
it "raises a NotFoundError exception if payment method cannot be found" do
|
@@ -1308,7 +1308,7 @@ describe Braintree::CreditCard do
|
|
1308
1308
|
|
1309
1309
|
credit_card = Braintree::CreditCard.from_nonce(nonce)
|
1310
1310
|
customer = Braintree::Customer.find(customer.id)
|
1311
|
-
credit_card.
|
1311
|
+
expect(credit_card).to eq(customer.credit_cards.first)
|
1312
1312
|
end
|
1313
1313
|
|
1314
1314
|
it "does not find a payment method for an unlocked nonce that points to a shared credit card" do
|
@@ -1352,14 +1352,14 @@ describe Braintree::CreditCard do
|
|
1352
1352
|
)
|
1353
1353
|
result = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00")
|
1354
1354
|
|
1355
|
-
result.success
|
1356
|
-
result.transaction.amount.
|
1357
|
-
result.transaction.type.
|
1358
|
-
result.transaction.customer_details.id.
|
1359
|
-
result.transaction.credit_card_details.token.
|
1360
|
-
result.transaction.credit_card_details.bin.
|
1361
|
-
result.transaction.credit_card_details.last_4.
|
1362
|
-
result.transaction.credit_card_details.expiration_date.
|
1355
|
+
expect(result.success?).to eq(true)
|
1356
|
+
expect(result.transaction.amount).to eq(BigDecimal("100.00"))
|
1357
|
+
expect(result.transaction.type).to eq("sale")
|
1358
|
+
expect(result.transaction.customer_details.id).to eq(customer.id)
|
1359
|
+
expect(result.transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
1360
|
+
expect(result.transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
1361
|
+
expect(result.transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
1362
|
+
expect(result.transaction.credit_card_details.expiration_date).to eq("05/2010")
|
1363
1363
|
end
|
1364
1364
|
|
1365
1365
|
it "allows passing a cvv in addition to the token" do
|
@@ -1376,12 +1376,12 @@ describe Braintree::CreditCard do
|
|
1376
1376
|
},
|
1377
1377
|
)
|
1378
1378
|
|
1379
|
-
result.success
|
1380
|
-
result.transaction.amount.
|
1381
|
-
result.transaction.type.
|
1382
|
-
result.transaction.customer_details.id.
|
1383
|
-
result.transaction.credit_card_details.token.
|
1384
|
-
result.transaction.cvv_response_code.
|
1379
|
+
expect(result.success?).to eq(true)
|
1380
|
+
expect(result.transaction.amount).to eq(BigDecimal("100.00"))
|
1381
|
+
expect(result.transaction.type).to eq("sale")
|
1382
|
+
expect(result.transaction.customer_details.id).to eq(customer.id)
|
1383
|
+
expect(result.transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
1384
|
+
expect(result.transaction.cvv_response_code).to eq("S")
|
1385
1385
|
end
|
1386
1386
|
end
|
1387
1387
|
|
@@ -1394,13 +1394,13 @@ describe Braintree::CreditCard do
|
|
1394
1394
|
},
|
1395
1395
|
)
|
1396
1396
|
transaction = Braintree::CreditCard.sale!(customer.credit_cards[0].token, :amount => "100.00")
|
1397
|
-
transaction.amount.
|
1398
|
-
transaction.type.
|
1399
|
-
transaction.customer_details.id.
|
1400
|
-
transaction.credit_card_details.token.
|
1401
|
-
transaction.credit_card_details.bin.
|
1402
|
-
transaction.credit_card_details.last_4.
|
1403
|
-
transaction.credit_card_details.expiration_date.
|
1397
|
+
expect(transaction.amount).to eq(BigDecimal("100.00"))
|
1398
|
+
expect(transaction.type).to eq("sale")
|
1399
|
+
expect(transaction.customer_details.id).to eq(customer.id)
|
1400
|
+
expect(transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
1401
|
+
expect(transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
1402
|
+
expect(transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
1403
|
+
expect(transaction.credit_card_details.expiration_date).to eq("05/2010")
|
1404
1404
|
end
|
1405
1405
|
end
|
1406
1406
|
|
@@ -1414,14 +1414,14 @@ describe Braintree::CreditCard do
|
|
1414
1414
|
:expiration_date => "05/2012",
|
1415
1415
|
)
|
1416
1416
|
|
1417
|
-
credit_card.nonce.
|
1417
|
+
expect(credit_card.nonce).not_to be_nil
|
1418
1418
|
end
|
1419
1419
|
end
|
1420
1420
|
|
1421
1421
|
describe "card on file network tokenization" do
|
1422
1422
|
it "should find a network tokenized credit card" do
|
1423
1423
|
credit_card = Braintree::CreditCard.find("network_tokenized_credit_card")
|
1424
|
-
credit_card.is_network_tokenized
|
1424
|
+
expect(credit_card.is_network_tokenized?).to eq(true)
|
1425
1425
|
end
|
1426
1426
|
|
1427
1427
|
it "should find a non-network tokenized credit card" do
|
@@ -1432,7 +1432,7 @@ describe Braintree::CreditCard do
|
|
1432
1432
|
:expiration_date => "05/2009",
|
1433
1433
|
).credit_card
|
1434
1434
|
credit_card_vaulted = Braintree::CreditCard.find(credit_card.token)
|
1435
|
-
credit_card_vaulted.is_network_tokenized
|
1435
|
+
expect(credit_card_vaulted.is_network_tokenized?).to eq(false)
|
1436
1436
|
end
|
1437
1437
|
end
|
1438
1438
|
end
|