braintree 4.14.0 → 4.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/account_updater_daily_report.rb +3 -3
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +4 -4
- data/lib/braintree/address_gateway.rb +5 -5
- data/lib/braintree/advanced_search.rb +10 -10
- data/lib/braintree/apple_pay.rb +3 -3
- data/lib/braintree/apple_pay_card.rb +3 -3
- data/lib/braintree/apple_pay_options.rb +3 -3
- data/lib/braintree/authorization_adjustment.rb +3 -3
- data/lib/braintree/base_module.rb +1 -1
- data/lib/braintree/bin_data.rb +2 -2
- data/lib/braintree/client_token_gateway.rb +1 -1
- data/lib/braintree/configuration.rb +22 -22
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +22 -9
- data/lib/braintree/credit_card_gateway.rb +23 -11
- data/lib/braintree/credit_card_verification.rb +3 -3
- data/lib/braintree/credit_card_verification_gateway.rb +28 -11
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +5 -9
- data/lib/braintree/customer_gateway.rb +7 -7
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +5 -5
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/dispute/paypal_message.rb +1 -1
- data/lib/braintree/dispute/status_history.rb +1 -1
- data/lib/braintree/dispute/transaction.rb +1 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +3 -3
- data/lib/braintree/dispute_gateway.rb +1 -1
- data/lib/braintree/dispute_search.rb +1 -1
- data/lib/braintree/document_upload.rb +2 -2
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +2 -2
- data/lib/braintree/error_codes.rb +4 -0
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +1 -2
- data/lib/braintree/exchange_rate.rb +2 -2
- data/lib/braintree/exchange_rate_quote.rb +3 -3
- data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
- data/lib/braintree/exchange_rate_quote_input.rb +3 -3
- data/lib/braintree/exchange_rate_quote_request.rb +3 -3
- data/lib/braintree/exchange_rate_quote_response.rb +3 -3
- data/lib/braintree/facilitated_details.rb +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/google_pay_card.rb +3 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +1 -1
- data/lib/braintree/http.rb +5 -5
- data/lib/braintree/local_payment_completed.rb +2 -2
- data/lib/braintree/local_payment_expired.rb +2 -2
- data/lib/braintree/local_payment_funded.rb +2 -2
- data/lib/braintree/local_payment_reversed.rb +2 -2
- data/lib/braintree/merchant.rb +3 -3
- data/lib/braintree/merchant_account.rb +2 -2
- data/lib/braintree/merchant_account_gateway.rb +9 -9
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +3 -3
- data/lib/braintree/oauth_credentials.rb +3 -3
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +2 -0
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
- data/lib/braintree/payment_method_gateway.rb +23 -10
- data/lib/braintree/payment_method_nonce.rb +4 -4
- data/lib/braintree/payment_method_nonce_details.rb +1 -1
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/paypal_account.rb +1 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/plan_gateway.rb +2 -2
- data/lib/braintree/resource_collection.rb +2 -2
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +1 -1
- data/lib/braintree/samsung_pay_card.rb +5 -5
- data/lib/braintree/sepa_direct_debit_account.rb +2 -2
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
- data/lib/braintree/sha256_digest.rb +1 -1
- data/lib/braintree/subscription/status_details.rb +1 -1
- data/lib/braintree/subscription.rb +2 -2
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +2 -2
- data/lib/braintree/test/credit_card.rb +7 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +4 -0
- data/lib/braintree/test/transaction_amounts.rb +2 -3
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/testing_gateway.rb +1 -1
- data/lib/braintree/three_d_secure_info.rb +1 -1
- data/lib/braintree/transaction/address_details.rb +2 -1
- data/lib/braintree/transaction/credit_card_details.rb +4 -1
- data/lib/braintree/transaction/customer_details.rb +1 -1
- data/lib/braintree/transaction/disbursement_details.rb +1 -1
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
- data/lib/braintree/transaction/package_details.rb +16 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +1 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +37 -20
- data/lib/braintree/transaction_gateway.rb +44 -15
- data/lib/braintree/transaction_line_item.rb +13 -10
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +1 -1
- data/lib/braintree/transaction_search.rb +7 -6
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +2 -2
- data/lib/braintree/us_bank_account_verification.rb +23 -15
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +3 -3
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +3 -3
- data/lib/braintree/venmo_profile_data.rb +6 -4
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +7 -7
- data/lib/braintree/webhook_notification.rb +3 -2
- data/lib/braintree/webhook_notification_gateway.rb +4 -4
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +18 -1
- data/lib/braintree/xml/generator.rb +1 -1
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +3 -3
- data/lib/braintree/xml/rexml.rb +2 -2
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +5 -1
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/client_api/spec_helper.rb +2 -2
- data/spec/integration/braintree/credit_card_spec.rb +227 -228
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +98 -53
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +317 -317
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_search_spec.rb +0 -1
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/package_tracking_spec.rb +111 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +89 -69
- data/spec/integration/braintree/payment_method_spec.rb +391 -391
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +150 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +12 -6
- data/spec/integration/braintree/transaction_search_spec.rb +225 -165
- data/spec/integration/braintree/transaction_spec.rb +1606 -1230
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +33 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +11 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +9 -9
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/package_tracking_spec.rb +74 -0
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +41 -9
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +12 -7
- data/spec/unit/braintree/util_spec.rb +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +16 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +14 -2
@@ -23,22 +23,22 @@ describe Braintree::PaymentMethod do
|
|
23
23
|
},
|
24
24
|
)
|
25
25
|
|
26
|
-
result.
|
26
|
+
expect(result).to be_success
|
27
27
|
us_bank_account = result.payment_method
|
28
|
-
us_bank_account.
|
29
|
-
us_bank_account.routing_number.
|
30
|
-
us_bank_account.last_4.
|
31
|
-
us_bank_account.account_type.
|
32
|
-
us_bank_account.account_holder_name.
|
33
|
-
us_bank_account.bank_name.
|
34
|
-
us_bank_account.default.
|
35
|
-
us_bank_account.ach_mandate.text.
|
36
|
-
us_bank_account.ach_mandate.accepted_at.
|
37
|
-
|
38
|
-
us_bank_account.verifications.count.
|
39
|
-
us_bank_account.verified.
|
40
|
-
|
41
|
-
Braintree::PaymentMethod.find(us_bank_account.token).
|
28
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
29
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
30
|
+
expect(us_bank_account.last_4).to eq("0000")
|
31
|
+
expect(us_bank_account.account_type).to eq("checking")
|
32
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
33
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
34
|
+
expect(us_bank_account.default).to eq(true)
|
35
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
36
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
37
|
+
|
38
|
+
expect(us_bank_account.verifications.count).to eq(0)
|
39
|
+
expect(us_bank_account.verified).to eq(false)
|
40
|
+
|
41
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
42
42
|
end
|
43
43
|
|
44
44
|
[
|
@@ -56,28 +56,100 @@ describe Braintree::PaymentMethod do
|
|
56
56
|
},
|
57
57
|
)
|
58
58
|
|
59
|
-
result.
|
59
|
+
expect(result).to be_success
|
60
60
|
us_bank_account = result.payment_method
|
61
|
-
us_bank_account.
|
62
|
-
us_bank_account.routing_number.
|
63
|
-
us_bank_account.last_4.
|
64
|
-
us_bank_account.account_type.
|
65
|
-
us_bank_account.account_holder_name.
|
66
|
-
us_bank_account.bank_name.
|
67
|
-
us_bank_account.default.
|
68
|
-
us_bank_account.ach_mandate.text.
|
69
|
-
us_bank_account.ach_mandate.accepted_at.
|
70
|
-
|
71
|
-
us_bank_account.verifications.count.
|
72
|
-
us_bank_account.verifications.first.status.
|
73
|
-
us_bank_account.verifications.first.verification_method.
|
74
|
-
us_bank_account.verifications.first.id.
|
75
|
-
us_bank_account.verifications.first.verification_determined_at.
|
76
|
-
us_bank_account.verified.
|
77
|
-
|
78
|
-
Braintree::PaymentMethod.find(us_bank_account.token).
|
61
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
62
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
63
|
+
expect(us_bank_account.last_4).to eq("0000")
|
64
|
+
expect(us_bank_account.account_type).to eq("checking")
|
65
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
66
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
67
|
+
expect(us_bank_account.default).to eq(true)
|
68
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
69
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
70
|
+
|
71
|
+
expect(us_bank_account.verifications.count).to eq(1)
|
72
|
+
expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
73
|
+
expect(us_bank_account.verifications.first.verification_method).to eq(method)
|
74
|
+
expect(us_bank_account.verifications.first.id).not_to be_empty
|
75
|
+
expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
|
76
|
+
expect(us_bank_account.verified).to eq(true)
|
77
|
+
|
78
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
79
79
|
end
|
80
80
|
end
|
81
|
+
|
82
|
+
it "succeeds and verifies with verification_add_ons for NetworkCheck with fake nonce" do
|
83
|
+
customer = Braintree::Customer.create.customer
|
84
|
+
result = Braintree::PaymentMethod.create(
|
85
|
+
:payment_method_nonce => Braintree::Test::Nonce::UsBankAccount,
|
86
|
+
:customer_id => customer.id,
|
87
|
+
:options => {
|
88
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
89
|
+
:verification_add_ons => Braintree::UsBankAccountVerification::VerificationAddOns::CustomerVerification,
|
90
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
91
|
+
},
|
92
|
+
)
|
93
|
+
|
94
|
+
expect(result).to be_success
|
95
|
+
us_bank_account = result.payment_method
|
96
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
97
|
+
expect(us_bank_account.routing_number).to eq("123456789")
|
98
|
+
expect(us_bank_account.last_4).to eq("0000")
|
99
|
+
expect(us_bank_account.account_type).to eq("checking")
|
100
|
+
expect(us_bank_account.account_holder_name).to eq("Dan Schulman")
|
101
|
+
expect(us_bank_account.bank_name).to match(/Wells Fargo/)
|
102
|
+
expect(us_bank_account.default).to eq(true)
|
103
|
+
expect(us_bank_account.ach_mandate.text).to eq("example mandate text")
|
104
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
105
|
+
|
106
|
+
expect(us_bank_account.verifications.count).to eq(1)
|
107
|
+
expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
108
|
+
expect(us_bank_account.verifications.first.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck)
|
109
|
+
expect(us_bank_account.verifications.first.id).not_to be_empty
|
110
|
+
expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
|
111
|
+
expect(us_bank_account.verifications.first.processor_response_code).to eq("1000")
|
112
|
+
expect(us_bank_account.verified).to eq(true)
|
113
|
+
|
114
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "returns additional processor response for failed NetworkCheck" do
|
118
|
+
customer = Braintree::Customer.create.customer
|
119
|
+
invalid_nonce = generate_non_plaid_us_bank_account_nonce(account_number = "1000000005")
|
120
|
+
result = Braintree::PaymentMethod.create(
|
121
|
+
:payment_method_nonce => invalid_nonce,
|
122
|
+
:customer_id => customer.id,
|
123
|
+
:options => {
|
124
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
125
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
126
|
+
},
|
127
|
+
)
|
128
|
+
|
129
|
+
expect(result).to be_success
|
130
|
+
us_bank_account = result.payment_method
|
131
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
132
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
133
|
+
expect(us_bank_account.last_4).to eq("0005")
|
134
|
+
expect(us_bank_account.account_type).to eq("checking")
|
135
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
136
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
137
|
+
expect(us_bank_account.default).to eq(true)
|
138
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
139
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
140
|
+
|
141
|
+
expect(us_bank_account.verifications.count).to eq(1)
|
142
|
+
expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::ProcessorDeclined)
|
143
|
+
expect(us_bank_account.verifications.first.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck)
|
144
|
+
expect(us_bank_account.verifications.first.id).not_to be_empty
|
145
|
+
expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
|
146
|
+
expect(us_bank_account.verifications.first.processor_response_code).to eq("2061")
|
147
|
+
expect(us_bank_account.verifications.first.additional_processor_response).to eq("Invalid routing number")
|
148
|
+
|
149
|
+
expect(us_bank_account.verified).to eq(false)
|
150
|
+
|
151
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
152
|
+
end
|
81
153
|
end
|
82
154
|
|
83
155
|
it "fails with invalid nonce" do
|
@@ -87,8 +159,8 @@ describe Braintree::PaymentMethod do
|
|
87
159
|
:customer_id => customer.id,
|
88
160
|
)
|
89
161
|
|
90
|
-
result.
|
91
|
-
result.errors.for(:payment_method).on(:payment_method_nonce)[0].code.
|
162
|
+
expect(result).not_to be_success
|
163
|
+
expect(result.errors.for(:payment_method).on(:payment_method_nonce)[0].code).to eq(Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown)
|
92
164
|
end
|
93
165
|
end
|
94
166
|
|
@@ -100,8 +172,8 @@ describe Braintree::PaymentMethod do
|
|
100
172
|
:customer_id => customer.id,
|
101
173
|
)
|
102
174
|
|
103
|
-
result.
|
104
|
-
result.errors.for(:payment_method).on(:payment_method_nonce)[0].code.
|
175
|
+
expect(result).not_to be_success
|
176
|
+
expect(result.errors.for(:payment_method).on(:payment_method_nonce)[0].code).to eq(Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown)
|
105
177
|
end
|
106
178
|
end
|
107
179
|
end
|
@@ -139,27 +211,27 @@ describe Braintree::PaymentMethod do
|
|
139
211
|
},
|
140
212
|
)
|
141
213
|
|
142
|
-
result.
|
214
|
+
expect(result).to be_success
|
143
215
|
|
144
216
|
us_bank_account = result.payment_method
|
145
|
-
us_bank_account.
|
146
|
-
us_bank_account.routing_number.
|
147
|
-
us_bank_account.last_4.
|
148
|
-
us_bank_account.account_type.
|
149
|
-
us_bank_account.account_holder_name.
|
150
|
-
us_bank_account.bank_name.
|
151
|
-
us_bank_account.default.
|
152
|
-
us_bank_account.ach_mandate.text.
|
153
|
-
us_bank_account.ach_mandate.accepted_at.
|
154
|
-
|
155
|
-
us_bank_account.verifications.count.
|
156
|
-
us_bank_account.verifications.first.status.
|
157
|
-
us_bank_account.verifications.first.verification_method.
|
158
|
-
us_bank_account.verifications.first.id.
|
159
|
-
us_bank_account.verifications.first.verification_determined_at.
|
160
|
-
us_bank_account.verified.
|
161
|
-
|
162
|
-
Braintree::PaymentMethod.find(us_bank_account.token).
|
217
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
218
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
219
|
+
expect(us_bank_account.last_4).to eq("0000")
|
220
|
+
expect(us_bank_account.account_type).to eq("checking")
|
221
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
222
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
223
|
+
expect(us_bank_account.default).to eq(true)
|
224
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
225
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
226
|
+
|
227
|
+
expect(us_bank_account.verifications.count).to eq(1)
|
228
|
+
expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
229
|
+
expect(us_bank_account.verifications.first.verification_method).to eq(method)
|
230
|
+
expect(us_bank_account.verifications.first.id).not_to be_empty
|
231
|
+
expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
|
232
|
+
expect(us_bank_account.verified).to eq(true)
|
233
|
+
|
234
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
163
235
|
end
|
164
236
|
end
|
165
237
|
|
@@ -172,8 +244,8 @@ describe Braintree::PaymentMethod do
|
|
172
244
|
},
|
173
245
|
)
|
174
246
|
|
175
|
-
result.
|
176
|
-
result.errors.for(:options).first.code.
|
247
|
+
expect(result).not_to be_success
|
248
|
+
expect(result.errors.for(:options).first.code).to eq(Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid)
|
177
249
|
end
|
178
250
|
end
|
179
251
|
end
|
@@ -210,29 +282,29 @@ describe Braintree::PaymentMethod do
|
|
210
282
|
},
|
211
283
|
)
|
212
284
|
|
213
|
-
result.
|
285
|
+
expect(result).to be_success
|
214
286
|
|
215
287
|
us_bank_account = result.payment_method
|
216
|
-
us_bank_account.
|
217
|
-
us_bank_account.routing_number.
|
218
|
-
us_bank_account.last_4.
|
219
|
-
us_bank_account.account_type.
|
220
|
-
us_bank_account.account_holder_name.
|
221
|
-
us_bank_account.bank_name.
|
222
|
-
us_bank_account.default.
|
223
|
-
us_bank_account.ach_mandate.text.
|
224
|
-
us_bank_account.ach_mandate.accepted_at.
|
225
|
-
|
226
|
-
us_bank_account.verifications.count.
|
288
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
289
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
290
|
+
expect(us_bank_account.last_4).to eq("0000")
|
291
|
+
expect(us_bank_account.account_type).to eq("checking")
|
292
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
293
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
294
|
+
expect(us_bank_account.default).to eq(true)
|
295
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
296
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
297
|
+
|
298
|
+
expect(us_bank_account.verifications.count).to eq(2)
|
227
299
|
verification = us_bank_account.verifications.find do |verification|
|
228
300
|
verification.verification_method == method
|
229
301
|
end
|
230
|
-
verification.status.
|
231
|
-
verification.id.
|
232
|
-
verification.verification_determined_at.
|
233
|
-
us_bank_account.verified.
|
302
|
+
expect(verification.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
303
|
+
expect(verification.id).not_to be_empty
|
304
|
+
expect(verification.verification_determined_at).to be_a Time
|
305
|
+
expect(us_bank_account.verified).to eq(true)
|
234
306
|
|
235
|
-
Braintree::PaymentMethod.find(us_bank_account.token).
|
307
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
236
308
|
end
|
237
309
|
end
|
238
310
|
|
@@ -244,8 +316,8 @@ describe Braintree::PaymentMethod do
|
|
244
316
|
},
|
245
317
|
)
|
246
318
|
|
247
|
-
result.
|
248
|
-
result.errors.for(:options).first.code.
|
319
|
+
expect(result).not_to be_success
|
320
|
+
expect(result.errors.for(:options).first.code).to eq(Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid)
|
249
321
|
end
|
250
322
|
end
|
251
323
|
end
|
@@ -15,17 +15,17 @@ describe Braintree::PayPalAccount do
|
|
15
15
|
:payment_method_nonce => nonce,
|
16
16
|
:customer_id => customer.id,
|
17
17
|
)
|
18
|
-
result.
|
18
|
+
expect(result).to be_success
|
19
19
|
|
20
20
|
paypal_account = Braintree::PayPalAccount.find(payment_method_token)
|
21
|
-
paypal_account.
|
22
|
-
paypal_account.token.
|
23
|
-
paypal_account.email.
|
24
|
-
paypal_account.image_url.
|
25
|
-
paypal_account.created_at.
|
26
|
-
paypal_account.updated_at.
|
27
|
-
paypal_account.customer_id.
|
28
|
-
paypal_account.revoked_at.
|
21
|
+
expect(paypal_account).to be_a(Braintree::PayPalAccount)
|
22
|
+
expect(paypal_account.token).to eq(payment_method_token)
|
23
|
+
expect(paypal_account.email).to eq("jane.doe@example.com")
|
24
|
+
expect(paypal_account.image_url).not_to be_nil
|
25
|
+
expect(paypal_account.created_at).not_to be_nil
|
26
|
+
expect(paypal_account.updated_at).not_to be_nil
|
27
|
+
expect(paypal_account.customer_id).to eq(customer.id)
|
28
|
+
expect(paypal_account.revoked_at).to be_nil
|
29
29
|
end
|
30
30
|
|
31
31
|
it "returns a PayPalAccount with a billing agreement id" do
|
@@ -37,10 +37,10 @@ describe Braintree::PayPalAccount do
|
|
37
37
|
:customer_id => customer.id,
|
38
38
|
:token => payment_method_token,
|
39
39
|
)
|
40
|
-
result.
|
40
|
+
expect(result).to be_success
|
41
41
|
|
42
42
|
paypal_account = Braintree::PayPalAccount.find(payment_method_token)
|
43
|
-
paypal_account.billing_agreement_id.
|
43
|
+
expect(paypal_account.billing_agreement_id).not_to be_nil
|
44
44
|
end
|
45
45
|
|
46
46
|
it "raises if the payment method token is not found" do
|
@@ -76,7 +76,7 @@ describe Braintree::PayPalAccount do
|
|
76
76
|
:payment_method_nonce => nonce,
|
77
77
|
:customer_id => customer.id,
|
78
78
|
)
|
79
|
-
result.
|
79
|
+
expect(result).to be_success
|
80
80
|
|
81
81
|
token = result.payment_method.token
|
82
82
|
|
@@ -91,7 +91,7 @@ describe Braintree::PayPalAccount do
|
|
91
91
|
).subscription
|
92
92
|
|
93
93
|
paypal_account = Braintree::PayPalAccount.find(token)
|
94
|
-
paypal_account.subscriptions.map(&:id).sort.
|
94
|
+
expect(paypal_account.subscriptions.map(&:id).sort).to eq([subscription1.id, subscription2.id].sort)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -108,9 +108,9 @@ describe Braintree::PayPalAccount do
|
|
108
108
|
},
|
109
109
|
)
|
110
110
|
|
111
|
-
result.
|
112
|
-
result.paypal_account.billing_agreement_id.
|
113
|
-
result.paypal_account.email.
|
111
|
+
expect(result).to be_success
|
112
|
+
expect(result.paypal_account.billing_agreement_id).to eq("some_billing_agreement_id")
|
113
|
+
expect(result.paypal_account.email).to eq("some@example.com")
|
114
114
|
end
|
115
115
|
|
116
116
|
it "throws an error if customer id is not specified" do
|
@@ -119,8 +119,8 @@ describe Braintree::PayPalAccount do
|
|
119
119
|
:email => "some@example.com",
|
120
120
|
)
|
121
121
|
|
122
|
-
result.success
|
123
|
-
result.errors.first.code.
|
122
|
+
expect(result.success?).to eq(false)
|
123
|
+
expect(result.errors.first.code).to eq("82905")
|
124
124
|
end
|
125
125
|
|
126
126
|
it "throws an error if billing agreement id is not specified" do
|
@@ -130,8 +130,8 @@ describe Braintree::PayPalAccount do
|
|
130
130
|
:email => "some@example.com",
|
131
131
|
)
|
132
132
|
|
133
|
-
result.success
|
134
|
-
result.errors.map(&:code).
|
133
|
+
expect(result.success?).to eq(false)
|
134
|
+
expect(result.errors.map(&:code)).to include("82902")
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -143,7 +143,7 @@ describe Braintree::PayPalAccount do
|
|
143
143
|
:billing_agreement_id => "first_billing_agreement_id",
|
144
144
|
:email => "first@example.com",
|
145
145
|
)
|
146
|
-
create_result.success
|
146
|
+
expect(create_result.success?).to eq(true)
|
147
147
|
|
148
148
|
update_result = Braintree::PayPalAccount.update(
|
149
149
|
create_result.paypal_account.token,
|
@@ -151,11 +151,11 @@ describe Braintree::PayPalAccount do
|
|
151
151
|
:email => "second@example.com",
|
152
152
|
)
|
153
153
|
|
154
|
-
update_result.success
|
154
|
+
expect(update_result.success?).to eq(true)
|
155
155
|
paypal_account = update_result.paypal_account
|
156
156
|
|
157
|
-
paypal_account.billing_agreement_id.
|
158
|
-
paypal_account.email.
|
157
|
+
expect(paypal_account.billing_agreement_id).to eq("second_billing_agreement_id")
|
158
|
+
expect(paypal_account.email).to eq("second@example.com")
|
159
159
|
end
|
160
160
|
|
161
161
|
it "updates a paypal account's token" do
|
@@ -177,7 +177,7 @@ describe Braintree::PayPalAccount do
|
|
177
177
|
)
|
178
178
|
|
179
179
|
updated_paypal_account = Braintree::PayPalAccount.find(updated_token)
|
180
|
-
updated_paypal_account.email.
|
180
|
+
expect(updated_paypal_account.email).to eq(original_result.payment_method.email)
|
181
181
|
|
182
182
|
expect do
|
183
183
|
Braintree::PayPalAccount.find(original_token)
|
@@ -192,7 +192,7 @@ describe Braintree::PayPalAccount do
|
|
192
192
|
:expiration_date => "05/2009",
|
193
193
|
:options => {:make_default => true},
|
194
194
|
)
|
195
|
-
result.
|
195
|
+
expect(result).to be_success
|
196
196
|
|
197
197
|
nonce = nonce_for_paypal_account(:consent_code => "consent-code")
|
198
198
|
original_token = Braintree::PaymentMethod.create(
|
@@ -206,7 +206,7 @@ describe Braintree::PayPalAccount do
|
|
206
206
|
)
|
207
207
|
|
208
208
|
updated_paypal_account = Braintree::PayPalAccount.find(original_token)
|
209
|
-
updated_paypal_account.
|
209
|
+
expect(updated_paypal_account).to be_default
|
210
210
|
end
|
211
211
|
|
212
212
|
it "returns an error if a token for account is used to attempt an update" do
|
@@ -237,8 +237,8 @@ describe Braintree::PayPalAccount do
|
|
237
237
|
:token => second_token,
|
238
238
|
)
|
239
239
|
|
240
|
-
updated_result.
|
241
|
-
updated_result.errors.first.code.
|
240
|
+
expect(updated_result).not_to be_success
|
241
|
+
expect(updated_result.errors.first.code).to eq("92906")
|
242
242
|
end
|
243
243
|
end
|
244
244
|
|
@@ -272,11 +272,11 @@ describe Braintree::PayPalAccount do
|
|
272
272
|
|
273
273
|
result = Braintree::PayPalAccount.sale(customer.paypal_accounts[0].token, :amount => "100.00")
|
274
274
|
|
275
|
-
result.success
|
276
|
-
result.transaction.amount.
|
277
|
-
result.transaction.type.
|
278
|
-
result.transaction.customer_details.id.
|
279
|
-
result.transaction.paypal_details.token.
|
275
|
+
expect(result.success?).to eq(true)
|
276
|
+
expect(result.transaction.amount).to eq(BigDecimal("100.00"))
|
277
|
+
expect(result.transaction.type).to eq("sale")
|
278
|
+
expect(result.transaction.customer_details.id).to eq(customer.id)
|
279
|
+
expect(result.transaction.paypal_details.token).to eq(customer.paypal_accounts[0].token)
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
@@ -288,10 +288,10 @@ describe Braintree::PayPalAccount do
|
|
288
288
|
|
289
289
|
transaction = Braintree::PayPalAccount.sale!(customer.paypal_accounts[0].token, :amount => "100.00")
|
290
290
|
|
291
|
-
transaction.amount.
|
292
|
-
transaction.type.
|
293
|
-
transaction.customer_details.id.
|
294
|
-
transaction.paypal_details.token.
|
291
|
+
expect(transaction.amount).to eq(BigDecimal("100.00"))
|
292
|
+
expect(transaction.type).to eq("sale")
|
293
|
+
expect(transaction.customer_details.id).to eq(customer.id)
|
294
|
+
expect(transaction.paypal_details.token).to eq(customer.paypal_accounts[0].token)
|
295
295
|
end
|
296
296
|
end
|
297
297
|
end
|
@@ -26,26 +26,26 @@ describe Braintree::Plan do
|
|
26
26
|
|
27
27
|
plans = Braintree::Plan.all
|
28
28
|
plan = plans.select { |plan| plan.id == plan_token }.first
|
29
|
-
plan.
|
30
|
-
plan.id.
|
31
|
-
plan.billing_day_of_month.
|
32
|
-
plan.billing_frequency.
|
33
|
-
plan.currency_iso_code.
|
34
|
-
plan.description.
|
35
|
-
plan.name.
|
36
|
-
plan.number_of_billing_cycles.
|
37
|
-
plan.price.
|
38
|
-
plan.trial_period.
|
39
|
-
plan.created_at.
|
40
|
-
plan.updated_at.
|
41
|
-
plan.add_ons.first.name.
|
42
|
-
plan.discounts.first.name.
|
29
|
+
expect(plan).not_to be_nil
|
30
|
+
expect(plan.id).to eq(attributes[:id])
|
31
|
+
expect(plan.billing_day_of_month).to eq(attributes[:billing_day_of_month])
|
32
|
+
expect(plan.billing_frequency).to eq(attributes[:billing_frequency])
|
33
|
+
expect(plan.currency_iso_code).to eq(attributes[:currency_iso_code])
|
34
|
+
expect(plan.description).to eq(attributes[:description])
|
35
|
+
expect(plan.name).to eq(attributes[:name])
|
36
|
+
expect(plan.number_of_billing_cycles).to eq(attributes[:number_of_billing_cycles])
|
37
|
+
expect(plan.price).to eq(Braintree::Util.to_big_decimal("1.00"))
|
38
|
+
expect(plan.trial_period).to eq(attributes[:trial_period])
|
39
|
+
expect(plan.created_at).not_to be_nil
|
40
|
+
expect(plan.updated_at).not_to be_nil
|
41
|
+
expect(plan.add_ons.first.name).to eq(add_on_name)
|
42
|
+
expect(plan.discounts.first.name).to eq(discount_name)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "returns an empty array if there are no plans" do
|
46
46
|
gateway = Braintree::Gateway.new(SpecHelper::TestMerchantConfig)
|
47
47
|
plans = gateway.plan.all
|
48
|
-
plans.
|
48
|
+
expect(plans).to eq([])
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|