braintree 2.74.0 → 4.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/braintree.gemspec +13 -7
- data/lib/braintree/account_updater_daily_report.rb +2 -2
- data/lib/braintree/ach_mandate.rb +2 -1
- data/lib/braintree/address/country_names.rb +4 -1
- data/lib/braintree/address.rb +30 -38
- data/lib/braintree/address_gateway.rb +12 -2
- data/lib/braintree/advanced_search.rb +8 -0
- data/lib/braintree/apple_pay.rb +29 -0
- data/lib/braintree/apple_pay_card.rb +28 -4
- data/lib/braintree/apple_pay_gateway.rb +37 -0
- data/lib/braintree/apple_pay_options.rb +19 -0
- data/lib/braintree/authorization_adjustment.rb +23 -0
- data/lib/braintree/base_module.rb +10 -0
- data/lib/braintree/bin_data.rb +33 -0
- data/lib/braintree/client_token.rb +3 -3
- data/lib/braintree/client_token_gateway.rb +3 -1
- data/lib/braintree/configuration.rb +57 -10
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +6 -2
- data/lib/braintree/connected_merchant_status_transitioned.rb +6 -2
- data/lib/braintree/credentials_parser.rb +5 -1
- data/lib/braintree/credit_card.rb +53 -107
- data/lib/braintree/credit_card_gateway.rb +43 -30
- data/lib/braintree/credit_card_verification.rb +61 -21
- data/lib/braintree/credit_card_verification_gateway.rb +19 -6
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +51 -98
- data/lib/braintree/customer_gateway.rb +30 -23
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +3 -1
- data/lib/braintree/disbursement.rb +24 -2
- data/lib/braintree/dispute/evidence.rb +24 -0
- data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -3
- data/lib/braintree/dispute/status_history.rb +18 -0
- data/lib/braintree/dispute/transaction.rb +20 -0
- data/lib/braintree/dispute/transaction_details.rb +2 -1
- data/lib/braintree/dispute.rb +114 -10
- data/lib/braintree/dispute_gateway.rb +142 -0
- data/lib/braintree/dispute_search.rb +31 -0
- data/lib/braintree/document_upload.rb +37 -0
- data/lib/braintree/document_upload_gateway.rb +38 -0
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +328 -109
- data/lib/braintree/error_result.rb +8 -1
- data/lib/braintree/exceptions.rb +5 -3
- 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 +21 -0
- data/lib/braintree/facilitator_details.rb +2 -1
- data/lib/braintree/gateway.rb +29 -11
- data/lib/braintree/google_pay_card.rb +61 -0
- data/lib/braintree/granted_payment_instrument_update.rb +23 -0
- data/lib/braintree/graphql_client.rb +34 -0
- data/lib/braintree/http.rb +81 -20
- data/lib/braintree/local_payment_completed.rb +23 -0
- 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 +11 -4
- data/lib/braintree/merchant_account/address_details.rb +4 -1
- data/lib/braintree/merchant_account/business_details.rb +4 -1
- data/lib/braintree/merchant_account/funding_details.rb +6 -1
- data/lib/braintree/merchant_account/individual_details.rb +7 -2
- data/lib/braintree/merchant_account.rb +23 -10
- data/lib/braintree/merchant_account_gateway.rb +13 -1
- data/lib/braintree/merchant_gateway.rb +2 -2
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +5 -2
- data/lib/braintree/oauth_gateway.rb +8 -14
- data/lib/braintree/paginated_result.rb +3 -1
- data/lib/braintree/payment_instrument_type.rb +11 -11
- data/lib/braintree/payment_method.rb +20 -12
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +82 -54
- data/lib/braintree/payment_method_nonce.rb +22 -8
- 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 +19 -2
- data/lib/braintree/payment_method_parser.rb +28 -0
- data/lib/braintree/paypal_account.rb +10 -1
- data/lib/braintree/plan.rb +25 -5
- data/lib/braintree/plan_gateway.rb +100 -0
- data/lib/braintree/processor_response_types.rb +7 -0
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +12 -2
- data/lib/braintree/samsung_pay_card.rb +83 -0
- 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 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +2 -0
- data/lib/braintree/subscription/status_details.rb +8 -1
- data/lib/braintree/subscription.rb +56 -41
- data/lib/braintree/subscription_gateway.rb +25 -2
- data/lib/braintree/successful_result.rb +23 -1
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +13 -0
- data/lib/braintree/test/nonce.rb +28 -20
- data/lib/braintree/test/transaction_amounts.rb +1 -0
- data/lib/braintree/three_d_secure_info.rb +34 -2
- data/lib/braintree/transaction/address_details.rb +24 -4
- data/lib/braintree/transaction/apple_pay_details.rb +20 -2
- data/lib/braintree/transaction/credit_card_details.rb +45 -6
- data/lib/braintree/transaction/customer_details.rb +8 -1
- data/lib/braintree/transaction/disbursement_details.rb +6 -1
- data/lib/braintree/transaction/google_pay_details.rb +41 -0
- 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 +24 -0
- data/lib/braintree/transaction/paypal_details.rb +26 -4
- data/lib/braintree/transaction/paypal_here_details.rb +23 -0
- data/lib/braintree/transaction/{masterpass_card_details.rb → samsung_pay_card_details.rb} +21 -6
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +5 -1
- data/lib/braintree/transaction/subscription_details.rb +4 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +8 -1
- data/lib/braintree/transaction/venmo_account_details.rb +5 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +19 -4
- data/lib/braintree/transaction.rb +201 -188
- data/lib/braintree/transaction_gateway.rb +124 -30
- data/lib/braintree/transaction_line_item.rb +40 -0
- data/lib/braintree/transaction_line_item_gateway.rb +19 -0
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +6 -3
- data/lib/braintree/unknown_payment_method.rb +3 -2
- data/lib/braintree/us_bank_account.rb +24 -8
- data/lib/braintree/us_bank_account_gateway.rb +0 -1
- data/lib/braintree/us_bank_account_verification.rb +81 -0
- data/lib/braintree/us_bank_account_verification_gateway.rb +51 -0
- data/lib/braintree/us_bank_account_verification_search.rb +19 -0
- data/lib/braintree/util.rb +79 -9
- data/lib/braintree/validation_error.rb +13 -3
- data/lib/braintree/validation_error_collection.rb +2 -1
- data/lib/braintree/venmo_account.rb +11 -4
- data/lib/braintree/venmo_profile_data.rb +23 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +29 -13
- data/lib/braintree/webhook_notification.rb +66 -26
- data/lib/braintree/webhook_notification_gateway.rb +5 -3
- data/lib/braintree/webhook_testing.rb +2 -2
- data/lib/braintree/webhook_testing_gateway.rb +721 -55
- data/lib/braintree/xml/generator.rb +6 -4
- data/lib/braintree/xml/parser.rb +22 -35
- data/lib/braintree/xml/rexml.rb +4 -5
- data/lib/braintree.rb +60 -22
- data/lib/ssl/api_braintreegateway_com.ca.crt +50 -0
- data/spec/fixtures/files/bt_logo.png +0 -0
- data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
- data/spec/fixtures/files/malformed_pdf.pdf +1 -0
- data/spec/fixtures/files/too_long.pdf +0 -0
- data/spec/integration/braintree/add_on_spec.rb +3 -3
- data/spec/integration/braintree/address_spec.rb +30 -113
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +63 -0
- data/spec/integration/braintree/braintree_gateway_spec.rb +72 -0
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -32
- data/spec/integration/braintree/client_api/spec_helper.rb +104 -65
- data/spec/integration/braintree/credit_card_spec.rb +460 -615
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +222 -6
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +810 -498
- data/spec/integration/braintree/discount_spec.rb +1 -1
- data/spec/integration/braintree/dispute_search_spec.rb +167 -0
- data/spec/integration/braintree/dispute_spec.rb +333 -0
- data/spec/integration/braintree/document_upload_spec.rb +87 -0
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
- data/spec/integration/braintree/graphql_client_spec.rb +72 -0
- data/spec/integration/braintree/http_spec.rb +12 -4
- data/spec/integration/braintree/merchant_account_spec.rb +74 -26
- data/spec/integration/braintree/merchant_spec.rb +39 -13
- data/spec/integration/braintree/oauth_spec.rb +18 -25
- data/spec/integration/braintree/payment_method_nonce_spec.rb +239 -5
- data/spec/integration/braintree/payment_method_spec.rb +882 -300
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +416 -0
- data/spec/integration/braintree/paypal_account_spec.rb +32 -31
- data/spec/integration/braintree/plan_spec.rb +82 -0
- data/spec/integration/braintree/samsung_pay_card_spec.rb +144 -0
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +196 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +274 -180
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +18 -18
- data/spec/integration/braintree/transaction_line_item_spec.rb +38 -0
- data/spec/integration/braintree/transaction_search_spec.rb +280 -152
- data/spec/integration/braintree/transaction_spec.rb +3709 -1175
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +438 -0
- data/spec/integration/braintree/us_bank_account_spec.rb +38 -17
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +178 -0
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +240 -0
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +27 -6
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +26 -23
- data/spec/unit/braintree/address_spec.rb +1 -9
- data/spec/unit/braintree/apple_pay_card_spec.rb +104 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +108 -33
- data/spec/unit/braintree/credit_card_spec.rb +62 -33
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +51 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +39 -6
- data/spec/unit/braintree/customer_spec.rb +107 -27
- data/spec/unit/braintree/disbursement_spec.rb +59 -7
- data/spec/unit/braintree/dispute_search_spec.rb +66 -0
- data/spec/unit/braintree/dispute_spec.rb +472 -8
- data/spec/unit/braintree/document_upload_spec.rb +35 -0
- data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- 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 +93 -5
- data/spec/unit/braintree/local_payment_completed_spec.rb +50 -0
- 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 +1 -1
- data/spec/unit/braintree/modification_spec.rb +1 -1
- 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 +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +30 -1
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +40 -6
- 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/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/subscription_spec.rb +2 -2
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +34 -6
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +19 -3
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +111 -0
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +171 -55
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +93 -0
- data/spec/unit/braintree/util_spec.rb +162 -19
- data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
- data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +546 -114
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- data/spec/unit/braintree/xml_spec.rb +31 -24
- data/spec/unit/braintree_spec.rb +1 -0
- metadata +290 -198
- data/README.rdoc +0 -93
- data/lib/braintree/amex_express_checkout_card.rb +0 -26
- data/lib/braintree/android_pay_card.rb +0 -35
- data/lib/braintree/coinbase_account.rb +0 -25
- data/lib/braintree/europe_bank_account.rb +0 -34
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -46
- data/lib/braintree/ideal_payment_gateway.rb +0 -18
- data/lib/braintree/masterpass_card.rb +0 -66
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -14
- data/lib/braintree/transaction/android_pay_details.rb +0 -17
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -13
- 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/httpsd.pid +0 -1
- data/spec/integration/braintree/coinbase_spec.rb +0 -31
- data/spec/integration/braintree/ideal_payment_spec.rb +0 -87
- 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
@@ -0,0 +1,416 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
3
|
+
|
4
|
+
describe Braintree::PaymentMethod do
|
5
|
+
describe "self.create" do
|
6
|
+
context "compliant merchant" do
|
7
|
+
before do
|
8
|
+
Braintree::Configuration.merchant_id = "integration2_merchant_id"
|
9
|
+
Braintree::Configuration.public_key = "integration2_public_key"
|
10
|
+
Braintree::Configuration.private_key = "integration2_private_key"
|
11
|
+
end
|
12
|
+
|
13
|
+
context "plaid verified nonce" do
|
14
|
+
let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
|
15
|
+
|
16
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
17
|
+
xit "succeeds" do
|
18
|
+
customer = Braintree::Customer.create.customer
|
19
|
+
result = Braintree::PaymentMethod.create(
|
20
|
+
:payment_method_nonce => nonce,
|
21
|
+
:customer_id => customer.id,
|
22
|
+
:options => {
|
23
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
24
|
+
},
|
25
|
+
)
|
26
|
+
|
27
|
+
result.should be_success
|
28
|
+
us_bank_account = result.payment_method
|
29
|
+
us_bank_account.should be_a(Braintree::UsBankAccount)
|
30
|
+
us_bank_account.routing_number.should == "011000015"
|
31
|
+
us_bank_account.last_4.should == "0000"
|
32
|
+
us_bank_account.account_type.should == "checking"
|
33
|
+
us_bank_account.account_holder_name.should == "PayPal, Inc."
|
34
|
+
us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
|
35
|
+
us_bank_account.default.should == true
|
36
|
+
us_bank_account.ach_mandate.text.should == "cl mandate text"
|
37
|
+
us_bank_account.ach_mandate.accepted_at.should be_a Time
|
38
|
+
|
39
|
+
us_bank_account.verifications.count.should == 1
|
40
|
+
us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
|
41
|
+
us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck
|
42
|
+
us_bank_account.verifications.first.id.should_not be_empty
|
43
|
+
us_bank_account.verifications.first.verification_determined_at.should be_a Time
|
44
|
+
us_bank_account.verified.should == true
|
45
|
+
|
46
|
+
Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
|
47
|
+
end
|
48
|
+
|
49
|
+
[
|
50
|
+
Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
|
51
|
+
Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
52
|
+
].each do |method|
|
53
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
54
|
+
xit "succeeds and verifies via #{method}" do
|
55
|
+
customer = Braintree::Customer.create.customer
|
56
|
+
result = Braintree::PaymentMethod.create(
|
57
|
+
:payment_method_nonce => nonce,
|
58
|
+
:customer_id => customer.id,
|
59
|
+
:options => {
|
60
|
+
:us_bank_account_verification_method => method,
|
61
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
62
|
+
},
|
63
|
+
)
|
64
|
+
|
65
|
+
result.should be_success
|
66
|
+
us_bank_account = result.payment_method
|
67
|
+
us_bank_account.should be_a(Braintree::UsBankAccount)
|
68
|
+
us_bank_account.routing_number.should == "011000015"
|
69
|
+
us_bank_account.last_4.should == "0000"
|
70
|
+
us_bank_account.account_type.should == "checking"
|
71
|
+
us_bank_account.account_holder_name.should == "PayPal, Inc."
|
72
|
+
us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
|
73
|
+
us_bank_account.default.should == true
|
74
|
+
us_bank_account.ach_mandate.text.should == "cl mandate text"
|
75
|
+
us_bank_account.ach_mandate.accepted_at.should be_a Time
|
76
|
+
us_bank_account.verified.should == true
|
77
|
+
|
78
|
+
us_bank_account.verifications.count.should == 2
|
79
|
+
|
80
|
+
us_bank_account.verifications.map(&:verification_method).should contain_exactly(
|
81
|
+
Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck,
|
82
|
+
method,
|
83
|
+
)
|
84
|
+
|
85
|
+
us_bank_account.verifications.each do |verification|
|
86
|
+
verification.status.should == Braintree::UsBankAccountVerification::Status::Verified
|
87
|
+
verification.id.should_not be_empty
|
88
|
+
verification.verification_determined_at.should be_a Time
|
89
|
+
end
|
90
|
+
|
91
|
+
Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "non plaid verified nonce" do
|
97
|
+
let(:nonce) { generate_non_plaid_us_bank_account_nonce }
|
98
|
+
|
99
|
+
it "succeeds and does not verify when no method provided" do
|
100
|
+
customer = Braintree::Customer.create.customer
|
101
|
+
result = Braintree::PaymentMethod.create(
|
102
|
+
:payment_method_nonce => nonce,
|
103
|
+
:customer_id => customer.id,
|
104
|
+
:options => {
|
105
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
106
|
+
},
|
107
|
+
)
|
108
|
+
|
109
|
+
result.should be_success
|
110
|
+
us_bank_account = result.payment_method
|
111
|
+
us_bank_account.should be_a(Braintree::UsBankAccount)
|
112
|
+
us_bank_account.routing_number.should == "021000021"
|
113
|
+
us_bank_account.last_4.should == "0000"
|
114
|
+
us_bank_account.account_type.should == "checking"
|
115
|
+
us_bank_account.account_holder_name.should == "John Doe"
|
116
|
+
us_bank_account.bank_name.should =~ /CHASE/
|
117
|
+
us_bank_account.default.should == true
|
118
|
+
us_bank_account.ach_mandate.text.should == "cl mandate text"
|
119
|
+
us_bank_account.ach_mandate.accepted_at.should be_a Time
|
120
|
+
|
121
|
+
us_bank_account.verifications.count.should == 0
|
122
|
+
us_bank_account.verified.should == false
|
123
|
+
|
124
|
+
Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
|
125
|
+
end
|
126
|
+
|
127
|
+
[
|
128
|
+
Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
|
129
|
+
Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
130
|
+
].each do |method|
|
131
|
+
it "succeeds and verifies via #{method}" do
|
132
|
+
customer = Braintree::Customer.create.customer
|
133
|
+
result = Braintree::PaymentMethod.create(
|
134
|
+
:payment_method_nonce => nonce,
|
135
|
+
:customer_id => customer.id,
|
136
|
+
:options => {
|
137
|
+
:us_bank_account_verification_method => method,
|
138
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
139
|
+
},
|
140
|
+
)
|
141
|
+
|
142
|
+
result.should be_success
|
143
|
+
us_bank_account = result.payment_method
|
144
|
+
us_bank_account.should be_a(Braintree::UsBankAccount)
|
145
|
+
us_bank_account.routing_number.should == "021000021"
|
146
|
+
us_bank_account.last_4.should == "0000"
|
147
|
+
us_bank_account.account_type.should == "checking"
|
148
|
+
us_bank_account.account_holder_name.should == "John Doe"
|
149
|
+
us_bank_account.bank_name.should =~ /CHASE/
|
150
|
+
us_bank_account.default.should == true
|
151
|
+
us_bank_account.ach_mandate.text.should == "cl mandate text"
|
152
|
+
us_bank_account.ach_mandate.accepted_at.should be_a Time
|
153
|
+
|
154
|
+
us_bank_account.verifications.count.should == 1
|
155
|
+
us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
|
156
|
+
us_bank_account.verifications.first.verification_method.should == method
|
157
|
+
us_bank_account.verifications.first.id.should_not be_empty
|
158
|
+
us_bank_account.verifications.first.verification_determined_at.should be_a Time
|
159
|
+
us_bank_account.verified.should == true
|
160
|
+
|
161
|
+
Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
it "fails with invalid nonce" do
|
167
|
+
customer = Braintree::Customer.create.customer
|
168
|
+
result = Braintree::PaymentMethod.create(
|
169
|
+
:payment_method_nonce => generate_invalid_us_bank_account_nonce,
|
170
|
+
:customer_id => customer.id,
|
171
|
+
)
|
172
|
+
|
173
|
+
result.should_not be_success
|
174
|
+
result.errors.for(:payment_method).on(:payment_method_nonce)[0].code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "exempt merchant" do
|
179
|
+
context "plaid verified nonce" do
|
180
|
+
before do
|
181
|
+
Braintree::Configuration.merchant_id = "integration_merchant_id"
|
182
|
+
Braintree::Configuration.public_key = "integration_public_key"
|
183
|
+
Braintree::Configuration.private_key = "integration_private_key"
|
184
|
+
end
|
185
|
+
|
186
|
+
let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
|
187
|
+
|
188
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
189
|
+
xit "succeeds and verifies via independent check" do
|
190
|
+
customer = Braintree::Customer.create.customer
|
191
|
+
result = Braintree::PaymentMethod.create(
|
192
|
+
:payment_method_nonce => nonce,
|
193
|
+
:customer_id => customer.id,
|
194
|
+
:options => {
|
195
|
+
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
196
|
+
},
|
197
|
+
)
|
198
|
+
|
199
|
+
result.should be_success
|
200
|
+
us_bank_account = result.payment_method
|
201
|
+
us_bank_account.should be_a(Braintree::UsBankAccount)
|
202
|
+
us_bank_account.routing_number.should == "011000015"
|
203
|
+
us_bank_account.last_4.should == "0000"
|
204
|
+
us_bank_account.account_type.should == "checking"
|
205
|
+
us_bank_account.account_holder_name.should == "PayPal, Inc."
|
206
|
+
us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
|
207
|
+
us_bank_account.default.should == true
|
208
|
+
us_bank_account.ach_mandate.text.should == "cl mandate text"
|
209
|
+
us_bank_account.ach_mandate.accepted_at.should be_a Time
|
210
|
+
|
211
|
+
us_bank_account.verifications.count.should == 1
|
212
|
+
us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
|
213
|
+
us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck
|
214
|
+
us_bank_account.verifications.first.id.should_not be_empty
|
215
|
+
us_bank_account.verifications.first.verification_determined_at.should be_a Time
|
216
|
+
us_bank_account.verified.should == true
|
217
|
+
|
218
|
+
Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
context "non plaid verified nonce" do
|
223
|
+
let(:nonce) { generate_non_plaid_us_bank_account_nonce }
|
224
|
+
|
225
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
226
|
+
xit "succeeds and verifies via independent check" do
|
227
|
+
customer = Braintree::Customer.create.customer
|
228
|
+
result = Braintree::PaymentMethod.create(
|
229
|
+
:payment_method_nonce => nonce,
|
230
|
+
:customer_id => customer.id,
|
231
|
+
:options => {
|
232
|
+
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
233
|
+
},
|
234
|
+
)
|
235
|
+
|
236
|
+
result.should be_success
|
237
|
+
us_bank_account = result.payment_method
|
238
|
+
us_bank_account.should be_a(Braintree::UsBankAccount)
|
239
|
+
us_bank_account.routing_number.should == "021000021"
|
240
|
+
us_bank_account.last_4.should == "0000"
|
241
|
+
us_bank_account.account_type.should == "checking"
|
242
|
+
us_bank_account.account_holder_name.should == "John Doe"
|
243
|
+
us_bank_account.bank_name.should =~ /CHASE/
|
244
|
+
us_bank_account.default.should == true
|
245
|
+
us_bank_account.ach_mandate.text.should == "cl mandate text"
|
246
|
+
us_bank_account.ach_mandate.accepted_at.should be_a Time
|
247
|
+
|
248
|
+
us_bank_account.verifications.count.should == 1
|
249
|
+
us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
|
250
|
+
us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck
|
251
|
+
us_bank_account.verifications.first.id.should_not be_empty
|
252
|
+
us_bank_account.verifications.first.verification_determined_at.should be_a Time
|
253
|
+
us_bank_account.verified.should == true
|
254
|
+
|
255
|
+
Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
it "fails with invalid nonce" do
|
260
|
+
customer = Braintree::Customer.create.customer
|
261
|
+
result = Braintree::PaymentMethod.create(
|
262
|
+
:payment_method_nonce => generate_invalid_us_bank_account_nonce,
|
263
|
+
:customer_id => customer.id,
|
264
|
+
)
|
265
|
+
|
266
|
+
result.should_not be_success
|
267
|
+
result.errors.for(:payment_method).on(:payment_method_nonce)[0].code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
context "self.update" do
|
273
|
+
context "compliant merchant" do
|
274
|
+
before do
|
275
|
+
Braintree::Configuration.merchant_id = "integration2_merchant_id"
|
276
|
+
Braintree::Configuration.public_key = "integration2_public_key"
|
277
|
+
Braintree::Configuration.private_key = "integration2_private_key"
|
278
|
+
end
|
279
|
+
|
280
|
+
context "unverified token" do
|
281
|
+
let(:payment_method) do
|
282
|
+
customer = Braintree::Customer.create.customer
|
283
|
+
result = Braintree::PaymentMethod.create(
|
284
|
+
:payment_method_nonce => generate_non_plaid_us_bank_account_nonce,
|
285
|
+
:customer_id => customer.id,
|
286
|
+
:options => {
|
287
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
288
|
+
},
|
289
|
+
).payment_method
|
290
|
+
end
|
291
|
+
|
292
|
+
[
|
293
|
+
Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
|
294
|
+
Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
295
|
+
].each do |method|
|
296
|
+
it "succeeds and verifies via #{method}" do
|
297
|
+
result = Braintree::PaymentMethod.update(
|
298
|
+
payment_method.token,
|
299
|
+
:options => {
|
300
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
301
|
+
:us_bank_account_verification_method => method,
|
302
|
+
},
|
303
|
+
)
|
304
|
+
|
305
|
+
result.should be_success
|
306
|
+
|
307
|
+
us_bank_account = result.payment_method
|
308
|
+
us_bank_account.should be_a(Braintree::UsBankAccount)
|
309
|
+
us_bank_account.routing_number.should == "021000021"
|
310
|
+
us_bank_account.last_4.should == "0000"
|
311
|
+
us_bank_account.account_type.should == "checking"
|
312
|
+
us_bank_account.account_holder_name.should == "John Doe"
|
313
|
+
us_bank_account.bank_name.should =~ /CHASE/
|
314
|
+
us_bank_account.default.should == true
|
315
|
+
us_bank_account.ach_mandate.text.should == "cl mandate text"
|
316
|
+
us_bank_account.ach_mandate.accepted_at.should be_a Time
|
317
|
+
|
318
|
+
us_bank_account.verifications.count.should == 1
|
319
|
+
us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
|
320
|
+
us_bank_account.verifications.first.verification_method.should == method
|
321
|
+
us_bank_account.verifications.first.id.should_not be_empty
|
322
|
+
us_bank_account.verifications.first.verification_determined_at.should be_a Time
|
323
|
+
us_bank_account.verified.should == true
|
324
|
+
|
325
|
+
Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
it "fails with invalid verification method" do
|
330
|
+
result = Braintree::PaymentMethod.update(
|
331
|
+
payment_method.token,
|
332
|
+
:options => {
|
333
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
334
|
+
:us_bank_account_verification_method => "blahblah",
|
335
|
+
},
|
336
|
+
)
|
337
|
+
|
338
|
+
result.should_not be_success
|
339
|
+
result.errors.for(:options).first.code.should == Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
context "exempt merchant" do
|
345
|
+
before do
|
346
|
+
Braintree::Configuration.merchant_id = "integration_merchant_id"
|
347
|
+
Braintree::Configuration.public_key = "integration_public_key"
|
348
|
+
Braintree::Configuration.private_key = "integration_private_key"
|
349
|
+
end
|
350
|
+
|
351
|
+
context "unverified token" do
|
352
|
+
let(:payment_method) do
|
353
|
+
customer = Braintree::Customer.create.customer
|
354
|
+
result = Braintree::PaymentMethod.create(
|
355
|
+
:payment_method_nonce => generate_non_plaid_us_bank_account_nonce,
|
356
|
+
:customer_id => customer.id,
|
357
|
+
:options => {
|
358
|
+
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
359
|
+
},
|
360
|
+
).payment_method
|
361
|
+
end
|
362
|
+
|
363
|
+
[
|
364
|
+
Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
|
365
|
+
Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
366
|
+
].each do |method|
|
367
|
+
it "succeeds and verifies via #{method}" do
|
368
|
+
result = Braintree::PaymentMethod.update(
|
369
|
+
payment_method.token,
|
370
|
+
:options => {
|
371
|
+
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
372
|
+
:us_bank_account_verification_method => method,
|
373
|
+
},
|
374
|
+
)
|
375
|
+
|
376
|
+
result.should be_success
|
377
|
+
|
378
|
+
us_bank_account = result.payment_method
|
379
|
+
us_bank_account.should be_a(Braintree::UsBankAccount)
|
380
|
+
us_bank_account.routing_number.should == "021000021"
|
381
|
+
us_bank_account.last_4.should == "0000"
|
382
|
+
us_bank_account.account_type.should == "checking"
|
383
|
+
us_bank_account.account_holder_name.should == "John Doe"
|
384
|
+
us_bank_account.bank_name.should =~ /CHASE/
|
385
|
+
us_bank_account.default.should == true
|
386
|
+
us_bank_account.ach_mandate.text.should == "cl mandate text"
|
387
|
+
us_bank_account.ach_mandate.accepted_at.should be_a Time
|
388
|
+
|
389
|
+
us_bank_account.verifications.count.should == 2
|
390
|
+
verification = us_bank_account.verifications.find do |verification|
|
391
|
+
verification.verification_method == method
|
392
|
+
end
|
393
|
+
verification.status.should == Braintree::UsBankAccountVerification::Status::Verified
|
394
|
+
verification.id.should_not be_empty
|
395
|
+
verification.verification_determined_at.should be_a Time
|
396
|
+
us_bank_account.verified.should == true
|
397
|
+
|
398
|
+
Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
it "fails with invalid verification method" do
|
403
|
+
result = Braintree::PaymentMethod.update(
|
404
|
+
payment_method.token,
|
405
|
+
:options => {
|
406
|
+
:us_bank_account_verification_method => "blahblah",
|
407
|
+
},
|
408
|
+
)
|
409
|
+
|
410
|
+
result.should_not be_success
|
411
|
+
result.errors.for(:options).first.code.should == Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid
|
412
|
+
end
|
413
|
+
end
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
@@ -9,11 +9,11 @@ describe Braintree::PayPalAccount do
|
|
9
9
|
|
10
10
|
nonce = nonce_for_paypal_account(
|
11
11
|
:consent_code => "consent-code",
|
12
|
-
:token => payment_method_token
|
12
|
+
:token => payment_method_token,
|
13
13
|
)
|
14
14
|
result = Braintree::PaymentMethod.create(
|
15
15
|
:payment_method_nonce => nonce,
|
16
|
-
:customer_id => customer.id
|
16
|
+
:customer_id => customer.id,
|
17
17
|
)
|
18
18
|
result.should be_success
|
19
19
|
|
@@ -25,6 +25,7 @@ describe Braintree::PayPalAccount do
|
|
25
25
|
paypal_account.created_at.should_not be_nil
|
26
26
|
paypal_account.updated_at.should_not be_nil
|
27
27
|
paypal_account.customer_id.should == customer.id
|
28
|
+
paypal_account.revoked_at.should be_nil
|
28
29
|
end
|
29
30
|
|
30
31
|
it "returns a PayPalAccount with a billing agreement id" do
|
@@ -34,7 +35,7 @@ describe Braintree::PayPalAccount do
|
|
34
35
|
result = Braintree::PaymentMethod.create(
|
35
36
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
36
37
|
:customer_id => customer.id,
|
37
|
-
:token => payment_method_token
|
38
|
+
:token => payment_method_token,
|
38
39
|
)
|
39
40
|
result.should be_success
|
40
41
|
|
@@ -55,7 +56,7 @@ describe Braintree::PayPalAccount do
|
|
55
56
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
56
57
|
:expiration_date => "05/2009",
|
57
58
|
:cvv => "100",
|
58
|
-
:token => "CREDIT_CARD_TOKEN"
|
59
|
+
:token => "CREDIT_CARD_TOKEN",
|
59
60
|
)
|
60
61
|
|
61
62
|
expect do
|
@@ -69,11 +70,11 @@ describe Braintree::PayPalAccount do
|
|
69
70
|
|
70
71
|
nonce = nonce_for_paypal_account(
|
71
72
|
:consent_code => "consent-code",
|
72
|
-
:token => payment_method_token
|
73
|
+
:token => payment_method_token,
|
73
74
|
)
|
74
75
|
result = Braintree::PaymentMethod.create(
|
75
76
|
:payment_method_nonce => nonce,
|
76
|
-
:customer_id => customer.id
|
77
|
+
:customer_id => customer.id,
|
77
78
|
)
|
78
79
|
result.should be_success
|
79
80
|
|
@@ -81,12 +82,12 @@ describe Braintree::PayPalAccount do
|
|
81
82
|
|
82
83
|
subscription1 = Braintree::Subscription.create(
|
83
84
|
:payment_method_token => token,
|
84
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
85
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
85
86
|
).subscription
|
86
87
|
|
87
88
|
subscription2 = Braintree::Subscription.create(
|
88
89
|
:payment_method_token => token,
|
89
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
90
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
90
91
|
).subscription
|
91
92
|
|
92
93
|
paypal_account = Braintree::PayPalAccount.find(token)
|
@@ -104,7 +105,7 @@ describe Braintree::PayPalAccount do
|
|
104
105
|
:options => {
|
105
106
|
:make_default => true,
|
106
107
|
:fail_on_duplicate_payment_method => true,
|
107
|
-
}
|
108
|
+
},
|
108
109
|
)
|
109
110
|
|
110
111
|
result.should be_success
|
@@ -115,7 +116,7 @@ describe Braintree::PayPalAccount do
|
|
115
116
|
it "throws an error if customer id is not specified" do
|
116
117
|
result = Braintree::PayPalAccount.create(
|
117
118
|
:billing_agreement_id => "some_billing_agreement_id",
|
118
|
-
:email => "some@example.com"
|
119
|
+
:email => "some@example.com",
|
119
120
|
)
|
120
121
|
|
121
122
|
result.success?.should == false
|
@@ -126,11 +127,11 @@ describe Braintree::PayPalAccount do
|
|
126
127
|
customer = Braintree::Customer.create!
|
127
128
|
result = Braintree::PayPalAccount.create(
|
128
129
|
:customer_id => customer.id,
|
129
|
-
:email => "some@example.com"
|
130
|
+
:email => "some@example.com",
|
130
131
|
)
|
131
132
|
|
132
133
|
result.success?.should == false
|
133
|
-
result.errors.
|
134
|
+
result.errors.map(&:code).should include("82902")
|
134
135
|
end
|
135
136
|
end
|
136
137
|
|
@@ -140,14 +141,14 @@ describe Braintree::PayPalAccount do
|
|
140
141
|
create_result = Braintree::PayPalAccount.create(
|
141
142
|
:customer_id => customer.id,
|
142
143
|
:billing_agreement_id => "first_billing_agreement_id",
|
143
|
-
:email => "first@example.com"
|
144
|
+
:email => "first@example.com",
|
144
145
|
)
|
145
146
|
create_result.success?.should == true
|
146
147
|
|
147
148
|
update_result = Braintree::PayPalAccount.update(
|
148
149
|
create_result.paypal_account.token,
|
149
150
|
:billing_agreement_id => "second_billing_agreement_id",
|
150
|
-
:email => "second@example.com"
|
151
|
+
:email => "second@example.com",
|
151
152
|
)
|
152
153
|
|
153
154
|
update_result.success?.should == true
|
@@ -162,17 +163,17 @@ describe Braintree::PayPalAccount do
|
|
162
163
|
original_token = random_payment_method_token
|
163
164
|
nonce = nonce_for_paypal_account(
|
164
165
|
:consent_code => "consent-code",
|
165
|
-
:token => original_token
|
166
|
+
:token => original_token,
|
166
167
|
)
|
167
168
|
original_result = Braintree::PaymentMethod.create(
|
168
169
|
:payment_method_nonce => nonce,
|
169
|
-
:customer_id => customer.id
|
170
|
+
:customer_id => customer.id,
|
170
171
|
)
|
171
172
|
|
172
173
|
updated_token = "UPDATED_TOKEN-" + rand(36**3).to_s(36)
|
173
174
|
updated_result = Braintree::PayPalAccount.update(
|
174
175
|
original_token,
|
175
|
-
:token => updated_token
|
176
|
+
:token => updated_token,
|
176
177
|
)
|
177
178
|
|
178
179
|
updated_paypal_account = Braintree::PayPalAccount.find(updated_token)
|
@@ -189,19 +190,19 @@ describe Braintree::PayPalAccount do
|
|
189
190
|
:customer_id => customer.id,
|
190
191
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
191
192
|
:expiration_date => "05/2009",
|
192
|
-
:options => {:make_default => true}
|
193
|
+
:options => {:make_default => true},
|
193
194
|
)
|
194
195
|
result.should be_success
|
195
196
|
|
196
197
|
nonce = nonce_for_paypal_account(:consent_code => "consent-code")
|
197
198
|
original_token = Braintree::PaymentMethod.create(
|
198
199
|
:payment_method_nonce => nonce,
|
199
|
-
:customer_id => customer.id
|
200
|
+
:customer_id => customer.id,
|
200
201
|
).payment_method.token
|
201
202
|
|
202
203
|
updated_result = Braintree::PayPalAccount.update(
|
203
204
|
original_token,
|
204
|
-
:options => {:make_default => true}
|
205
|
+
:options => {:make_default => true},
|
205
206
|
)
|
206
207
|
|
207
208
|
updated_paypal_account = Braintree::PayPalAccount.find(original_token)
|
@@ -215,25 +216,25 @@ describe Braintree::PayPalAccount do
|
|
215
216
|
|
216
217
|
first_nonce = nonce_for_paypal_account(
|
217
218
|
:consent_code => "consent-code",
|
218
|
-
:token => first_token
|
219
|
+
:token => first_token,
|
219
220
|
)
|
220
221
|
first_result = Braintree::PaymentMethod.create(
|
221
222
|
:payment_method_nonce => first_nonce,
|
222
|
-
:customer_id => customer.id
|
223
|
+
:customer_id => customer.id,
|
223
224
|
)
|
224
225
|
|
225
226
|
second_nonce = nonce_for_paypal_account(
|
226
227
|
:consent_code => "consent-code",
|
227
|
-
:token => second_token
|
228
|
+
:token => second_token,
|
228
229
|
)
|
229
230
|
second_result = Braintree::PaymentMethod.create(
|
230
231
|
:payment_method_nonce => second_nonce,
|
231
|
-
:customer_id => customer.id
|
232
|
+
:customer_id => customer.id,
|
232
233
|
)
|
233
234
|
|
234
235
|
updated_result = Braintree::PayPalAccount.update(
|
235
236
|
first_token,
|
236
|
-
:token => second_token
|
237
|
+
:token => second_token,
|
237
238
|
)
|
238
239
|
|
239
240
|
updated_result.should_not be_success
|
@@ -248,11 +249,11 @@ describe Braintree::PayPalAccount do
|
|
248
249
|
|
249
250
|
nonce = nonce_for_paypal_account(
|
250
251
|
:consent_code => "consent-code",
|
251
|
-
:token => token
|
252
|
+
:token => token,
|
252
253
|
)
|
253
254
|
Braintree::PaymentMethod.create(
|
254
255
|
:payment_method_nonce => nonce,
|
255
|
-
:customer_id => customer.id
|
256
|
+
:customer_id => customer.id,
|
256
257
|
)
|
257
258
|
|
258
259
|
result = Braintree::PayPalAccount.delete(token)
|
@@ -266,13 +267,13 @@ describe Braintree::PayPalAccount do
|
|
266
267
|
context "self.sale" do
|
267
268
|
it "creates a transaction using a paypal account and returns a result object" do
|
268
269
|
customer = Braintree::Customer.create!(
|
269
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
270
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
270
271
|
)
|
271
272
|
|
272
273
|
result = Braintree::PayPalAccount.sale(customer.paypal_accounts[0].token, :amount => "100.00")
|
273
274
|
|
274
275
|
result.success?.should == true
|
275
|
-
result.transaction.amount.should == BigDecimal
|
276
|
+
result.transaction.amount.should == BigDecimal("100.00")
|
276
277
|
result.transaction.type.should == "sale"
|
277
278
|
result.transaction.customer_details.id.should == customer.id
|
278
279
|
result.transaction.paypal_details.token.should == customer.paypal_accounts[0].token
|
@@ -282,12 +283,12 @@ describe Braintree::PayPalAccount do
|
|
282
283
|
context "self.sale!" do
|
283
284
|
it "creates a transaction using a paypal account and returns a transaction" do
|
284
285
|
customer = Braintree::Customer.create!(
|
285
|
-
:payment_method_nonce => Braintree::Test::Nonce::
|
286
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
286
287
|
)
|
287
288
|
|
288
289
|
transaction = Braintree::PayPalAccount.sale!(customer.paypal_accounts[0].token, :amount => "100.00")
|
289
290
|
|
290
|
-
transaction.amount.should == BigDecimal
|
291
|
+
transaction.amount.should == BigDecimal("100.00")
|
291
292
|
transaction.type.should == "sale"
|
292
293
|
transaction.customer_details.id.should == customer.id
|
293
294
|
transaction.paypal_details.token.should == customer.paypal_accounts[0].token
|