braintree 2.98.0 → 4.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/braintree.gemspec +7 -4
- data/lib/braintree/account_updater_daily_report.rb +4 -4
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +7 -27
- data/lib/braintree/address_gateway.rb +8 -7
- data/lib/braintree/advanced_search.rb +11 -12
- data/lib/braintree/apple_pay.rb +4 -4
- data/lib/braintree/apple_pay_card.rb +18 -4
- data/lib/braintree/apple_pay_options.rb +4 -4
- data/lib/braintree/authorization_adjustment.rb +4 -4
- data/lib/braintree/base_module.rb +11 -1
- data/lib/braintree/bin_data.rb +10 -3
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/client_token_gateway.rb +4 -3
- data/lib/braintree/configuration.rb +35 -35
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +2 -2
- data/lib/braintree/connected_merchant_status_transitioned.rb +2 -2
- data/lib/braintree/credit_card.rb +40 -86
- data/lib/braintree/credit_card_gateway.rb +58 -44
- data/lib/braintree/credit_card_verification.rb +39 -20
- data/lib/braintree/credit_card_verification_gateway.rb +35 -5
- data/lib/braintree/credit_card_verification_search.rb +2 -2
- data/lib/braintree/customer.rb +23 -88
- data/lib/braintree/customer_gateway.rb +17 -32
- data/lib/braintree/customer_search.rb +2 -2
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +7 -7
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
- data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
- data/lib/braintree/dispute/transaction.rb +3 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +47 -6
- data/lib/braintree/dispute_gateway.rb +5 -10
- data/lib/braintree/dispute_search.rb +8 -4
- data/lib/braintree/document_upload.rb +3 -3
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +217 -175
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +6 -5
- data/lib/braintree/exchange_rate.rb +13 -0
- data/lib/braintree/exchange_rate_quote.rb +24 -0
- data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
- data/lib/braintree/exchange_rate_quote_input.rb +21 -0
- data/lib/braintree/exchange_rate_quote_request.rb +18 -0
- data/lib/braintree/exchange_rate_quote_response.rb +18 -0
- data/lib/braintree/facilitated_details.rb +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/gateway.rb +6 -12
- data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +18 -5
- data/lib/braintree/granted_payment_instrument_update.rb +2 -2
- data/lib/braintree/graphql_client.rb +14 -8
- data/lib/braintree/http.rb +9 -10
- data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
- data/lib/braintree/local_payment_completed.rb +10 -5
- data/lib/braintree/local_payment_expired.rb +21 -0
- data/lib/braintree/local_payment_funded.rb +22 -0
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +4 -4
- data/lib/braintree/merchant_account.rb +3 -3
- data/lib/braintree/merchant_account_gateway.rb +10 -8
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +4 -4
- data/lib/braintree/oauth_credentials.rb +4 -4
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +14 -13
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +52 -22
- data/lib/braintree/payment_method_nonce.rb +12 -7
- data/lib/braintree/payment_method_nonce_details.rb +40 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +14 -3
- data/lib/braintree/payment_method_parser.rb +4 -7
- data/lib/braintree/paypal_account.rb +3 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +22 -2
- data/lib/braintree/plan_gateway.rb +101 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/resource_collection.rb +10 -5
- data/lib/braintree/revoked_payment_method_metadata.rb +2 -2
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +10 -3
- data/lib/braintree/samsung_pay_card.rb +8 -6
- data/lib/braintree/sepa_direct_debit_account.rb +60 -0
- data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
- data/lib/braintree/sha256_digest.rb +1 -1
- data/lib/braintree/subscription/status_details.rb +1 -1
- data/lib/braintree/subscription.rb +13 -13
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +5 -4
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +9 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +27 -20
- data/lib/braintree/test/transaction_amounts.rb +2 -3
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/testing_gateway.rb +1 -1
- data/lib/braintree/three_d_secure_info.rb +23 -11
- data/lib/braintree/transaction/address_details.rb +14 -1
- data/lib/braintree/transaction/apple_pay_details.rb +13 -10
- data/lib/braintree/transaction/credit_card_details.rb +8 -1
- data/lib/braintree/transaction/customer_details.rb +3 -2
- data/lib/braintree/transaction/disbursement_details.rb +2 -1
- data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +6 -1
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/local_payment_details.rb +3 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
- data/lib/braintree/transaction/package_details.rb +19 -0
- data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
- data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
- data/lib/braintree/transaction/payment_receipt.rb +31 -0
- data/lib/braintree/transaction/paypal_details.rb +5 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +3 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +3 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +2 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +119 -128
- data/lib/braintree/transaction_gateway.rb +138 -64
- data/lib/braintree/transaction_line_item.rb +14 -11
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +11 -7
- data/lib/braintree/unknown_payment_method.rb +2 -2
- data/lib/braintree/us_bank_account.rb +5 -5
- data/lib/braintree/us_bank_account_verification.rb +24 -16
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +25 -10
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +4 -4
- data/lib/braintree/venmo_profile_data.rb +25 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +8 -8
- data/lib/braintree/webhook_notification.rb +55 -33
- data/lib/braintree/webhook_notification_gateway.rb +9 -9
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +569 -46
- data/lib/braintree/xml/generator.rb +6 -5
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +24 -37
- data/lib/braintree/xml/rexml.rb +6 -7
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +41 -24
- data/lib/ssl/api_braintreegateway_com.ca.crt +401 -168
- data/spec/integration/braintree/add_on_spec.rb +10 -10
- data/spec/integration/braintree/address_spec.rb +101 -178
- data/spec/integration/braintree/advanced_search_spec.rb +93 -93
- data/spec/integration/braintree/apple_pay_spec.rb +12 -12
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +279 -62
- data/spec/integration/braintree/client_api/spec_helper.rb +99 -73
- data/spec/integration/braintree/credit_card_spec.rb +522 -821
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/credit_card_verification_spec.rb +219 -30
- data/spec/integration/braintree/customer_search_spec.rb +28 -28
- data/spec/integration/braintree/customer_spec.rb +840 -757
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_search_spec.rb +45 -9
- data/spec/integration/braintree/dispute_spec.rb +109 -82
- data/spec/integration/braintree/document_upload_spec.rb +29 -17
- data/spec/integration/braintree/error_codes_spec.rb +3 -3
- data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
- data/spec/integration/braintree/graphql_client_spec.rb +0 -2
- data/spec/integration/braintree/http_spec.rb +31 -33
- data/spec/integration/braintree/merchant_account_spec.rb +155 -156
- data/spec/integration/braintree/merchant_spec.rb +71 -192
- data/spec/integration/braintree/oauth_spec.rb +72 -72
- data/spec/integration/braintree/package_tracking_spec.rb +130 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +173 -78
- data/spec/integration/braintree/payment_method_spec.rb +953 -501
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +147 -234
- data/spec/integration/braintree/paypal_account_spec.rb +74 -72
- data/spec/integration/braintree/plan_spec.rb +96 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +75 -73
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +194 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +18 -18
- data/spec/integration/braintree/subscription_spec.rb +507 -513
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +4 -4
- data/spec/integration/braintree/test_transaction_spec.rb +29 -29
- data/spec/integration/braintree/transaction_line_item_spec.rb +12 -6
- data/spec/integration/braintree/transaction_search_spec.rb +410 -217
- data/spec/integration/braintree/transaction_spec.rb +3252 -2102
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +42 -278
- data/spec/integration/braintree/us_bank_account_spec.rb +36 -36
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +25 -25
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +41 -41
- data/spec/integration/braintree/visa_checkout_card_spec.rb +62 -62
- data/spec/integration/spec_helper.rb +22 -7
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +15 -20
- data/spec/unit/braintree/address_spec.rb +9 -17
- data/spec/unit/braintree/apple_pay_card_spec.rb +110 -7
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +6 -6
- data/spec/unit/braintree/configuration_spec.rb +84 -84
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +91 -58
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +56 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +10 -10
- data/spec/unit/braintree/credit_card_verification_spec.rb +40 -18
- data/spec/unit/braintree/customer_spec.rb +102 -57
- data/spec/unit/braintree/digest_spec.rb +5 -6
- data/spec/unit/braintree/disbursement_spec.rb +14 -14
- data/spec/unit/braintree/dispute_search_spec.rb +6 -2
- data/spec/unit/braintree/dispute_spec.rb +144 -66
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +41 -0
- data/spec/unit/braintree/error_result_spec.rb +11 -11
- data/spec/unit/braintree/errors_spec.rb +17 -17
- data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
- data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
- data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
- data/spec/unit/braintree/http_spec.rb +19 -17
- data/spec/unit/braintree/local_payment_completed_spec.rb +62 -8
- data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
- data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
- data/spec/unit/braintree/merchant_account_spec.rb +5 -5
- data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/package_tracking_spec.rb +77 -0
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
- data/spec/unit/braintree/payment_method_spec.rb +20 -20
- data/spec/unit/braintree/paypal_account_spec.rb +16 -7
- data/spec/unit/braintree/resource_collection_spec.rb +34 -5
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +38 -8
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
- data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +18 -18
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +6 -6
- data/spec/unit/braintree/three_d_secure_info_spec.rb +37 -17
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +22 -6
- data/spec/unit/braintree/transaction/customer_details_spec.rb +3 -2
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +4 -4
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +36 -0
- data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +150 -0
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +221 -124
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +12 -7
- data/spec/unit/braintree/util_spec.rb +78 -44
- data/spec/unit/braintree/validation_error_collection_spec.rb +62 -62
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +43 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +434 -197
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +27 -22
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +38 -38
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +91 -30
- data/lib/braintree/amex_express_checkout_card.rb +0 -38
- data/lib/braintree/coinbase_account.rb +0 -34
- data/lib/braintree/europe_bank_account.rb +0 -36
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -61
- data/lib/braintree/ideal_payment_gateway.rb +0 -19
- data/lib/braintree/masterpass_card.rb +0 -81
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
- data/lib/braintree/transaction/masterpass_card_details.rb +0 -47
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/integration/braintree/coinbase_spec.rb +0 -34
- data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -23,9 +23,9 @@ describe Braintree::Disbursement do
|
|
23
23
|
}
|
24
24
|
|
25
25
|
disbursement = Braintree::Disbursement._new(Braintree::Configuration.gateway, attributes)
|
26
|
-
disbursement.transactions.maximum_size.
|
26
|
+
expect(disbursement.transactions.maximum_size).to eq(1)
|
27
27
|
transaction = disbursement.transactions.first
|
28
|
-
transaction.id.
|
28
|
+
expect(transaction.id).to eq("sub_merchant_transaction")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -20,15 +20,15 @@ describe Braintree::Discount do
|
|
20
20
|
discounts = Braintree::Discount.all
|
21
21
|
discount = discounts.select { |discount| discount.id == id }.first
|
22
22
|
|
23
|
-
discount.
|
24
|
-
discount.amount.
|
25
|
-
discount.created_at.
|
26
|
-
discount.description.
|
27
|
-
discount.kind.
|
28
|
-
discount.name.
|
29
|
-
discount.never_expires.
|
30
|
-
discount.number_of_billing_cycles.
|
31
|
-
discount.updated_at.
|
23
|
+
expect(discount).not_to be_nil
|
24
|
+
expect(discount.amount).to eq(BigDecimal(expected[:amount]))
|
25
|
+
expect(discount.created_at).not_to be_nil
|
26
|
+
expect(discount.description).to eq(expected[:description])
|
27
|
+
expect(discount.kind).to eq(expected[:kind])
|
28
|
+
expect(discount.name).to eq(expected[:name])
|
29
|
+
expect(discount.never_expires).to eq(expected[:never_expires])
|
30
|
+
expect(discount.number_of_billing_cycles).to eq(expected[:number_of_billing_cycles])
|
31
|
+
expect(discount.updated_at).not_to be_nil
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -18,16 +18,15 @@ describe Braintree::Dispute, "search" do
|
|
18
18
|
|
19
19
|
let(:transaction) do
|
20
20
|
result = Braintree::Transaction.sale(
|
21
|
-
:amount =>
|
21
|
+
:amount => "10.00",
|
22
22
|
:credit_card => {
|
23
|
-
:expiration_date =>
|
23
|
+
:expiration_date => "01/2020",
|
24
24
|
:number => Braintree::Test::CreditCardNumbers::Disputes::Chargeback,
|
25
25
|
},
|
26
26
|
:customer_id => customer.id,
|
27
|
-
:merchant_account_id => "14LaddersLLC_instant",
|
28
27
|
:options => {
|
29
28
|
:submit_for_settlement => true,
|
30
|
-
}
|
29
|
+
},
|
31
30
|
)
|
32
31
|
|
33
32
|
result.transaction
|
@@ -74,15 +73,52 @@ describe Braintree::Dispute, "search" do
|
|
74
73
|
]
|
75
74
|
end
|
76
75
|
|
77
|
-
expect(collection.disputes.count).to
|
78
|
-
|
76
|
+
expect(collection.disputes.count).to be >= 2
|
77
|
+
end
|
78
|
+
|
79
|
+
it "correctly returns disputes by chargeback protection level flag" do
|
80
|
+
collection = Braintree::Dispute.search do |search|
|
81
|
+
search.chargeback_protection_level.in [
|
82
|
+
Braintree::Dispute::ChargebackProtectionLevel::Effortless
|
83
|
+
]
|
84
|
+
end
|
85
|
+
expect(collection.disputes.count).to be > 0
|
86
|
+
|
87
|
+
# NEXT_MAJOR_VERSION Remove this assertion when chargeback_protection_level is removed from the SDK
|
88
|
+
collection.disputes.each do |dispute|
|
89
|
+
expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Effortless)
|
90
|
+
expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::EffortlessCBP)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "pre-dispute program" do
|
95
|
+
it "correctly returns disputes by pre-dispute program" do
|
96
|
+
collection = Braintree::Dispute.search do |search|
|
97
|
+
search.pre_dispute_program.in [
|
98
|
+
Braintree::Dispute::PreDisputeProgram::VisaRdr
|
99
|
+
]
|
100
|
+
end
|
101
|
+
|
102
|
+
expect(collection.disputes.count).to eq(1)
|
103
|
+
dispute = collection.disputes.first
|
104
|
+
expect(dispute.pre_dispute_program).to eq(Braintree::Dispute::PreDisputeProgram::VisaRdr)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "correctly returns disputes with no pre-dispute program" do
|
108
|
+
collection = Braintree::Dispute.search do |search|
|
109
|
+
search.pre_dispute_program.is Braintree::Dispute::PreDisputeProgram::None
|
110
|
+
end
|
111
|
+
|
112
|
+
expect(collection.disputes.count).to be > 1
|
113
|
+
expect(collection.disputes.map(&:pre_dispute_program).uniq).to eq([Braintree::Dispute::PreDisputeProgram::None])
|
114
|
+
end
|
79
115
|
end
|
80
116
|
|
81
117
|
it "correctly returns disputes by effective_date range" do
|
82
118
|
effective_date = transaction.disputes.first.status_history.first.effective_date
|
83
119
|
|
84
120
|
collection = Braintree::Dispute.search do |search|
|
85
|
-
search.effective_date.between(effective_date,
|
121
|
+
search.effective_date.between(effective_date, effective_date.next_day)
|
86
122
|
end
|
87
123
|
|
88
124
|
expect(collection.disputes.count).to be >= 1
|
@@ -95,7 +131,7 @@ describe Braintree::Dispute, "search" do
|
|
95
131
|
disbursement_date = transaction.disputes.first.status_history.first.disbursement_date
|
96
132
|
|
97
133
|
collection = Braintree::Dispute.search do |search|
|
98
|
-
search.disbursement_date.between(disbursement_date,
|
134
|
+
search.disbursement_date.between(disbursement_date, disbursement_date.next_day)
|
99
135
|
end
|
100
136
|
|
101
137
|
expect(collection.disputes.count).to be >= 1
|
@@ -109,7 +145,7 @@ describe Braintree::Dispute, "search" do
|
|
109
145
|
search.received_date.between("03/03/2014", "03/05/2014")
|
110
146
|
end
|
111
147
|
|
112
|
-
expect(collection.disputes.count).to
|
148
|
+
expect(collection.disputes.count).to be >= 1
|
113
149
|
dispute = collection.disputes.first
|
114
150
|
|
115
151
|
expect(dispute.received_date).to eq(Date.new(2014, 3, 4))
|
@@ -6,19 +6,19 @@ describe Braintree::Dispute do
|
|
6
6
|
let(:document_upload) do
|
7
7
|
file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/bt_logo.png", "r")
|
8
8
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
9
|
-
|
9
|
+
response.document_upload
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:transaction) do
|
13
13
|
result = Braintree::Transaction.sale(
|
14
|
-
:amount =>
|
14
|
+
:amount => "10.00",
|
15
15
|
:credit_card => {
|
16
|
-
:expiration_date =>
|
16
|
+
:expiration_date => "01/2020",
|
17
17
|
:number => Braintree::Test::CreditCardNumbers::Disputes::Chargeback
|
18
18
|
},
|
19
19
|
:options => {
|
20
20
|
:submit_for_settlement => true
|
21
|
-
}
|
21
|
+
},
|
22
22
|
)
|
23
23
|
|
24
24
|
result.transaction
|
@@ -30,27 +30,27 @@ describe Braintree::Dispute do
|
|
30
30
|
it "changes the dispute status to accepted" do
|
31
31
|
result = Braintree::Dispute.accept(dispute.id)
|
32
32
|
|
33
|
-
result.success
|
33
|
+
expect(result.success?).to eq(true)
|
34
34
|
|
35
35
|
refreshed_dispute = Braintree::Dispute.find(dispute.id)
|
36
|
-
refreshed_dispute.status.
|
36
|
+
expect(refreshed_dispute.status).to eq(Braintree::Dispute::Status::Accepted)
|
37
37
|
|
38
38
|
dispute_from_transaction = Braintree::Transaction.find(dispute.transaction.id).disputes[0]
|
39
|
-
dispute_from_transaction.status.
|
39
|
+
expect(dispute_from_transaction.status).to eq(Braintree::Dispute::Status::Accepted)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "returns an error response if the dispute is not in open status" do
|
43
43
|
result = Braintree::Dispute.accept("wells_dispute")
|
44
44
|
|
45
|
-
result.success
|
46
|
-
result.errors.for(:dispute)[0].code.
|
47
|
-
result.errors.for(:dispute)[0].message.
|
45
|
+
expect(result.success?).to eq(false)
|
46
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyAcceptOpenDispute)
|
47
|
+
expect(result.errors.for(:dispute)[0].message).to eq("Disputes can only be accepted when they are in an Open state")
|
48
48
|
end
|
49
49
|
|
50
50
|
it "raises a NotFound exception if the dispute cannot be found" do
|
51
51
|
expect do
|
52
52
|
Braintree::Dispute.accept("invalid-id")
|
53
|
-
end.to raise_error(Braintree::NotFoundError,
|
53
|
+
end.to raise_error(Braintree::NotFoundError, "dispute with id invalid-id not found")
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -58,13 +58,13 @@ describe Braintree::Dispute do
|
|
58
58
|
it "creates file evidence for the dispute" do
|
59
59
|
result = Braintree::Dispute.add_file_evidence(dispute.id, document_upload.id)
|
60
60
|
|
61
|
-
result.success
|
62
|
-
result.evidence.category.
|
63
|
-
result.evidence.comment.
|
64
|
-
result.evidence.created_at.between?(Time.now - 10, Time.now).
|
65
|
-
result.evidence.id.
|
66
|
-
result.evidence.sent_to_processor_at.
|
67
|
-
result.evidence.url.
|
61
|
+
expect(result.success?).to eq(true)
|
62
|
+
expect(result.evidence.category).to be_nil
|
63
|
+
expect(result.evidence.comment).to be_nil
|
64
|
+
expect(result.evidence.created_at.between?(Time.now - 10, Time.now)).to eq(true)
|
65
|
+
expect(result.evidence.id).to match(/^\w{16,}$/)
|
66
|
+
expect(result.evidence.sent_to_processor_at).to eq(nil)
|
67
|
+
expect(result.evidence.url).to include("bt_logo.png")
|
68
68
|
end
|
69
69
|
|
70
70
|
it "returns a NotFoundError if the dispute doesn't exist" do
|
@@ -77,9 +77,9 @@ describe Braintree::Dispute do
|
|
77
77
|
Braintree::Dispute.accept(dispute.id)
|
78
78
|
|
79
79
|
result = Braintree::Dispute.add_file_evidence(dispute.id, document_upload.id)
|
80
|
-
result.success
|
81
|
-
result.errors.for(:dispute)[0].code.
|
82
|
-
result.errors.for(:dispute)[0].message.
|
80
|
+
expect(result.success?).to eq(false)
|
81
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyAddEvidenceToOpenDispute)
|
82
|
+
expect(result.errors.for(:dispute)[0].message).to eq("Evidence can only be attached to disputes that are in an Open state")
|
83
83
|
end
|
84
84
|
|
85
85
|
it "returns the new evidence record in subsequent dispute finds" do
|
@@ -87,17 +87,17 @@ describe Braintree::Dispute do
|
|
87
87
|
refreshed_dispute = Braintree::Dispute.find(dispute.id)
|
88
88
|
|
89
89
|
expected_evidence = refreshed_dispute.evidence.find { |e| e.id == result.evidence.id }
|
90
|
-
expected_evidence.
|
91
|
-
expected_evidence.comment.
|
92
|
-
expected_evidence.url.
|
90
|
+
expect(expected_evidence).not_to eq(nil)
|
91
|
+
expect(expected_evidence.comment).to be_nil
|
92
|
+
expect(expected_evidence.url).to include("bt_logo.png")
|
93
93
|
end
|
94
94
|
|
95
95
|
it "creates file evidence with a category when provided" do
|
96
96
|
result = Braintree::Dispute.add_file_evidence(dispute.id, {category: "GENERAL", document_id: document_upload.id})
|
97
97
|
|
98
|
-
result.success
|
99
|
-
result.evidence.category.
|
100
|
-
result.evidence.url.
|
98
|
+
expect(result.success?).to eq(true)
|
99
|
+
expect(result.evidence.category).to eq("GENERAL")
|
100
|
+
expect(result.evidence.url).to include("bt_logo.png")
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -105,15 +105,15 @@ describe Braintree::Dispute do
|
|
105
105
|
it "creates text evidence for the dispute" do
|
106
106
|
result = Braintree::Dispute.add_text_evidence(dispute.id, "text evidence")
|
107
107
|
|
108
|
-
result.success
|
109
|
-
result.evidence.category.
|
110
|
-
result.evidence.comment.
|
111
|
-
result.evidence.created_at.between?(Time.now - 10, Time.now).
|
112
|
-
result.evidence.id.
|
113
|
-
result.evidence.sent_to_processor_at.
|
114
|
-
result.evidence.url.
|
115
|
-
result.evidence.tag.
|
116
|
-
result.evidence.sequence_number.
|
108
|
+
expect(result.success?).to eq(true)
|
109
|
+
expect(result.evidence.category).to eq(nil)
|
110
|
+
expect(result.evidence.comment).to eq("text evidence")
|
111
|
+
expect(result.evidence.created_at.between?(Time.now - 10, Time.now)).to eq(true)
|
112
|
+
expect(result.evidence.id).to match(/^\w{16,}$/)
|
113
|
+
expect(result.evidence.sent_to_processor_at).to eq(nil)
|
114
|
+
expect(result.evidence.url).to eq(nil)
|
115
|
+
expect(result.evidence.tag).to eq(nil)
|
116
|
+
expect(result.evidence.sequence_number).to eq(nil)
|
117
117
|
end
|
118
118
|
|
119
119
|
it "returns a NotFoundError if the dispute doesn't exist" do
|
@@ -126,9 +126,9 @@ describe Braintree::Dispute do
|
|
126
126
|
Braintree::Dispute.accept(dispute.id)
|
127
127
|
|
128
128
|
result = Braintree::Dispute.add_text_evidence(dispute.id, "text evidence")
|
129
|
-
result.success
|
130
|
-
result.errors.for(:dispute)[0].code.
|
131
|
-
result.errors.for(:dispute)[0].message.
|
129
|
+
expect(result.success?).to eq(false)
|
130
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyAddEvidenceToOpenDispute)
|
131
|
+
expect(result.errors.for(:dispute)[0].message).to eq("Evidence can only be attached to disputes that are in an Open state")
|
132
132
|
end
|
133
133
|
|
134
134
|
it "returns the new evidence record in subsequent dispute finds" do
|
@@ -136,21 +136,47 @@ describe Braintree::Dispute do
|
|
136
136
|
refreshed_dispute = Braintree::Dispute.find(dispute.id)
|
137
137
|
|
138
138
|
expected_evidence = refreshed_dispute.evidence.find { |e| e.id == result.evidence.id }
|
139
|
-
expected_evidence.
|
140
|
-
expected_evidence.comment.
|
139
|
+
expect(expected_evidence).not_to eq(nil)
|
140
|
+
expect(expected_evidence.comment).to eq("text evidence")
|
141
141
|
end
|
142
142
|
|
143
143
|
it "creates text evidence for the dispute with optional parameters" do
|
144
|
-
result = Braintree::Dispute.add_text_evidence(dispute.id, {
|
144
|
+
result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "123456789", category: "REFUND_ID", sequence_number: 7})
|
145
|
+
|
146
|
+
expect(result.success?).to eq(true)
|
147
|
+
expect(result.evidence.category).to eq("REFUND_ID")
|
148
|
+
expect(result.evidence.comment).to eq("123456789")
|
149
|
+
expect(result.evidence.created_at.between?(Time.now - 10, Time.now)).to eq(true)
|
150
|
+
expect(result.evidence.id).to match(/^\w{16,}$/)
|
151
|
+
expect(result.evidence.sent_to_processor_at).to eq(nil)
|
152
|
+
expect(result.evidence.sequence_number).to eq(7)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "creates text evidence for the dispute with CARRIER_NAME shipping tracking" do
|
156
|
+
result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "UPS", category: "CARRIER_NAME", sequence_number: 0})
|
157
|
+
|
158
|
+
expect(result.success?).to eq(true)
|
159
|
+
expect(result.evidence.category).to eq("CARRIER_NAME")
|
160
|
+
expect(result.evidence.comment).to eq("UPS")
|
161
|
+
expect(result.evidence.sequence_number).to eq(0)
|
162
|
+
end
|
163
|
+
|
164
|
+
it "creates text evidence for the dispute with TRACKING_NUMBER shipping tracking" do
|
165
|
+
result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "3", category: "TRACKING_NUMBER", sequence_number: 0})
|
166
|
+
|
167
|
+
expect(result.success?).to eq(true)
|
168
|
+
expect(result.evidence.category).to eq("TRACKING_NUMBER")
|
169
|
+
expect(result.evidence.comment).to eq("3")
|
170
|
+
expect(result.evidence.sequence_number).to eq(0)
|
171
|
+
end
|
172
|
+
|
173
|
+
it "creates text evidence for the dispute with TRACKING_URL shipping tracking" do
|
174
|
+
result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "https://example.com/tracking-number/abc12345", category: "TRACKING_URL", sequence_number: 1})
|
145
175
|
|
146
|
-
result.success
|
147
|
-
result.evidence.category.
|
148
|
-
result.evidence.comment.
|
149
|
-
result.evidence.
|
150
|
-
result.evidence.id.should =~ /^\w{16,}$/
|
151
|
-
result.evidence.sent_to_processor_at.should == nil
|
152
|
-
result.evidence.tag.should == "REFUND_ID"
|
153
|
-
result.evidence.sequence_number.should == 7
|
176
|
+
expect(result.success?).to eq(true)
|
177
|
+
expect(result.evidence.category).to eq("TRACKING_URL")
|
178
|
+
expect(result.evidence.comment).to eq("https://example.com/tracking-number/abc12345")
|
179
|
+
expect(result.evidence.sequence_number).to eq(1)
|
154
180
|
end
|
155
181
|
end
|
156
182
|
|
@@ -158,24 +184,24 @@ describe Braintree::Dispute do
|
|
158
184
|
it "changes the dispute status to disputed" do
|
159
185
|
result = Braintree::Dispute.finalize(dispute.id)
|
160
186
|
|
161
|
-
result.success
|
187
|
+
expect(result.success?).to eq(true)
|
162
188
|
|
163
189
|
refreshed_dispute = Braintree::Dispute.find(dispute.id)
|
164
|
-
refreshed_dispute.status.
|
190
|
+
expect(refreshed_dispute.status).to eq(Braintree::Dispute::Status::Disputed)
|
165
191
|
end
|
166
192
|
|
167
193
|
it "returns an error response if the dispute is not in open status" do
|
168
194
|
result = Braintree::Dispute.finalize("wells_dispute")
|
169
195
|
|
170
|
-
result.success
|
171
|
-
result.errors.for(:dispute)[0].code.
|
172
|
-
result.errors.for(:dispute)[0].message.
|
196
|
+
expect(result.success?).to eq(false)
|
197
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyFinalizeOpenDispute)
|
198
|
+
expect(result.errors.for(:dispute)[0].message).to eq("Disputes can only be finalized when they are in an Open state")
|
173
199
|
end
|
174
200
|
|
175
201
|
it "raises a NotFound exception if the dispute cannot be found" do
|
176
202
|
expect do
|
177
203
|
Braintree::Dispute.finalize("invalid-id")
|
178
|
-
end.to raise_error(Braintree::NotFoundError,
|
204
|
+
end.to raise_error(Braintree::NotFoundError, "dispute with id invalid-id not found")
|
179
205
|
end
|
180
206
|
end
|
181
207
|
|
@@ -183,12 +209,13 @@ describe Braintree::Dispute do
|
|
183
209
|
it "finds the dispute with the given id" do
|
184
210
|
dispute = Braintree::Dispute.find("open_dispute")
|
185
211
|
|
186
|
-
dispute.amount_disputed.
|
187
|
-
dispute.amount_won.
|
188
|
-
dispute.id.
|
189
|
-
dispute.
|
190
|
-
dispute.
|
191
|
-
dispute.transaction.
|
212
|
+
expect(dispute.amount_disputed).to eq(31.0)
|
213
|
+
expect(dispute.amount_won).to eq(0.0)
|
214
|
+
expect(dispute.id).to eq("open_dispute")
|
215
|
+
expect(dispute.graphql_id).not_to be_nil
|
216
|
+
expect(dispute.status).to eq(Braintree::Dispute::Status::Open)
|
217
|
+
expect(dispute.transaction.amount).to eq(31.0)
|
218
|
+
expect(dispute.transaction.id).to eq("open_disputed_transaction")
|
192
219
|
end
|
193
220
|
|
194
221
|
it "raises an ArgumentError if dispute_id is not a string" do
|
@@ -216,7 +243,7 @@ describe Braintree::Dispute do
|
|
216
243
|
it "removes evidence from the dispute" do
|
217
244
|
result = Braintree::Dispute.remove_evidence(dispute.id, evidence.id)
|
218
245
|
|
219
|
-
result.success
|
246
|
+
expect(result.success?).to eq(true)
|
220
247
|
end
|
221
248
|
|
222
249
|
it "returns a NotFoundError if the dispute doesn't exist" do
|
@@ -236,9 +263,9 @@ describe Braintree::Dispute do
|
|
236
263
|
Braintree::Dispute.accept(dispute.id)
|
237
264
|
|
238
265
|
result = Braintree::Dispute.remove_evidence(dispute.id, evidence.id)
|
239
|
-
result.success
|
240
|
-
result.errors.for(:dispute)[0].code.
|
241
|
-
result.errors.for(:dispute)[0].message.
|
266
|
+
expect(result.success?).to eq(false)
|
267
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyRemoveEvidenceFromOpenDispute)
|
268
|
+
expect(result.errors.for(:dispute)[0].message).to eq("Evidence can only be removed from disputes that are in an Open state")
|
242
269
|
end
|
243
270
|
end
|
244
271
|
|
@@ -246,61 +273,61 @@ describe Braintree::Dispute do
|
|
246
273
|
it "fails to create file evidence for an unsupported category" do
|
247
274
|
result = Braintree::Dispute.add_file_evidence(dispute.id, {category: "NOTREALCATEGORY", document_id: document_upload.id})
|
248
275
|
|
249
|
-
result.success
|
250
|
-
result.errors.for(:dispute)[0].code.
|
276
|
+
expect(result.success?).to eq(false)
|
277
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyCreateEvidenceWithValidCategory)
|
251
278
|
end
|
252
279
|
|
253
280
|
it "fails to create text evidence for an unsupported category" do
|
254
281
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {category: "NOTREALCATEGORY", content: "evidence"})
|
255
282
|
|
256
|
-
result.success
|
257
|
-
result.errors.for(:dispute)[0].code.
|
283
|
+
expect(result.success?).to eq(false)
|
284
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::CanOnlyCreateEvidenceWithValidCategory)
|
258
285
|
end
|
259
286
|
|
260
287
|
it "fails to create text evidence for a file only category MERCHANT_WEBSITE_OR_APP_ACCESS" do
|
261
288
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {category: "MERCHANT_WEBSITE_OR_APP_ACCESS", content: "evidence"})
|
262
289
|
|
263
|
-
result.success
|
264
|
-
result.errors.for(:dispute)[0].code.
|
290
|
+
expect(result.success?).to eq(false)
|
291
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::EvidenceCategoryDocumentOnly)
|
265
292
|
end
|
266
293
|
|
267
294
|
it "fails to create file evidence for a text only category DEVICE_ID" do
|
268
295
|
result = Braintree::Dispute.add_file_evidence(dispute.id, {category: "DEVICE_ID", document_id: document_upload.id})
|
269
296
|
|
270
|
-
result.success
|
271
|
-
result.errors.for(:dispute)[0].code.
|
297
|
+
expect(result.success?).to eq(false)
|
298
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::EvidenceCategoryTextOnly)
|
272
299
|
end
|
273
300
|
|
274
301
|
it "fails to create evidence with an invalid date time format" do
|
275
302
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {category: "DOWNLOAD_DATE_TIME", content: "baddate"})
|
276
303
|
|
277
|
-
result.success
|
278
|
-
result.errors.for(:dispute)[0].code.
|
304
|
+
expect(result.success?).to eq(false)
|
305
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::EvidenceContentDateInvalid)
|
279
306
|
end
|
280
307
|
|
281
308
|
it "successfully creates text evidence with an valid date time format" do
|
282
309
|
result = Braintree::Dispute.add_text_evidence(dispute.id, {category: "DOWNLOAD_DATE_TIME", content: "2018-10-20T18:00:00-0500"})
|
283
310
|
|
284
|
-
result.success
|
311
|
+
expect(result.success?).to eq(true)
|
285
312
|
end
|
286
313
|
|
287
314
|
it "fails to finalize a dispute with digital goods missing" do
|
288
315
|
Braintree::Dispute.add_text_evidence(dispute.id, {category: "DEVICE_ID", content: "iphone_id"})
|
289
316
|
result = Braintree::Dispute.finalize(dispute.id)
|
290
317
|
|
291
|
-
result.success
|
318
|
+
expect(result.success?).to eq(false)
|
292
319
|
error_codes = result.errors.for(:dispute).map(&:code)
|
293
320
|
|
294
|
-
error_codes.
|
295
|
-
error_codes.
|
321
|
+
expect(error_codes).to include(Braintree::ErrorCodes::Dispute::DigitalGoodsMissingDownloadDate)
|
322
|
+
expect(error_codes).to include(Braintree::ErrorCodes::Dispute::DigitalGoodsMissingEvidence)
|
296
323
|
end
|
297
324
|
|
298
325
|
it "fails to finalize a dispute with partial non-disputed transaction information provided" do
|
299
326
|
Braintree::Dispute.add_text_evidence(dispute.id, {category: "PRIOR_NON_DISPUTED_TRANSACTION_ARN", content: "123"})
|
300
327
|
result = Braintree::Dispute.finalize(dispute.id)
|
301
328
|
|
302
|
-
result.success
|
303
|
-
result.errors.for(:dispute)[0].code.
|
329
|
+
expect(result.success?).to eq(false)
|
330
|
+
expect(result.errors.for(:dispute)[0].code).to eq(Braintree::ErrorCodes::Dispute::NonDisputedPriorTransactionEvidenceMissingDate)
|
304
331
|
end
|
305
332
|
end
|
306
333
|
end
|
@@ -7,30 +7,30 @@ describe Braintree::DocumentUploadGateway do
|
|
7
7
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
8
8
|
document_upload = response.document_upload
|
9
9
|
|
10
|
-
response.success
|
11
|
-
document_upload.id.
|
12
|
-
document_upload.content_type.
|
13
|
-
document_upload.kind.
|
14
|
-
document_upload.name.
|
15
|
-
document_upload.size.
|
10
|
+
expect(response.success?).to eq(true)
|
11
|
+
expect(document_upload.id).not_to be_nil
|
12
|
+
expect(document_upload.content_type).to eq("image/png")
|
13
|
+
expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::EvidenceDocument)
|
14
|
+
expect(document_upload.name).to eq("bt_logo.png")
|
15
|
+
expect(document_upload.size).to eq(2443)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "returns file type error with unsupported file type" do
|
19
19
|
file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/gif_extension_bt_logo.gif", "r")
|
20
20
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
21
|
-
response.errors.for(:document_upload).first.code.
|
21
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::FileTypeIsInvalid)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns malformed error with malformed file" do
|
25
25
|
file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/malformed_pdf.pdf", "r")
|
26
26
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
27
|
-
response.errors.for(:document_upload).first.code.
|
27
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::FileIsMalformedOrEncrypted)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "returns invalid kind error with invalid kind" do
|
31
31
|
file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/bt_logo.png", "r")
|
32
32
|
response = Braintree::DocumentUpload.create({:kind => "invalid_kind", :file => file})
|
33
|
-
response.errors.for(:document_upload).first.code.
|
33
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::KindIsInvalid)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "returns file too large error with file over 4mb" do
|
@@ -40,7 +40,19 @@ describe Braintree::DocumentUploadGateway do
|
|
40
40
|
File.open(filename, "w+") { |f| write_times.times { f.write "a" } }
|
41
41
|
file = File.new(filename, "r")
|
42
42
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
43
|
-
response.errors.for(:document_upload).first.code.
|
43
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::FileIsTooLarge)
|
44
|
+
ensure
|
45
|
+
File.delete(filename)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns file is empty error with empty file" do
|
50
|
+
filename = "#{File.dirname(__FILE__)}/../../fixtures/files/empty_file.png"
|
51
|
+
begin
|
52
|
+
File.open(filename, "w+") {}
|
53
|
+
file = File.new(filename, "r")
|
54
|
+
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
55
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::FileIsEmpty)
|
44
56
|
ensure
|
45
57
|
File.delete(filename)
|
46
58
|
end
|
@@ -50,12 +62,12 @@ describe Braintree::DocumentUploadGateway do
|
|
50
62
|
filename = "#{File.dirname(__FILE__)}/../../fixtures/files/too_long.pdf"
|
51
63
|
file = File.new(filename, "r")
|
52
64
|
response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
53
|
-
response.errors.for(:document_upload).first.code.
|
65
|
+
expect(response.errors.for(:document_upload).first.code).to eq(Braintree::ErrorCodes::DocumentUpload::FileIsTooLong)
|
54
66
|
end
|
55
67
|
|
56
68
|
it "returns invalid keys error if signature is invalid" do
|
57
69
|
expect do
|
58
|
-
|
70
|
+
Braintree::DocumentUpload.create({:invalid_key => "do not add", :kind => Braintree::DocumentUpload::Kind::EvidenceDocument})
|
59
71
|
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
60
72
|
end
|
61
73
|
end
|
@@ -65,11 +77,11 @@ describe Braintree::DocumentUploadGateway do
|
|
65
77
|
file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/bt_logo.png", "r")
|
66
78
|
document_upload = Braintree::DocumentUpload.create!({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
|
67
79
|
|
68
|
-
document_upload.id.
|
69
|
-
document_upload.content_type.
|
70
|
-
document_upload.kind.
|
71
|
-
document_upload.name.
|
72
|
-
document_upload.size.
|
80
|
+
expect(document_upload.id).not_to be_nil
|
81
|
+
expect(document_upload.content_type).to eq("image/png")
|
82
|
+
expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::EvidenceDocument)
|
83
|
+
expect(document_upload.name).to eq("bt_logo.png")
|
84
|
+
expect(document_upload.size).to eq(2443)
|
73
85
|
end
|
74
86
|
end
|
75
87
|
end
|
@@ -6,10 +6,10 @@ describe Braintree::ErrorCodes do
|
|
6
6
|
result = Braintree::Customer.create(
|
7
7
|
:credit_card => {
|
8
8
|
:cardholder_name => "x" * 256
|
9
|
-
}
|
9
|
+
},
|
10
10
|
)
|
11
|
-
result.success
|
12
|
-
result.errors.for(:customer).for(:credit_card).map { |e| e.code }.
|
11
|
+
expect(result.success?).to eq(false)
|
12
|
+
expect(result.errors.for(:customer).for(:credit_card).map { |e| e.code }).to \
|
13
13
|
include(Braintree::ErrorCodes::CreditCard::CardholderNameIsTooLong)
|
14
14
|
end
|
15
15
|
end
|