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,51 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::PaymentMethodNonceDetails do
|
4
|
+
let(:payment_method_nonce_details) {
|
5
|
+
Braintree::PaymentMethodNonceDetails.new(
|
6
|
+
:bank_reference_token => "a-bank-reference-token",
|
7
|
+
:bin => "bin",
|
8
|
+
:card_type => "American Express",
|
9
|
+
:expiration_month => "12",
|
10
|
+
:expiration_year => "2025",
|
11
|
+
:is_network_tokenized => true,
|
12
|
+
:last_4 => "abcd",
|
13
|
+
:last_two => "11",
|
14
|
+
:mandate_type => "ONE_OFF",
|
15
|
+
:merchant_or_partner_customer_id => "a-mp-customer-id",
|
16
|
+
:payer_info => {
|
17
|
+
:billing_agreement_id => "1234",
|
18
|
+
:country_code => "US",
|
19
|
+
},
|
20
|
+
)
|
21
|
+
}
|
22
|
+
|
23
|
+
describe "#initialize" do
|
24
|
+
it "sets attributes" do
|
25
|
+
payment_method_nonce_details.bin.should == "bin"
|
26
|
+
payment_method_nonce_details.card_type.should == "American Express"
|
27
|
+
payment_method_nonce_details.expiration_month.should == "12"
|
28
|
+
payment_method_nonce_details.expiration_year.should == "2025"
|
29
|
+
payment_method_nonce_details.is_network_tokenized.should == true
|
30
|
+
payment_method_nonce_details.last_two.should == "11"
|
31
|
+
payment_method_nonce_details.payer_info.billing_agreement_id.should == "1234"
|
32
|
+
payment_method_nonce_details.payer_info.country_code.should == "US"
|
33
|
+
payment_method_nonce_details.sepa_direct_debit_account_nonce_details.bank_reference_token.should == "a-bank-reference-token"
|
34
|
+
payment_method_nonce_details.sepa_direct_debit_account_nonce_details.last_4.should == "abcd"
|
35
|
+
payment_method_nonce_details.sepa_direct_debit_account_nonce_details.mandate_type.should == "ONE_OFF"
|
36
|
+
payment_method_nonce_details.sepa_direct_debit_account_nonce_details.merchant_or_partner_customer_id.should == "a-mp-customer-id"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "inspect" do
|
41
|
+
it "prints the attributes" do
|
42
|
+
payment_method_nonce_details.inspect.should == %(#<PaymentMethodNonceDetails bin: "bin", card_type: "American Express", expiration_month: "12", expiration_year: "2025", is_network_tokenized: true, last_two: "11", payer_info: #<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: "1234", country_code: "US", email: nil, first_name: nil, last_name: nil, payer_id: nil>, sepa_direct_debit_account_nonce_details: #<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">>)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "is_network_tokenized" do
|
47
|
+
it "is aliased to is_network_tokenized?" do
|
48
|
+
payment_method_nonce_details.is_network_tokenized?.should == true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::PaymentMethodNonce do
|
4
|
+
let(:payment_method_nonce) {
|
5
|
+
Braintree::PaymentMethodNonce._new(
|
6
|
+
:gateway,
|
7
|
+
:nonce => "some-nonce",
|
8
|
+
:type => "CreditCard",
|
9
|
+
:default => true,
|
10
|
+
:details => {
|
11
|
+
:bin => "some-bin"
|
12
|
+
},
|
13
|
+
:three_d_secure_info => {
|
14
|
+
:liability_shift_possible => false,
|
15
|
+
:liability_shifted => false
|
16
|
+
},
|
17
|
+
:bin_data => {
|
18
|
+
:country_of_issuance => "USA"
|
19
|
+
},
|
20
|
+
)
|
21
|
+
}
|
22
|
+
|
23
|
+
describe "#initialize" do
|
24
|
+
it "sets attributes" do
|
25
|
+
expect(payment_method_nonce.nonce).to eq("some-nonce")
|
26
|
+
expect(payment_method_nonce.type).to eq("CreditCard")
|
27
|
+
expect(payment_method_nonce.default).to be true
|
28
|
+
expect(payment_method_nonce.details.bin).to eq("some-bin")
|
29
|
+
expect(payment_method_nonce.three_d_secure_info.liability_shift_possible).to be false
|
30
|
+
expect(payment_method_nonce.three_d_secure_info.liability_shifted).to be false
|
31
|
+
expect(payment_method_nonce.bin_data.country_of_issuance).to eq("USA")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "default" do
|
36
|
+
it "is aliased to default?" do
|
37
|
+
expect(payment_method_nonce.default?).to be true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -28,7 +28,7 @@ describe Braintree::PaymentMethod do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "delete" do
|
31
|
-
let(:http_stub) { double(
|
31
|
+
let(:http_stub) { double("http_stub").as_null_object }
|
32
32
|
it "accepts revoke_all_grants option with value true" do
|
33
33
|
Braintree::Http.stub(:new).and_return http_stub
|
34
34
|
http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=true")
|
@@ -8,7 +8,7 @@ describe Braintree::PayPalAccount do
|
|
8
8
|
:invalid_key => "bad stuff",
|
9
9
|
:options => {
|
10
10
|
:invalid_option => "bad option",
|
11
|
-
}
|
11
|
+
},
|
12
12
|
)
|
13
13
|
end.to raise_error(ArgumentError, "invalid keys: invalid_key, options[invalid_option]")
|
14
14
|
end
|
@@ -17,7 +17,7 @@ describe Braintree::PayPalAccount do
|
|
17
17
|
describe "self.update" do
|
18
18
|
it "raises an exception if attributes contain an invalid key" do
|
19
19
|
expect do
|
20
|
-
Braintree::PayPalAccount.update("some_token", :invalid_key =>
|
20
|
+
Braintree::PayPalAccount.update("some_token", :invalid_key => "val")
|
21
21
|
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
22
22
|
end
|
23
23
|
end
|
@@ -5,7 +5,7 @@ describe "Braintree::ResourceCollection" do
|
|
5
5
|
it "iterates over the elements, yielding to the block in pages" do
|
6
6
|
values = %w(a b c d e)
|
7
7
|
collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2}) do |ids|
|
8
|
-
ids.map {|id| values[id] }
|
8
|
+
ids.map { |id| values[id] }
|
9
9
|
end
|
10
10
|
|
11
11
|
count = 0
|
@@ -18,6 +18,35 @@ describe "Braintree::ResourceCollection" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
describe "#first" do
|
22
|
+
it "returns nil with no results" do
|
23
|
+
values = %w(a b c d e)
|
24
|
+
collection = Braintree::ResourceCollection.new(:search_results => {:ids => [], :page_size => 2}) do |ids|
|
25
|
+
ids.map { |id| values[id] }
|
26
|
+
end
|
27
|
+
|
28
|
+
collection.first.should == nil
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with results" do
|
32
|
+
let(:collection) do
|
33
|
+
values = %w(a b c d e)
|
34
|
+
|
35
|
+
Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2}) do |ids|
|
36
|
+
ids.map { |id| values[id] }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns the first occourence" do
|
41
|
+
collection.first.should == "a"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns the first N occourences" do
|
45
|
+
collection.first(4).should == ["a","b","c","d"]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
21
50
|
describe "#ids" do
|
22
51
|
it "returns a list of the resource collection ids" do
|
23
52
|
collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2})
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::Transaction::LiabilityShift do
|
4
|
+
describe "#initialize" do
|
5
|
+
it "sets responsible party and conditions" do
|
6
|
+
liability_shift = Braintree::Transaction::LiabilityShift.new(
|
7
|
+
:responsible_party => "paypal",
|
8
|
+
:conditions => ["unauthorized","item_not_received"],
|
9
|
+
)
|
10
|
+
|
11
|
+
expect(liability_shift.responsible_party).to eql "paypal"
|
12
|
+
expect(liability_shift.conditions.first).to eql "unauthorized"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "inspect" do
|
17
|
+
it "prints the attributes" do
|
18
|
+
details = Braintree::Transaction::LiabilityShift.new(
|
19
|
+
:responsible_party => "paypal",
|
20
|
+
:conditions => ["unauthorized","item_not_received"],
|
21
|
+
)
|
22
|
+
|
23
|
+
expect(details.inspect).to eql %(#<LiabilityShift responsible_party: "paypal", conditions: ["unauthorized", "item_not_received"]>)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -2,10 +2,31 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
2
|
|
3
3
|
describe Braintree::RiskData do
|
4
4
|
describe "#initialize" do
|
5
|
-
it "sets id and
|
6
|
-
risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS")
|
7
|
-
risk_data.id.
|
8
|
-
risk_data.decision.
|
5
|
+
it "sets id, decision, device_data_captured, decision_reasons and transaction_risk_score" do
|
6
|
+
risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS", :device_data_captured => true, :fraud_service_provider => "fraud_protection", :decision_reasons => ["reason"], :transaction_risk_score => "12")
|
7
|
+
expect(risk_data.id).to eql "123"
|
8
|
+
expect(risk_data.decision).to eql "YOU WON $1000 DOLLARS"
|
9
|
+
expect(risk_data.device_data_captured).to be_truthy
|
10
|
+
expect(risk_data.fraud_service_provider).to eql "fraud_protection"
|
11
|
+
expect(risk_data.decision_reasons).to eql ["reason"]
|
12
|
+
expect(risk_data.transaction_risk_score).to eql "12"
|
13
|
+
expect(risk_data.liability_shift).to be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it "sets liability shift info" do
|
17
|
+
risk_data = Braintree::RiskData.new(
|
18
|
+
:id => "123",
|
19
|
+
:decision => "YOU WON $1000 DOLLARS",
|
20
|
+
:device_data_captured => true,
|
21
|
+
:fraud_service_provider => "fraud_protection",
|
22
|
+
:decision_reasons => ["reason"],
|
23
|
+
:transaction_risk_score => "12",
|
24
|
+
:liability_shift => {
|
25
|
+
:responsible_party => "paypal",
|
26
|
+
:conditions => ["unauthorized"]},
|
27
|
+
)
|
28
|
+
expect(risk_data.liability_shift.responsible_party).to eql "paypal"
|
29
|
+
expect(risk_data.liability_shift.conditions).to eql ["unauthorized"]
|
9
30
|
end
|
10
31
|
end
|
11
32
|
|
@@ -13,9 +34,22 @@ describe Braintree::RiskData do
|
|
13
34
|
it "prints the attributes" do
|
14
35
|
details = Braintree::RiskData.new(
|
15
36
|
:id => "123",
|
16
|
-
:decision => "YOU WON $1000 DOLLARS"
|
37
|
+
:decision => "YOU WON $1000 DOLLARS",
|
38
|
+
:decision_reasons => ["reason"],
|
39
|
+
:device_data_captured => true,
|
40
|
+
:fraud_service_provider => "fraud_protection",
|
41
|
+
:transaction_risk_score => "12",
|
42
|
+
)
|
43
|
+
expect(details.inspect).to eql %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", decision_reasons: ["reason"], device_data_captured: true, fraud_service_provider: "fraud_protection", liability_shift: nil, transaction_risk_score: "12">)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "prints liability shift attributes, too" do
|
47
|
+
details = Braintree::RiskData.new(
|
48
|
+
:liability_shift => {
|
49
|
+
:responsible_party => "paypal",
|
50
|
+
:conditions => ["unauthorized"]},
|
17
51
|
)
|
18
|
-
details.inspect.
|
52
|
+
expect(details.inspect).to eql %(#<RiskData id: nil, decision: nil, decision_reasons: nil, device_data_captured: nil, fraud_service_provider: nil, liability_shift: #<LiabilityShift responsible_party: "paypal", conditions: ["unauthorized"]>, transaction_risk_score: nil>)
|
19
53
|
end
|
20
54
|
end
|
21
55
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::SepaDirectDebitAccountNonceDetails do
|
4
|
+
subject do
|
5
|
+
described_class.new(
|
6
|
+
:bank_reference_token => "a-bank-reference-token",
|
7
|
+
:last_4 => "abcd",
|
8
|
+
:mandate_type => "ONE_OFF",
|
9
|
+
:merchant_or_partner_customer_id => "a-mp-customer-id",
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#initialize" do
|
14
|
+
it "sets attributes" do
|
15
|
+
is_expected.to have_attributes(
|
16
|
+
:bank_reference_token => "a-bank-reference-token",
|
17
|
+
:last_4 => "abcd",
|
18
|
+
:mandate_type => "ONE_OFF",
|
19
|
+
:merchant_or_partner_customer_id => "a-mp-customer-id",
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "inspect" do
|
25
|
+
it "prints the attributes" do
|
26
|
+
subject.inspect.should == %(#<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::SepaDirectDebitAccount do
|
4
|
+
describe "self.new" do
|
5
|
+
subject do
|
6
|
+
-> { described_class.new }
|
7
|
+
end
|
8
|
+
|
9
|
+
it "is protected" do
|
10
|
+
is_expected.to raise_error(NoMethodError, /protected method .new/)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "self._new" do
|
15
|
+
let(:params) do
|
16
|
+
{
|
17
|
+
bank_reference_token: "a-reference-token",
|
18
|
+
created_at: Time.now,
|
19
|
+
customer_global_id: "a-customer-global-id",
|
20
|
+
customer_id: "a-customer-id",
|
21
|
+
default: true,
|
22
|
+
global_id: "a-global-id",
|
23
|
+
image_url: "a-image-url",
|
24
|
+
last_4: "4321",
|
25
|
+
mandate_type: "ONE_OFF",
|
26
|
+
merchant_or_partner_customer_id: "a-mp-customer-id",
|
27
|
+
subscriptions: [{price: "10.00"}],
|
28
|
+
token: "a-token",
|
29
|
+
updated_at: Time.now,
|
30
|
+
view_mandate_url: "a-view-mandate-url",
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
subject do
|
35
|
+
described_class._new(:gateway, params)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "initializes the object with the appropriate attributes set" do
|
39
|
+
is_expected.to have_attributes(**params)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "self.find" do
|
44
|
+
let(:token) { "token" }
|
45
|
+
|
46
|
+
subject do
|
47
|
+
described_class.find(token)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "calls gateway find" do
|
51
|
+
expect_any_instance_of(Braintree::SepaDirectDebitAccountGateway).to receive(:find).with(token)
|
52
|
+
subject
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "self.delete" do
|
57
|
+
let(:token) { "token" }
|
58
|
+
|
59
|
+
subject do
|
60
|
+
described_class.delete(token)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "calls gateway delete" do
|
64
|
+
expect_any_instance_of(Braintree::SepaDirectDebitAccountGateway).to receive(:delete).with(token)
|
65
|
+
subject
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "default?" do
|
70
|
+
subject do
|
71
|
+
described_class._new(:gateway, :default => default).default?
|
72
|
+
end
|
73
|
+
|
74
|
+
context "when sepa debit account is the default payment method for the customer" do
|
75
|
+
let(:default) { true }
|
76
|
+
|
77
|
+
it { is_expected.to be true }
|
78
|
+
end
|
79
|
+
|
80
|
+
context "when sepa debit account is not the default payment method for the customer" do
|
81
|
+
let(:default) { false }
|
82
|
+
|
83
|
+
it { is_expected.to be false }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -11,8 +11,8 @@ describe Braintree::Subscription do
|
|
11
11
|
|
12
12
|
context "price" do
|
13
13
|
it "accepts price as either a String or a BigDecimal" do
|
14
|
-
Braintree::Subscription._new(:gateway, default_params.merge(:price => "12.34")).price.should == BigDecimal
|
15
|
-
Braintree::Subscription._new(:gateway, default_params.merge(:price => BigDecimal
|
14
|
+
Braintree::Subscription._new(:gateway, default_params.merge(:price => "12.34")).price.should == BigDecimal("12.34")
|
15
|
+
Braintree::Subscription._new(:gateway, default_params.merge(:price => BigDecimal("12.34"))).price.should == BigDecimal("12.34")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "blows up if price is not a string or BigDecimal" do
|
@@ -5,7 +5,7 @@ describe Braintree::SuccessfulResult do
|
|
5
5
|
it "sets instance variables from the values in the hash" do
|
6
6
|
result = Braintree::SuccessfulResult.new(
|
7
7
|
:transaction => "transaction_value",
|
8
|
-
:credit_card => "credit_card_value"
|
8
|
+
:credit_card => "credit_card_value",
|
9
9
|
)
|
10
10
|
result.success?.should == true
|
11
11
|
result.transaction.should == "transaction_value"
|
@@ -3,27 +3,55 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
3
3
|
describe Braintree::ThreeDSecureInfo do
|
4
4
|
let(:three_d_secure_info) {
|
5
5
|
Braintree::ThreeDSecureInfo.new(
|
6
|
+
:acs_transaction_id => "acs_id",
|
7
|
+
:cavv => "cavvvalue",
|
8
|
+
:ds_transaction_id => "dstrxid",
|
9
|
+
:eci_flag => "06",
|
6
10
|
:enrolled => "Y",
|
7
|
-
:liability_shifted => true,
|
8
11
|
:liability_shift_possible => true,
|
9
|
-
:
|
12
|
+
:liability_shifted => true,
|
13
|
+
:pares_status => "Y",
|
14
|
+
:status => "authenticate_successful",
|
15
|
+
:three_d_secure_authentication_id => "auth_id",
|
16
|
+
:three_d_secure_transaction_id => "trans_id",
|
17
|
+
:three_d_secure_version => "1.0.2",
|
10
18
|
:xid => "xidvalue",
|
11
|
-
:
|
19
|
+
:authentication => {
|
20
|
+
:trans_status => "authstatus",
|
21
|
+
:trans_status_reason => "authstatusreason"
|
22
|
+
},
|
23
|
+
:lookup => {
|
24
|
+
:trans_status => "lookupstatus",
|
25
|
+
:trans_status_reason => "lookupstatusreason"
|
26
|
+
},
|
12
27
|
)
|
13
28
|
}
|
14
29
|
|
15
30
|
describe "#initialize" do
|
16
31
|
it "sets attributes" do
|
32
|
+
three_d_secure_info.acs_transaction_id.should == "acs_id"
|
33
|
+
three_d_secure_info.cavv.should == "cavvvalue"
|
34
|
+
three_d_secure_info.ds_transaction_id.should == "dstrxid"
|
35
|
+
three_d_secure_info.eci_flag.should == "06"
|
17
36
|
three_d_secure_info.enrolled.should == "Y"
|
18
|
-
three_d_secure_info.status.should == "authenticate_successful"
|
19
|
-
three_d_secure_info.liability_shifted.should == true
|
20
37
|
three_d_secure_info.liability_shift_possible.should == true
|
38
|
+
three_d_secure_info.liability_shifted.should == true
|
39
|
+
three_d_secure_info.pares_status.should == "Y"
|
40
|
+
three_d_secure_info.status.should == "authenticate_successful"
|
41
|
+
three_d_secure_info.three_d_secure_authentication_id.should == "auth_id"
|
42
|
+
three_d_secure_info.three_d_secure_transaction_id.should == "trans_id"
|
43
|
+
three_d_secure_info.three_d_secure_version.should == "1.0.2"
|
44
|
+
three_d_secure_info.xid.should == "xidvalue"
|
45
|
+
three_d_secure_info.lookup[:trans_status].should == "lookupstatus"
|
46
|
+
three_d_secure_info.lookup[:trans_status_reason].should == "lookupstatusreason"
|
47
|
+
three_d_secure_info.authentication[:trans_status].should == "authstatus"
|
48
|
+
three_d_secure_info.authentication[:trans_status_reason].should == "authstatusreason"
|
21
49
|
end
|
22
50
|
end
|
23
51
|
|
24
52
|
describe "inspect" do
|
25
53
|
it "prints the attributes" do
|
26
|
-
three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo enrolled: "Y",
|
54
|
+
three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo acs_transaction_id: "acs_id", authentication: {:trans_status=>"authstatus", :trans_status_reason=>"authstatusreason"}, cavv: "cavvvalue", ds_transaction_id: "dstrxid", eci_flag: "06", enrolled: "Y", liability_shift_possible: true, liability_shifted: true, lookup: {:trans_status=>"lookupstatus", :trans_status_reason=>"lookupstatusreason"}, pares_status: "Y", status: "authenticate_successful", three_d_secure_authentication_id: "auth_id", three_d_secure_transaction_id: "trans_id", three_d_secure_version: "1.0.2", xid: "xidvalue">)
|
27
55
|
end
|
28
56
|
end
|
29
57
|
|
@@ -5,7 +5,7 @@ describe Braintree::Transaction::CreditCardDetails do
|
|
5
5
|
it "concats expiration_month and expiration_year" do
|
6
6
|
details = Braintree::Transaction::CreditCardDetails.new(
|
7
7
|
:expiration_month => "08",
|
8
|
-
:expiration_year => "2009"
|
8
|
+
:expiration_year => "2009",
|
9
9
|
)
|
10
10
|
details.expiration_date.should == "08/2009"
|
11
11
|
end
|
@@ -32,7 +32,7 @@ describe Braintree::Transaction::CreditCardDetails do
|
|
32
32
|
:country_of_issuance => "Lilliput",
|
33
33
|
:issuing_bank => "Gulliver Bank",
|
34
34
|
:image_url => "example.com/visa.png",
|
35
|
-
:unique_number_identifier => "abc123"
|
35
|
+
:unique_number_identifier => "abc123",
|
36
36
|
)
|
37
37
|
details.inspect.should == %(#<token: "token", bin: "123456", last_4: "6789", card_type: "Visa", expiration_date: "05/2012", cardholder_name: "The Cardholder", customer_location: "US", prepaid: "Yes", healthcare: "No", durbin_regulated: "No", debit: "Yes", commercial: "Unknown", payroll: "Unknown", product_id: "Unknown", country_of_issuance: "Lilliput", issuing_bank: "Gulliver Bank", image_url: "example.com/visa.png", unique_number_identifier: "abc123">)
|
38
38
|
end
|
@@ -41,9 +41,25 @@ describe Braintree::Transaction::CreditCardDetails do
|
|
41
41
|
describe "masked_number" do
|
42
42
|
it "concatenates the bin, some *'s, and the last_4" do
|
43
43
|
details = Braintree::Transaction::CreditCardDetails.new(
|
44
|
-
:bin => "510510", :last_4 => "5100"
|
44
|
+
:bin => "510510", :last_4 => "5100",
|
45
45
|
)
|
46
46
|
details.masked_number.should == "510510******5100"
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
describe "is_network_tokenized" do
|
51
|
+
it "returns true if is_network_tokenized is true" do
|
52
|
+
details = Braintree::Transaction::CreditCardDetails.new(
|
53
|
+
:is_network_tokenized => true,
|
54
|
+
)
|
55
|
+
details.is_network_tokenized?.should == true
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns false if is_network_tokenized is false" do
|
59
|
+
details = Braintree::Transaction::CreditCardDetails.new(
|
60
|
+
:is_network_tokenized => false,
|
61
|
+
)
|
62
|
+
details.is_network_tokenized?.should == false
|
63
|
+
end
|
64
|
+
end
|
49
65
|
end
|
@@ -11,7 +11,7 @@ describe Braintree::Transaction::CustomerDetails do
|
|
11
11
|
:company => "Smith Co.",
|
12
12
|
:website => "http://www.example.com",
|
13
13
|
:phone => "6145551234",
|
14
|
-
:fax => "3125551234"
|
14
|
+
:fax => "3125551234",
|
15
15
|
)
|
16
16
|
details.inspect.should == %(#<id: "id", first_name: "Amy", last_name: "Smith", email: "amy.smith@example.com", company: "Smith Co.", website: "http://www.example.com", phone: "6145551234", fax: "3125551234">)
|
17
17
|
end
|
@@ -4,13 +4,13 @@ describe Braintree::Transaction::DisbursementDetails do
|
|
4
4
|
describe "valid?" do
|
5
5
|
it "returns true if disbursement details are initialized" do
|
6
6
|
details = Braintree::Transaction::DisbursementDetails.new(
|
7
|
-
:disbursement_date => Date.new(2013, 4, 1)
|
7
|
+
:disbursement_date => Date.new(2013, 4, 1).to_s,
|
8
8
|
)
|
9
9
|
details.valid?.should == true
|
10
10
|
end
|
11
11
|
it "returns true if disbursement details are initialized" do
|
12
12
|
details = Braintree::Transaction::DisbursementDetails.new(
|
13
|
-
:disbursement_date => nil
|
13
|
+
:disbursement_date => nil,
|
14
14
|
)
|
15
15
|
details.valid?.should == false
|
16
16
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::Transaction::Installment do
|
4
|
+
describe "inspect" do
|
5
|
+
it "assigns all fields" do
|
6
|
+
adjustment_attributes = {
|
7
|
+
:amount => "0.98",
|
8
|
+
:kind => "REFUND",
|
9
|
+
:projected_disbursement_date => "2020-01-03 01:02:03Z",
|
10
|
+
:actual_disbursement_date => "2020-01-04 01:02:03Z",
|
11
|
+
}
|
12
|
+
installment_attributes = {
|
13
|
+
:id => "abc123",
|
14
|
+
:amount => "1.23",
|
15
|
+
:projected_disbursement_date => "2020-01-01 01:02:03Z",
|
16
|
+
:actual_disbursement_date => "2020-01-02 01:02:03Z",
|
17
|
+
:adjustments => [adjustment_attributes],
|
18
|
+
}
|
19
|
+
|
20
|
+
installment = Braintree::Transaction::Installment.new(installment_attributes)
|
21
|
+
|
22
|
+
expect(installment.inspect).to eq('#<id: "abc123", amount: 0.123e1, projected_disbursement_date: "2020-01-01 01:02:03Z", actual_disbursement_date: "2020-01-02 01:02:03Z", adjustments: [#<amount: 0.98e0, kind: "REFUND", projected_disbursement_date: "2020-01-03 01:02:03Z", actual_disbursement_date: "2020-01-04 01:02:03Z">]>')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::Transaction::PayPalDetails do
|
4
|
+
describe "initialize" do
|
5
|
+
it "sets all fields" do
|
6
|
+
details = Braintree::Transaction::PayPalDetails.new(
|
7
|
+
:authorization_id => "id",
|
8
|
+
:billing_agreement_id => "billing-agreement-id",
|
9
|
+
:capture_id => "capture-id",
|
10
|
+
:custom_field => "custom-field",
|
11
|
+
:debug_id => "debug-id",
|
12
|
+
:description => "description",
|
13
|
+
:image_url => "www.image.com",
|
14
|
+
:implicitly_vaulted_payment_method_global_id => "global-id",
|
15
|
+
:implicitly_vaulted_payment_method_token => "payment-method-token",
|
16
|
+
:payee_email => "payee@example.com",
|
17
|
+
:payee_id => "payee-id",
|
18
|
+
:payer_email => "payer@example.com",
|
19
|
+
:payer_first_name => "Grace",
|
20
|
+
:payer_id => "payer-id",
|
21
|
+
:payer_last_name => "Hopper",
|
22
|
+
:payer_status =>"status",
|
23
|
+
:payment_id => "payment-id",
|
24
|
+
:refund_from_transaction_fee_amount => "1.00",
|
25
|
+
:refund_from_transaction_fee_currency_iso_code => "123",
|
26
|
+
:refund_id => "refund-id",
|
27
|
+
:seller_protection_status => "seller-protection-status",
|
28
|
+
:tax_id => "tax-id",
|
29
|
+
:tax_id_type => "tax-id-type",
|
30
|
+
:token => "token",
|
31
|
+
:transaction_fee_amount => "2.00",
|
32
|
+
:transaction_fee_currency_iso_code => "123",
|
33
|
+
)
|
34
|
+
|
35
|
+
expect(details.authorization_id).to eq("id")
|
36
|
+
expect(details.billing_agreement_id).to eq("billing-agreement-id")
|
37
|
+
expect(details.capture_id).to eq("capture-id")
|
38
|
+
expect(details.custom_field).to eq("custom-field")
|
39
|
+
expect(details.debug_id).to eq("debug-id")
|
40
|
+
expect(details.description).to eq("description")
|
41
|
+
expect(details.image_url).to eq("www.image.com")
|
42
|
+
expect(details.implicitly_vaulted_payment_method_global_id).to eq("global-id")
|
43
|
+
expect(details.implicitly_vaulted_payment_method_token).to eq("payment-method-token")
|
44
|
+
expect(details.payee_email).to eq("payee@example.com")
|
45
|
+
expect(details.payee_id).to eq("payee-id")
|
46
|
+
expect(details.payer_email).to eq("payer@example.com")
|
47
|
+
expect(details.payer_first_name).to eq("Grace")
|
48
|
+
expect(details.payer_id).to eq("payer-id")
|
49
|
+
expect(details.payer_last_name).to eq("Hopper")
|
50
|
+
expect(details.payer_status).to eq("status")
|
51
|
+
expect(details.payment_id).to eq("payment-id")
|
52
|
+
expect(details.refund_from_transaction_fee_amount).to eq("1.00")
|
53
|
+
expect(details.refund_from_transaction_fee_currency_iso_code).to eq("123")
|
54
|
+
expect(details.refund_id).to eq("refund-id")
|
55
|
+
expect(details.seller_protection_status).to eq("seller-protection-status")
|
56
|
+
expect(details.tax_id).to eq("tax-id")
|
57
|
+
expect(details.tax_id_type).to eq("tax-id-type")
|
58
|
+
expect(details.token).to eq("token")
|
59
|
+
expect(details.transaction_fee_amount).to eq("2.00")
|
60
|
+
expect(details.transaction_fee_currency_iso_code).to eq("123")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|