braintree 2.98.0 → 4.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/braintree.gemspec +7 -4
- data/lib/braintree/account_updater_daily_report.rb +4 -4
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +7 -27
- data/lib/braintree/address_gateway.rb +8 -7
- data/lib/braintree/advanced_search.rb +11 -12
- data/lib/braintree/apple_pay.rb +4 -4
- data/lib/braintree/apple_pay_card.rb +18 -4
- data/lib/braintree/apple_pay_options.rb +4 -4
- data/lib/braintree/authorization_adjustment.rb +4 -4
- data/lib/braintree/base_module.rb +11 -1
- data/lib/braintree/bin_data.rb +10 -3
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/client_token_gateway.rb +4 -3
- data/lib/braintree/configuration.rb +35 -35
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +2 -2
- data/lib/braintree/connected_merchant_status_transitioned.rb +2 -2
- data/lib/braintree/credit_card.rb +40 -86
- data/lib/braintree/credit_card_gateway.rb +58 -44
- data/lib/braintree/credit_card_verification.rb +39 -20
- data/lib/braintree/credit_card_verification_gateway.rb +35 -5
- data/lib/braintree/credit_card_verification_search.rb +2 -2
- data/lib/braintree/customer.rb +23 -88
- data/lib/braintree/customer_gateway.rb +17 -32
- data/lib/braintree/customer_search.rb +2 -2
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +7 -7
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
- data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
- data/lib/braintree/dispute/transaction.rb +3 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +47 -6
- data/lib/braintree/dispute_gateway.rb +5 -10
- data/lib/braintree/dispute_search.rb +8 -4
- data/lib/braintree/document_upload.rb +3 -3
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +217 -175
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +6 -5
- data/lib/braintree/exchange_rate.rb +13 -0
- data/lib/braintree/exchange_rate_quote.rb +24 -0
- data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
- data/lib/braintree/exchange_rate_quote_input.rb +21 -0
- data/lib/braintree/exchange_rate_quote_request.rb +18 -0
- data/lib/braintree/exchange_rate_quote_response.rb +18 -0
- data/lib/braintree/facilitated_details.rb +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/gateway.rb +6 -12
- data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +18 -5
- data/lib/braintree/granted_payment_instrument_update.rb +2 -2
- data/lib/braintree/graphql_client.rb +14 -8
- data/lib/braintree/http.rb +9 -10
- data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
- data/lib/braintree/local_payment_completed.rb +10 -5
- data/lib/braintree/local_payment_expired.rb +21 -0
- data/lib/braintree/local_payment_funded.rb +22 -0
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +4 -4
- data/lib/braintree/merchant_account.rb +3 -3
- data/lib/braintree/merchant_account_gateway.rb +10 -8
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +4 -4
- data/lib/braintree/oauth_credentials.rb +4 -4
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +14 -13
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +52 -22
- data/lib/braintree/payment_method_nonce.rb +12 -7
- data/lib/braintree/payment_method_nonce_details.rb +40 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +14 -3
- data/lib/braintree/payment_method_parser.rb +4 -7
- data/lib/braintree/paypal_account.rb +3 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +22 -2
- data/lib/braintree/plan_gateway.rb +101 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/resource_collection.rb +10 -5
- data/lib/braintree/revoked_payment_method_metadata.rb +2 -2
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +10 -3
- data/lib/braintree/samsung_pay_card.rb +8 -6
- data/lib/braintree/sepa_direct_debit_account.rb +60 -0
- data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- 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 +13 -13
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +5 -4
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +9 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +27 -20
- 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 +23 -11
- data/lib/braintree/transaction/address_details.rb +14 -1
- data/lib/braintree/transaction/apple_pay_details.rb +13 -10
- data/lib/braintree/transaction/credit_card_details.rb +8 -1
- data/lib/braintree/transaction/customer_details.rb +3 -2
- data/lib/braintree/transaction/disbursement_details.rb +2 -1
- data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +6 -1
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/local_payment_details.rb +3 -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/package_details.rb +19 -0
- data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
- data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
- data/lib/braintree/transaction/payment_receipt.rb +31 -0
- data/lib/braintree/transaction/paypal_details.rb +5 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +3 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +3 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +2 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +119 -128
- data/lib/braintree/transaction_gateway.rb +138 -64
- data/lib/braintree/transaction_line_item.rb +14 -11
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +11 -7
- data/lib/braintree/unknown_payment_method.rb +2 -2
- data/lib/braintree/us_bank_account.rb +5 -5
- data/lib/braintree/us_bank_account_verification.rb +24 -16
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +25 -10
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +4 -4
- data/lib/braintree/venmo_profile_data.rb +25 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +8 -8
- data/lib/braintree/webhook_notification.rb +55 -33
- data/lib/braintree/webhook_notification_gateway.rb +9 -9
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +569 -46
- data/lib/braintree/xml/generator.rb +6 -5
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +24 -37
- data/lib/braintree/xml/rexml.rb +6 -7
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +41 -24
- data/lib/ssl/api_braintreegateway_com.ca.crt +401 -168
- data/spec/integration/braintree/add_on_spec.rb +10 -10
- data/spec/integration/braintree/address_spec.rb +101 -178
- data/spec/integration/braintree/advanced_search_spec.rb +93 -93
- data/spec/integration/braintree/apple_pay_spec.rb +12 -12
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +279 -62
- data/spec/integration/braintree/client_api/spec_helper.rb +99 -73
- data/spec/integration/braintree/credit_card_spec.rb +522 -821
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/credit_card_verification_spec.rb +219 -30
- data/spec/integration/braintree/customer_search_spec.rb +28 -28
- data/spec/integration/braintree/customer_spec.rb +840 -757
- 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 +45 -9
- data/spec/integration/braintree/dispute_spec.rb +109 -82
- data/spec/integration/braintree/document_upload_spec.rb +29 -17
- data/spec/integration/braintree/error_codes_spec.rb +3 -3
- data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
- data/spec/integration/braintree/graphql_client_spec.rb +0 -2
- data/spec/integration/braintree/http_spec.rb +31 -33
- data/spec/integration/braintree/merchant_account_spec.rb +155 -156
- data/spec/integration/braintree/merchant_spec.rb +71 -192
- data/spec/integration/braintree/oauth_spec.rb +72 -72
- data/spec/integration/braintree/package_tracking_spec.rb +130 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +173 -78
- data/spec/integration/braintree/payment_method_spec.rb +953 -501
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +147 -234
- data/spec/integration/braintree/paypal_account_spec.rb +74 -72
- data/spec/integration/braintree/plan_spec.rb +96 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +75 -73
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +194 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +18 -18
- data/spec/integration/braintree/subscription_spec.rb +507 -513
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +4 -4
- data/spec/integration/braintree/test_transaction_spec.rb +29 -29
- data/spec/integration/braintree/transaction_line_item_spec.rb +12 -6
- data/spec/integration/braintree/transaction_search_spec.rb +410 -217
- data/spec/integration/braintree/transaction_spec.rb +3252 -2102
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +42 -278
- data/spec/integration/braintree/us_bank_account_spec.rb +36 -36
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +25 -25
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +41 -41
- data/spec/integration/braintree/visa_checkout_card_spec.rb +62 -62
- data/spec/integration/spec_helper.rb +22 -7
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +15 -20
- data/spec/unit/braintree/address_spec.rb +9 -17
- data/spec/unit/braintree/apple_pay_card_spec.rb +110 -7
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +6 -6
- data/spec/unit/braintree/configuration_spec.rb +84 -84
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +91 -58
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +56 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +10 -10
- data/spec/unit/braintree/credit_card_verification_spec.rb +40 -18
- data/spec/unit/braintree/customer_spec.rb +102 -57
- data/spec/unit/braintree/digest_spec.rb +5 -6
- data/spec/unit/braintree/disbursement_spec.rb +14 -14
- data/spec/unit/braintree/dispute_search_spec.rb +6 -2
- data/spec/unit/braintree/dispute_spec.rb +144 -66
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +41 -0
- data/spec/unit/braintree/error_result_spec.rb +11 -11
- data/spec/unit/braintree/errors_spec.rb +17 -17
- data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
- data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
- data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
- data/spec/unit/braintree/http_spec.rb +19 -17
- data/spec/unit/braintree/local_payment_completed_spec.rb +62 -8
- data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
- data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
- data/spec/unit/braintree/merchant_account_spec.rb +5 -5
- 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/package_tracking_spec.rb +77 -0
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
- data/spec/unit/braintree/payment_method_spec.rb +20 -20
- data/spec/unit/braintree/paypal_account_spec.rb +16 -7
- data/spec/unit/braintree/resource_collection_spec.rb +34 -5
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +38 -8
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
- data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
- 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 +18 -18
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +6 -6
- data/spec/unit/braintree/three_d_secure_info_spec.rb +37 -17
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +22 -6
- data/spec/unit/braintree/transaction/customer_details_spec.rb +3 -2
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +4 -4
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +36 -0
- data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +150 -0
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +221 -124
- 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 +78 -44
- data/spec/unit/braintree/validation_error_collection_spec.rb +62 -62
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +43 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +434 -197
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +27 -22
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +38 -38
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +91 -30
- data/lib/braintree/amex_express_checkout_card.rb +0 -38
- data/lib/braintree/coinbase_account.rb +0 -34
- data/lib/braintree/europe_bank_account.rb +0 -36
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -61
- data/lib/braintree/ideal_payment_gateway.rb +0 -19
- data/lib/braintree/masterpass_card.rb +0 -81
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
- data/lib/braintree/transaction/masterpass_card_details.rb +0 -47
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/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
@@ -15,17 +15,17 @@ describe Braintree::CreditCard do
|
|
15
15
|
:customer_id => customer.id,
|
16
16
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
17
17
|
:expiration_date => "05/2009",
|
18
|
-
:cvv => "100"
|
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
|
@@ -35,10 +35,9 @@ describe Braintree::CreditCard do
|
|
35
35
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
36
36
|
:expiration_date => "05/2009",
|
37
37
|
:cvv => "100",
|
38
|
-
:
|
39
|
-
:fraud_merchant_id => "7"
|
38
|
+
:device_data => "device_data",
|
40
39
|
)
|
41
|
-
result.success
|
40
|
+
expect(result.success?).to eq(true)
|
42
41
|
end
|
43
42
|
|
44
43
|
it "can provide expiration month and year separately" do
|
@@ -47,13 +46,13 @@ describe Braintree::CreditCard do
|
|
47
46
|
:customer_id => customer.id,
|
48
47
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
49
48
|
:expiration_month => "05",
|
50
|
-
:expiration_year => "2012"
|
49
|
+
:expiration_year => "2012",
|
51
50
|
)
|
52
|
-
result.success
|
51
|
+
expect(result.success?).to eq(true)
|
53
52
|
credit_card = result.credit_card
|
54
|
-
credit_card.expiration_month.
|
55
|
-
credit_card.expiration_year.
|
56
|
-
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")
|
57
56
|
end
|
58
57
|
|
59
58
|
it "can specify the desired token" do
|
@@ -64,14 +63,14 @@ describe Braintree::CreditCard do
|
|
64
63
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
65
64
|
:expiration_date => "05/2009",
|
66
65
|
:cvv => "100",
|
67
|
-
:token => token
|
66
|
+
:token => token,
|
68
67
|
)
|
69
|
-
result.success
|
68
|
+
expect(result.success?).to eq(true)
|
70
69
|
credit_card = result.credit_card
|
71
|
-
credit_card.token.
|
72
|
-
credit_card.bin.
|
73
|
-
credit_card.last_4.
|
74
|
-
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")
|
75
74
|
end
|
76
75
|
|
77
76
|
it "accepts billing_address_id" do
|
@@ -82,12 +81,12 @@ describe Braintree::CreditCard do
|
|
82
81
|
:customer_id => customer.id,
|
83
82
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
84
83
|
:expiration_date => "05/2009",
|
85
|
-
:billing_address_id => address.id
|
84
|
+
:billing_address_id => address.id,
|
86
85
|
).credit_card
|
87
86
|
|
88
|
-
credit_card.billing_address.id.
|
89
|
-
credit_card.billing_address.first_name.
|
90
|
-
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")
|
91
90
|
end
|
92
91
|
|
93
92
|
it "accepts empty options hash" do
|
@@ -96,9 +95,9 @@ describe Braintree::CreditCard do
|
|
96
95
|
:customer_id => customer.id,
|
97
96
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
98
97
|
:expiration_date => "05/2009",
|
99
|
-
:options => {}
|
98
|
+
:options => {},
|
100
99
|
)
|
101
|
-
result.success
|
100
|
+
expect(result.success?).to eq(true)
|
102
101
|
end
|
103
102
|
|
104
103
|
it "verifies the credit card if options[verify_card]=true" do
|
@@ -107,16 +106,16 @@ describe Braintree::CreditCard do
|
|
107
106
|
:customer_id => customer.id,
|
108
107
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
109
108
|
:expiration_date => "05/2009",
|
110
|
-
:options => {:verify_card => true}
|
109
|
+
:options => {:verify_card => true},
|
111
110
|
)
|
112
|
-
result.success
|
113
|
-
result.credit_card_verification.status.
|
114
|
-
result.credit_card_verification.processor_response_code.
|
115
|
-
result.credit_card_verification.processor_response_text.
|
116
|
-
result.credit_card_verification.cvv_response_code.
|
117
|
-
result.credit_card_verification.avs_error_response_code.
|
118
|
-
result.credit_card_verification.avs_postal_code_response_code.
|
119
|
-
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")
|
120
119
|
end
|
121
120
|
|
122
121
|
it "allows passing a specific verification amount" do
|
@@ -125,20 +124,20 @@ describe Braintree::CreditCard do
|
|
125
124
|
:customer_id => customer.id,
|
126
125
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
127
126
|
:expiration_date => "05/2009",
|
128
|
-
:options => {:verify_card => true, :verification_amount => "100.00"}
|
127
|
+
:options => {:verify_card => true, :verification_amount => "100.00"},
|
129
128
|
)
|
130
|
-
result.success
|
131
|
-
result.credit_card_verification.status.
|
132
|
-
result.credit_card_verification.processor_response_code.
|
133
|
-
result.credit_card_verification.processor_response_text.
|
134
|
-
result.credit_card_verification.cvv_response_code.
|
135
|
-
result.credit_card_verification.avs_error_response_code.
|
136
|
-
result.credit_card_verification.avs_postal_code_response_code.
|
137
|
-
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")
|
138
137
|
end
|
139
138
|
|
140
139
|
it "returns risk data on verification on credit_card create" do
|
141
|
-
|
140
|
+
with_fraud_protection_enterprise_merchant do
|
142
141
|
customer = Braintree::Customer.create!
|
143
142
|
credit_card = Braintree::CreditCard.create!(
|
144
143
|
:cardholder_name => "Original Holder",
|
@@ -146,13 +145,57 @@ describe Braintree::CreditCard do
|
|
146
145
|
:cvv => "123",
|
147
146
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
148
147
|
:expiration_date => "05/2020",
|
149
|
-
:options => {:verify_card => true}
|
148
|
+
:options => {:verify_card => true},
|
150
149
|
)
|
151
150
|
verification = credit_card.verification
|
152
|
-
verification.risk_data.
|
153
|
-
verification.risk_data.
|
154
|
-
verification.risk_data.
|
155
|
-
verification.risk_data.
|
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
|
+
expect(verification.risk_data).to respond_to(:device_data_captured)
|
155
|
+
expect(verification.risk_data).to respond_to(:fraud_service_provider)
|
156
|
+
expect(verification.risk_data).to respond_to(:transaction_risk_score)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
it "includes risk data when skip_advanced_fraud_checking is false" do
|
161
|
+
with_fraud_protection_enterprise_merchant do
|
162
|
+
customer = Braintree::Customer.create!
|
163
|
+
result = Braintree::CreditCard.create(
|
164
|
+
:cardholder_name => "Original Holder",
|
165
|
+
:customer_id => customer.id,
|
166
|
+
:cvv => "123",
|
167
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
168
|
+
:expiration_date => "05/2020",
|
169
|
+
:options => {
|
170
|
+
:skip_advanced_fraud_checking => false,
|
171
|
+
:verify_card => true,
|
172
|
+
},
|
173
|
+
)
|
174
|
+
|
175
|
+
expect(result).to be_success
|
176
|
+
verification = result.credit_card.verification
|
177
|
+
expect(verification.risk_data).not_to be_nil
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it "does not include risk data when skip_advanced_fraud_checking is true" do
|
182
|
+
with_fraud_protection_enterprise_merchant do
|
183
|
+
customer = Braintree::Customer.create!
|
184
|
+
result = Braintree::CreditCard.create(
|
185
|
+
:cardholder_name => "Original Holder",
|
186
|
+
:customer_id => customer.id,
|
187
|
+
:cvv => "123",
|
188
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
189
|
+
:expiration_date => "05/2020",
|
190
|
+
:options => {
|
191
|
+
:skip_advanced_fraud_checking => true,
|
192
|
+
:verify_card => true,
|
193
|
+
},
|
194
|
+
)
|
195
|
+
|
196
|
+
expect(result).to be_success
|
197
|
+
verification = result.credit_card.verification
|
198
|
+
expect(verification.risk_data).to be_nil
|
156
199
|
end
|
157
200
|
end
|
158
201
|
|
@@ -172,10 +215,10 @@ describe Braintree::CreditCard do
|
|
172
215
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
173
216
|
:expiration_date => "05/2009",
|
174
217
|
:cvv => "200",
|
175
|
-
:options => {:verify_card => true}
|
218
|
+
:options => {:verify_card => true},
|
176
219
|
)
|
177
|
-
result.success
|
178
|
-
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)
|
179
222
|
ensure
|
180
223
|
Braintree::Configuration.merchant_id = old_merchant
|
181
224
|
Braintree::Configuration.public_key = old_public_key
|
@@ -189,16 +232,16 @@ describe Braintree::CreditCard do
|
|
189
232
|
:customer_id => customer.id,
|
190
233
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
191
234
|
:expiration_date => "05/2009",
|
192
|
-
:options => {:verify_card => true, :verification_amount => "1.01"}
|
235
|
+
:options => {:verify_card => true, :verification_amount => "1.01"},
|
193
236
|
)
|
194
|
-
result.success
|
195
|
-
result.credit_card_verification.status.
|
196
|
-
result.credit_card_verification.processor_response_code.
|
197
|
-
result.credit_card_verification.processor_response_text.
|
198
|
-
result.credit_card_verification.cvv_response_code.
|
199
|
-
result.credit_card_verification.avs_error_response_code.
|
200
|
-
result.credit_card_verification.avs_postal_code_response_code.
|
201
|
-
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")
|
202
245
|
end
|
203
246
|
|
204
247
|
it "allows user to specify merchant account for verification" do
|
@@ -210,10 +253,10 @@ describe Braintree::CreditCard do
|
|
210
253
|
:options => {
|
211
254
|
:verify_card => true,
|
212
255
|
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
213
|
-
}
|
256
|
+
},
|
214
257
|
)
|
215
|
-
result.success
|
216
|
-
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)
|
217
260
|
end
|
218
261
|
|
219
262
|
it "does not verify the card if options[verify_card]=false" do
|
@@ -222,9 +265,51 @@ describe Braintree::CreditCard do
|
|
222
265
|
:customer_id => customer.id,
|
223
266
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
224
267
|
:expiration_date => "05/2009",
|
225
|
-
:options => {:verify_card => false}
|
268
|
+
:options => {:verify_card => false},
|
226
269
|
)
|
227
|
-
result.success
|
270
|
+
expect(result.success?).to eq(true)
|
271
|
+
end
|
272
|
+
|
273
|
+
it "validates presence of three_d_secure_version in 3ds pass thru params" do
|
274
|
+
customer = Braintree::Customer.create!
|
275
|
+
result = Braintree::CreditCard.create(
|
276
|
+
:customer_id => customer.id,
|
277
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
278
|
+
:three_d_secure_pass_thru => {
|
279
|
+
:eci_flag => "05",
|
280
|
+
:cavv => "some_cavv",
|
281
|
+
:xid => "some_xid",
|
282
|
+
:authentication_response => "Y",
|
283
|
+
:directory_response => "Y",
|
284
|
+
:cavv_algorithm => "2",
|
285
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
286
|
+
},
|
287
|
+
:options => {:verify_card => true},
|
288
|
+
)
|
289
|
+
expect(result).not_to be_success
|
290
|
+
error = result.errors.for(:verification).first
|
291
|
+
expect(error.code).to eq(Braintree::ErrorCodes::Verification::ThreeDSecurePassThru::ThreeDSecureVersionIsRequired)
|
292
|
+
expect(error.message).to eq("ThreeDSecureVersion is required.")
|
293
|
+
end
|
294
|
+
|
295
|
+
it "accepts three_d_secure pass thru params in the request" do
|
296
|
+
customer = Braintree::Customer.create!
|
297
|
+
result = Braintree::CreditCard.create(
|
298
|
+
:customer_id => customer.id,
|
299
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
300
|
+
:three_d_secure_pass_thru => {
|
301
|
+
:eci_flag => "05",
|
302
|
+
:cavv => "some_cavv",
|
303
|
+
:xid => "some_xid",
|
304
|
+
:three_d_secure_version => "1.0.2",
|
305
|
+
:authentication_response => "Y",
|
306
|
+
:directory_response => "Y",
|
307
|
+
:cavv_algorithm => "2",
|
308
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
309
|
+
},
|
310
|
+
:options => {:verify_card => true},
|
311
|
+
)
|
312
|
+
expect(result.success?).to eq(true)
|
228
313
|
end
|
229
314
|
|
230
315
|
it "returns 3DS info on cc verification" do
|
@@ -232,20 +317,20 @@ describe Braintree::CreditCard do
|
|
232
317
|
result = Braintree::CreditCard.create(
|
233
318
|
:customer_id => customer.id,
|
234
319
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
235
|
-
:options => {:verify_card => true}
|
320
|
+
:options => {:verify_card => true},
|
236
321
|
)
|
237
|
-
result.success
|
322
|
+
expect(result.success?).to eq(true)
|
238
323
|
|
239
324
|
three_d_secure_info = result.credit_card.verification.three_d_secure_info
|
240
|
-
three_d_secure_info.
|
241
|
-
three_d_secure_info.
|
242
|
-
three_d_secure_info.
|
243
|
-
three_d_secure_info.
|
244
|
-
three_d_secure_info.cavv.
|
245
|
-
three_d_secure_info.xid.
|
246
|
-
three_d_secure_info.eci_flag.
|
247
|
-
three_d_secure_info.three_d_secure_version.
|
248
|
-
three_d_secure_info.
|
325
|
+
expect(three_d_secure_info.status).to eq("authenticate_successful")
|
326
|
+
expect(three_d_secure_info).to be_liability_shifted
|
327
|
+
expect(three_d_secure_info).to be_liability_shift_possible
|
328
|
+
expect(three_d_secure_info.enrolled).to be_a(String)
|
329
|
+
expect(three_d_secure_info.cavv).to be_a(String)
|
330
|
+
expect(three_d_secure_info.xid).to be_a(String)
|
331
|
+
expect(three_d_secure_info.eci_flag).to be_a(String)
|
332
|
+
expect(three_d_secure_info.three_d_secure_version).to be_a(String)
|
333
|
+
expect(three_d_secure_info.three_d_secure_authentication_id).to be_a(String)
|
249
334
|
end
|
250
335
|
|
251
336
|
it "adds credit card with billing address to customer" do
|
@@ -259,12 +344,12 @@ describe Braintree::CreditCard do
|
|
259
344
|
:locality => "Chicago",
|
260
345
|
:region => "Illinois",
|
261
346
|
:postal_code => "60622"
|
262
|
-
}
|
347
|
+
},
|
263
348
|
)
|
264
|
-
result.success
|
349
|
+
expect(result.success?).to eq(true)
|
265
350
|
credit_card = result.credit_card
|
266
|
-
credit_card.bin.
|
267
|
-
credit_card.billing_address.street_address.
|
351
|
+
expect(credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::MasterCard[0, 6])
|
352
|
+
expect(credit_card.billing_address.street_address).to eq("123 Abc Way")
|
268
353
|
end
|
269
354
|
|
270
355
|
it "adds credit card with billing using country_code" do
|
@@ -278,14 +363,14 @@ describe Braintree::CreditCard do
|
|
278
363
|
:country_code_alpha2 => "US",
|
279
364
|
:country_code_alpha3 => "USA",
|
280
365
|
:country_code_numeric => "840"
|
281
|
-
}
|
366
|
+
},
|
282
367
|
)
|
283
|
-
result.success
|
368
|
+
expect(result.success?).to eq(true)
|
284
369
|
credit_card = result.credit_card
|
285
|
-
credit_card.billing_address.country_name.
|
286
|
-
credit_card.billing_address.country_code_alpha2.
|
287
|
-
credit_card.billing_address.country_code_alpha3.
|
288
|
-
credit_card.billing_address.country_code_numeric.
|
370
|
+
expect(credit_card.billing_address.country_name).to eq("United States of America")
|
371
|
+
expect(credit_card.billing_address.country_code_alpha2).to eq("US")
|
372
|
+
expect(credit_card.billing_address.country_code_alpha3).to eq("USA")
|
373
|
+
expect(credit_card.billing_address.country_code_numeric).to eq("840")
|
289
374
|
end
|
290
375
|
|
291
376
|
it "returns an error when given inconsistent country information" do
|
@@ -297,10 +382,10 @@ describe Braintree::CreditCard do
|
|
297
382
|
:billing_address => {
|
298
383
|
:country_name => "Mexico",
|
299
384
|
:country_code_alpha2 => "US"
|
300
|
-
}
|
385
|
+
},
|
301
386
|
)
|
302
|
-
result.success
|
303
|
-
result.errors.for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }.
|
387
|
+
expect(result.success?).to eq(false)
|
388
|
+
expect(result.errors.for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::InconsistentCountry)
|
304
389
|
end
|
305
390
|
|
306
391
|
it "returns an error response if unsuccessful" do
|
@@ -308,10 +393,10 @@ describe Braintree::CreditCard do
|
|
308
393
|
result = Braintree::CreditCard.create(
|
309
394
|
:customer_id => customer.id,
|
310
395
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
311
|
-
:expiration_date => "invalid_date"
|
396
|
+
:expiration_date => "invalid_date",
|
312
397
|
)
|
313
|
-
result.success
|
314
|
-
result.errors.for(:credit_card).on(:expiration_date)[0].message.
|
398
|
+
expect(result.success?).to eq(false)
|
399
|
+
expect(result.errors.for(:credit_card).on(:expiration_date)[0].message).to eq("Expiration date is invalid.")
|
315
400
|
end
|
316
401
|
|
317
402
|
it "can set the default flag" do
|
@@ -319,9 +404,9 @@ describe Braintree::CreditCard do
|
|
319
404
|
card1 = Braintree::CreditCard.create(
|
320
405
|
:customer_id => customer.id,
|
321
406
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
322
|
-
:expiration_date => "05/2009"
|
407
|
+
:expiration_date => "05/2009",
|
323
408
|
).credit_card
|
324
|
-
card1.
|
409
|
+
expect(card1).to be_default
|
325
410
|
|
326
411
|
card2 = Braintree::CreditCard.create(
|
327
412
|
:customer_id => customer.id,
|
@@ -329,11 +414,26 @@ describe Braintree::CreditCard do
|
|
329
414
|
:expiration_date => "05/2009",
|
330
415
|
:options => {
|
331
416
|
:make_default => true
|
332
|
-
}
|
417
|
+
},
|
333
418
|
).credit_card
|
334
|
-
card2.
|
419
|
+
expect(card2).to be_default
|
335
420
|
|
336
|
-
Braintree::CreditCard.find(card1.token).
|
421
|
+
expect(Braintree::CreditCard.find(card1.token)).not_to be_default
|
422
|
+
end
|
423
|
+
|
424
|
+
it "can set the network transaction identifier when creating a credit card" do
|
425
|
+
customer = Braintree::Customer.create!
|
426
|
+
|
427
|
+
result = Braintree::CreditCard.create(
|
428
|
+
:customer_id => customer.id,
|
429
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
430
|
+
:expiration_date => "05/2009",
|
431
|
+
:external_vault => {
|
432
|
+
:network_transaction_id => "MCC123456789",
|
433
|
+
},
|
434
|
+
)
|
435
|
+
|
436
|
+
expect(result.success?).to eq(true)
|
337
437
|
end
|
338
438
|
|
339
439
|
context "card type indicators" do
|
@@ -343,10 +443,10 @@ describe Braintree::CreditCard do
|
|
343
443
|
:customer_id => customer.id,
|
344
444
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
345
445
|
:expiration_date => "05/2014",
|
346
|
-
:options => {:verify_card => true}
|
446
|
+
:options => {:verify_card => true},
|
347
447
|
)
|
348
448
|
credit_card = result.credit_card
|
349
|
-
credit_card.prepaid.
|
449
|
+
expect(credit_card.prepaid).to eq(Braintree::CreditCard::Prepaid::Yes)
|
350
450
|
end
|
351
451
|
|
352
452
|
it "sets the healthcare field if the card is healthcare" do
|
@@ -355,11 +455,11 @@ describe Braintree::CreditCard do
|
|
355
455
|
:customer_id => customer.id,
|
356
456
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Healthcare,
|
357
457
|
:expiration_date => "05/2014",
|
358
|
-
:options => {:verify_card => true}
|
458
|
+
:options => {:verify_card => true},
|
359
459
|
)
|
360
460
|
credit_card = result.credit_card
|
361
|
-
credit_card.healthcare.
|
362
|
-
credit_card.product_id.
|
461
|
+
expect(credit_card.healthcare).to eq(Braintree::CreditCard::Healthcare::Yes)
|
462
|
+
expect(credit_card.product_id).to eq("J3")
|
363
463
|
end
|
364
464
|
|
365
465
|
it "sets the durbin regulated field if the card is durbin regulated" do
|
@@ -368,10 +468,10 @@ describe Braintree::CreditCard do
|
|
368
468
|
:customer_id => customer.id,
|
369
469
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::DurbinRegulated,
|
370
470
|
:expiration_date => "05/2014",
|
371
|
-
:options => {:verify_card => true}
|
471
|
+
:options => {:verify_card => true},
|
372
472
|
)
|
373
473
|
credit_card = result.credit_card
|
374
|
-
credit_card.durbin_regulated.
|
474
|
+
expect(credit_card.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Yes)
|
375
475
|
end
|
376
476
|
|
377
477
|
it "sets the country of issuance field" do
|
@@ -380,10 +480,10 @@ describe Braintree::CreditCard do
|
|
380
480
|
:customer_id => customer.id,
|
381
481
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::CountryOfIssuance,
|
382
482
|
:expiration_date => "05/2014",
|
383
|
-
:options => {:verify_card => true}
|
483
|
+
:options => {:verify_card => true},
|
384
484
|
)
|
385
485
|
credit_card = result.credit_card
|
386
|
-
credit_card.country_of_issuance.
|
486
|
+
expect(credit_card.country_of_issuance).to eq(Braintree::Test::CreditCardDefaults::CountryOfIssuance)
|
387
487
|
end
|
388
488
|
|
389
489
|
it "sets the issuing bank field" do
|
@@ -392,10 +492,10 @@ describe Braintree::CreditCard do
|
|
392
492
|
:customer_id => customer.id,
|
393
493
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::IssuingBank,
|
394
494
|
:expiration_date => "05/2014",
|
395
|
-
:options => {:verify_card => true}
|
495
|
+
:options => {:verify_card => true},
|
396
496
|
)
|
397
497
|
credit_card = result.credit_card
|
398
|
-
credit_card.issuing_bank.
|
498
|
+
expect(credit_card.issuing_bank).to eq(Braintree::Test::CreditCardDefaults::IssuingBank)
|
399
499
|
end
|
400
500
|
|
401
501
|
it "sets the payroll field if the card is payroll" do
|
@@ -404,11 +504,11 @@ describe Braintree::CreditCard do
|
|
404
504
|
:customer_id => customer.id,
|
405
505
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Payroll,
|
406
506
|
:expiration_date => "05/2014",
|
407
|
-
:options => {:verify_card => true}
|
507
|
+
:options => {:verify_card => true},
|
408
508
|
)
|
409
509
|
credit_card = result.credit_card
|
410
|
-
credit_card.payroll.
|
411
|
-
credit_card.product_id.
|
510
|
+
expect(credit_card.payroll).to eq(Braintree::CreditCard::Payroll::Yes)
|
511
|
+
expect(credit_card.product_id).to eq("MSA")
|
412
512
|
end
|
413
513
|
|
414
514
|
it "sets the debit field if the card is debit" do
|
@@ -417,10 +517,10 @@ describe Braintree::CreditCard do
|
|
417
517
|
:customer_id => customer.id,
|
418
518
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Debit,
|
419
519
|
:expiration_date => "05/2014",
|
420
|
-
:options => {:verify_card => true}
|
520
|
+
:options => {:verify_card => true},
|
421
521
|
)
|
422
522
|
credit_card = result.credit_card
|
423
|
-
credit_card.debit.
|
523
|
+
expect(credit_card.debit).to eq(Braintree::CreditCard::Debit::Yes)
|
424
524
|
end
|
425
525
|
|
426
526
|
it "sets the commercial field if the card is commercial" do
|
@@ -429,10 +529,10 @@ describe Braintree::CreditCard do
|
|
429
529
|
:customer_id => customer.id,
|
430
530
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Commercial,
|
431
531
|
:expiration_date => "05/2014",
|
432
|
-
:options => {:verify_card => true}
|
532
|
+
:options => {:verify_card => true},
|
433
533
|
)
|
434
534
|
credit_card = result.credit_card
|
435
|
-
credit_card.commercial.
|
535
|
+
expect(credit_card.commercial).to eq(Braintree::CreditCard::Commercial::Yes)
|
436
536
|
end
|
437
537
|
|
438
538
|
it "sets negative card type identifiers" do
|
@@ -441,16 +541,16 @@ describe Braintree::CreditCard do
|
|
441
541
|
:customer_id => customer.id,
|
442
542
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::No,
|
443
543
|
:expiration_date => "05/2014",
|
444
|
-
:options => {:verify_card => true}
|
544
|
+
:options => {:verify_card => true},
|
445
545
|
)
|
446
546
|
credit_card = result.credit_card
|
447
|
-
credit_card.prepaid.
|
448
|
-
credit_card.commercial.
|
449
|
-
credit_card.payroll.
|
450
|
-
credit_card.debit.
|
451
|
-
credit_card.durbin_regulated.
|
452
|
-
credit_card.healthcare.
|
453
|
-
credit_card.product_id.
|
547
|
+
expect(credit_card.prepaid).to eq(Braintree::CreditCard::Prepaid::No)
|
548
|
+
expect(credit_card.commercial).to eq(Braintree::CreditCard::Prepaid::No)
|
549
|
+
expect(credit_card.payroll).to eq(Braintree::CreditCard::Prepaid::No)
|
550
|
+
expect(credit_card.debit).to eq(Braintree::CreditCard::Prepaid::No)
|
551
|
+
expect(credit_card.durbin_regulated).to eq(Braintree::CreditCard::Prepaid::No)
|
552
|
+
expect(credit_card.healthcare).to eq(Braintree::CreditCard::Prepaid::No)
|
553
|
+
expect(credit_card.product_id).to eq("MSB")
|
454
554
|
end
|
455
555
|
|
456
556
|
it "doesn't set the card type identifiers for an un-identified card" do
|
@@ -459,81 +559,21 @@ describe Braintree::CreditCard do
|
|
459
559
|
:customer_id => customer.id,
|
460
560
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Unknown,
|
461
561
|
:expiration_date => "05/2014",
|
462
|
-
:options => {:verify_card => true}
|
562
|
+
:options => {:verify_card => true},
|
463
563
|
)
|
464
564
|
credit_card = result.credit_card
|
465
|
-
credit_card.prepaid.
|
466
|
-
credit_card.commercial.
|
467
|
-
credit_card.payroll.
|
468
|
-
credit_card.debit.
|
469
|
-
credit_card.durbin_regulated.
|
470
|
-
credit_card.healthcare.
|
565
|
+
expect(credit_card.prepaid).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
566
|
+
expect(credit_card.commercial).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
567
|
+
expect(credit_card.payroll).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
568
|
+
expect(credit_card.debit).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
569
|
+
expect(credit_card.durbin_regulated).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
570
|
+
expect(credit_card.healthcare).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
471
571
|
credit_card.country_of_issuance == Braintree::CreditCard::CountryOfIssuance::Unknown
|
472
572
|
credit_card.issuing_bank == Braintree::CreditCard::IssuingBank::Unknown
|
473
573
|
credit_card.product_id == Braintree::CreditCard::ProductId::Unknown
|
474
574
|
end
|
475
575
|
end
|
476
576
|
|
477
|
-
context "venmo_sdk" do
|
478
|
-
describe "venmo_sdk_payment_method_code" do
|
479
|
-
it "can pass a venmo sdk payment method code" do
|
480
|
-
customer = Braintree::Customer.create!
|
481
|
-
result = Braintree::CreditCard.create(
|
482
|
-
:customer_id => customer.id,
|
483
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
|
484
|
-
)
|
485
|
-
result.success?.should == true
|
486
|
-
result.credit_card.venmo_sdk?.should == false
|
487
|
-
result.credit_card.bin.should == "400934"
|
488
|
-
result.credit_card.last_4.should == "1881"
|
489
|
-
end
|
490
|
-
|
491
|
-
it "success? returns false when given an invalid venmo sdk payment method code" do
|
492
|
-
customer = Braintree::Customer.create!
|
493
|
-
result = Braintree::CreditCard.create(
|
494
|
-
:customer_id => customer.id,
|
495
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode
|
496
|
-
)
|
497
|
-
|
498
|
-
result.success?.should == false
|
499
|
-
result.message.should == "Invalid VenmoSDK payment method code"
|
500
|
-
result.errors.first.code.should == "91727"
|
501
|
-
end
|
502
|
-
end
|
503
|
-
|
504
|
-
describe "venmo_sdk_session" do
|
505
|
-
it "venmo_sdk? returns true when given a valid session" do
|
506
|
-
customer = Braintree::Customer.create!
|
507
|
-
result = Braintree::CreditCard.create(
|
508
|
-
:customer_id => customer.id,
|
509
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
510
|
-
:expiration_date => "05/2009",
|
511
|
-
:cvv => "100",
|
512
|
-
:options => {
|
513
|
-
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
514
|
-
}
|
515
|
-
)
|
516
|
-
result.success?.should == true
|
517
|
-
result.credit_card.venmo_sdk?.should == false
|
518
|
-
end
|
519
|
-
|
520
|
-
it "venmo_sdk? returns false when given an invalid session" do
|
521
|
-
customer = Braintree::Customer.create!
|
522
|
-
result = Braintree::CreditCard.create(
|
523
|
-
:customer_id => customer.id,
|
524
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
525
|
-
:expiration_date => "05/2009",
|
526
|
-
:cvv => "100",
|
527
|
-
:options => {
|
528
|
-
:venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession
|
529
|
-
}
|
530
|
-
)
|
531
|
-
result.success?.should == true
|
532
|
-
result.credit_card.venmo_sdk?.should == false
|
533
|
-
end
|
534
|
-
end
|
535
|
-
end
|
536
|
-
|
537
577
|
context "client API" do
|
538
578
|
it "adds credit card to an existing customer using a payment method nonce" do
|
539
579
|
nonce = nonce_for_new_payment_method(
|
@@ -542,19 +582,19 @@ describe Braintree::CreditCard do
|
|
542
582
|
:expiration_month => "11",
|
543
583
|
:expiration_year => "2099",
|
544
584
|
},
|
545
|
-
:share => true
|
585
|
+
:share => true,
|
546
586
|
)
|
547
587
|
customer = Braintree::Customer.create!
|
548
588
|
result = Braintree::CreditCard.create(
|
549
589
|
:customer_id => customer.id,
|
550
|
-
:payment_method_nonce => nonce
|
590
|
+
:payment_method_nonce => nonce,
|
551
591
|
)
|
552
592
|
|
553
|
-
result.success
|
593
|
+
expect(result.success?).to eq(true)
|
554
594
|
credit_card = result.credit_card
|
555
|
-
credit_card.bin.
|
556
|
-
credit_card.last_4.
|
557
|
-
credit_card.expiration_date.
|
595
|
+
expect(credit_card.bin).to eq("411111")
|
596
|
+
expect(credit_card.last_4).to eq("1111")
|
597
|
+
expect(credit_card.expiration_date).to eq("11/2099")
|
558
598
|
end
|
559
599
|
end
|
560
600
|
|
@@ -566,9 +606,9 @@ describe Braintree::CreditCard do
|
|
566
606
|
:number => Braintree::Test::CreditCardNumbers::Elo,
|
567
607
|
:expiration_date => "10/2020",
|
568
608
|
)
|
569
|
-
result.success
|
609
|
+
expect(result.success?).to eq(true)
|
570
610
|
credit_card = result.credit_card
|
571
|
-
credit_card.card_type.
|
611
|
+
expect(credit_card.card_type).to eq(Braintree::CreditCard::CardType::Elo)
|
572
612
|
end
|
573
613
|
end
|
574
614
|
|
@@ -582,9 +622,9 @@ describe Braintree::CreditCard do
|
|
582
622
|
:expiration_year => "2099",
|
583
623
|
:options => {
|
584
624
|
:verify_card => true,
|
585
|
-
:verification_merchant_account_id => SpecHelper::
|
625
|
+
:verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
586
626
|
:verification_account_type => "debit",
|
587
|
-
}
|
627
|
+
},
|
588
628
|
)
|
589
629
|
|
590
630
|
expect(result).to be_success
|
@@ -601,14 +641,13 @@ describe Braintree::CreditCard do
|
|
601
641
|
:verify_card => true,
|
602
642
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
603
643
|
:verification_account_type => "credit",
|
604
|
-
}
|
644
|
+
},
|
605
645
|
)
|
606
646
|
|
607
647
|
expect(result).to be_success
|
608
648
|
end
|
609
649
|
|
610
650
|
it "errors with invalid account_type" do
|
611
|
-
customer = Braintree::Customer.create!
|
612
651
|
result = Braintree::CreditCard.create(
|
613
652
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
614
653
|
:expiration_month => "11",
|
@@ -617,7 +656,7 @@ describe Braintree::CreditCard do
|
|
617
656
|
:verify_card => true,
|
618
657
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
619
658
|
:verification_account_type => "ach",
|
620
|
-
}
|
659
|
+
},
|
621
660
|
)
|
622
661
|
|
623
662
|
expect(result).to_not be_success
|
@@ -625,7 +664,6 @@ describe Braintree::CreditCard do
|
|
625
664
|
end
|
626
665
|
|
627
666
|
it "errors when account_type not supported by merchant" do
|
628
|
-
customer = Braintree::Customer.create!
|
629
667
|
result = Braintree::CreditCard.create(
|
630
668
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
631
669
|
:expiration_month => "11",
|
@@ -633,7 +671,7 @@ describe Braintree::CreditCard do
|
|
633
671
|
:options => {
|
634
672
|
:verify_card => true,
|
635
673
|
:verification_account_type => "credit",
|
636
|
-
}
|
674
|
+
},
|
637
675
|
)
|
638
676
|
|
639
677
|
expect(result).to_not be_success
|
@@ -649,12 +687,12 @@ describe Braintree::CreditCard do
|
|
649
687
|
:customer_id => customer.id,
|
650
688
|
:cardholder_name => "Adam Davis",
|
651
689
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
652
|
-
:expiration_date => "05/2009"
|
690
|
+
:expiration_date => "05/2009",
|
653
691
|
)
|
654
|
-
credit_card.bin.
|
655
|
-
credit_card.cardholder_name.
|
656
|
-
credit_card.last_4.
|
657
|
-
credit_card.expiration_date.
|
692
|
+
expect(credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
693
|
+
expect(credit_card.cardholder_name).to eq("Adam Davis")
|
694
|
+
expect(credit_card.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
695
|
+
expect(credit_card.expiration_date).to eq("05/2009")
|
658
696
|
end
|
659
697
|
|
660
698
|
it "raises a ValidationsFailed if unsuccessful" do
|
@@ -663,32 +701,34 @@ describe Braintree::CreditCard do
|
|
663
701
|
Braintree::CreditCard.create!(
|
664
702
|
:customer_id => customer.id,
|
665
703
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
666
|
-
:expiration_date => "invalid_date"
|
704
|
+
:expiration_date => "invalid_date",
|
667
705
|
)
|
668
706
|
end.to raise_error(Braintree::ValidationsFailed)
|
669
707
|
end
|
670
708
|
end
|
671
709
|
|
710
|
+
# NEXT_MAJOR_VERSION remove this test
|
711
|
+
# CreditCard.credit has been deprecated in favor of Transaction.credit
|
672
712
|
describe "self.credit" do
|
673
713
|
it "creates a credit transaction using the payment method token, returning a result object" do
|
674
714
|
customer = Braintree::Customer.create!(
|
675
715
|
:credit_card => {
|
676
716
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
677
717
|
:expiration_date => "05/2010"
|
678
|
-
}
|
718
|
+
},
|
679
719
|
)
|
680
720
|
result = Braintree::CreditCard.credit(
|
681
721
|
customer.credit_cards[0].token,
|
682
|
-
:amount => "100.00"
|
722
|
+
:amount => "100.00",
|
683
723
|
)
|
684
|
-
result.success
|
685
|
-
result.transaction.amount.
|
686
|
-
result.transaction.type.
|
687
|
-
result.transaction.customer_details.id.
|
688
|
-
result.transaction.credit_card_details.token.
|
689
|
-
result.transaction.credit_card_details.bin.
|
690
|
-
result.transaction.credit_card_details.last_4.
|
691
|
-
result.transaction.credit_card_details.expiration_date.
|
724
|
+
expect(result.success?).to eq(true)
|
725
|
+
expect(result.transaction.amount).to eq(BigDecimal("100.00"))
|
726
|
+
expect(result.transaction.type).to eq("credit")
|
727
|
+
expect(result.transaction.customer_details.id).to eq(customer.id)
|
728
|
+
expect(result.transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
729
|
+
expect(result.transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
730
|
+
expect(result.transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
731
|
+
expect(result.transaction.credit_card_details.expiration_date).to eq("05/2010")
|
692
732
|
end
|
693
733
|
end
|
694
734
|
|
@@ -698,108 +738,19 @@ describe Braintree::CreditCard do
|
|
698
738
|
:credit_card => {
|
699
739
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
700
740
|
:expiration_date => "05/2010"
|
701
|
-
}
|
741
|
+
},
|
702
742
|
)
|
703
743
|
transaction = Braintree::CreditCard.credit!(
|
704
744
|
customer.credit_cards[0].token,
|
705
|
-
:amount => "100.00"
|
706
|
-
)
|
707
|
-
transaction.amount.should == BigDecimal("100.00")
|
708
|
-
transaction.type.should == "credit"
|
709
|
-
transaction.customer_details.id.should == customer.id
|
710
|
-
transaction.credit_card_details.token.should == customer.credit_cards[0].token
|
711
|
-
transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
712
|
-
transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
713
|
-
transaction.credit_card_details.expiration_date.should == "05/2010"
|
714
|
-
end
|
715
|
-
end
|
716
|
-
|
717
|
-
describe "self.create_from_transparent_redirect" do
|
718
|
-
it "returns a successful result if successful" do
|
719
|
-
result = Braintree::Customer.create
|
720
|
-
result.success?.should == true
|
721
|
-
customer = result.customer
|
722
|
-
params = {
|
723
|
-
:credit_card => {
|
724
|
-
:cardholder_name => "Card Holder",
|
725
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
726
|
-
:expiration_date => "05/2012"
|
727
|
-
}
|
728
|
-
}
|
729
|
-
tr_data_params = {
|
730
|
-
:credit_card => {
|
731
|
-
:customer_id => customer.id
|
732
|
-
}
|
733
|
-
}
|
734
|
-
tr_data = Braintree::TransparentRedirect.create_credit_card_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
735
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::CreditCard.create_credit_card_url)
|
736
|
-
result = Braintree::CreditCard.create_from_transparent_redirect(query_string_response)
|
737
|
-
result.success?.should == true
|
738
|
-
credit_card = result.credit_card
|
739
|
-
credit_card.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
740
|
-
credit_card.cardholder_name.should == "Card Holder"
|
741
|
-
credit_card.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
742
|
-
credit_card.expiration_month.should == "05"
|
743
|
-
credit_card.expiration_year.should == "2012"
|
744
|
-
credit_card.expiration_date.should == "05/2012"
|
745
|
-
credit_card.customer_id.should == customer.id
|
746
|
-
end
|
747
|
-
|
748
|
-
it "create card as default" do
|
749
|
-
customer = Braintree::Customer.create!(
|
750
|
-
:credit_card => {
|
751
|
-
:cardholder_name => "Old Cardholder Name",
|
752
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
753
|
-
:expiration_date => "05/2012"
|
754
|
-
}
|
745
|
+
:amount => "100.00",
|
755
746
|
)
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
:options => {:make_default => true}
|
764
|
-
}
|
765
|
-
}
|
766
|
-
tr_data_params = {
|
767
|
-
:credit_card => {
|
768
|
-
:customer_id => customer.id
|
769
|
-
}
|
770
|
-
}
|
771
|
-
tr_data = Braintree::TransparentRedirect.create_credit_card_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
772
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::CreditCard.create_credit_card_url)
|
773
|
-
result = Braintree::CreditCard.create_from_transparent_redirect(query_string_response)
|
774
|
-
result.success?.should == true
|
775
|
-
card2 = result.credit_card
|
776
|
-
|
777
|
-
Braintree::CreditCard.find(card1.token).should_not be_default
|
778
|
-
card2.should be_default
|
779
|
-
end
|
780
|
-
|
781
|
-
it "returns xml with nested errors if validation errors" do
|
782
|
-
customer = Braintree::Customer.create.customer
|
783
|
-
params = {
|
784
|
-
:credit_card => {
|
785
|
-
:cardholder_name => "Card Holder",
|
786
|
-
:number => "eleventy",
|
787
|
-
:expiration_date => "y2k"
|
788
|
-
}
|
789
|
-
}
|
790
|
-
tr_data_params = {
|
791
|
-
:credit_card => {
|
792
|
-
:customer_id => customer.id
|
793
|
-
}
|
794
|
-
}
|
795
|
-
tr_data = Braintree::TransparentRedirect.create_credit_card_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
796
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::CreditCard.create_credit_card_url)
|
797
|
-
result = Braintree::CreditCard.create_from_transparent_redirect(query_string_response)
|
798
|
-
result.success?.should == false
|
799
|
-
result.params[:customer_id] == customer.id
|
800
|
-
result.params[:credit_card]["cardholder_name"] == customer.id
|
801
|
-
result.params[:credit_card]["number"] == "eleventy"
|
802
|
-
result.params[:credit_card]["exipiration_date"] == "y2k"
|
747
|
+
expect(transaction.amount).to eq(BigDecimal("100.00"))
|
748
|
+
expect(transaction.type).to eq("credit")
|
749
|
+
expect(transaction.customer_details.id).to eq(customer.id)
|
750
|
+
expect(transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
751
|
+
expect(transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
752
|
+
expect(transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
753
|
+
expect(transaction.credit_card_details.expiration_date).to eq("05/2010")
|
803
754
|
end
|
804
755
|
end
|
805
756
|
|
@@ -811,21 +762,124 @@ describe Braintree::CreditCard do
|
|
811
762
|
:customer_id => customer.id,
|
812
763
|
:cvv => "123",
|
813
764
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
814
|
-
:expiration_date => "05/2012"
|
765
|
+
:expiration_date => "05/2012",
|
815
766
|
)
|
816
767
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
817
768
|
:cardholder_name => "New Holder",
|
818
769
|
:cvv => "456",
|
819
770
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
820
|
-
:expiration_date => "06/2013"
|
771
|
+
:expiration_date => "06/2013",
|
821
772
|
)
|
822
|
-
update_result.success
|
823
|
-
update_result.credit_card.
|
773
|
+
expect(update_result.success?).to eq(true)
|
774
|
+
expect(update_result.credit_card).to eq(credit_card)
|
824
775
|
updated_credit_card = update_result.credit_card
|
825
|
-
updated_credit_card.bin.
|
826
|
-
updated_credit_card.last_4.
|
827
|
-
updated_credit_card.expiration_date.
|
828
|
-
updated_credit_card.cardholder_name.
|
776
|
+
expect(updated_credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::MasterCard[0, 6])
|
777
|
+
expect(updated_credit_card.last_4).to eq(Braintree::Test::CreditCardNumbers::MasterCard[-4..-1])
|
778
|
+
expect(updated_credit_card.expiration_date).to eq("06/2013")
|
779
|
+
expect(updated_credit_card.cardholder_name).to eq("New Holder")
|
780
|
+
end
|
781
|
+
|
782
|
+
it "validates presence of three_d_secure_version in 3ds pass thru params" do
|
783
|
+
customer = Braintree::Customer.create!
|
784
|
+
credit_card = Braintree::CreditCard.create!(
|
785
|
+
:cardholder_name => "Original Holder",
|
786
|
+
:customer_id => customer.id,
|
787
|
+
:cvv => "123",
|
788
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
789
|
+
:expiration_date => "05/2012",
|
790
|
+
)
|
791
|
+
result = Braintree::CreditCard.update(credit_card.token,
|
792
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
793
|
+
:three_d_secure_pass_thru => {
|
794
|
+
:eci_flag => "05",
|
795
|
+
:cavv => "some_cavv",
|
796
|
+
:xid => "some_xid",
|
797
|
+
:authentication_response => "Y",
|
798
|
+
:directory_response => "Y",
|
799
|
+
:cavv_algorithm => "2",
|
800
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
801
|
+
},
|
802
|
+
:options => {:verify_card => true},
|
803
|
+
)
|
804
|
+
expect(result).not_to be_success
|
805
|
+
error = result.errors.for(:verification).first
|
806
|
+
expect(error.code).to eq(Braintree::ErrorCodes::Verification::ThreeDSecurePassThru::ThreeDSecureVersionIsRequired)
|
807
|
+
expect(error.message).to eq("ThreeDSecureVersion is required.")
|
808
|
+
end
|
809
|
+
|
810
|
+
it "accepts three_d_secure pass thru params in the request" do
|
811
|
+
customer = Braintree::Customer.create!
|
812
|
+
credit_card = Braintree::CreditCard.create!(
|
813
|
+
:cardholder_name => "Original Holder",
|
814
|
+
:customer_id => customer.id,
|
815
|
+
:cvv => "123",
|
816
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
817
|
+
:expiration_date => "05/2012",
|
818
|
+
)
|
819
|
+
result = Braintree::CreditCard.update(credit_card.token,
|
820
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
821
|
+
:three_d_secure_pass_thru => {
|
822
|
+
:eci_flag => "05",
|
823
|
+
:cavv => "some_cavv",
|
824
|
+
:three_d_secure_version=> "2.1.0",
|
825
|
+
:xid => "some_xid",
|
826
|
+
:authentication_response => "Y",
|
827
|
+
:directory_response => "Y",
|
828
|
+
:cavv_algorithm => "2",
|
829
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
830
|
+
},
|
831
|
+
:options => {:verify_card => true},
|
832
|
+
)
|
833
|
+
|
834
|
+
expect(result.success?).to eq(true)
|
835
|
+
end
|
836
|
+
|
837
|
+
it "includes risk data when skip_advanced_fraud_checking is false" do
|
838
|
+
with_fraud_protection_enterprise_merchant do
|
839
|
+
customer = Braintree::Customer.create!
|
840
|
+
credit_card = Braintree::CreditCard.create!(
|
841
|
+
:cardholder_name => "Original Holder",
|
842
|
+
:customer_id => customer.id,
|
843
|
+
:cvv => "123",
|
844
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
845
|
+
:expiration_date => "05/2020",
|
846
|
+
)
|
847
|
+
updated_result = Braintree::CreditCard.update(credit_card.token,
|
848
|
+
:expiration_date => "05/2021",
|
849
|
+
:options => {
|
850
|
+
:verify_card => true,
|
851
|
+
:skip_advanced_fraud_checking => false,
|
852
|
+
},
|
853
|
+
)
|
854
|
+
|
855
|
+
expect(updated_result).to be_success
|
856
|
+
verification = updated_result.credit_card.verification
|
857
|
+
expect(verification.risk_data).not_to be_nil
|
858
|
+
end
|
859
|
+
end
|
860
|
+
|
861
|
+
it "does not include risk data when skip_advanced_fraud_checking is true" do
|
862
|
+
with_fraud_protection_enterprise_merchant do
|
863
|
+
customer = Braintree::Customer.create!
|
864
|
+
credit_card = Braintree::CreditCard.create!(
|
865
|
+
:cardholder_name => "Original Holder",
|
866
|
+
:customer_id => customer.id,
|
867
|
+
:cvv => "123",
|
868
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
869
|
+
:expiration_date => "05/2020",
|
870
|
+
)
|
871
|
+
updated_result = Braintree::CreditCard.update(credit_card.token,
|
872
|
+
:expiration_date => "05/2021",
|
873
|
+
:options => {
|
874
|
+
:verify_card => true,
|
875
|
+
:skip_advanced_fraud_checking => true,
|
876
|
+
},
|
877
|
+
)
|
878
|
+
|
879
|
+
expect(updated_result).to be_success
|
880
|
+
verification = updated_result.credit_card.verification
|
881
|
+
expect(verification.risk_data).to be_nil
|
882
|
+
end
|
829
883
|
end
|
830
884
|
|
831
885
|
context "billing address" do
|
@@ -837,18 +891,18 @@ describe Braintree::CreditCard do
|
|
837
891
|
:expiration_date => "05/2012",
|
838
892
|
:billing_address => {
|
839
893
|
:street_address => "123 Nigeria Ave"
|
840
|
-
}
|
894
|
+
},
|
841
895
|
)
|
842
896
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
843
897
|
:billing_address => {
|
844
898
|
:region => "IL"
|
845
|
-
}
|
899
|
+
},
|
846
900
|
)
|
847
|
-
update_result.success
|
901
|
+
expect(update_result.success?).to eq(true)
|
848
902
|
updated_credit_card = update_result.credit_card
|
849
|
-
updated_credit_card.billing_address.region.
|
850
|
-
updated_credit_card.billing_address.street_address.
|
851
|
-
updated_credit_card.billing_address.id.
|
903
|
+
expect(updated_credit_card.billing_address.region).to eq("IL")
|
904
|
+
expect(updated_credit_card.billing_address.street_address).to eq(nil)
|
905
|
+
expect(updated_credit_card.billing_address.id).not_to eq(credit_card.billing_address.id)
|
852
906
|
end
|
853
907
|
|
854
908
|
it "updates the billing address if option is specified" do
|
@@ -859,19 +913,19 @@ describe Braintree::CreditCard do
|
|
859
913
|
:expiration_date => "05/2012",
|
860
914
|
:billing_address => {
|
861
915
|
:street_address => "123 Nigeria Ave"
|
862
|
-
}
|
916
|
+
},
|
863
917
|
)
|
864
918
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
865
919
|
:billing_address => {
|
866
920
|
:region => "IL",
|
867
921
|
:options => {:update_existing => true}
|
868
|
-
}
|
922
|
+
},
|
869
923
|
)
|
870
|
-
update_result.success
|
924
|
+
expect(update_result.success?).to eq(true)
|
871
925
|
updated_credit_card = update_result.credit_card
|
872
|
-
updated_credit_card.billing_address.region.
|
873
|
-
updated_credit_card.billing_address.street_address.
|
874
|
-
updated_credit_card.billing_address.id.
|
926
|
+
expect(updated_credit_card.billing_address.region).to eq("IL")
|
927
|
+
expect(updated_credit_card.billing_address.street_address).to eq("123 Nigeria Ave")
|
928
|
+
expect(updated_credit_card.billing_address.id).to eq(credit_card.billing_address.id)
|
875
929
|
end
|
876
930
|
|
877
931
|
it "updates the country via codes" do
|
@@ -882,7 +936,7 @@ describe Braintree::CreditCard do
|
|
882
936
|
:expiration_date => "05/2012",
|
883
937
|
:billing_address => {
|
884
938
|
:street_address => "123 Nigeria Ave"
|
885
|
-
}
|
939
|
+
},
|
886
940
|
)
|
887
941
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
888
942
|
:billing_address => {
|
@@ -891,14 +945,14 @@ describe Braintree::CreditCard do
|
|
891
945
|
:country_code_alpha3 => "ASM",
|
892
946
|
:country_code_numeric => "016",
|
893
947
|
:options => {:update_existing => true}
|
894
|
-
}
|
948
|
+
},
|
895
949
|
)
|
896
|
-
update_result.success
|
950
|
+
expect(update_result.success?).to eq(true)
|
897
951
|
updated_credit_card = update_result.credit_card
|
898
|
-
updated_credit_card.billing_address.country_name.
|
899
|
-
updated_credit_card.billing_address.country_code_alpha2.
|
900
|
-
updated_credit_card.billing_address.country_code_alpha3.
|
901
|
-
updated_credit_card.billing_address.country_code_numeric.
|
952
|
+
expect(updated_credit_card.billing_address.country_name).to eq("American Samoa")
|
953
|
+
expect(updated_credit_card.billing_address.country_code_alpha2).to eq("AS")
|
954
|
+
expect(updated_credit_card.billing_address.country_code_alpha3).to eq("ASM")
|
955
|
+
expect(updated_credit_card.billing_address.country_code_numeric).to eq("016")
|
902
956
|
end
|
903
957
|
end
|
904
958
|
|
@@ -907,18 +961,18 @@ describe Braintree::CreditCard do
|
|
907
961
|
credit_card = Braintree::CreditCard.create!(
|
908
962
|
:customer_id => customer.id,
|
909
963
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
910
|
-
:expiration_date => "05/2012"
|
964
|
+
:expiration_date => "05/2012",
|
911
965
|
)
|
912
966
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
913
967
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
914
968
|
:expiration_month => "07",
|
915
|
-
:expiration_year => "2011"
|
969
|
+
:expiration_year => "2011",
|
916
970
|
)
|
917
|
-
update_result.success
|
918
|
-
update_result.credit_card.
|
919
|
-
update_result.credit_card.expiration_month.
|
920
|
-
update_result.credit_card.expiration_year.
|
921
|
-
update_result.credit_card.expiration_date.
|
971
|
+
expect(update_result.success?).to eq(true)
|
972
|
+
expect(update_result.credit_card).to eq(credit_card)
|
973
|
+
expect(update_result.credit_card.expiration_month).to eq("07")
|
974
|
+
expect(update_result.credit_card.expiration_year).to eq("2011")
|
975
|
+
expect(update_result.credit_card.expiration_date).to eq("07/2011")
|
922
976
|
end
|
923
977
|
|
924
978
|
it "verifies the update if options[verify_card]=true" do
|
@@ -928,18 +982,18 @@ describe Braintree::CreditCard do
|
|
928
982
|
:customer_id => customer.id,
|
929
983
|
:cvv => "123",
|
930
984
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
931
|
-
:expiration_date => "05/2012"
|
985
|
+
:expiration_date => "05/2012",
|
932
986
|
)
|
933
987
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
934
988
|
:cardholder_name => "New Holder",
|
935
989
|
:cvv => "456",
|
936
990
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
|
937
991
|
:expiration_date => "06/2013",
|
938
|
-
:options => {:verify_card => true}
|
992
|
+
:options => {:verify_card => true},
|
939
993
|
)
|
940
|
-
update_result.success
|
941
|
-
update_result.credit_card_verification.status.
|
942
|
-
update_result.credit_card_verification.gateway_rejection_reason.
|
994
|
+
expect(update_result.success?).to eq(false)
|
995
|
+
expect(update_result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::ProcessorDeclined)
|
996
|
+
expect(update_result.credit_card_verification.gateway_rejection_reason).to be_nil
|
943
997
|
end
|
944
998
|
|
945
999
|
it "can update the billing address" do
|
@@ -960,7 +1014,7 @@ describe Braintree::CreditCard do
|
|
960
1014
|
:region => "Old State",
|
961
1015
|
:postal_code => "12345",
|
962
1016
|
:country_name => "Canada"
|
963
|
-
}
|
1017
|
+
},
|
964
1018
|
)
|
965
1019
|
result = Braintree::CreditCard.update(credit_card.token,
|
966
1020
|
:options => {:verify_card => false},
|
@@ -974,19 +1028,19 @@ describe Braintree::CreditCard do
|
|
974
1028
|
:region => "New State",
|
975
1029
|
:postal_code => "56789",
|
976
1030
|
:country_name => "United States of America"
|
977
|
-
}
|
1031
|
+
},
|
978
1032
|
)
|
979
|
-
result.success
|
1033
|
+
expect(result.success?).to eq(true)
|
980
1034
|
address = result.credit_card.billing_address
|
981
|
-
address.first_name.
|
982
|
-
address.last_name.
|
983
|
-
address.company.
|
984
|
-
address.street_address.
|
985
|
-
address.extended_address.
|
986
|
-
address.locality.
|
987
|
-
address.region.
|
988
|
-
address.postal_code.
|
989
|
-
address.country_name.
|
1035
|
+
expect(address.first_name).to eq("New First Name")
|
1036
|
+
expect(address.last_name).to eq("New Last Name")
|
1037
|
+
expect(address.company).to eq("New Company")
|
1038
|
+
expect(address.street_address).to eq("123 New St")
|
1039
|
+
expect(address.extended_address).to eq("Apt New")
|
1040
|
+
expect(address.locality).to eq("New City")
|
1041
|
+
expect(address.region).to eq("New State")
|
1042
|
+
expect(address.postal_code).to eq("56789")
|
1043
|
+
expect(address.country_name).to eq("United States of America")
|
990
1044
|
end
|
991
1045
|
|
992
1046
|
it "returns an error response if invalid" do
|
@@ -995,15 +1049,15 @@ describe Braintree::CreditCard do
|
|
995
1049
|
:cardholder_name => "Original Holder",
|
996
1050
|
:customer_id => customer.id,
|
997
1051
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
998
|
-
:expiration_date => "05/2012"
|
1052
|
+
:expiration_date => "05/2012",
|
999
1053
|
)
|
1000
1054
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
1001
1055
|
:cardholder_name => "New Holder",
|
1002
1056
|
:number => "invalid",
|
1003
|
-
:expiration_date => "05/2014"
|
1057
|
+
:expiration_date => "05/2014",
|
1004
1058
|
)
|
1005
|
-
update_result.success
|
1006
|
-
update_result.errors.for(:credit_card).on(:number)[0].message.
|
1059
|
+
expect(update_result.success?).to eq(false)
|
1060
|
+
expect(update_result.errors.for(:credit_card).on(:number)[0].message).to eq("Credit card number must be 12-19 digits.")
|
1007
1061
|
end
|
1008
1062
|
|
1009
1063
|
it "can update the default" do
|
@@ -1011,21 +1065,21 @@ describe Braintree::CreditCard do
|
|
1011
1065
|
card1 = Braintree::CreditCard.create(
|
1012
1066
|
:customer_id => customer.id,
|
1013
1067
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1014
|
-
:expiration_date => "05/2009"
|
1068
|
+
:expiration_date => "05/2009",
|
1015
1069
|
).credit_card
|
1016
1070
|
card2 = Braintree::CreditCard.create(
|
1017
1071
|
:customer_id => customer.id,
|
1018
1072
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1019
|
-
:expiration_date => "05/2009"
|
1073
|
+
:expiration_date => "05/2009",
|
1020
1074
|
).credit_card
|
1021
1075
|
|
1022
|
-
card1.
|
1023
|
-
card2.
|
1076
|
+
expect(card1).to be_default
|
1077
|
+
expect(card2).not_to be_default
|
1024
1078
|
|
1025
1079
|
Braintree::CreditCard.update(card2.token, :options => {:make_default => true})
|
1026
1080
|
|
1027
|
-
Braintree::CreditCard.find(card1.token).
|
1028
|
-
Braintree::CreditCard.find(card2.token).
|
1081
|
+
expect(Braintree::CreditCard.find(card1.token)).not_to be_default
|
1082
|
+
expect(Braintree::CreditCard.find(card2.token)).to be_default
|
1029
1083
|
end
|
1030
1084
|
|
1031
1085
|
context "verification_account_type" do
|
@@ -1059,7 +1113,7 @@ describe Braintree::CreditCard do
|
|
1059
1113
|
:options => {
|
1060
1114
|
:verify_card => true,
|
1061
1115
|
:verification_account_type => "debit",
|
1062
|
-
:verification_merchant_account_id => SpecHelper::
|
1116
|
+
:verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
1063
1117
|
},
|
1064
1118
|
)
|
1065
1119
|
expect(update_result).to be_success
|
@@ -1074,19 +1128,19 @@ describe Braintree::CreditCard do
|
|
1074
1128
|
:cardholder_name => "Original Holder",
|
1075
1129
|
:customer_id => customer.id,
|
1076
1130
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1077
|
-
:expiration_date => "05/2012"
|
1131
|
+
:expiration_date => "05/2012",
|
1078
1132
|
)
|
1079
1133
|
updated_credit_card = Braintree::CreditCard.update!(credit_card.token,
|
1080
1134
|
:cardholder_name => "New Holder",
|
1081
1135
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1082
|
-
:expiration_date => "06/2013"
|
1136
|
+
:expiration_date => "06/2013",
|
1083
1137
|
)
|
1084
|
-
updated_credit_card.token.
|
1085
|
-
updated_credit_card.bin.
|
1086
|
-
updated_credit_card.last_4.
|
1087
|
-
updated_credit_card.expiration_date.
|
1088
|
-
updated_credit_card.cardholder_name.
|
1089
|
-
updated_credit_card.updated_at.between?(Time.now - 60, Time.now).
|
1138
|
+
expect(updated_credit_card.token).to eq(credit_card.token)
|
1139
|
+
expect(updated_credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::MasterCard[0, 6])
|
1140
|
+
expect(updated_credit_card.last_4).to eq(Braintree::Test::CreditCardNumbers::MasterCard[-4..-1])
|
1141
|
+
expect(updated_credit_card.expiration_date).to eq("06/2013")
|
1142
|
+
expect(updated_credit_card.cardholder_name).to eq("New Holder")
|
1143
|
+
expect(updated_credit_card.updated_at.between?(Time.now - 60, Time.now)).to eq(true)
|
1090
1144
|
end
|
1091
1145
|
|
1092
1146
|
it "raises a ValidationsFailed if invalid" do
|
@@ -1095,156 +1149,30 @@ describe Braintree::CreditCard do
|
|
1095
1149
|
:cardholder_name => "Original Holder",
|
1096
1150
|
:customer_id => customer.id,
|
1097
1151
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1098
|
-
:expiration_date => "05/2012"
|
1152
|
+
:expiration_date => "05/2012",
|
1099
1153
|
)
|
1100
1154
|
expect do
|
1101
1155
|
Braintree::CreditCard.update!(credit_card.token,
|
1102
1156
|
:cardholder_name => "New Holder",
|
1103
1157
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1104
|
-
:expiration_date => "invalid/date"
|
1158
|
+
:expiration_date => "invalid/date",
|
1105
1159
|
)
|
1106
1160
|
end.to raise_error(Braintree::ValidationsFailed)
|
1107
1161
|
end
|
1108
1162
|
end
|
1109
1163
|
|
1110
|
-
describe "self.update_from_transparent_redirect" do
|
1111
|
-
it "updates the credit card" do
|
1112
|
-
old_token = "token_#{rand(10**10)}"
|
1113
|
-
new_token = "token_#{rand(10**10)}"
|
1114
|
-
customer = Braintree::Customer.create!(
|
1115
|
-
:credit_card => {
|
1116
|
-
:cardholder_name => "Old Cardholder Name",
|
1117
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1118
|
-
:expiration_date => "05/2012",
|
1119
|
-
:token => old_token
|
1120
|
-
}
|
1121
|
-
)
|
1122
|
-
credit_card = customer.credit_cards[0]
|
1123
|
-
params = {
|
1124
|
-
:credit_card => {
|
1125
|
-
:cardholder_name => "New Cardholder Name",
|
1126
|
-
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1127
|
-
:expiration_date => "05/2014"
|
1128
|
-
}
|
1129
|
-
}
|
1130
|
-
tr_data_params = {
|
1131
|
-
:payment_method_token => old_token,
|
1132
|
-
:credit_card => {
|
1133
|
-
:token => new_token
|
1134
|
-
}
|
1135
|
-
}
|
1136
|
-
tr_data = Braintree::TransparentRedirect.update_credit_card_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
1137
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::CreditCard.update_credit_card_url)
|
1138
|
-
result = Braintree::CreditCard.update_from_transparent_redirect(query_string_response)
|
1139
|
-
result.success?.should == true
|
1140
|
-
credit_card = result.credit_card
|
1141
|
-
credit_card.cardholder_name.should == "New Cardholder Name"
|
1142
|
-
credit_card.masked_number.should == "555555******4444"
|
1143
|
-
credit_card.expiration_date.should == "05/2014"
|
1144
|
-
credit_card.token.should == new_token
|
1145
|
-
end
|
1146
|
-
|
1147
|
-
it "updates the default credit card" do
|
1148
|
-
customer = Braintree::Customer.create!(
|
1149
|
-
:credit_card => {
|
1150
|
-
:cardholder_name => "Old Cardholder Name",
|
1151
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1152
|
-
:expiration_date => "05/2012"
|
1153
|
-
}
|
1154
|
-
)
|
1155
|
-
card1 = customer.credit_cards[0]
|
1156
|
-
|
1157
|
-
card2 = Braintree::CreditCard.create(
|
1158
|
-
:customer_id => customer.id,
|
1159
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1160
|
-
:expiration_date => "05/2009"
|
1161
|
-
).credit_card
|
1162
|
-
|
1163
|
-
card1.should be_default
|
1164
|
-
card2.should_not be_default
|
1165
|
-
|
1166
|
-
params = {
|
1167
|
-
:credit_card => {
|
1168
|
-
:options => {:make_default => true}
|
1169
|
-
}
|
1170
|
-
}
|
1171
|
-
tr_data_params = {
|
1172
|
-
:payment_method_token => card2.token
|
1173
|
-
}
|
1174
|
-
tr_data = Braintree::TransparentRedirect.update_credit_card_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
1175
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::CreditCard.update_credit_card_url)
|
1176
|
-
result = Braintree::CreditCard.update_from_transparent_redirect(query_string_response)
|
1177
|
-
|
1178
|
-
Braintree::CreditCard.find(card1.token).should_not be_default
|
1179
|
-
Braintree::CreditCard.find(card2.token).should be_default
|
1180
|
-
end
|
1181
|
-
end
|
1182
|
-
|
1183
|
-
describe "credit" do
|
1184
|
-
it "creates a credit transaction using the customer, returning a result object" do
|
1185
|
-
customer = Braintree::Customer.create!(
|
1186
|
-
:credit_card => {
|
1187
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1188
|
-
:expiration_date => "05/2010"
|
1189
|
-
}
|
1190
|
-
)
|
1191
|
-
result = customer.credit_cards[0].credit(
|
1192
|
-
:amount => "100.00"
|
1193
|
-
)
|
1194
|
-
result.success?.should == true
|
1195
|
-
result.transaction.amount.should == BigDecimal("100.00")
|
1196
|
-
result.transaction.type.should == "credit"
|
1197
|
-
result.transaction.customer_details.id.should == customer.id
|
1198
|
-
result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
|
1199
|
-
result.transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
1200
|
-
result.transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
1201
|
-
result.transaction.credit_card_details.expiration_date.should == "05/2010"
|
1202
|
-
end
|
1203
|
-
end
|
1204
|
-
|
1205
|
-
describe "credit!" do
|
1206
|
-
it "returns the created credit tranaction if valid" do
|
1207
|
-
customer = Braintree::Customer.create!(
|
1208
|
-
:credit_card => {
|
1209
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1210
|
-
:expiration_date => "05/2010"
|
1211
|
-
}
|
1212
|
-
)
|
1213
|
-
transaction = customer.credit_cards[0].credit!(:amount => "100.00")
|
1214
|
-
transaction.amount.should == BigDecimal("100.00")
|
1215
|
-
transaction.type.should == "credit"
|
1216
|
-
transaction.customer_details.id.should == customer.id
|
1217
|
-
transaction.credit_card_details.token.should == customer.credit_cards[0].token
|
1218
|
-
transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
1219
|
-
transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
1220
|
-
transaction.credit_card_details.expiration_date.should == "05/2010"
|
1221
|
-
end
|
1222
|
-
|
1223
|
-
it "raises a ValidationsFailed if invalid" do
|
1224
|
-
customer = Braintree::Customer.create!(
|
1225
|
-
:credit_card => {
|
1226
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1227
|
-
:expiration_date => "05/2010"
|
1228
|
-
}
|
1229
|
-
)
|
1230
|
-
expect do
|
1231
|
-
customer.credit_cards[0].credit!(:amount => "invalid")
|
1232
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
1233
|
-
end
|
1234
|
-
end
|
1235
|
-
|
1236
1164
|
describe "self.delete" do
|
1237
1165
|
it "deletes the credit card" do
|
1238
1166
|
customer = Braintree::Customer.create.customer
|
1239
1167
|
result = Braintree::CreditCard.create(
|
1240
1168
|
:customer_id => customer.id,
|
1241
1169
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1242
|
-
:expiration_date => "05/2012"
|
1170
|
+
:expiration_date => "05/2012",
|
1243
1171
|
)
|
1244
1172
|
|
1245
|
-
result.success
|
1173
|
+
expect(result.success?).to eq(true)
|
1246
1174
|
credit_card = result.credit_card
|
1247
|
-
Braintree::CreditCard.delete(credit_card.token).
|
1175
|
+
expect(Braintree::CreditCard.delete(credit_card.token)).to eq(true)
|
1248
1176
|
expect do
|
1249
1177
|
Braintree::CreditCard.find(credit_card.token)
|
1250
1178
|
end.to raise_error(Braintree::NotFoundError)
|
@@ -1259,18 +1187,18 @@ describe Braintree::CreditCard do
|
|
1259
1187
|
Braintree::CreditCard.create!(
|
1260
1188
|
:customer_id => customer.id,
|
1261
1189
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1262
|
-
:expiration_date => "01
|
1190
|
+
:expiration_date => "01/#{Time.now.year - 3}",
|
1263
1191
|
)
|
1264
1192
|
end
|
1265
1193
|
|
1266
1194
|
collection = Braintree::CreditCard.expired
|
1267
|
-
collection.maximum_size.
|
1195
|
+
expect(collection.maximum_size).to be > 100
|
1268
1196
|
|
1269
1197
|
credit_card_ids = collection.map do |c|
|
1270
|
-
c.expired
|
1198
|
+
expect(c.expired?).to eq(true)
|
1271
1199
|
c.token
|
1272
1200
|
end.uniq.compact
|
1273
|
-
credit_card_ids.size.
|
1201
|
+
expect(credit_card_ids.size).to eq(collection.maximum_size)
|
1274
1202
|
end
|
1275
1203
|
end
|
1276
1204
|
|
@@ -1278,9 +1206,9 @@ describe Braintree::CreditCard do
|
|
1278
1206
|
it "finds payment methods expiring between the given dates" do
|
1279
1207
|
next_year = Time.now.year + 1
|
1280
1208
|
collection = Braintree::CreditCard.expiring_between(Time.mktime(next_year, 1), Time.mktime(next_year, 12))
|
1281
|
-
collection.maximum_size.
|
1282
|
-
collection.all? { |pm| pm.expired
|
1283
|
-
collection.all? { |pm| pm.expiration_year.
|
1209
|
+
expect(collection.maximum_size).to be > 0
|
1210
|
+
collection.all? { |pm| expect(pm.expired?).to eq(false) }
|
1211
|
+
collection.all? { |pm| expect(pm.expiration_year).to eq(next_year.to_s) }
|
1284
1212
|
end
|
1285
1213
|
|
1286
1214
|
it "can iterate over all items" do
|
@@ -1290,15 +1218,15 @@ describe Braintree::CreditCard do
|
|
1290
1218
|
Braintree::CreditCard.create!(
|
1291
1219
|
:customer_id => customer.id,
|
1292
1220
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1293
|
-
:expiration_date => "01/2010"
|
1221
|
+
:expiration_date => "01/2010",
|
1294
1222
|
)
|
1295
1223
|
end
|
1296
1224
|
|
1297
1225
|
collection = Braintree::CreditCard.expiring_between(Time.mktime(2010, 1, 1), Time.mktime(2010,3, 1))
|
1298
|
-
collection.maximum_size.
|
1226
|
+
expect(collection.maximum_size).to be > 100
|
1299
1227
|
|
1300
|
-
credit_card_ids = collection.map {|c| c.token }.uniq.compact
|
1301
|
-
credit_card_ids.size.
|
1228
|
+
credit_card_ids = collection.map { |c| c.token }.uniq.compact
|
1229
|
+
expect(credit_card_ids.size).to eq(collection.maximum_size)
|
1302
1230
|
end
|
1303
1231
|
end
|
1304
1232
|
|
@@ -1308,14 +1236,14 @@ describe Braintree::CreditCard do
|
|
1308
1236
|
result = Braintree::CreditCard.create(
|
1309
1237
|
:customer_id => customer.id,
|
1310
1238
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1311
|
-
:expiration_date => "05/2012"
|
1239
|
+
:expiration_date => "05/2012",
|
1312
1240
|
)
|
1313
|
-
result.success
|
1241
|
+
expect(result.success?).to eq(true)
|
1314
1242
|
credit_card = Braintree::CreditCard.find(result.credit_card.token)
|
1315
|
-
credit_card.bin.
|
1316
|
-
credit_card.last_4.
|
1317
|
-
credit_card.token.
|
1318
|
-
credit_card.expiration_date.
|
1243
|
+
expect(credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
1244
|
+
expect(credit_card.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
1245
|
+
expect(credit_card.token).to eq(result.credit_card.token)
|
1246
|
+
expect(credit_card.expiration_date).to eq("05/2012")
|
1319
1247
|
end
|
1320
1248
|
|
1321
1249
|
it "returns associated subscriptions with the credit card" do
|
@@ -1323,20 +1251,20 @@ describe Braintree::CreditCard do
|
|
1323
1251
|
credit_card = Braintree::CreditCard.create(
|
1324
1252
|
:customer_id => customer.id,
|
1325
1253
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1326
|
-
:expiration_date => "05/2012"
|
1254
|
+
:expiration_date => "05/2012",
|
1327
1255
|
).credit_card
|
1328
1256
|
|
1329
1257
|
subscription = Braintree::Subscription.create(
|
1330
1258
|
:payment_method_token => credit_card.token,
|
1331
1259
|
:plan_id => "integration_trialless_plan",
|
1332
|
-
:price => "1.00"
|
1260
|
+
:price => "1.00",
|
1333
1261
|
).subscription
|
1334
1262
|
|
1335
1263
|
found_card = Braintree::CreditCard.find(credit_card.token)
|
1336
|
-
found_card.subscriptions.first.id.
|
1337
|
-
found_card.subscriptions.first.plan_id.
|
1338
|
-
found_card.subscriptions.first.payment_method_token.
|
1339
|
-
found_card.subscriptions.first.price.
|
1264
|
+
expect(found_card.subscriptions.first.id).to eq(subscription.id)
|
1265
|
+
expect(found_card.subscriptions.first.plan_id).to eq("integration_trialless_plan")
|
1266
|
+
expect(found_card.subscriptions.first.payment_method_token).to eq(credit_card.token)
|
1267
|
+
expect(found_card.subscriptions.first.price).to eq(BigDecimal("1.00"))
|
1340
1268
|
end
|
1341
1269
|
|
1342
1270
|
it "raises a NotFoundError exception if payment method cannot be found" do
|
@@ -1373,12 +1301,12 @@ describe Braintree::CreditCard do
|
|
1373
1301
|
:expiration_month => "11",
|
1374
1302
|
:expiration_year => "2099",
|
1375
1303
|
},
|
1376
|
-
:client_token_options => {:customer_id => customer.id}
|
1304
|
+
:client_token_options => {:customer_id => customer.id},
|
1377
1305
|
)
|
1378
1306
|
|
1379
1307
|
credit_card = Braintree::CreditCard.from_nonce(nonce)
|
1380
1308
|
customer = Braintree::Customer.find(customer.id)
|
1381
|
-
credit_card.
|
1309
|
+
expect(credit_card).to eq(customer.credit_cards.first)
|
1382
1310
|
end
|
1383
1311
|
|
1384
1312
|
it "does not find a payment method for an unlocked nonce that points to a shared credit card" do
|
@@ -1387,7 +1315,7 @@ describe Braintree::CreditCard do
|
|
1387
1315
|
:number => "4111111111111111",
|
1388
1316
|
:expiration_month => "11",
|
1389
1317
|
:expiration_year => "2099",
|
1390
|
-
}
|
1318
|
+
},
|
1391
1319
|
)
|
1392
1320
|
expect do
|
1393
1321
|
Braintree::CreditCard.from_nonce(nonce)
|
@@ -1402,7 +1330,7 @@ describe Braintree::CreditCard do
|
|
1402
1330
|
:expiration_month => "11",
|
1403
1331
|
:expiration_year => "2099",
|
1404
1332
|
},
|
1405
|
-
:client_token_options => {:customer_id => customer.id}
|
1333
|
+
:client_token_options => {:customer_id => customer.id},
|
1406
1334
|
)
|
1407
1335
|
|
1408
1336
|
Braintree::CreditCard.from_nonce(nonce)
|
@@ -1412,24 +1340,26 @@ describe Braintree::CreditCard do
|
|
1412
1340
|
end
|
1413
1341
|
end
|
1414
1342
|
|
1343
|
+
# NEXT_MAJOR_VERSION remove these tests
|
1344
|
+
# CreditCard.sale has been deprecated in favor of Transaction.sale
|
1415
1345
|
describe "self.sale" do
|
1416
1346
|
it "creates a sale transaction using the credit card, returning a result object" do
|
1417
1347
|
customer = Braintree::Customer.create!(
|
1418
1348
|
:credit_card => {
|
1419
1349
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1420
1350
|
:expiration_date => "05/2010"
|
1421
|
-
}
|
1351
|
+
},
|
1422
1352
|
)
|
1423
1353
|
result = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00")
|
1424
1354
|
|
1425
|
-
result.success
|
1426
|
-
result.transaction.amount.
|
1427
|
-
result.transaction.type.
|
1428
|
-
result.transaction.customer_details.id.
|
1429
|
-
result.transaction.credit_card_details.token.
|
1430
|
-
result.transaction.credit_card_details.bin.
|
1431
|
-
result.transaction.credit_card_details.last_4.
|
1432
|
-
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")
|
1433
1363
|
end
|
1434
1364
|
|
1435
1365
|
it "allows passing a cvv in addition to the token" do
|
@@ -1437,303 +1367,74 @@ describe Braintree::CreditCard do
|
|
1437
1367
|
:credit_card => {
|
1438
1368
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1439
1369
|
:expiration_date => "05/2010"
|
1440
|
-
}
|
1370
|
+
},
|
1441
1371
|
)
|
1442
1372
|
result = Braintree::CreditCard.sale(customer.credit_cards[0].token,
|
1443
1373
|
:amount => "100.00",
|
1444
1374
|
:credit_card => {
|
1445
1375
|
:cvv => "301"
|
1446
|
-
}
|
1376
|
+
},
|
1447
1377
|
)
|
1448
1378
|
|
1449
|
-
result.success
|
1450
|
-
result.transaction.amount.
|
1451
|
-
result.transaction.type.
|
1452
|
-
result.transaction.customer_details.id.
|
1453
|
-
result.transaction.credit_card_details.token.
|
1454
|
-
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")
|
1455
1385
|
end
|
1456
1386
|
end
|
1457
1387
|
|
1388
|
+
# NEXT_MAJOR_VERSION remove this test
|
1389
|
+
# CreditCard.sale has been deprecated in favor of Transaction.sale
|
1458
1390
|
describe "self.sale!" do
|
1459
1391
|
it "creates a sale transaction using the credit card, returning the transaction" do
|
1460
1392
|
customer = Braintree::Customer.create!(
|
1461
1393
|
:credit_card => {
|
1462
1394
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1463
1395
|
:expiration_date => "05/2010"
|
1464
|
-
}
|
1396
|
+
},
|
1465
1397
|
)
|
1466
1398
|
transaction = Braintree::CreditCard.sale!(customer.credit_cards[0].token, :amount => "100.00")
|
1467
|
-
transaction.amount.
|
1468
|
-
transaction.type.
|
1469
|
-
transaction.customer_details.id.
|
1470
|
-
transaction.credit_card_details.token.
|
1471
|
-
transaction.credit_card_details.bin.
|
1472
|
-
transaction.credit_card_details.last_4.
|
1473
|
-
transaction.credit_card_details.expiration_date.
|
1399
|
+
expect(transaction.amount).to eq(BigDecimal("100.00"))
|
1400
|
+
expect(transaction.type).to eq("sale")
|
1401
|
+
expect(transaction.customer_details.id).to eq(customer.id)
|
1402
|
+
expect(transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
1403
|
+
expect(transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
1404
|
+
expect(transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
1405
|
+
expect(transaction.credit_card_details.expiration_date).to eq("05/2010")
|
1474
1406
|
end
|
1475
1407
|
end
|
1476
1408
|
|
1477
|
-
describe "
|
1478
|
-
it "
|
1479
|
-
customer = Braintree::Customer.create!(
|
1480
|
-
:credit_card => {
|
1481
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1482
|
-
:expiration_date => "05/2010"
|
1483
|
-
}
|
1484
|
-
)
|
1485
|
-
result = customer.credit_cards[0].sale(
|
1486
|
-
:amount => "100.00"
|
1487
|
-
)
|
1488
|
-
result.success?.should == true
|
1489
|
-
result.transaction.amount.should == BigDecimal("100.00")
|
1490
|
-
result.transaction.type.should == "sale"
|
1491
|
-
result.transaction.customer_details.id.should == customer.id
|
1492
|
-
result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
|
1493
|
-
result.transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
1494
|
-
result.transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
1495
|
-
result.transaction.credit_card_details.expiration_date.should == "05/2010"
|
1496
|
-
end
|
1497
|
-
end
|
1498
|
-
|
1499
|
-
describe "sale!" do
|
1500
|
-
it "returns the created sale tranaction if valid" do
|
1501
|
-
customer = Braintree::Customer.create!(
|
1502
|
-
:credit_card => {
|
1503
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1504
|
-
:expiration_date => "05/2010"
|
1505
|
-
}
|
1506
|
-
)
|
1507
|
-
transaction = customer.credit_cards[0].sale!(:amount => "100.00")
|
1508
|
-
transaction.amount.should == BigDecimal("100.00")
|
1509
|
-
transaction.type.should == "sale"
|
1510
|
-
transaction.customer_details.id.should == customer.id
|
1511
|
-
transaction.credit_card_details.token.should == customer.credit_cards[0].token
|
1512
|
-
transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
1513
|
-
transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
1514
|
-
transaction.credit_card_details.expiration_date.should == "05/2010"
|
1515
|
-
end
|
1516
|
-
|
1517
|
-
it "raises a ValidationsFailed if invalid" do
|
1518
|
-
customer = Braintree::Customer.create!(
|
1519
|
-
:credit_card => {
|
1520
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1521
|
-
:expiration_date => "05/2010"
|
1522
|
-
}
|
1523
|
-
)
|
1524
|
-
expect do
|
1525
|
-
customer.credit_cards[0].sale!(:amount => "invalid")
|
1526
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
1527
|
-
end
|
1528
|
-
end
|
1529
|
-
|
1530
|
-
describe "update" do
|
1531
|
-
it "updates the credit card" do
|
1532
|
-
customer = Braintree::Customer.create!
|
1533
|
-
credit_card = Braintree::CreditCard.create!(
|
1534
|
-
:cardholder_name => "Original Holder",
|
1535
|
-
:customer_id => customer.id,
|
1536
|
-
:cvv => "123",
|
1537
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1538
|
-
:expiration_date => "05/2012"
|
1539
|
-
)
|
1540
|
-
update_result = credit_card.update(
|
1541
|
-
:cardholder_name => "New Holder",
|
1542
|
-
:cvv => "456",
|
1543
|
-
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1544
|
-
:expiration_date => "06/2013"
|
1545
|
-
)
|
1546
|
-
update_result.success?.should == true
|
1547
|
-
update_result.credit_card.should == credit_card
|
1548
|
-
updated_credit_card = update_result.credit_card
|
1549
|
-
updated_credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
1550
|
-
updated_credit_card.last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
1551
|
-
updated_credit_card.expiration_date.should == "06/2013"
|
1552
|
-
updated_credit_card.cardholder_name.should == "New Holder"
|
1553
|
-
end
|
1554
|
-
|
1555
|
-
it "verifies the update if options[verify_card]=true" do
|
1556
|
-
customer = Braintree::Customer.create!
|
1557
|
-
credit_card = Braintree::CreditCard.create!(
|
1558
|
-
:cardholder_name => "Original Holder",
|
1559
|
-
:customer_id => customer.id,
|
1560
|
-
:cvv => "123",
|
1561
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1562
|
-
:expiration_date => "05/2012"
|
1563
|
-
)
|
1564
|
-
update_result = credit_card.update(
|
1565
|
-
:cardholder_name => "New Holder",
|
1566
|
-
:cvv => "456",
|
1567
|
-
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
|
1568
|
-
:expiration_date => "06/2013",
|
1569
|
-
:options => {:verify_card => true}
|
1570
|
-
)
|
1571
|
-
update_result.success?.should == false
|
1572
|
-
update_result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
1573
|
-
end
|
1574
|
-
|
1575
|
-
it "fails on create if credit_card[options][fail_on_duplicate_payment_method]=true and there is a duplicated payment method" do
|
1576
|
-
customer = Braintree::Customer.create!
|
1577
|
-
Braintree::CreditCard.create(
|
1578
|
-
:customer_id => customer.id,
|
1579
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1580
|
-
:expiration_date => "05/2015"
|
1581
|
-
)
|
1582
|
-
|
1583
|
-
result = Braintree::CreditCard.create(
|
1584
|
-
:customer_id => customer.id,
|
1585
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1586
|
-
:expiration_date => "05/2015",
|
1587
|
-
:options => {:fail_on_duplicate_payment_method => true}
|
1588
|
-
)
|
1589
|
-
|
1590
|
-
result.success?.should == false
|
1591
|
-
result.errors.for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
|
1592
|
-
end
|
1593
|
-
|
1594
|
-
it "allows user to specify merchant account for verification" do
|
1595
|
-
customer = Braintree::Customer.create!
|
1596
|
-
credit_card = Braintree::CreditCard.create!(
|
1597
|
-
:cardholder_name => "Original Holder",
|
1598
|
-
:customer_id => customer.id,
|
1599
|
-
:cvv => "123",
|
1600
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1601
|
-
:expiration_date => "05/2012"
|
1602
|
-
)
|
1603
|
-
update_result = credit_card.update(
|
1604
|
-
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
1605
|
-
:expiration_date => "05/2009",
|
1606
|
-
:options => {
|
1607
|
-
:verify_card => true,
|
1608
|
-
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
1609
|
-
}
|
1610
|
-
)
|
1611
|
-
update_result.success?.should == false
|
1612
|
-
update_result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
1613
|
-
update_result.credit_card_verification.processor_response_code.should == "2000"
|
1614
|
-
update_result.credit_card_verification.processor_response_text.should == "Do Not Honor"
|
1615
|
-
update_result.credit_card_verification.cvv_response_code.should == "I"
|
1616
|
-
update_result.credit_card_verification.avs_error_response_code.should == nil
|
1617
|
-
update_result.credit_card_verification.avs_postal_code_response_code.should == "I"
|
1618
|
-
update_result.credit_card_verification.avs_street_address_response_code.should == "I"
|
1619
|
-
end
|
1620
|
-
|
1621
|
-
it "can update the billing address" do
|
1409
|
+
describe "nonce" do
|
1410
|
+
it "returns the credit card nonce" do
|
1622
1411
|
customer = Braintree::Customer.create!
|
1623
1412
|
credit_card = Braintree::CreditCard.create!(
|
1624
1413
|
:cardholder_name => "Original Holder",
|
1625
1414
|
:customer_id => customer.id,
|
1626
|
-
:cvv => "123",
|
1627
1415
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1628
1416
|
:expiration_date => "05/2012",
|
1629
|
-
:billing_address => {
|
1630
|
-
:first_name => "Old First Name",
|
1631
|
-
:last_name => "Old Last Name",
|
1632
|
-
:company => "Old Company",
|
1633
|
-
:street_address => "123 Old St",
|
1634
|
-
:extended_address => "Apt Old",
|
1635
|
-
:locality => "Old City",
|
1636
|
-
:region => "Old State",
|
1637
|
-
:postal_code => "12345",
|
1638
|
-
:country_name => "Canada"
|
1639
|
-
}
|
1640
|
-
)
|
1641
|
-
result = credit_card.update(
|
1642
|
-
:options => {:verify_card => false},
|
1643
|
-
:billing_address => {
|
1644
|
-
:first_name => "New First Name",
|
1645
|
-
:last_name => "New Last Name",
|
1646
|
-
:company => "New Company",
|
1647
|
-
:street_address => "123 New St",
|
1648
|
-
:extended_address => "Apt New",
|
1649
|
-
:locality => "New City",
|
1650
|
-
:region => "New State",
|
1651
|
-
:postal_code => "56789",
|
1652
|
-
:country_name => "United States of America"
|
1653
|
-
}
|
1654
1417
|
)
|
1655
|
-
result.success?.should == true
|
1656
|
-
address = result.credit_card.billing_address
|
1657
|
-
address.should == credit_card.billing_address # making sure credit card instance was updated
|
1658
|
-
address.first_name.should == "New First Name"
|
1659
|
-
address.last_name.should == "New Last Name"
|
1660
|
-
address.company.should == "New Company"
|
1661
|
-
address.street_address.should == "123 New St"
|
1662
|
-
address.extended_address.should == "Apt New"
|
1663
|
-
address.locality.should == "New City"
|
1664
|
-
address.region.should == "New State"
|
1665
|
-
address.postal_code.should == "56789"
|
1666
|
-
address.country_name.should == "United States of America"
|
1667
|
-
end
|
1668
1418
|
|
1669
|
-
|
1670
|
-
customer = Braintree::Customer.create!
|
1671
|
-
credit_card = Braintree::CreditCard.create!(
|
1672
|
-
:cardholder_name => "Original Holder",
|
1673
|
-
:customer_id => customer.id,
|
1674
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1675
|
-
:expiration_date => "05/2012"
|
1676
|
-
)
|
1677
|
-
update_result = credit_card.update(
|
1678
|
-
:cardholder_name => "New Holder",
|
1679
|
-
:number => "invalid",
|
1680
|
-
:expiration_date => "05/2014"
|
1681
|
-
)
|
1682
|
-
update_result.success?.should == false
|
1683
|
-
update_result.errors.for(:credit_card).on(:number)[0].message.should == "Credit card number must be 12-19 digits."
|
1419
|
+
expect(credit_card.nonce).not_to be_nil
|
1684
1420
|
end
|
1685
1421
|
end
|
1686
1422
|
|
1687
|
-
describe "
|
1688
|
-
it "
|
1689
|
-
|
1690
|
-
credit_card
|
1691
|
-
:cardholder_name => "Original Holder",
|
1692
|
-
:customer_id => customer.id,
|
1693
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1694
|
-
:expiration_date => "05/2012"
|
1695
|
-
)
|
1696
|
-
credit_card.update!(
|
1697
|
-
:cardholder_name => "New Holder",
|
1698
|
-
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1699
|
-
:expiration_date => "06/2013"
|
1700
|
-
).should == credit_card
|
1701
|
-
credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
1702
|
-
credit_card.last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
1703
|
-
credit_card.expiration_date.should == "06/2013"
|
1704
|
-
credit_card.cardholder_name.should == "New Holder"
|
1705
|
-
credit_card.updated_at.between?(Time.now - 60, Time.now).should == true
|
1706
|
-
end
|
1707
|
-
|
1708
|
-
it "raises a ValidationsFailed if invalid" do
|
1709
|
-
customer = Braintree::Customer.create!
|
1710
|
-
credit_card = Braintree::CreditCard.create!(
|
1711
|
-
:cardholder_name => "Original Holder",
|
1712
|
-
:customer_id => customer.id,
|
1713
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1714
|
-
:expiration_date => "05/2012"
|
1715
|
-
)
|
1716
|
-
expect do
|
1717
|
-
credit_card.update!(
|
1718
|
-
:cardholder_name => "New Holder",
|
1719
|
-
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1720
|
-
:expiration_date => "invalid/date"
|
1721
|
-
)
|
1722
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
1423
|
+
describe "card on file network tokenization" do
|
1424
|
+
it "should find a network tokenized credit card" do
|
1425
|
+
credit_card = Braintree::CreditCard.find("network_tokenized_credit_card")
|
1426
|
+
expect(credit_card.is_network_tokenized?).to eq(true)
|
1723
1427
|
end
|
1724
|
-
end
|
1725
1428
|
|
1726
|
-
|
1727
|
-
it "returns the credit card nonce" do
|
1429
|
+
it "should find a non-network tokenized credit card" do
|
1728
1430
|
customer = Braintree::Customer.create!
|
1729
|
-
credit_card = Braintree::CreditCard.create
|
1730
|
-
:cardholder_name => "Original Holder",
|
1431
|
+
credit_card = Braintree::CreditCard.create(
|
1731
1432
|
:customer_id => customer.id,
|
1732
1433
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1733
|
-
:expiration_date => "05/
|
1734
|
-
)
|
1735
|
-
|
1736
|
-
|
1434
|
+
:expiration_date => "05/2009",
|
1435
|
+
).credit_card
|
1436
|
+
credit_card_vaulted = Braintree::CreditCard.find(credit_card.token)
|
1437
|
+
expect(credit_card_vaulted.is_network_tokenized?).to eq(false)
|
1737
1438
|
end
|
1738
1439
|
end
|
1739
1440
|
end
|