braintree 2.10.0 → 4.26.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 +7 -0
- data/LICENSE +1 -1
- data/braintree.gemspec +24 -0
- data/lib/braintree/account_updater_daily_report.rb +20 -0
- data/lib/braintree/ach_mandate.rb +14 -0
- data/lib/braintree/add_on.rb +4 -0
- data/lib/braintree/add_on_gateway.rb +17 -0
- data/lib/braintree/address/country_names.rb +4 -1
- data/lib/braintree/address.rb +35 -43
- data/lib/braintree/address_gateway.rb +24 -11
- data/lib/braintree/advanced_search.rb +26 -11
- data/lib/braintree/apple_pay.rb +29 -0
- data/lib/braintree/apple_pay_card.rb +66 -0
- 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 +11 -1
- data/lib/braintree/bin_data.rb +34 -0
- data/lib/braintree/client_token.rb +11 -0
- data/lib/braintree/client_token_gateway.rb +45 -0
- data/lib/braintree/configuration.rb +231 -39
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +22 -0
- data/lib/braintree/connected_merchant_status_transitioned.rb +22 -0
- data/lib/braintree/credentials_parser.rb +44 -0
- data/lib/braintree/credit_card.rb +107 -132
- data/lib/braintree/credit_card_gateway.rb +90 -41
- data/lib/braintree/credit_card_verification.rb +90 -17
- data/lib/braintree/credit_card_verification_gateway.rb +87 -0
- data/lib/braintree/credit_card_verification_search.rb +20 -0
- data/lib/braintree/customer.rb +80 -118
- data/lib/braintree/customer_gateway.rb +66 -39
- data/lib/braintree/customer_search.rb +5 -2
- data/lib/braintree/customer_session_gateway.rb +194 -0
- data/lib/braintree/descriptor.rb +4 -2
- data/lib/braintree/digest.rb +16 -3
- data/lib/braintree/disbursement.rb +63 -0
- data/lib/braintree/discount.rb +4 -0
- data/lib/braintree/discount_gateway.rb +17 -0
- data/lib/braintree/dispute/evidence.rb +24 -0
- data/lib/braintree/dispute/paypal_message.rb +15 -0
- data/lib/braintree/dispute/status_history.rb +18 -0
- data/lib/braintree/dispute/transaction.rb +20 -0
- data/lib/braintree/dispute/transaction_details.rb +15 -0
- data/lib/braintree/dispute.rb +165 -0
- 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 +680 -15
- data/lib/braintree/error_result.rb +13 -6
- data/lib/braintree/errors.rb +5 -5
- data/lib/braintree/exceptions.rb +14 -20
- 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 +20 -0
- data/lib/braintree/gateway.rb +104 -6
- data/lib/braintree/google_pay_card.rb +62 -0
- data/lib/braintree/granted_payment_instrument_update.rb +23 -0
- data/lib/braintree/graphql/enums/recommendations.rb +7 -0
- data/lib/braintree/graphql/enums/recommended_payment_option.rb +8 -0
- data/lib/braintree/graphql/inputs/create_customer_session_input.rb +35 -0
- data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +41 -0
- data/lib/braintree/graphql/inputs/customer_session_input.rb +39 -0
- data/lib/braintree/graphql/inputs/phone_input.rb +32 -0
- data/lib/braintree/graphql/inputs/update_customer_session_input.rb +37 -0
- data/lib/braintree/graphql/types/customer_recommendations_payload.rb +32 -0
- data/lib/braintree/graphql/types/payment_options.rb +33 -0
- data/lib/braintree/graphql/unions/customer_recommendations.rb +34 -0
- data/lib/braintree/graphql_client.rb +50 -0
- data/lib/braintree/http.rb +119 -25
- data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
- data/lib/braintree/local_payment_completed.rb +28 -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 +34 -0
- data/lib/braintree/merchant_account/address_details.rb +16 -0
- data/lib/braintree/merchant_account/business_details.rb +17 -0
- data/lib/braintree/merchant_account/funding_details.rb +18 -0
- data/lib/braintree/merchant_account/individual_details.rb +20 -0
- data/lib/braintree/merchant_account.rb +76 -0
- data/lib/braintree/merchant_account_gateway.rb +130 -0
- data/lib/braintree/merchant_gateway.rb +38 -0
- data/lib/braintree/meta_checkout_card.rb +90 -0
- data/lib/braintree/meta_checkout_token.rb +89 -0
- data/lib/braintree/modification.rb +16 -5
- data/lib/braintree/oauth_credentials.rb +22 -0
- data/lib/braintree/oauth_gateway.rb +73 -0
- data/lib/braintree/paginated_collection.rb +25 -0
- data/lib/braintree/paginated_result.rb +15 -0
- data/lib/braintree/payment_instrument_type.rb +18 -0
- data/lib/braintree/payment_method.rb +37 -0
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +221 -0
- data/lib/braintree/payment_method_nonce.rb +49 -0
- 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 +38 -0
- data/lib/braintree/payment_method_parser.rb +29 -0
- data/lib/braintree/paypal_account.rb +60 -0
- data/lib/braintree/paypal_account_gateway.rb +73 -0
- data/lib/braintree/paypal_payment_resource.rb +22 -0
- data/lib/braintree/paypal_payment_resource_gateway.rb +36 -0
- data/lib/braintree/plan.rb +62 -0
- data/lib/braintree/plan_gateway.rb +117 -0
- data/lib/braintree/processor_response_types.rb +7 -0
- data/lib/braintree/resource_collection.rb +12 -5
- 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 +29 -0
- data/lib/braintree/samsung_pay_card.rb +85 -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 +25 -0
- data/lib/braintree/settlement_batch_summary_gateway.rb +27 -0
- data/lib/braintree/sha256_digest.rb +13 -0
- data/lib/braintree/signature_service.rb +19 -0
- data/lib/braintree/subscription/status_details.rb +20 -0
- data/lib/braintree/subscription.rb +67 -47
- data/lib/braintree/subscription_gateway.rb +43 -16
- data/lib/braintree/subscription_search.rb +2 -2
- data/lib/braintree/successful_result.rb +30 -10
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +76 -0
- data/lib/braintree/test/merchant_account.rb +12 -0
- data/lib/braintree/test/nonce.rb +81 -0
- data/lib/braintree/test/transaction_amounts.rb +3 -5
- data/lib/braintree/test/venmo_sdk.rb +21 -0
- data/lib/braintree/test_transaction.rb +19 -0
- data/lib/braintree/testing_gateway.rb +43 -0
- data/lib/braintree/three_d_secure_info.rb +53 -0
- data/lib/braintree/transaction/address_details.rb +27 -5
- data/lib/braintree/transaction/apple_pay_details.rb +35 -0
- data/lib/braintree/transaction/credit_card_details.rb +55 -4
- data/lib/braintree/transaction/customer_details.rb +11 -3
- data/lib/braintree/transaction/disbursement_details.rb +28 -0
- data/lib/braintree/transaction/google_pay_details.rb +42 -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 +27 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +55 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +58 -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 +40 -0
- data/lib/braintree/transaction/paypal_here_details.rb +23 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +50 -0
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +6 -2
- data/lib/braintree/transaction/subscription_details.rb +5 -2
- data/lib/braintree/transaction/us_bank_account_details.rb +22 -0
- data/lib/braintree/transaction/venmo_account_details.rb +17 -0
- data/lib/braintree/transaction/visa_checkout_card_details.rb +51 -0
- data/lib/braintree/transaction.rb +293 -150
- data/lib/braintree/transaction_gateway.rb +303 -59
- data/lib/braintree/transaction_line_item.rb +43 -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 +17 -9
- data/lib/braintree/unknown_payment_method.rb +26 -0
- data/lib/braintree/us_bank_account.rb +57 -0
- data/lib/braintree/us_bank_account_gateway.rb +17 -0
- data/lib/braintree/us_bank_account_verification.rb +89 -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 +91 -11
- data/lib/braintree/validation_error.rb +14 -5
- data/lib/braintree/validation_error_collection.rb +5 -5
- data/lib/braintree/venmo_account.rb +34 -0
- data/lib/braintree/venmo_profile_data.rb +25 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +90 -0
- data/lib/braintree/webhook_notification.rb +146 -0
- data/lib/braintree/webhook_notification_gateway.rb +46 -0
- data/lib/braintree/webhook_testing.rb +7 -0
- data/lib/braintree/webhook_testing_gateway.rb +1239 -0
- data/lib/braintree/xml/generator.rb +18 -10
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +24 -36
- data/lib/braintree/xml/rexml.rb +6 -7
- data/lib/braintree/xml.rb +1 -2
- data/lib/braintree.rb +186 -52
- data/lib/ssl/api_braintreegateway_com.ca.crt +474 -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 +46 -0
- data/spec/integration/braintree/address_spec.rb +101 -178
- data/spec/integration/braintree/advanced_search_spec.rb +100 -97
- 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 +407 -0
- data/spec/integration/braintree/client_api/spec_helper.rb +300 -0
- data/spec/integration/braintree/credit_card_spec.rb +885 -654
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +193 -0
- data/spec/integration/braintree/credit_card_verification_spec.rb +473 -0
- data/spec/integration/braintree/customer_search_spec.rb +69 -21
- data/spec/integration/braintree/customer_session_spec.rb +143 -0
- data/spec/integration/braintree/customer_spec.rb +1437 -518
- data/spec/integration/braintree/disbursement_spec.rb +31 -0
- data/spec/integration/braintree/discount_spec.rb +34 -0
- data/spec/integration/braintree/dispute_search_spec.rb +165 -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 +3 -3
- 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 +106 -56
- data/spec/integration/braintree/merchant_account_spec.rb +603 -0
- data/spec/integration/braintree/merchant_spec.rb +227 -0
- data/spec/integration/braintree/oauth_spec.rb +225 -0
- data/spec/integration/braintree/package_tracking_spec.rb +130 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +345 -0
- data/spec/integration/braintree/payment_method_spec.rb +2146 -0
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +325 -0
- data/spec/integration/braintree/paypal_account_spec.rb +299 -0
- data/spec/integration/braintree/paypal_payment_resource_spec.rb +141 -0
- data/spec/integration/braintree/plan_spec.rb +136 -0
- data/spec/integration/braintree/samsung_pay_card_spec.rb +146 -0
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +194 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +62 -0
- data/spec/integration/braintree/subscription_spec.rb +785 -431
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +4 -4
- data/spec/integration/braintree/test_transaction_spec.rb +145 -0
- data/spec/integration/braintree/transaction_line_item_spec.rb +44 -0
- data/spec/integration/braintree/transaction_search_spec.rb +745 -156
- data/spec/integration/braintree/transaction_spec.rb +7452 -1288
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +196 -0
- data/spec/integration/braintree/us_bank_account_spec.rb +113 -0
- 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 +110 -0
- data/spec/integration/spec_helper.rb +61 -5
- data/spec/oauth_test_helper.rb +17 -0
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +77 -21
- data/spec/ssl/certificate.crt +17 -0
- data/spec/ssl/geotrust_global.crt +20 -0
- data/spec/ssl/privateKey.key +15 -0
- data/spec/unit/braintree/address_spec.rb +27 -16
- data/spec/unit/braintree/apple_pay_card_spec.rb +133 -0
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +37 -0
- data/spec/unit/braintree/configuration_spec.rb +293 -43
- data/spec/unit/braintree/credentials_parser_spec.rb +81 -0
- data/spec/unit/braintree/credit_card_spec.rb +138 -47
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +56 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +79 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +132 -6
- data/spec/unit/braintree/customer_session_gateway_spec.rb +120 -0
- data/spec/unit/braintree/customer_spec.rb +196 -40
- data/spec/unit/braintree/digest_spec.rb +16 -3
- data/spec/unit/braintree/disbursement_spec.rb +131 -0
- data/spec/unit/braintree/dispute_search_spec.rb +66 -0
- data/spec/unit/braintree/dispute_spec.rb +479 -0
- data/spec/unit/braintree/document_upload_spec.rb +35 -0
- 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/google_pay_card_spec.rb +8 -0
- data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +81 -0
- data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +110 -0
- data/spec/unit/braintree/graphql/customer_session_input_spec.rb +81 -0
- data/spec/unit/braintree/graphql/phone_input_spec.rb +51 -0
- data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +93 -0
- data/spec/unit/braintree/graphql_client_spec.rb +37 -0
- data/spec/unit/braintree/http_spec.rb +164 -2
- data/spec/unit/braintree/local_payment_completed_spec.rb +90 -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 +33 -0
- data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +62 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +65 -0
- data/spec/unit/braintree/modification_spec.rb +7 -0
- 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 +43 -0
- data/spec/unit/braintree/payment_method_spec.rb +135 -0
- data/spec/unit/braintree/paypal_account_spec.rb +53 -0
- data/spec/unit/braintree/paypal_payment_resource_spec.rb +125 -0
- data/spec/unit/braintree/resource_collection_spec.rb +44 -3
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +55 -0
- 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 +11 -0
- data/spec/unit/braintree/signature_service_spec.rb +23 -0
- data/spec/unit/braintree/subscription_search_spec.rb +25 -18
- data/spec/unit/braintree/subscription_spec.rb +34 -7
- data/spec/unit/braintree/successful_result_spec.rb +9 -9
- data/spec/unit/braintree/three_d_secure_info_spec.rb +69 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +34 -6
- data/spec/unit/braintree/transaction/customer_details_spec.rb +3 -2
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +18 -0
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +8 -0
- 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/meta_checkout_card_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +8 -0
- data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +68 -0
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +8 -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 +366 -52
- data/spec/unit/braintree/unknown_payment_method_spec.rb +33 -0
- data/spec/unit/braintree/us_bank_account_spec.rb +13 -0
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +98 -0
- data/spec/unit/braintree/util_spec.rb +199 -39
- data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
- 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/visa_checkout_card_spec.rb +8 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +977 -0
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +39 -5
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +39 -32
- data/spec/unit/braintree_spec.rb +3 -2
- data/spec/unit/credit_card_details_spec.rb +8 -0
- metadata +314 -73
- data/README.rdoc +0 -80
- data/lib/braintree/test/credit_card_numbers.rb +0 -52
- data/lib/braintree/transparent_redirect.rb +0 -51
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/lib/ssl/sandbox_braintreegateway_com.ca.crt +0 -19
- data/lib/ssl/www_braintreegateway_com.ca.crt +0 -202
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -236
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -160
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::DisputeSearch do
|
|
4
|
+
it "overrides previous 'is' with new 'is' for the same field" do
|
|
5
|
+
search = Braintree::DisputeSearch.new
|
|
6
|
+
search.id.is "dispute1"
|
|
7
|
+
search.id.is "dispute2"
|
|
8
|
+
expect(search.to_hash).to eq({:id => {:is => "dispute2"}})
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "overrides previous 'in' with new 'in' for the same field" do
|
|
12
|
+
search = Braintree::DisputeSearch.new
|
|
13
|
+
search.status.in Braintree::Dispute::Status::Open
|
|
14
|
+
search.status.in Braintree::Dispute::Status::Won
|
|
15
|
+
expect(search.to_hash).to eq({:status => [Braintree::Dispute::Status::Won]})
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
[
|
|
19
|
+
:amount_disputed,
|
|
20
|
+
:amount_won,
|
|
21
|
+
:case_number,
|
|
22
|
+
:customer_id,
|
|
23
|
+
:disbursement_date,
|
|
24
|
+
:effective_date,
|
|
25
|
+
:id,
|
|
26
|
+
:merchant_account_id,
|
|
27
|
+
:reason_code,
|
|
28
|
+
:received_date,
|
|
29
|
+
:reference_number,
|
|
30
|
+
:reply_by_date,
|
|
31
|
+
:transaction_id,
|
|
32
|
+
:transaction_source,
|
|
33
|
+
].each do |field|
|
|
34
|
+
it "allows searching on #{field}" do
|
|
35
|
+
search = Braintree::DisputeSearch.new
|
|
36
|
+
|
|
37
|
+
expect do
|
|
38
|
+
search.send(field).is "hello"
|
|
39
|
+
end.not_to raise_error
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
[
|
|
44
|
+
# NEXT_MAJOR_VERSION Remove this assertion when chargeback_protection_level is removed from the SDK
|
|
45
|
+
:chargeback_protection_level,
|
|
46
|
+
:protection_level,
|
|
47
|
+
:kind,
|
|
48
|
+
:reason,
|
|
49
|
+
:status,
|
|
50
|
+
:pre_dispute_program,
|
|
51
|
+
].each do |field|
|
|
52
|
+
it "raises if provided an unknown #{field} value" do
|
|
53
|
+
search = Braintree::DisputeSearch.new
|
|
54
|
+
expect do
|
|
55
|
+
search.send(field).is "unknown value"
|
|
56
|
+
end.to raise_error(/Invalid argument/)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "raises if no operator is provided" do
|
|
61
|
+
search = Braintree::DisputeSearch.new
|
|
62
|
+
expect do
|
|
63
|
+
search.id "one"
|
|
64
|
+
end.to raise_error(RuntimeError, "An operator is required")
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::Dispute do
|
|
4
|
+
let(:attributes) do
|
|
5
|
+
{
|
|
6
|
+
:id => "open_dispute",
|
|
7
|
+
:amount => "31.00",
|
|
8
|
+
:amount_disputed => "500.00",
|
|
9
|
+
:amount_won => "0.00",
|
|
10
|
+
:chargeback_protection_level => nil,
|
|
11
|
+
:created_at => Time.utc(2009, 3, 9, 10, 50, 39),
|
|
12
|
+
:processor_comments => "forwarded comments",
|
|
13
|
+
:date_opened => "2009-03-09",
|
|
14
|
+
:date_won => "2009-04-15",
|
|
15
|
+
:original_dispute_id => "original_dispute_id",
|
|
16
|
+
:received_date => "2009-03-09",
|
|
17
|
+
:reply_by_date => nil,
|
|
18
|
+
:updated_at => Time.utc(2009, 3, 9, 10, 50, 39),
|
|
19
|
+
:pre_dispute_program => Braintree::Dispute::PreDisputeProgram::None,
|
|
20
|
+
:evidence => [
|
|
21
|
+
{
|
|
22
|
+
comment: nil,
|
|
23
|
+
created_at: Time.utc(2009, 3, 10, 12, 5, 20),
|
|
24
|
+
id: "evidence1",
|
|
25
|
+
sent_to_processor_at: nil,
|
|
26
|
+
url: "url_of_file_evidence",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
comment: "text evidence",
|
|
30
|
+
created_at: Time.utc(2009, 3, 10, 12, 5, 21),
|
|
31
|
+
id: "evidence2",
|
|
32
|
+
sent_to_processor_at: "2009-03-13",
|
|
33
|
+
url: nil,
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
:status_history => [
|
|
37
|
+
{
|
|
38
|
+
:effective_date => "2009-03-09",
|
|
39
|
+
:status => "open",
|
|
40
|
+
:timestamp => Time.utc(2009, 3, 9, 10, 50, 39),
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
:transaction => {
|
|
44
|
+
:amount => "31.00",
|
|
45
|
+
:id => "open_disputed_transaction",
|
|
46
|
+
:created_at => Time.utc(2009, 2, 9, 12, 59, 59),
|
|
47
|
+
:installment_count => nil,
|
|
48
|
+
:order_id => nil,
|
|
49
|
+
:purchase_order_number => "po",
|
|
50
|
+
:payment_instrument_subtype => "Visa",
|
|
51
|
+
},
|
|
52
|
+
:paypal_messages => [
|
|
53
|
+
{
|
|
54
|
+
:message => "message",
|
|
55
|
+
:sender => "seller",
|
|
56
|
+
:sent_at => Time.utc(2009, 3, 9, 10, 50, 39),
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
[
|
|
63
|
+
:accept,
|
|
64
|
+
:finalize,
|
|
65
|
+
:find
|
|
66
|
+
].each do |method_name|
|
|
67
|
+
describe "self.#{method_name}" do
|
|
68
|
+
it "raises an exception if the id is blank" do
|
|
69
|
+
expect do
|
|
70
|
+
Braintree::Dispute.public_send(method_name, " ")
|
|
71
|
+
end.to raise_error(ArgumentError)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "raises an exception if the id is nil" do
|
|
75
|
+
expect do
|
|
76
|
+
Braintree::Dispute.public_send(method_name, nil)
|
|
77
|
+
end.to raise_error(ArgumentError)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "does not raise an exception if the id is a fixnum" do
|
|
81
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
82
|
+
allow(Braintree::Dispute).to receive(:_new).and_return nil
|
|
83
|
+
allow(Braintree::ErrorResult).to receive(:new).and_return nil
|
|
84
|
+
|
|
85
|
+
expect do
|
|
86
|
+
Braintree::Dispute.public_send(method_name, 8675309)
|
|
87
|
+
end.to_not raise_error
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe "self.add_file_evidence" do
|
|
93
|
+
it "raises an exception if the dispute_id is blank" do
|
|
94
|
+
expect do
|
|
95
|
+
Braintree::Dispute.add_file_evidence(" ", "doc_upload_id")
|
|
96
|
+
end.to raise_error(ArgumentError)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "raises an exception if the dispute_id is nil" do
|
|
100
|
+
expect do
|
|
101
|
+
Braintree::Dispute.add_file_evidence(nil, "doc_upload_id")
|
|
102
|
+
end.to raise_error(ArgumentError)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "raises an exception if the dispute_id contains invalid characters" do
|
|
106
|
+
expect do
|
|
107
|
+
Braintree::Dispute.add_file_evidence("@#$%", "doc_upload_id")
|
|
108
|
+
end.to raise_error(ArgumentError)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it "does not raise an exception if the dispute_id is a fixnum" do
|
|
112
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
113
|
+
allow(Braintree::Dispute).to receive(:_new).and_return nil
|
|
114
|
+
expect do
|
|
115
|
+
Braintree::Dispute.add_file_evidence(8675309, "doc_upload_id")
|
|
116
|
+
end.to_not raise_error
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it "raises an exception if the document_upload_id is blank" do
|
|
120
|
+
expect do
|
|
121
|
+
Braintree::Dispute.add_file_evidence("dispute_id", " ")
|
|
122
|
+
end.to raise_error(ArgumentError)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "raises an exception if the document_upload_id is nil" do
|
|
126
|
+
expect do
|
|
127
|
+
Braintree::Dispute.add_file_evidence("dispute_id", nil)
|
|
128
|
+
end.to raise_error(ArgumentError)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it "raises an exception if the document_upload_id contains invalid characters" do
|
|
132
|
+
expect do
|
|
133
|
+
Braintree::Dispute.add_file_evidence("dispute_id", "@#$%")
|
|
134
|
+
end.to raise_error(ArgumentError)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it "does not raise an exception if the document_upload_id is a fixnum" do
|
|
138
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
139
|
+
allow(Braintree::Dispute).to receive(:_new).and_return nil
|
|
140
|
+
expect do
|
|
141
|
+
Braintree::Dispute.add_file_evidence("dispute_id", 8675309)
|
|
142
|
+
end.to_not raise_error
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
describe "with optional params" do
|
|
146
|
+
it "does not raise an exception if the optional parameters are valid" do
|
|
147
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
148
|
+
expect do
|
|
149
|
+
Braintree::Dispute.add_file_evidence("dispute_id", {category: "GENERAL", document_id: "document_id"})
|
|
150
|
+
end.to_not raise_error
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it "raises an exception if the optional params contain invalid keys" do
|
|
154
|
+
expect do
|
|
155
|
+
Braintree::Dispute.add_file_evidence("dispute_id", {random_param: ""})
|
|
156
|
+
end.to raise_error(ArgumentError)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it "raises an exception if the param tag is not a string" do
|
|
160
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
161
|
+
|
|
162
|
+
expect do
|
|
163
|
+
Braintree::Dispute.add_file_evidence("dispute_id", {category: 3, document_id: "document_id"})
|
|
164
|
+
end.to raise_error(ArgumentError)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
describe "self.add_text_evidence" do
|
|
170
|
+
it "raises an exception if the id is blank" do
|
|
171
|
+
expect do
|
|
172
|
+
Braintree::Dispute.add_text_evidence(" ", "text evidence")
|
|
173
|
+
end.to raise_error(ArgumentError)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "raises an exception if the id is nil" do
|
|
177
|
+
expect do
|
|
178
|
+
Braintree::Dispute.add_text_evidence(nil, "text evidence")
|
|
179
|
+
end.to raise_error(ArgumentError)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it "raises an exception if the id contains invalid characters" do
|
|
183
|
+
expect do
|
|
184
|
+
Braintree::Dispute.add_text_evidence("@#$%", "text evidence")
|
|
185
|
+
end.to raise_error(ArgumentError)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it "does not raise an exception if the id is a fixnum" do
|
|
189
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
190
|
+
allow(Braintree::Dispute).to receive(:_new).and_return nil
|
|
191
|
+
expect do
|
|
192
|
+
Braintree::Dispute.add_text_evidence(8675309, "text evidence")
|
|
193
|
+
end.to_not raise_error
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "raises an exception if the content is blank" do
|
|
197
|
+
expect do
|
|
198
|
+
Braintree::Dispute.add_text_evidence("dispute_id", " ")
|
|
199
|
+
end.to raise_error(ArgumentError)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it "raises an exception if the content is nil" do
|
|
203
|
+
expect do
|
|
204
|
+
Braintree::Dispute.add_text_evidence("dispute_id", nil)
|
|
205
|
+
end.to raise_error(ArgumentError)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
describe "with optional params" do
|
|
209
|
+
it "does not raise an exception if the optional parameters are valid" do
|
|
210
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
211
|
+
expect do
|
|
212
|
+
Braintree::Dispute.add_text_evidence("dispute_id", {content: "a", category: "", sequence_number: 3})
|
|
213
|
+
end.to_not raise_error
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
it "raises an exception if the optional params contain invalid keys" do
|
|
217
|
+
expect do
|
|
218
|
+
Braintree::Dispute.add_text_evidence("dispute_id", {random_param: ""})
|
|
219
|
+
end.to raise_error(ArgumentError)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it "raises an exception if sequence_number is provided and not an integer" do
|
|
223
|
+
expect do
|
|
224
|
+
Braintree::Dispute.add_text_evidence("dispute_id", {sequence_number: "abc"})
|
|
225
|
+
end.to raise_error(ArgumentError)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it "raises an exception if the param tag is not a string" do
|
|
229
|
+
expect do
|
|
230
|
+
Braintree::Dispute.add_text_evidence("dispute_id", {tag: 3})
|
|
231
|
+
end.to raise_error(ArgumentError)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
it "raises an exception if the param category is not a string" do
|
|
235
|
+
expect do
|
|
236
|
+
Braintree::Dispute.add_text_evidence("dispute_id", {category: 3})
|
|
237
|
+
end.to raise_error(ArgumentError)
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
describe "self.remove_evidence" do
|
|
243
|
+
it "raises an exception if the dispute_id is blank" do
|
|
244
|
+
expect do
|
|
245
|
+
Braintree::Dispute.remove_evidence(" ")
|
|
246
|
+
end.to raise_error(ArgumentError)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
it "raises an exception if the dispute_id is nil" do
|
|
250
|
+
expect do
|
|
251
|
+
Braintree::Dispute.remove_evidence(nil)
|
|
252
|
+
end.to raise_error(ArgumentError)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
it "raises an exception if the content is blank" do
|
|
256
|
+
expect do
|
|
257
|
+
Braintree::Dispute.remove_evidence("dispute_id", " ")
|
|
258
|
+
end.to raise_error(ArgumentError)
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
it "raises an exception if the content is nil" do
|
|
262
|
+
expect do
|
|
263
|
+
Braintree::Dispute.remove_evidence("dispute_id", nil)
|
|
264
|
+
end.to raise_error(ArgumentError)
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
it "raises an exception if the dispute_id contains invalid characters" do
|
|
268
|
+
expect do
|
|
269
|
+
Braintree::Dispute.remove_evidence("@#$%", "evidence_id")
|
|
270
|
+
end.to raise_error(ArgumentError)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
it "raises an exception if the evidence_id contains invalid characters" do
|
|
274
|
+
expect do
|
|
275
|
+
Braintree::Dispute.remove_evidence("dispute_id", "@#$%")
|
|
276
|
+
end.to raise_error(ArgumentError)
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
describe "initialize" do
|
|
281
|
+
it "converts string amount_dispute and amount_won" do
|
|
282
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
283
|
+
|
|
284
|
+
expect(dispute.amount_disputed).to eq(500.0)
|
|
285
|
+
expect(dispute.amount_won).to eq(0.0)
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
it "returns 'Effortless Chargeback Protection tool' when initial chargeback_protection_level is effortless" do
|
|
289
|
+
attributes.merge!(:chargeback_protection_level => Braintree::Dispute::ChargebackProtectionLevel::Effortless)
|
|
290
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
291
|
+
|
|
292
|
+
expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Effortless)
|
|
293
|
+
expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::EffortlessCBP)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
it "returns 'Chargeback Protection tool' when initial chargeback_protection_level is standard" do
|
|
297
|
+
attributes.merge!(:chargeback_protection_level => Braintree::Dispute::ChargebackProtectionLevel::Standard)
|
|
298
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
299
|
+
|
|
300
|
+
expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Standard)
|
|
301
|
+
expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::StandardCBP)
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
it "returns 'No Protection' when initial chargeback_protection_level is nil" do
|
|
305
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
306
|
+
|
|
307
|
+
expect(dispute.chargeback_protection_level).to eq(nil)
|
|
308
|
+
expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::NoProtection)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
it "returns 'No Protection' when initial chargeback_protection_level is empty" do
|
|
312
|
+
attributes.merge!(:chargeback_protection_level => "")
|
|
313
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
314
|
+
|
|
315
|
+
expect(dispute.chargeback_protection_level).to eq("")
|
|
316
|
+
expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::NoProtection)
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
it "returns 'No Protection' when initial chargeback_protection_level is not_protected" do
|
|
320
|
+
attributes.merge!(:chargeback_protection_level => Braintree::Dispute::ChargebackProtectionLevel::NotProtected)
|
|
321
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
322
|
+
|
|
323
|
+
expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::NotProtected)
|
|
324
|
+
expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::NoProtection)
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
[
|
|
328
|
+
:reply_by_date,
|
|
329
|
+
:amount,
|
|
330
|
+
:date_opened,
|
|
331
|
+
:date_won,
|
|
332
|
+
:status_history,
|
|
333
|
+
].each do |field|
|
|
334
|
+
it "handles nil #{field}" do
|
|
335
|
+
attributes.delete(field)
|
|
336
|
+
|
|
337
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
338
|
+
|
|
339
|
+
expect(dispute.send(field)).to eq(nil)
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
it "converts date_opened, date_won, reply_by_date, received_date from String to Date" do
|
|
344
|
+
dispute = Braintree::Dispute._new(attributes.merge(:reply_by_date => "2009-03-14"))
|
|
345
|
+
|
|
346
|
+
expect(dispute.date_opened).to eq(Date.new(2009, 3, 9))
|
|
347
|
+
expect(dispute.date_won).to eq(Date.new(2009, 4, 15))
|
|
348
|
+
expect(dispute.received_date).to eq(Date.new(2009, 3, 9))
|
|
349
|
+
expect(dispute.reply_by_date).to eq(Date.new(2009, 3, 14))
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
it "converts transaction hash into a Dispute::TransactionDetails object first" do
|
|
353
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
354
|
+
|
|
355
|
+
expect(dispute.transaction_details.id).to eq("open_disputed_transaction")
|
|
356
|
+
expect(dispute.transaction_details.amount).to eq(31.00)
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
it "converts transaction hash into a Dispute::Transaction object" do
|
|
360
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
361
|
+
|
|
362
|
+
expect(dispute.transaction.amount).to eq(31.00)
|
|
363
|
+
expect(dispute.transaction.id).to eq("open_disputed_transaction")
|
|
364
|
+
expect(dispute.transaction.created_at).to eq(Time.utc(2009, 2, 9, 12, 59, 59))
|
|
365
|
+
expect(dispute.transaction.installment_count).to eq(nil)
|
|
366
|
+
expect(dispute.transaction.order_id).to eq(nil)
|
|
367
|
+
expect(dispute.transaction.purchase_order_number).to eq("po")
|
|
368
|
+
expect(dispute.transaction.payment_instrument_subtype).to eq("Visa")
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
it "converts status_history hash into an array of Dispute::StatusHistory objects" do
|
|
372
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
373
|
+
|
|
374
|
+
expect(dispute.status_history.length).to eq(1)
|
|
375
|
+
status_history_1 = dispute.status_history.first
|
|
376
|
+
expect(status_history_1.status).to eq(Braintree::Dispute::Status::Open)
|
|
377
|
+
expect(status_history_1.timestamp).to eq(Time.utc(2009, 3, 9, 10, 50, 39))
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
it "converts evidence hash into an array of Dispute::Evidence objects" do
|
|
381
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
382
|
+
|
|
383
|
+
expect(dispute.evidence.length).to eq(2)
|
|
384
|
+
evidence1 = dispute.evidence.first
|
|
385
|
+
expect(evidence1.comment).to eq(nil)
|
|
386
|
+
expect(evidence1.created_at).to eq(Time.utc(2009, 3, 10, 12, 5, 20))
|
|
387
|
+
expect(evidence1.id).to eq("evidence1")
|
|
388
|
+
expect(evidence1.sent_to_processor_at).to eq(nil)
|
|
389
|
+
expect(evidence1.url).to eq("url_of_file_evidence")
|
|
390
|
+
|
|
391
|
+
evidence2 = dispute.evidence.last
|
|
392
|
+
expect(evidence2.comment).to eq("text evidence")
|
|
393
|
+
expect(evidence2.created_at).to eq(Time.utc(2009, 3, 10, 12, 5, 21))
|
|
394
|
+
expect(evidence2.id).to eq("evidence2")
|
|
395
|
+
expect(evidence2.sent_to_processor_at).to eq(Date.new(2009, 3, 13))
|
|
396
|
+
expect(evidence2.url).to eq(nil)
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
it "converts paypal_messages hash into an array of Dispute::PayPalMessage objects" do
|
|
400
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
401
|
+
|
|
402
|
+
expect(dispute.paypal_messages.length).to eq(1)
|
|
403
|
+
paypal_message_1 = dispute.paypal_messages.first
|
|
404
|
+
expect(paypal_message_1.message).to eq("message")
|
|
405
|
+
expect(paypal_message_1.sender).to eq("seller")
|
|
406
|
+
expect(paypal_message_1.sent_at).to eq(Time.utc(2009, 3, 9, 10, 50, 39))
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
it "handles nil evidence" do
|
|
410
|
+
attributes.delete(:evidence)
|
|
411
|
+
|
|
412
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
413
|
+
|
|
414
|
+
expect(dispute.evidence).to eq(nil)
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
it "handles nil paypal_messages" do
|
|
418
|
+
attributes.delete(:paypal_messages)
|
|
419
|
+
|
|
420
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
421
|
+
|
|
422
|
+
expect(dispute.paypal_messages).to eq(nil)
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
it "sets the older webhook fields for backwards compatibility" do
|
|
426
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
427
|
+
|
|
428
|
+
expect(dispute.amount).to eq(31.00)
|
|
429
|
+
expect(dispute.date_opened).to eq(Date.new(2009, 3, 9))
|
|
430
|
+
expect(dispute.date_won).to eq(Date.new(2009, 4, 15))
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
it "returns pre_dispute_program value" do
|
|
434
|
+
attributes.merge!(:pre_dispute_program => Braintree::Dispute::PreDisputeProgram::VisaRdr)
|
|
435
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
436
|
+
|
|
437
|
+
expect(dispute.pre_dispute_program).to eq(Braintree::Dispute::PreDisputeProgram::VisaRdr)
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
describe "==" do
|
|
442
|
+
it "returns true when given a dispute with the same id" do
|
|
443
|
+
first = Braintree::Dispute._new(attributes)
|
|
444
|
+
second = Braintree::Dispute._new(attributes)
|
|
445
|
+
|
|
446
|
+
expect(first).to eq(second)
|
|
447
|
+
expect(second).to eq(first)
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
it "returns false when given a dispute with a different id" do
|
|
451
|
+
first = Braintree::Dispute._new(attributes)
|
|
452
|
+
second = Braintree::Dispute._new(attributes.merge(:id => "1234"))
|
|
453
|
+
|
|
454
|
+
expect(first).not_to eq(second)
|
|
455
|
+
expect(second).not_to eq(first)
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
it "returns false when not given a dispute" do
|
|
459
|
+
dispute = Braintree::Dispute._new(attributes)
|
|
460
|
+
expect(dispute).not_to eq("not a dispute")
|
|
461
|
+
end
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
describe "comments" do
|
|
465
|
+
let(:dispute) { Braintree::Dispute._new(attributes) }
|
|
466
|
+
|
|
467
|
+
it "#processor_comments" do
|
|
468
|
+
expect(dispute.processor_comments).to eq(attributes[:processor_comments])
|
|
469
|
+
end
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
describe "new" do
|
|
473
|
+
it "is protected" do
|
|
474
|
+
expect do
|
|
475
|
+
Braintree::Dispute.new
|
|
476
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
|
477
|
+
end
|
|
478
|
+
end
|
|
479
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::DocumentUpload do
|
|
4
|
+
describe "initialize" do
|
|
5
|
+
it "sets attributes" do
|
|
6
|
+
response = {:size => 555, :kind => "evidence_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
|
|
7
|
+
document_upload = Braintree::DocumentUpload._new(response)
|
|
8
|
+
expect(document_upload.id).to eq("my_id")
|
|
9
|
+
expect(document_upload.size).to eq(555)
|
|
10
|
+
expect(document_upload.name).to eq("up_file.pdf")
|
|
11
|
+
expect(document_upload.content_type).to eq("application/pdf")
|
|
12
|
+
expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::EvidenceDocument)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "kind" do
|
|
17
|
+
it "sets identity document" do
|
|
18
|
+
response = {:size => 555, :kind => "identity_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
|
|
19
|
+
document_upload = Braintree::DocumentUpload._new(response)
|
|
20
|
+
expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::IdentityDocument)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "sets evidence document" do
|
|
24
|
+
response = {:size => 555, :kind => "evidence_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
|
|
25
|
+
document_upload = Braintree::DocumentUpload._new(response)
|
|
26
|
+
expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::EvidenceDocument)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "sets payout invoice document" do
|
|
30
|
+
response = {:size => 555, :kind => "payout_invoice_document", :name => "up_file.pdf", :content_type => "application/pdf", :id => "my_id"}
|
|
31
|
+
document_upload = Braintree::DocumentUpload._new(response)
|
|
32
|
+
expect(document_upload.kind).to eq(Braintree::DocumentUpload::Kind::PayoutInvoiceDocument)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::EnrichedCustomerData do
|
|
4
|
+
describe "self.new" do
|
|
5
|
+
it "is protected" do
|
|
6
|
+
expect do
|
|
7
|
+
Braintree::EnrichedCustomerData.new
|
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "self._new" do
|
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
|
14
|
+
|
|
15
|
+
address = {
|
|
16
|
+
street_address: "a-street-address",
|
|
17
|
+
extended_address: "an-extended-address",
|
|
18
|
+
locality: "a-locality",
|
|
19
|
+
region: "a-region",
|
|
20
|
+
postal_code: "a-postal-code"
|
|
21
|
+
}
|
|
22
|
+
params = {
|
|
23
|
+
fields_updated: ["username"],
|
|
24
|
+
profile_data: {
|
|
25
|
+
username: "a-username",
|
|
26
|
+
first_name: "a-first-name",
|
|
27
|
+
last_name: "a-last-name",
|
|
28
|
+
phone_number: "a-phone-number",
|
|
29
|
+
email: "a-email",
|
|
30
|
+
billing_address: address,
|
|
31
|
+
shipping_address: address,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
payment_method_customer_data_updated = Braintree::EnrichedCustomerData._new(params)
|
|
36
|
+
|
|
37
|
+
expect(payment_method_customer_data_updated.profile_data).to be_a(Braintree::VenmoProfileData)
|
|
38
|
+
expect(payment_method_customer_data_updated.fields_updated).to eq(["username"])
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -5,12 +5,12 @@ describe Braintree::ErrorResult do
|
|
|
5
5
|
it "ignores data other than params, errors, and message" do
|
|
6
6
|
# so that we can add more data into the response in the future without breaking the client lib
|
|
7
7
|
expect do
|
|
8
|
-
|
|
8
|
+
Braintree::ErrorResult.new(
|
|
9
9
|
:gateway,
|
|
10
10
|
:params => "params",
|
|
11
11
|
:errors => {:errors => []},
|
|
12
12
|
:extra => "is ignored",
|
|
13
|
-
:message => "foo bar"
|
|
13
|
+
:message => "foo bar",
|
|
14
14
|
)
|
|
15
15
|
end.to_not raise_error
|
|
16
16
|
end
|
|
@@ -27,7 +27,7 @@ describe Braintree::ErrorResult do
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
result = Braintree::ErrorResult.new(:gateway, :params => "params", :errors => errors)
|
|
30
|
-
result.inspect.
|
|
30
|
+
expect(result.inspect).to eq("#<Braintree::ErrorResult params:{...} errors:<level1:[(code1) message], level1/level2:[(code2) message2]>>")
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "includes the credit_card_verification if there is one" do
|
|
@@ -36,9 +36,9 @@ describe Braintree::ErrorResult do
|
|
|
36
36
|
:params => "params",
|
|
37
37
|
:errors => {},
|
|
38
38
|
:verification => {},
|
|
39
|
-
:transaction => nil
|
|
39
|
+
:transaction => nil,
|
|
40
40
|
)
|
|
41
|
-
result.inspect.
|
|
41
|
+
expect(result.inspect).to include("credit_card_verification: #<Braintree::CreditCardVerification amount: ")
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "does not include the credit_card_verification if there isn't one" do
|
|
@@ -47,9 +47,9 @@ describe Braintree::ErrorResult do
|
|
|
47
47
|
:params => "params",
|
|
48
48
|
:errors => {},
|
|
49
49
|
:verification => nil,
|
|
50
|
-
:transaction => nil
|
|
50
|
+
:transaction => nil,
|
|
51
51
|
)
|
|
52
|
-
result.inspect.
|
|
52
|
+
expect(result.inspect).not_to include("credit_card_verification")
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it "includes the transaction if there is one" do
|
|
@@ -58,9 +58,9 @@ describe Braintree::ErrorResult do
|
|
|
58
58
|
:params => "params",
|
|
59
59
|
:errors => {},
|
|
60
60
|
:verification => nil,
|
|
61
|
-
:transaction => {}
|
|
61
|
+
:transaction => {},
|
|
62
62
|
)
|
|
63
|
-
result.inspect.
|
|
63
|
+
expect(result.inspect).to include("transaction: #<Braintree::Transaction id: ")
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "does not include the transaction if there isn't one" do
|
|
@@ -69,9 +69,9 @@ describe Braintree::ErrorResult do
|
|
|
69
69
|
:params => "params",
|
|
70
70
|
:errors => {},
|
|
71
71
|
:verification => nil,
|
|
72
|
-
:transaction => nil
|
|
72
|
+
:transaction => nil,
|
|
73
73
|
)
|
|
74
|
-
result.inspect.
|
|
74
|
+
expect(result.inspect).not_to include("transaction")
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
end
|