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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
|
2
3
|
|
|
3
4
|
describe Braintree::Transaction, "search" do
|
|
4
5
|
context "advanced" do
|
|
@@ -7,13 +8,14 @@ describe Braintree::Transaction, "search" do
|
|
|
7
8
|
search.billing_first_name.is "thisnameisnotreal"
|
|
8
9
|
end
|
|
9
10
|
|
|
10
|
-
collection.maximum_size.
|
|
11
|
+
expect(collection.maximum_size).to eq(0)
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
#Disabling test until we have more stable CI
|
|
15
|
+
xit "can search on text fields" do
|
|
16
|
+
first_name = "Tim_#{rand(10**10)}"
|
|
17
|
+
token = "creditcard_#{rand(10**10)}"
|
|
18
|
+
customer_id = "customer_#{rand(10**10)}"
|
|
17
19
|
|
|
18
20
|
transaction = Braintree::Transaction.sale!(
|
|
19
21
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
@@ -59,11 +61,12 @@ describe Braintree::Transaction, "search" do
|
|
|
59
61
|
:postal_code => "54321",
|
|
60
62
|
:region => "MA",
|
|
61
63
|
:street_address => "456 Road"
|
|
62
|
-
}
|
|
64
|
+
},
|
|
63
65
|
)
|
|
64
66
|
|
|
65
67
|
SpecHelper.settle_transaction transaction.id
|
|
66
68
|
transaction = Braintree::Transaction.find(transaction.id)
|
|
69
|
+
credit_card = Braintree::CreditCard.find(token)
|
|
67
70
|
|
|
68
71
|
search_criteria = {
|
|
69
72
|
:billing_company => "Braintree",
|
|
@@ -78,6 +81,7 @@ describe Braintree::Transaction, "search" do
|
|
|
78
81
|
:credit_card_cardholder_name => "Tom Smith",
|
|
79
82
|
:credit_card_expiration_date => "05/2012",
|
|
80
83
|
:credit_card_number => Braintree::Test::CreditCardNumbers::Visa,
|
|
84
|
+
:credit_card_unique_identifier => credit_card.unique_number_identifier,
|
|
81
85
|
:customer_company => "Braintree",
|
|
82
86
|
:customer_email => "smith@example.com",
|
|
83
87
|
:customer_fax => "5551231234",
|
|
@@ -106,14 +110,14 @@ describe Braintree::Transaction, "search" do
|
|
|
106
110
|
search.id.is transaction.id
|
|
107
111
|
search.send(criterion).is value
|
|
108
112
|
end
|
|
109
|
-
collection.maximum_size.
|
|
110
|
-
collection.first.id.
|
|
113
|
+
expect(collection.maximum_size).to eq(1)
|
|
114
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
111
115
|
|
|
112
116
|
collection = Braintree::Transaction.search do |search|
|
|
113
117
|
search.id.is transaction.id
|
|
114
118
|
search.send(criterion).is("invalid_attribute")
|
|
115
119
|
end
|
|
116
|
-
collection.
|
|
120
|
+
expect(collection).to be_empty
|
|
117
121
|
end
|
|
118
122
|
|
|
119
123
|
collection = Braintree::Transaction.search do |search|
|
|
@@ -123,8 +127,76 @@ describe Braintree::Transaction, "search" do
|
|
|
123
127
|
end
|
|
124
128
|
end
|
|
125
129
|
|
|
126
|
-
collection.maximum_size.
|
|
127
|
-
collection.first.id.
|
|
130
|
+
expect(collection.maximum_size).to eq(1)
|
|
131
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
#Disabling test until we have more stable CI
|
|
135
|
+
xit "searches on users" do
|
|
136
|
+
transaction = Braintree::Transaction.sale!(
|
|
137
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
138
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
collection = Braintree::Transaction.search do |search|
|
|
142
|
+
search.user.is "integration_user_public_id"
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
expect(collection.any? { |t| t.id == transaction.id }).to eq(true)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it "searches on paypal transactions" do
|
|
149
|
+
transaction = Braintree::Transaction.sale!(
|
|
150
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
151
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
paypal_details = transaction.paypal_details
|
|
155
|
+
|
|
156
|
+
collection = Braintree::Transaction.search do |search|
|
|
157
|
+
search.paypal_payment_id.is paypal_details.payment_id
|
|
158
|
+
search.paypal_authorization_id.is paypal_details.authorization_id
|
|
159
|
+
search.paypal_payer_email.is paypal_details.payer_email
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
expect(collection.maximum_size).to eq(1)
|
|
163
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it "searches on store_id" do
|
|
167
|
+
transaction_id = "contact_visa_transaction"
|
|
168
|
+
store_id = "store-id"
|
|
169
|
+
|
|
170
|
+
collection = Braintree::Transaction.search do |search|
|
|
171
|
+
search.id.is transaction_id
|
|
172
|
+
search.store_ids.in store_id
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
expect(collection.maximum_size).to eq(1)
|
|
176
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it "searches on reason_code" do
|
|
180
|
+
transaction_id = "ach_txn_ret1"
|
|
181
|
+
reason_code = "R01"
|
|
182
|
+
|
|
183
|
+
collection = Braintree::Transaction.search do |search|
|
|
184
|
+
search.reason_code.in reason_code
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
expect(collection.maximum_size).to eq(1)
|
|
188
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
189
|
+
expect(collection.first.ach_return_responses.first[:reason_code]).to eq("R01")
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
it "searches on reason_codes" do
|
|
193
|
+
reason_code = "any_reason_code"
|
|
194
|
+
|
|
195
|
+
collection = Braintree::Transaction.search do |search|
|
|
196
|
+
search.reason_code.is reason_code
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
expect(collection.maximum_size).to eq(2)
|
|
128
200
|
end
|
|
129
201
|
|
|
130
202
|
context "multiple value fields" do
|
|
@@ -134,7 +206,7 @@ describe Braintree::Transaction, "search" do
|
|
|
134
206
|
:credit_card => {
|
|
135
207
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
136
208
|
:expiration_date => "05/12"
|
|
137
|
-
}
|
|
209
|
+
},
|
|
138
210
|
)
|
|
139
211
|
|
|
140
212
|
collection = Braintree::Transaction.search do |search|
|
|
@@ -142,21 +214,21 @@ describe Braintree::Transaction, "search" do
|
|
|
142
214
|
search.created_using.is Braintree::Transaction::CreatedUsing::FullInformation
|
|
143
215
|
end
|
|
144
216
|
|
|
145
|
-
collection.maximum_size.
|
|
217
|
+
expect(collection.maximum_size).to eq(1)
|
|
146
218
|
|
|
147
219
|
collection = Braintree::Transaction.search do |search|
|
|
148
220
|
search.id.is transaction.id
|
|
149
221
|
search.created_using.in Braintree::Transaction::CreatedUsing::FullInformation, Braintree::Transaction::CreatedUsing::Token
|
|
150
222
|
end
|
|
151
223
|
|
|
152
|
-
collection.maximum_size.
|
|
224
|
+
expect(collection.maximum_size).to eq(1)
|
|
153
225
|
|
|
154
226
|
collection = Braintree::Transaction.search do |search|
|
|
155
227
|
search.id.is transaction.id
|
|
156
228
|
search.created_using.is Braintree::Transaction::CreatedUsing::Token
|
|
157
229
|
end
|
|
158
230
|
|
|
159
|
-
collection.maximum_size.
|
|
231
|
+
expect(collection.maximum_size).to eq(0)
|
|
160
232
|
end
|
|
161
233
|
|
|
162
234
|
it "searches on credit_card_customer_location" do
|
|
@@ -165,7 +237,7 @@ describe Braintree::Transaction, "search" do
|
|
|
165
237
|
:credit_card => {
|
|
166
238
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
167
239
|
:expiration_date => "05/12"
|
|
168
|
-
}
|
|
240
|
+
},
|
|
169
241
|
)
|
|
170
242
|
|
|
171
243
|
collection = Braintree::Transaction.search do |search|
|
|
@@ -173,21 +245,21 @@ describe Braintree::Transaction, "search" do
|
|
|
173
245
|
search.credit_card_customer_location.is Braintree::CreditCard::CustomerLocation::US
|
|
174
246
|
end
|
|
175
247
|
|
|
176
|
-
collection.maximum_size.
|
|
248
|
+
expect(collection.maximum_size).to eq(1)
|
|
177
249
|
|
|
178
250
|
collection = Braintree::Transaction.search do |search|
|
|
179
251
|
search.id.is transaction.id
|
|
180
252
|
search.credit_card_customer_location.in Braintree::CreditCard::CustomerLocation::US, Braintree::CreditCard::CustomerLocation::International
|
|
181
253
|
end
|
|
182
254
|
|
|
183
|
-
collection.maximum_size.
|
|
255
|
+
expect(collection.maximum_size).to eq(1)
|
|
184
256
|
|
|
185
257
|
collection = Braintree::Transaction.search do |search|
|
|
186
258
|
search.id.is transaction.id
|
|
187
259
|
search.credit_card_customer_location.is Braintree::CreditCard::CustomerLocation::International
|
|
188
260
|
end
|
|
189
261
|
|
|
190
|
-
collection.maximum_size.
|
|
262
|
+
expect(collection.maximum_size).to eq(0)
|
|
191
263
|
end
|
|
192
264
|
|
|
193
265
|
it "searches on merchant_account_id" do
|
|
@@ -196,7 +268,7 @@ describe Braintree::Transaction, "search" do
|
|
|
196
268
|
:credit_card => {
|
|
197
269
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
198
270
|
:expiration_date => "05/12"
|
|
199
|
-
}
|
|
271
|
+
},
|
|
200
272
|
)
|
|
201
273
|
|
|
202
274
|
collection = Braintree::Transaction.search do |search|
|
|
@@ -204,21 +276,21 @@ describe Braintree::Transaction, "search" do
|
|
|
204
276
|
search.merchant_account_id.is transaction.merchant_account_id
|
|
205
277
|
end
|
|
206
278
|
|
|
207
|
-
collection.maximum_size.
|
|
279
|
+
expect(collection.maximum_size).to eq(1)
|
|
208
280
|
|
|
209
281
|
collection = Braintree::Transaction.search do |search|
|
|
210
282
|
search.id.is transaction.id
|
|
211
283
|
search.merchant_account_id.in transaction.merchant_account_id, "bogus_merchant_account_id"
|
|
212
284
|
end
|
|
213
285
|
|
|
214
|
-
collection.maximum_size.
|
|
286
|
+
expect(collection.maximum_size).to eq(1)
|
|
215
287
|
|
|
216
288
|
collection = Braintree::Transaction.search do |search|
|
|
217
289
|
search.id.is transaction.id
|
|
218
290
|
search.merchant_account_id.is "bogus_merchant_account_id"
|
|
219
291
|
end
|
|
220
292
|
|
|
221
|
-
collection.maximum_size.
|
|
293
|
+
expect(collection.maximum_size).to eq(0)
|
|
222
294
|
end
|
|
223
295
|
|
|
224
296
|
it "searches on credit_card_card_type" do
|
|
@@ -227,7 +299,7 @@ describe Braintree::Transaction, "search" do
|
|
|
227
299
|
:credit_card => {
|
|
228
300
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
229
301
|
:expiration_date => "05/12"
|
|
230
|
-
}
|
|
302
|
+
},
|
|
231
303
|
)
|
|
232
304
|
|
|
233
305
|
collection = Braintree::Transaction.search do |search|
|
|
@@ -235,28 +307,142 @@ describe Braintree::Transaction, "search" do
|
|
|
235
307
|
search.credit_card_card_type.is Braintree::CreditCard::CardType::Visa
|
|
236
308
|
end
|
|
237
309
|
|
|
238
|
-
collection.maximum_size.
|
|
310
|
+
expect(collection.maximum_size).to eq(1)
|
|
239
311
|
|
|
240
312
|
collection = Braintree::Transaction.search do |search|
|
|
241
313
|
search.id.is transaction.id
|
|
242
314
|
search.credit_card_card_type.is transaction.credit_card_details.card_type
|
|
243
315
|
end
|
|
244
316
|
|
|
245
|
-
collection.maximum_size.
|
|
317
|
+
expect(collection.maximum_size).to eq(1)
|
|
246
318
|
|
|
247
319
|
collection = Braintree::Transaction.search do |search|
|
|
248
320
|
search.id.is transaction.id
|
|
249
321
|
search.credit_card_card_type.in Braintree::CreditCard::CardType::Visa, Braintree::CreditCard::CardType::MasterCard
|
|
250
322
|
end
|
|
251
323
|
|
|
252
|
-
collection.maximum_size.
|
|
324
|
+
expect(collection.maximum_size).to eq(1)
|
|
253
325
|
|
|
254
326
|
collection = Braintree::Transaction.search do |search|
|
|
255
327
|
search.id.is transaction.id
|
|
256
328
|
search.credit_card_card_type.is Braintree::CreditCard::CardType::MasterCard
|
|
257
329
|
end
|
|
258
330
|
|
|
259
|
-
collection.maximum_size.
|
|
331
|
+
expect(collection.maximum_size).to eq(0)
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
it "searches for an Elo card" do
|
|
335
|
+
transaction = Braintree::Transaction.sale!(
|
|
336
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
337
|
+
:merchant_account_id => SpecHelper::AdyenMerchantAccountId,
|
|
338
|
+
:credit_card => {
|
|
339
|
+
:number => Braintree::Test::CreditCardNumbers::Elo,
|
|
340
|
+
:cvv => "737",
|
|
341
|
+
:expiration_date => "10/2020"
|
|
342
|
+
},
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
collection = Braintree::Transaction.search do |search|
|
|
346
|
+
search.id.is transaction.id
|
|
347
|
+
search.credit_card_card_type.is Braintree::CreditCard::CardType::Elo
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
expect(collection.maximum_size).to eq(1)
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
it "searches by payment instrument type CreditCardDetail" do
|
|
354
|
+
transaction = Braintree::Transaction.sale!(
|
|
355
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
356
|
+
:credit_card => {
|
|
357
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
358
|
+
:expiration_date => "05/12"
|
|
359
|
+
},
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
collection = Braintree::Transaction.search do |search|
|
|
363
|
+
search.id.is transaction.id
|
|
364
|
+
search.payment_instrument_type.in ["CreditCardDetail"]
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
368
|
+
expect(collection.first.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::CreditCard)
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
it "searches by payment instrument type PayPal" do
|
|
372
|
+
transaction = Braintree::Transaction.sale!(
|
|
373
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
374
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
collection = Braintree::Transaction.search do |search|
|
|
378
|
+
search.id.is transaction.id
|
|
379
|
+
search.payment_instrument_type.in ["PayPalDetail"]
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
383
|
+
expect(collection.first.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::PayPalAccount)
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
it "searches by payment instrument type LocalPaymentDetail" do
|
|
387
|
+
transaction = Braintree::Transaction.sale!(
|
|
388
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
389
|
+
:payment_method_nonce => Braintree::Test::Nonce::LocalPayment,
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
collection = Braintree::Transaction.search do |search|
|
|
393
|
+
search.id.is transaction.id
|
|
394
|
+
search.payment_instrument_type.in ["LocalPaymentDetail"]
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
398
|
+
expect(collection.first.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::LocalPayment)
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
it "searches by payment instrument type SepaDebitAccountDetail" do
|
|
402
|
+
transaction = Braintree::Transaction.sale!(
|
|
403
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
404
|
+
:payment_method_nonce => Braintree::Test::Nonce::SepaDirectDebit,
|
|
405
|
+
:options => {:submit_for_settlement => true},
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
collection = Braintree::Transaction.search do |search|
|
|
409
|
+
search.id.is transaction.id
|
|
410
|
+
search.payment_instrument_type.in ["SEPADebitAccountDetail"]
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
414
|
+
expect(collection.first.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::SepaDirectDebitAccount)
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
it "searches by paypal_v2_order_id" do
|
|
418
|
+
transaction = Braintree::Transaction.sale!(
|
|
419
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
420
|
+
:payment_method_nonce => Braintree::Test::Nonce::SepaDirectDebit,
|
|
421
|
+
:options => {:submit_for_settlement => true},
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
collection = Braintree::Transaction.search do |search|
|
|
425
|
+
search.id.is transaction.id
|
|
426
|
+
search.sepa_debit_paypal_v2_order_id.is transaction.sepa_direct_debit_account_details.paypal_v2_order_id
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
430
|
+
expect(collection.first.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::SepaDirectDebitAccount)
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
it "searches by payment instrument type ApplePay" do
|
|
434
|
+
transaction = Braintree::Transaction.sale!(
|
|
435
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
436
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
|
|
437
|
+
)
|
|
438
|
+
|
|
439
|
+
collection = Braintree::Transaction.search do |search|
|
|
440
|
+
search.id.is transaction.id
|
|
441
|
+
search.payment_instrument_type.in ["ApplePayDetail"]
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
445
|
+
expect(collection.first.payment_instrument_type).to eq(Braintree::PaymentInstrumentType::ApplePayCard)
|
|
260
446
|
end
|
|
261
447
|
|
|
262
448
|
it "searches on status" do
|
|
@@ -265,7 +451,7 @@ describe Braintree::Transaction, "search" do
|
|
|
265
451
|
:credit_card => {
|
|
266
452
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
267
453
|
:expiration_date => "05/12"
|
|
268
|
-
}
|
|
454
|
+
},
|
|
269
455
|
)
|
|
270
456
|
|
|
271
457
|
collection = Braintree::Transaction.search do |search|
|
|
@@ -273,21 +459,32 @@ describe Braintree::Transaction, "search" do
|
|
|
273
459
|
search.status.is Braintree::Transaction::Status::Authorized
|
|
274
460
|
end
|
|
275
461
|
|
|
276
|
-
collection.maximum_size.
|
|
462
|
+
expect(collection.maximum_size).to eq(1)
|
|
277
463
|
|
|
278
464
|
collection = Braintree::Transaction.search do |search|
|
|
279
465
|
search.id.is transaction.id
|
|
280
466
|
search.status.in Braintree::Transaction::Status::Authorized, Braintree::Transaction::Status::ProcessorDeclined
|
|
281
467
|
end
|
|
282
468
|
|
|
283
|
-
collection.maximum_size.
|
|
469
|
+
expect(collection.maximum_size).to eq(1)
|
|
284
470
|
|
|
285
471
|
collection = Braintree::Transaction.search do |search|
|
|
286
472
|
search.id.is transaction.id
|
|
287
473
|
search.status.is Braintree::Transaction::Status::ProcessorDeclined
|
|
288
474
|
end
|
|
289
475
|
|
|
290
|
-
collection.maximum_size.
|
|
476
|
+
expect(collection.maximum_size).to eq(0)
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
it "searches for settlement_confirmed transaction" do
|
|
480
|
+
transaction_id = "settlement_confirmed_txn"
|
|
481
|
+
|
|
482
|
+
collection = Braintree::Transaction.search do |search|
|
|
483
|
+
search.id.is transaction_id
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
expect(collection.maximum_size).to eq(1)
|
|
487
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
291
488
|
end
|
|
292
489
|
|
|
293
490
|
it "finds expired authorizations by status" do
|
|
@@ -295,8 +492,8 @@ describe Braintree::Transaction, "search" do
|
|
|
295
492
|
search.status.in Braintree::Transaction::Status::AuthorizationExpired
|
|
296
493
|
end
|
|
297
494
|
|
|
298
|
-
collection.maximum_size.
|
|
299
|
-
collection.first.status.
|
|
495
|
+
expect(collection.maximum_size).to be > 0
|
|
496
|
+
expect(collection.first.status).to eq(Braintree::Transaction::Status::AuthorizationExpired)
|
|
300
497
|
end
|
|
301
498
|
|
|
302
499
|
it "searches on source" do
|
|
@@ -305,7 +502,7 @@ describe Braintree::Transaction, "search" do
|
|
|
305
502
|
:credit_card => {
|
|
306
503
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
307
504
|
:expiration_date => "05/12"
|
|
308
|
-
}
|
|
505
|
+
},
|
|
309
506
|
)
|
|
310
507
|
|
|
311
508
|
collection = Braintree::Transaction.search do |search|
|
|
@@ -313,21 +510,21 @@ describe Braintree::Transaction, "search" do
|
|
|
313
510
|
search.source.is Braintree::Transaction::Source::Api
|
|
314
511
|
end
|
|
315
512
|
|
|
316
|
-
collection.maximum_size.
|
|
513
|
+
expect(collection.maximum_size).to eq(1)
|
|
317
514
|
|
|
318
515
|
collection = Braintree::Transaction.search do |search|
|
|
319
516
|
search.id.is transaction.id
|
|
320
517
|
search.source.in Braintree::Transaction::Source::Api, Braintree::Transaction::Source::ControlPanel
|
|
321
518
|
end
|
|
322
519
|
|
|
323
|
-
collection.maximum_size.
|
|
520
|
+
expect(collection.maximum_size).to eq(1)
|
|
324
521
|
|
|
325
522
|
collection = Braintree::Transaction.search do |search|
|
|
326
523
|
search.id.is transaction.id
|
|
327
524
|
search.source.is Braintree::Transaction::Source::ControlPanel
|
|
328
525
|
end
|
|
329
526
|
|
|
330
|
-
collection.maximum_size.
|
|
527
|
+
expect(collection.maximum_size).to eq(0)
|
|
331
528
|
end
|
|
332
529
|
|
|
333
530
|
it "searches on type" do
|
|
@@ -338,7 +535,7 @@ describe Braintree::Transaction, "search" do
|
|
|
338
535
|
:cardholder_name => cardholder_name,
|
|
339
536
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
340
537
|
:expiration_date => "05/12"
|
|
341
|
-
}
|
|
538
|
+
},
|
|
342
539
|
)
|
|
343
540
|
|
|
344
541
|
transaction = Braintree::Transaction.sale!(
|
|
@@ -348,18 +545,18 @@ describe Braintree::Transaction, "search" do
|
|
|
348
545
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
349
546
|
:expiration_date => "05/12"
|
|
350
547
|
},
|
|
351
|
-
:options => {
|
|
548
|
+
:options => {:submit_for_settlement => true},
|
|
352
549
|
)
|
|
353
550
|
SpecHelper.settle_transaction transaction.id
|
|
354
551
|
|
|
355
|
-
refund_transaction =
|
|
552
|
+
refund_transaction = Braintree::Transaction.refund(transaction.id).transaction
|
|
356
553
|
|
|
357
554
|
collection = Braintree::Transaction.search do |search|
|
|
358
555
|
search.credit_card_cardholder_name.is cardholder_name
|
|
359
556
|
search.type.is Braintree::Transaction::Type::Credit
|
|
360
557
|
end
|
|
361
558
|
|
|
362
|
-
collection.maximum_size.
|
|
559
|
+
expect(collection.maximum_size).to eq(2)
|
|
363
560
|
|
|
364
561
|
collection = Braintree::Transaction.search do |search|
|
|
365
562
|
search.credit_card_cardholder_name.is cardholder_name
|
|
@@ -367,8 +564,8 @@ describe Braintree::Transaction, "search" do
|
|
|
367
564
|
search.refund.is true
|
|
368
565
|
end
|
|
369
566
|
|
|
370
|
-
collection.maximum_size.
|
|
371
|
-
collection.first.id.
|
|
567
|
+
expect(collection.maximum_size).to eq(1)
|
|
568
|
+
expect(collection.first.id).to eq(refund_transaction.id)
|
|
372
569
|
|
|
373
570
|
collection = Braintree::Transaction.search do |search|
|
|
374
571
|
search.credit_card_cardholder_name.is cardholder_name
|
|
@@ -376,8 +573,88 @@ describe Braintree::Transaction, "search" do
|
|
|
376
573
|
search.refund.is false
|
|
377
574
|
end
|
|
378
575
|
|
|
379
|
-
collection.maximum_size.
|
|
380
|
-
collection.first.id.
|
|
576
|
+
expect(collection.maximum_size).to eq(1)
|
|
577
|
+
expect(collection.first.id).to eq(credit_transaction.id)
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
it "searches on store_ids" do
|
|
581
|
+
transaction_id = "contact_visa_transaction"
|
|
582
|
+
store_ids = ["store-id"]
|
|
583
|
+
|
|
584
|
+
collection = Braintree::Transaction.search do |search|
|
|
585
|
+
search.id.is transaction_id
|
|
586
|
+
search.store_ids.in store_ids
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
expect(collection.maximum_size).to eq(1)
|
|
590
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
591
|
+
end
|
|
592
|
+
|
|
593
|
+
it "searches on reason_codes for 2 items" do
|
|
594
|
+
reason_code = ["R01", "R02"]
|
|
595
|
+
|
|
596
|
+
collection = Braintree::Transaction.search do |search|
|
|
597
|
+
search.reason_code.in reason_code
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
expect(collection.maximum_size).to eq(2)
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
it "searches on a reason_code" do
|
|
604
|
+
reason_code = ["R01"]
|
|
605
|
+
transaction_id = "ach_txn_ret1"
|
|
606
|
+
|
|
607
|
+
collection = Braintree::Transaction.search do |search|
|
|
608
|
+
search.reason_code.in reason_code
|
|
609
|
+
end
|
|
610
|
+
|
|
611
|
+
expect(collection.maximum_size).to eq(1)
|
|
612
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
xit "searches on debit_network" do
|
|
616
|
+
transaction = Braintree::Transaction.sale!(
|
|
617
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
618
|
+
:merchant_account_id => SpecHelper::PinlessDebitMerchantAccountId,
|
|
619
|
+
:currency_iso_code => "USD",
|
|
620
|
+
:payment_method_nonce => Braintree::Test::Nonce::TransactablePinlessDebitVisa,
|
|
621
|
+
:options => {
|
|
622
|
+
:submit_for_settlement => true
|
|
623
|
+
},
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
collection = Braintree::Transaction.search do |search|
|
|
627
|
+
search.id.is transaction.id
|
|
628
|
+
search.credit_card_card_type.is Braintree::CreditCard::CardType::Visa
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
expect(collection.maximum_size).to be > 0
|
|
632
|
+
|
|
633
|
+
collection = Braintree::Transaction.search do |search|
|
|
634
|
+
search.id.is transaction.id
|
|
635
|
+
search.debit_network.in Braintree::CreditCard::DebitNetwork::All
|
|
636
|
+
end
|
|
637
|
+
|
|
638
|
+
expect(collection.maximum_size).to be > 0
|
|
639
|
+
end
|
|
640
|
+
end
|
|
641
|
+
|
|
642
|
+
context "invalid search" do
|
|
643
|
+
it "raises an exception on invalid transaction type" do
|
|
644
|
+
expect do
|
|
645
|
+
Braintree::Transaction.search do |search|
|
|
646
|
+
search.customer_id.is "9171566"
|
|
647
|
+
search.type.is "settled"
|
|
648
|
+
end
|
|
649
|
+
end.to raise_error(ArgumentError)
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
it "raises an exception on invalid debit network" do
|
|
653
|
+
expect do
|
|
654
|
+
Braintree::Transaction.search do |search|
|
|
655
|
+
search.debit_network.is "invalid_network"
|
|
656
|
+
end
|
|
657
|
+
end.to raise_error(ArgumentError)
|
|
381
658
|
end
|
|
382
659
|
end
|
|
383
660
|
|
|
@@ -389,7 +666,7 @@ describe Braintree::Transaction, "search" do
|
|
|
389
666
|
:credit_card => {
|
|
390
667
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
391
668
|
:expiration_date => "05/12"
|
|
392
|
-
}
|
|
669
|
+
},
|
|
393
670
|
)
|
|
394
671
|
|
|
395
672
|
collection = Braintree::Transaction.search do |search|
|
|
@@ -397,48 +674,48 @@ describe Braintree::Transaction, "search" do
|
|
|
397
674
|
search.amount.between "500.00", "1500.00"
|
|
398
675
|
end
|
|
399
676
|
|
|
400
|
-
collection.maximum_size.
|
|
401
|
-
collection.first.id.
|
|
677
|
+
expect(collection.maximum_size).to eq(1)
|
|
678
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
402
679
|
|
|
403
680
|
collection = Braintree::Transaction.search do |search|
|
|
404
681
|
search.id.is transaction.id
|
|
405
682
|
search.amount >= "500.00"
|
|
406
683
|
end
|
|
407
684
|
|
|
408
|
-
collection.maximum_size.
|
|
409
|
-
collection.first.id.
|
|
685
|
+
expect(collection.maximum_size).to eq(1)
|
|
686
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
410
687
|
|
|
411
688
|
collection = Braintree::Transaction.search do |search|
|
|
412
689
|
search.id.is transaction.id
|
|
413
690
|
search.amount <= "1500.00"
|
|
414
691
|
end
|
|
415
692
|
|
|
416
|
-
collection.maximum_size.
|
|
417
|
-
collection.first.id.
|
|
693
|
+
expect(collection.maximum_size).to eq(1)
|
|
694
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
418
695
|
|
|
419
696
|
collection = Braintree::Transaction.search do |search|
|
|
420
697
|
search.id.is transaction.id
|
|
421
698
|
search.amount.between "500.00", "900.00"
|
|
422
699
|
end
|
|
423
700
|
|
|
424
|
-
collection.maximum_size.
|
|
701
|
+
expect(collection.maximum_size).to eq(0)
|
|
425
702
|
end
|
|
426
703
|
|
|
427
704
|
it "can also take BigDecimal for amount" do
|
|
428
705
|
transaction = Braintree::Transaction.sale!(
|
|
429
|
-
:amount => BigDecimal
|
|
706
|
+
:amount => BigDecimal("1000.00"),
|
|
430
707
|
:credit_card => {
|
|
431
708
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
432
709
|
:expiration_date => "05/12"
|
|
433
|
-
}
|
|
710
|
+
},
|
|
434
711
|
)
|
|
435
712
|
|
|
436
713
|
collection = Braintree::Transaction.search do |search|
|
|
437
714
|
search.id.is transaction.id
|
|
438
|
-
search.amount <= BigDecimal
|
|
715
|
+
search.amount <= BigDecimal("1000.00")
|
|
439
716
|
end
|
|
440
717
|
|
|
441
|
-
collection.maximum_size.
|
|
718
|
+
expect(collection.maximum_size).to eq(1)
|
|
442
719
|
end
|
|
443
720
|
end
|
|
444
721
|
|
|
@@ -449,56 +726,56 @@ describe Braintree::Transaction, "search" do
|
|
|
449
726
|
:credit_card => {
|
|
450
727
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
451
728
|
:expiration_date => "05/12"
|
|
452
|
-
}
|
|
729
|
+
},
|
|
453
730
|
)
|
|
454
731
|
|
|
455
732
|
created_at = transaction.created_at
|
|
456
|
-
created_at.
|
|
733
|
+
expect(created_at).to be_utc
|
|
457
734
|
|
|
458
735
|
collection = Braintree::Transaction.search do |search|
|
|
459
736
|
search.id.is transaction.id
|
|
460
737
|
search.created_at.between(
|
|
461
738
|
created_at - 60,
|
|
462
|
-
created_at + 60
|
|
739
|
+
created_at + 60,
|
|
463
740
|
)
|
|
464
741
|
end
|
|
465
742
|
|
|
466
|
-
collection.maximum_size.
|
|
467
|
-
collection.first.id.
|
|
743
|
+
expect(collection.maximum_size).to eq(1)
|
|
744
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
468
745
|
|
|
469
746
|
collection = Braintree::Transaction.search do |search|
|
|
470
747
|
search.id.is transaction.id
|
|
471
748
|
search.created_at >= created_at - 1
|
|
472
749
|
end
|
|
473
750
|
|
|
474
|
-
collection.maximum_size.
|
|
475
|
-
collection.first.id.
|
|
751
|
+
expect(collection.maximum_size).to eq(1)
|
|
752
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
476
753
|
|
|
477
754
|
collection = Braintree::Transaction.search do |search|
|
|
478
755
|
search.id.is transaction.id
|
|
479
756
|
search.created_at <= created_at + 1
|
|
480
757
|
end
|
|
481
758
|
|
|
482
|
-
collection.maximum_size.
|
|
483
|
-
collection.first.id.
|
|
759
|
+
expect(collection.maximum_size).to eq(1)
|
|
760
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
484
761
|
|
|
485
762
|
collection = Braintree::Transaction.search do |search|
|
|
486
763
|
search.id.is transaction.id
|
|
487
764
|
search.created_at.between(
|
|
488
765
|
created_at - 300,
|
|
489
|
-
created_at - 100
|
|
766
|
+
created_at - 100,
|
|
490
767
|
)
|
|
491
768
|
end
|
|
492
769
|
|
|
493
|
-
collection.maximum_size.
|
|
770
|
+
expect(collection.maximum_size).to eq(0)
|
|
494
771
|
|
|
495
772
|
collection = Braintree::Transaction.search do |search|
|
|
496
773
|
search.id.is transaction.id
|
|
497
774
|
search.created_at.is created_at
|
|
498
775
|
end
|
|
499
776
|
|
|
500
|
-
collection.maximum_size.
|
|
501
|
-
collection.first.id.
|
|
777
|
+
expect(collection.maximum_size).to eq(1)
|
|
778
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
502
779
|
end
|
|
503
780
|
|
|
504
781
|
it "searches on created_at in local time" do
|
|
@@ -507,7 +784,7 @@ describe Braintree::Transaction, "search" do
|
|
|
507
784
|
:credit_card => {
|
|
508
785
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
509
786
|
:expiration_date => "05/12"
|
|
510
|
-
}
|
|
787
|
+
},
|
|
511
788
|
)
|
|
512
789
|
|
|
513
790
|
now = Time.now
|
|
@@ -516,38 +793,38 @@ describe Braintree::Transaction, "search" do
|
|
|
516
793
|
search.id.is transaction.id
|
|
517
794
|
search.created_at.between(
|
|
518
795
|
now - 60,
|
|
519
|
-
now + 60
|
|
796
|
+
now + 60,
|
|
520
797
|
)
|
|
521
798
|
end
|
|
522
799
|
|
|
523
|
-
collection.maximum_size.
|
|
524
|
-
collection.first.id.
|
|
800
|
+
expect(collection.maximum_size).to eq(1)
|
|
801
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
525
802
|
|
|
526
803
|
collection = Braintree::Transaction.search do |search|
|
|
527
804
|
search.id.is transaction.id
|
|
528
805
|
search.created_at >= now - 60
|
|
529
806
|
end
|
|
530
807
|
|
|
531
|
-
collection.maximum_size.
|
|
532
|
-
collection.first.id.
|
|
808
|
+
expect(collection.maximum_size).to eq(1)
|
|
809
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
533
810
|
|
|
534
811
|
collection = Braintree::Transaction.search do |search|
|
|
535
812
|
search.id.is transaction.id
|
|
536
813
|
search.created_at <= now + 60
|
|
537
814
|
end
|
|
538
815
|
|
|
539
|
-
collection.maximum_size.
|
|
540
|
-
collection.first.id.
|
|
816
|
+
expect(collection.maximum_size).to eq(1)
|
|
817
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
541
818
|
|
|
542
819
|
collection = Braintree::Transaction.search do |search|
|
|
543
820
|
search.id.is transaction.id
|
|
544
821
|
search.created_at.between(
|
|
545
822
|
now - 300,
|
|
546
|
-
now - 100
|
|
823
|
+
now - 100,
|
|
547
824
|
)
|
|
548
825
|
end
|
|
549
826
|
|
|
550
|
-
collection.maximum_size.
|
|
827
|
+
expect(collection.maximum_size).to eq(0)
|
|
551
828
|
end
|
|
552
829
|
|
|
553
830
|
it "searches on created_at with dates" do
|
|
@@ -556,19 +833,255 @@ describe Braintree::Transaction, "search" do
|
|
|
556
833
|
:credit_card => {
|
|
557
834
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
558
835
|
:expiration_date => "05/12"
|
|
559
|
-
}
|
|
836
|
+
},
|
|
560
837
|
)
|
|
561
838
|
|
|
562
839
|
collection = Braintree::Transaction.search do |search|
|
|
563
840
|
search.id.is transaction.id
|
|
564
841
|
search.created_at.between(
|
|
565
842
|
Date.today - 1,
|
|
566
|
-
Date.today + 1
|
|
843
|
+
Date.today + 1,
|
|
844
|
+
)
|
|
845
|
+
end
|
|
846
|
+
|
|
847
|
+
expect(collection.maximum_size).to eq(1)
|
|
848
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
849
|
+
end
|
|
850
|
+
end
|
|
851
|
+
|
|
852
|
+
context "ach return response created at" do
|
|
853
|
+
it "it finds records within date range of the custom field" do
|
|
854
|
+
date_search = Braintree::Transaction.search do |search|
|
|
855
|
+
search.ach_return_responses_created_at.between(DateTime.now - 1.0, DateTime.now + 1.0)
|
|
856
|
+
end
|
|
857
|
+
|
|
858
|
+
expect(date_search.maximum_size).to eq(2)
|
|
859
|
+
end
|
|
860
|
+
|
|
861
|
+
it "it does not find records not within date range of the custom field" do
|
|
862
|
+
neg_date_search = Braintree::Transaction.search do |search|
|
|
863
|
+
search.ach_return_responses_created_at.between(DateTime.now + 1.0, DateTime.now - 1.0)
|
|
864
|
+
end
|
|
865
|
+
|
|
866
|
+
expect(neg_date_search.maximum_size).to eq(0)
|
|
867
|
+
end
|
|
868
|
+
end
|
|
869
|
+
|
|
870
|
+
context "disbursement_date" do
|
|
871
|
+
it "searches on disbursement_date in UTC, as a date" do
|
|
872
|
+
disbursement_time = Date.parse("2013-04-10")
|
|
873
|
+
transaction_id = "deposittransaction"
|
|
874
|
+
|
|
875
|
+
collection = Braintree::Transaction.search do |search|
|
|
876
|
+
search.id.is transaction_id
|
|
877
|
+
search.disbursement_date.between(
|
|
878
|
+
disbursement_time - 60,
|
|
879
|
+
disbursement_time + 60,
|
|
880
|
+
)
|
|
881
|
+
end
|
|
882
|
+
|
|
883
|
+
expect(collection.maximum_size).to eq(1)
|
|
884
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
885
|
+
|
|
886
|
+
collection = Braintree::Transaction.search do |search|
|
|
887
|
+
search.id.is transaction_id
|
|
888
|
+
search.disbursement_date >= disbursement_time - 1
|
|
889
|
+
end
|
|
890
|
+
|
|
891
|
+
expect(collection.maximum_size).to eq(1)
|
|
892
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
893
|
+
|
|
894
|
+
collection = Braintree::Transaction.search do |search|
|
|
895
|
+
search.id.is transaction_id
|
|
896
|
+
search.disbursement_date <= disbursement_time + 1
|
|
897
|
+
end
|
|
898
|
+
|
|
899
|
+
expect(collection.maximum_size).to eq(1)
|
|
900
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
901
|
+
|
|
902
|
+
collection = Braintree::Transaction.search do |search|
|
|
903
|
+
search.id.is transaction_id
|
|
904
|
+
search.disbursement_date.between(
|
|
905
|
+
disbursement_time - 300,
|
|
906
|
+
disbursement_time - 100,
|
|
907
|
+
)
|
|
908
|
+
end
|
|
909
|
+
|
|
910
|
+
expect(collection.maximum_size).to eq(0)
|
|
911
|
+
|
|
912
|
+
collection = Braintree::Transaction.search do |search|
|
|
913
|
+
search.id.is transaction_id
|
|
914
|
+
search.disbursement_date.is disbursement_time
|
|
915
|
+
end
|
|
916
|
+
|
|
917
|
+
expect(collection.maximum_size).to eq(1)
|
|
918
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
919
|
+
end
|
|
920
|
+
|
|
921
|
+
it "searches on disbursement_date in local time" do
|
|
922
|
+
now = Time.parse("2013-04-09 18:00:00 CST")
|
|
923
|
+
transaction_id = "deposittransaction"
|
|
924
|
+
|
|
925
|
+
collection = Braintree::Transaction.search do |search|
|
|
926
|
+
search.id.is transaction_id
|
|
927
|
+
search.disbursement_date.between(
|
|
928
|
+
now - 60,
|
|
929
|
+
now + 60,
|
|
930
|
+
)
|
|
931
|
+
end
|
|
932
|
+
|
|
933
|
+
expect(collection.maximum_size).to eq(1)
|
|
934
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
935
|
+
|
|
936
|
+
collection = Braintree::Transaction.search do |search|
|
|
937
|
+
search.id.is transaction_id
|
|
938
|
+
search.disbursement_date >= now - 60
|
|
939
|
+
end
|
|
940
|
+
|
|
941
|
+
expect(collection.maximum_size).to eq(1)
|
|
942
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
943
|
+
|
|
944
|
+
collection = Braintree::Transaction.search do |search|
|
|
945
|
+
search.id.is transaction_id
|
|
946
|
+
search.disbursement_date <= now + 60
|
|
947
|
+
end
|
|
948
|
+
|
|
949
|
+
expect(collection.maximum_size).to eq(1)
|
|
950
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
951
|
+
|
|
952
|
+
collection = Braintree::Transaction.search do |search|
|
|
953
|
+
search.id.is transaction_id
|
|
954
|
+
search.disbursement_date.between(
|
|
955
|
+
now - 300,
|
|
956
|
+
now - 100,
|
|
957
|
+
)
|
|
958
|
+
end
|
|
959
|
+
|
|
960
|
+
expect(collection.maximum_size).to eq(0)
|
|
961
|
+
end
|
|
962
|
+
|
|
963
|
+
it "searches on disbursement_date with date ranges" do
|
|
964
|
+
disbursement_date = Date.new(2013, 4, 10)
|
|
965
|
+
transaction_id = "deposittransaction"
|
|
966
|
+
|
|
967
|
+
collection = Braintree::Transaction.search do |search|
|
|
968
|
+
search.id.is transaction_id
|
|
969
|
+
search.disbursement_date.between(
|
|
970
|
+
disbursement_date - 1,
|
|
971
|
+
disbursement_date + 1,
|
|
972
|
+
)
|
|
973
|
+
end
|
|
974
|
+
|
|
975
|
+
expect(collection.maximum_size).to eq(1)
|
|
976
|
+
expect(collection.first.id).to eq(transaction_id)
|
|
977
|
+
end
|
|
978
|
+
end
|
|
979
|
+
|
|
980
|
+
context "dispute_date" do
|
|
981
|
+
before(:all) do
|
|
982
|
+
@disputed_transaction = Braintree::Transaction.sale!(
|
|
983
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
984
|
+
:credit_card => {
|
|
985
|
+
:number => Braintree::Test::CreditCardNumbers::Disputes::Chargeback,
|
|
986
|
+
:expiration_date => "03/18"
|
|
987
|
+
},
|
|
988
|
+
)
|
|
989
|
+
|
|
990
|
+
@disputed_date = @disputed_transaction.disputes.first.received_date
|
|
991
|
+
@disputed_time = @disputed_date.to_time
|
|
992
|
+
|
|
993
|
+
Timeout::timeout(60) {
|
|
994
|
+
dispute_date_indexed = false
|
|
995
|
+
until dispute_date_indexed
|
|
996
|
+
sleep 1
|
|
997
|
+
collection = Braintree::Transaction.search do |search|
|
|
998
|
+
search.id.is @disputed_transaction.id
|
|
999
|
+
search.dispute_date.is @disputed_date
|
|
1000
|
+
end
|
|
1001
|
+
|
|
1002
|
+
dispute_date_indexed = collection.maximum_size == 1
|
|
1003
|
+
end
|
|
1004
|
+
}
|
|
1005
|
+
end
|
|
1006
|
+
|
|
1007
|
+
xit "searches on dispute_date in UTC" do
|
|
1008
|
+
collection = Braintree::Transaction.search do |search|
|
|
1009
|
+
search.id.is @disputed_transaction.id
|
|
1010
|
+
search.dispute_date.between(
|
|
1011
|
+
@disputed_time - 60,
|
|
1012
|
+
@disputed_time + 60,
|
|
1013
|
+
)
|
|
1014
|
+
end
|
|
1015
|
+
|
|
1016
|
+
expect(collection.maximum_size).to eq(1)
|
|
1017
|
+
expect(collection.first.id).to eq(@disputed_transaction.id)
|
|
1018
|
+
|
|
1019
|
+
collection = Braintree::Transaction.search do |search|
|
|
1020
|
+
search.id.is @disputed_transaction.id
|
|
1021
|
+
search.dispute_date >= @disputed_time - 1
|
|
1022
|
+
end
|
|
1023
|
+
|
|
1024
|
+
expect(collection.maximum_size).to eq(1)
|
|
1025
|
+
expect(collection.first.id).to eq(@disputed_transaction.id)
|
|
1026
|
+
|
|
1027
|
+
collection = Braintree::Transaction.search do |search|
|
|
1028
|
+
search.id.is @disputed_transaction.id
|
|
1029
|
+
search.dispute_date <= @disputed_time + 1
|
|
1030
|
+
end
|
|
1031
|
+
|
|
1032
|
+
expect(collection.maximum_size).to eq(1)
|
|
1033
|
+
expect(collection.first.id).to eq(@disputed_transaction.id)
|
|
1034
|
+
|
|
1035
|
+
collection = Braintree::Transaction.search do |search|
|
|
1036
|
+
search.id.is @disputed_transaction.id
|
|
1037
|
+
search.dispute_date.is @disputed_time
|
|
1038
|
+
end
|
|
1039
|
+
|
|
1040
|
+
expect(collection.maximum_size).to eq(1)
|
|
1041
|
+
expect(collection.first.id).to eq(@disputed_transaction.id)
|
|
1042
|
+
end
|
|
1043
|
+
|
|
1044
|
+
xit "searches on dispute_date in local time" do
|
|
1045
|
+
now = @disputed_time.localtime("-06:00")
|
|
1046
|
+
|
|
1047
|
+
collection = Braintree::Transaction.search do |search|
|
|
1048
|
+
search.id.is @disputed_transaction.id
|
|
1049
|
+
search.dispute_date.between(
|
|
1050
|
+
now - 60,
|
|
1051
|
+
now + 60,
|
|
567
1052
|
)
|
|
568
1053
|
end
|
|
569
1054
|
|
|
570
|
-
collection.maximum_size.
|
|
571
|
-
collection.first.id.
|
|
1055
|
+
expect(collection.maximum_size).to eq(1)
|
|
1056
|
+
expect(collection.first.id).to eq(@disputed_transaction.id)
|
|
1057
|
+
|
|
1058
|
+
collection = Braintree::Transaction.search do |search|
|
|
1059
|
+
search.id.is @disputed_transaction.id
|
|
1060
|
+
search.dispute_date >= now - 60
|
|
1061
|
+
end
|
|
1062
|
+
|
|
1063
|
+
expect(collection.maximum_size).to eq(1)
|
|
1064
|
+
expect(collection.first.id).to eq(@disputed_transaction.id)
|
|
1065
|
+
|
|
1066
|
+
collection = Braintree::Transaction.search do |search|
|
|
1067
|
+
search.id.is @disputed_transaction.id
|
|
1068
|
+
search.dispute_date <= now + 60
|
|
1069
|
+
end
|
|
1070
|
+
|
|
1071
|
+
expect(collection.maximum_size).to eq(1)
|
|
1072
|
+
end
|
|
1073
|
+
|
|
1074
|
+
xit "searches on dispute_date with date ranges" do
|
|
1075
|
+
collection = Braintree::Transaction.search do |search|
|
|
1076
|
+
search.id.is @disputed_transaction.id
|
|
1077
|
+
search.dispute_date.between(
|
|
1078
|
+
@disputed_date - 1,
|
|
1079
|
+
@disputed_date + 1,
|
|
1080
|
+
)
|
|
1081
|
+
end
|
|
1082
|
+
|
|
1083
|
+
expect(collection.maximum_size).to eq(1)
|
|
1084
|
+
expect(collection.first.id).to eq(@disputed_transaction.id)
|
|
572
1085
|
end
|
|
573
1086
|
end
|
|
574
1087
|
|
|
@@ -579,29 +1092,29 @@ describe Braintree::Transaction, "search" do
|
|
|
579
1092
|
:credit_card => {
|
|
580
1093
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
581
1094
|
:expiration_date => "05/12"
|
|
582
|
-
}
|
|
1095
|
+
},
|
|
583
1096
|
)
|
|
584
1097
|
|
|
585
1098
|
collection = Braintree::Transaction.search do |search|
|
|
586
1099
|
search.id.is transaction.id
|
|
587
1100
|
search.authorized_at.between(
|
|
588
1101
|
Date.today - 2,
|
|
589
|
-
Date.today - 1
|
|
1102
|
+
Date.today - 1,
|
|
590
1103
|
)
|
|
591
1104
|
end
|
|
592
1105
|
|
|
593
|
-
collection.maximum_size.
|
|
1106
|
+
expect(collection.maximum_size).to eq(0)
|
|
594
1107
|
|
|
595
1108
|
collection = Braintree::Transaction.search do |search|
|
|
596
1109
|
search.id.is transaction.id
|
|
597
1110
|
search.authorized_at.between(
|
|
598
1111
|
Date.today - 1,
|
|
599
|
-
Date.today + 1
|
|
1112
|
+
Date.today + 1,
|
|
600
1113
|
)
|
|
601
1114
|
end
|
|
602
1115
|
|
|
603
|
-
collection.maximum_size.
|
|
604
|
-
collection.first.id.
|
|
1116
|
+
expect(collection.maximum_size).to eq(1)
|
|
1117
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
605
1118
|
end
|
|
606
1119
|
|
|
607
1120
|
it "finds transactions failed in a given range" do
|
|
@@ -610,50 +1123,50 @@ describe Braintree::Transaction, "search" do
|
|
|
610
1123
|
:credit_card => {
|
|
611
1124
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
612
1125
|
:expiration_date => "05/12"
|
|
613
|
-
}
|
|
1126
|
+
},
|
|
614
1127
|
).transaction
|
|
615
1128
|
|
|
616
1129
|
collection = Braintree::Transaction.search do |search|
|
|
617
1130
|
search.id.is transaction.id
|
|
618
1131
|
search.failed_at.between(
|
|
619
1132
|
Date.today - 2,
|
|
620
|
-
Date.today - 1
|
|
1133
|
+
Date.today - 1,
|
|
621
1134
|
)
|
|
622
1135
|
end
|
|
623
1136
|
|
|
624
|
-
collection.maximum_size.
|
|
1137
|
+
expect(collection.maximum_size).to eq(0)
|
|
625
1138
|
|
|
626
1139
|
collection = Braintree::Transaction.search do |search|
|
|
627
1140
|
search.id.is transaction.id
|
|
628
1141
|
search.failed_at.between(
|
|
629
1142
|
Date.today - 1,
|
|
630
|
-
Date.today + 1
|
|
1143
|
+
Date.today + 1,
|
|
631
1144
|
)
|
|
632
1145
|
end
|
|
633
1146
|
|
|
634
|
-
collection.maximum_size.
|
|
635
|
-
collection.first.id.
|
|
1147
|
+
expect(collection.maximum_size).to eq(1)
|
|
1148
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
636
1149
|
end
|
|
637
1150
|
|
|
638
1151
|
it "finds expired authorizations in a given range" do
|
|
639
1152
|
collection = Braintree::Transaction.search do |search|
|
|
640
1153
|
search.authorization_expired_at.between(
|
|
641
1154
|
Date.today - 2,
|
|
642
|
-
Date.today - 1
|
|
1155
|
+
Date.today - 1,
|
|
643
1156
|
)
|
|
644
1157
|
end
|
|
645
1158
|
|
|
646
|
-
collection.maximum_size.
|
|
1159
|
+
expect(collection.maximum_size).to eq(0)
|
|
647
1160
|
|
|
648
1161
|
collection = Braintree::Transaction.search do |search|
|
|
649
1162
|
search.authorization_expired_at.between(
|
|
650
1163
|
Date.today - 1,
|
|
651
|
-
Date.today + 1
|
|
1164
|
+
Date.today + 1,
|
|
652
1165
|
)
|
|
653
1166
|
end
|
|
654
1167
|
|
|
655
|
-
collection.maximum_size.
|
|
656
|
-
collection.first.status.
|
|
1168
|
+
expect(collection.maximum_size).to be > 0
|
|
1169
|
+
expect(collection.first.status).to eq(Braintree::Transaction::Status::AuthorizationExpired)
|
|
657
1170
|
end
|
|
658
1171
|
|
|
659
1172
|
it "finds transactions gateway_rejected in a given range" do
|
|
@@ -672,29 +1185,29 @@ describe Braintree::Transaction, "search" do
|
|
|
672
1185
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
673
1186
|
:expiration_date => "05/12",
|
|
674
1187
|
:cvv => "200"
|
|
675
|
-
}
|
|
1188
|
+
},
|
|
676
1189
|
).transaction
|
|
677
1190
|
|
|
678
1191
|
collection = Braintree::Transaction.search do |search|
|
|
679
1192
|
search.id.is transaction.id
|
|
680
1193
|
search.gateway_rejected_at.between(
|
|
681
1194
|
Date.today - 2,
|
|
682
|
-
Date.today - 1
|
|
1195
|
+
Date.today - 1,
|
|
683
1196
|
)
|
|
684
1197
|
end
|
|
685
1198
|
|
|
686
|
-
collection.maximum_size.
|
|
1199
|
+
expect(collection.maximum_size).to eq(0)
|
|
687
1200
|
|
|
688
1201
|
collection = Braintree::Transaction.search do |search|
|
|
689
1202
|
search.id.is transaction.id
|
|
690
1203
|
search.gateway_rejected_at.between(
|
|
691
1204
|
Date.today - 1,
|
|
692
|
-
Date.today + 1
|
|
1205
|
+
Date.today + 1,
|
|
693
1206
|
)
|
|
694
1207
|
end
|
|
695
1208
|
|
|
696
|
-
collection.maximum_size.
|
|
697
|
-
collection.first.id.
|
|
1209
|
+
expect(collection.maximum_size).to eq(1)
|
|
1210
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
698
1211
|
ensure
|
|
699
1212
|
Braintree::Configuration.merchant_id = old_merchant
|
|
700
1213
|
Braintree::Configuration.public_key = old_public_key
|
|
@@ -708,29 +1221,29 @@ describe Braintree::Transaction, "search" do
|
|
|
708
1221
|
:credit_card => {
|
|
709
1222
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
710
1223
|
:expiration_date => "05/12"
|
|
711
|
-
}
|
|
1224
|
+
},
|
|
712
1225
|
).transaction
|
|
713
1226
|
|
|
714
1227
|
collection = Braintree::Transaction.search do |search|
|
|
715
1228
|
search.id.is transaction.id
|
|
716
1229
|
search.processor_declined_at.between(
|
|
717
1230
|
Date.today - 2,
|
|
718
|
-
Date.today - 1
|
|
1231
|
+
Date.today - 1,
|
|
719
1232
|
)
|
|
720
1233
|
end
|
|
721
1234
|
|
|
722
|
-
collection.maximum_size.
|
|
1235
|
+
expect(collection.maximum_size).to eq(0)
|
|
723
1236
|
|
|
724
1237
|
collection = Braintree::Transaction.search do |search|
|
|
725
1238
|
search.id.is transaction.id
|
|
726
1239
|
search.processor_declined_at.between(
|
|
727
1240
|
Date.today - 1,
|
|
728
|
-
Date.today + 1
|
|
1241
|
+
Date.today + 1,
|
|
729
1242
|
)
|
|
730
1243
|
end
|
|
731
1244
|
|
|
732
|
-
collection.maximum_size.
|
|
733
|
-
collection.first.id.
|
|
1245
|
+
expect(collection.maximum_size).to eq(1)
|
|
1246
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
734
1247
|
end
|
|
735
1248
|
|
|
736
1249
|
it "finds transactions settled in a given range" do
|
|
@@ -742,7 +1255,7 @@ describe Braintree::Transaction, "search" do
|
|
|
742
1255
|
},
|
|
743
1256
|
:options => {
|
|
744
1257
|
:submit_for_settlement => true
|
|
745
|
-
}
|
|
1258
|
+
},
|
|
746
1259
|
).transaction
|
|
747
1260
|
|
|
748
1261
|
SpecHelper.settle_transaction transaction.id
|
|
@@ -751,22 +1264,22 @@ describe Braintree::Transaction, "search" do
|
|
|
751
1264
|
search.id.is transaction.id
|
|
752
1265
|
search.settled_at.between(
|
|
753
1266
|
Date.today - 2,
|
|
754
|
-
Date.today - 1
|
|
1267
|
+
Date.today - 1,
|
|
755
1268
|
)
|
|
756
1269
|
end
|
|
757
1270
|
|
|
758
|
-
collection.maximum_size.
|
|
1271
|
+
expect(collection.maximum_size).to eq(0)
|
|
759
1272
|
|
|
760
1273
|
collection = Braintree::Transaction.search do |search|
|
|
761
1274
|
search.id.is transaction.id
|
|
762
1275
|
search.settled_at.between(
|
|
763
1276
|
Date.today - 1,
|
|
764
|
-
Date.today + 1
|
|
1277
|
+
Date.today + 1,
|
|
765
1278
|
)
|
|
766
1279
|
end
|
|
767
1280
|
|
|
768
|
-
collection.maximum_size.
|
|
769
|
-
collection.first.id.
|
|
1281
|
+
expect(collection.maximum_size).to eq(1)
|
|
1282
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
770
1283
|
end
|
|
771
1284
|
|
|
772
1285
|
it "finds transactions submitted for settlement in a given range" do
|
|
@@ -778,29 +1291,29 @@ describe Braintree::Transaction, "search" do
|
|
|
778
1291
|
},
|
|
779
1292
|
:options => {
|
|
780
1293
|
:submit_for_settlement => true
|
|
781
|
-
}
|
|
1294
|
+
},
|
|
782
1295
|
).transaction
|
|
783
1296
|
|
|
784
1297
|
collection = Braintree::Transaction.search do |search|
|
|
785
1298
|
search.id.is transaction.id
|
|
786
1299
|
search.submitted_for_settlement_at.between(
|
|
787
1300
|
Date.today - 2,
|
|
788
|
-
Date.today - 1
|
|
1301
|
+
Date.today - 1,
|
|
789
1302
|
)
|
|
790
1303
|
end
|
|
791
1304
|
|
|
792
|
-
collection.maximum_size.
|
|
1305
|
+
expect(collection.maximum_size).to eq(0)
|
|
793
1306
|
|
|
794
1307
|
collection = Braintree::Transaction.search do |search|
|
|
795
1308
|
search.id.is transaction.id
|
|
796
1309
|
search.submitted_for_settlement_at.between(
|
|
797
1310
|
Date.today - 1,
|
|
798
|
-
Date.today + 1
|
|
1311
|
+
Date.today + 1,
|
|
799
1312
|
)
|
|
800
1313
|
end
|
|
801
1314
|
|
|
802
|
-
collection.maximum_size.
|
|
803
|
-
collection.first.id.
|
|
1315
|
+
expect(collection.maximum_size).to eq(1)
|
|
1316
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
804
1317
|
end
|
|
805
1318
|
|
|
806
1319
|
it "finds transactions voided in a given range" do
|
|
@@ -809,7 +1322,7 @@ describe Braintree::Transaction, "search" do
|
|
|
809
1322
|
:credit_card => {
|
|
810
1323
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
811
1324
|
:expiration_date => "05/12"
|
|
812
|
-
}
|
|
1325
|
+
},
|
|
813
1326
|
)
|
|
814
1327
|
transaction = Braintree::Transaction.void(transaction.id).transaction
|
|
815
1328
|
|
|
@@ -817,22 +1330,22 @@ describe Braintree::Transaction, "search" do
|
|
|
817
1330
|
search.id.is transaction.id
|
|
818
1331
|
search.voided_at.between(
|
|
819
1332
|
Date.today - 2,
|
|
820
|
-
Date.today - 1
|
|
1333
|
+
Date.today - 1,
|
|
821
1334
|
)
|
|
822
1335
|
end
|
|
823
1336
|
|
|
824
|
-
collection.maximum_size.
|
|
1337
|
+
expect(collection.maximum_size).to eq(0)
|
|
825
1338
|
|
|
826
1339
|
collection = Braintree::Transaction.search do |search|
|
|
827
1340
|
search.id.is transaction.id
|
|
828
1341
|
search.voided_at.between(
|
|
829
1342
|
Date.today - 1,
|
|
830
|
-
Date.today + 1
|
|
1343
|
+
Date.today + 1,
|
|
831
1344
|
)
|
|
832
1345
|
end
|
|
833
1346
|
|
|
834
|
-
collection.maximum_size.
|
|
835
|
-
collection.first.id.
|
|
1347
|
+
expect(collection.maximum_size).to eq(1)
|
|
1348
|
+
expect(collection.first.id).to eq(transaction.id)
|
|
836
1349
|
end
|
|
837
1350
|
end
|
|
838
1351
|
|
|
@@ -845,31 +1358,32 @@ describe Braintree::Transaction, "search" do
|
|
|
845
1358
|
},
|
|
846
1359
|
:options => {
|
|
847
1360
|
:submit_for_settlement => true
|
|
848
|
-
}
|
|
1361
|
+
},
|
|
849
1362
|
)
|
|
850
1363
|
|
|
851
1364
|
collection = Braintree::Transaction.search do |search|
|
|
852
1365
|
search.id.is transaction.id
|
|
853
1366
|
search.authorized_at.between(
|
|
854
1367
|
Date.today - 1,
|
|
855
|
-
Date.today + 1
|
|
1368
|
+
Date.today + 1,
|
|
856
1369
|
)
|
|
857
1370
|
search.submitted_for_settlement_at.between(
|
|
858
1371
|
Date.today - 1,
|
|
859
|
-
Date.today + 1
|
|
1372
|
+
Date.today + 1,
|
|
860
1373
|
)
|
|
861
1374
|
end
|
|
862
1375
|
|
|
863
|
-
collection.maximum_size.
|
|
1376
|
+
expect(collection.maximum_size).to be > 0
|
|
864
1377
|
end
|
|
865
1378
|
end
|
|
866
1379
|
|
|
867
|
-
|
|
1380
|
+
#Disabling until we have a more stable CI
|
|
1381
|
+
xit "returns multiple results" do
|
|
868
1382
|
collection = Braintree::Transaction.search
|
|
869
|
-
collection.maximum_size.
|
|
1383
|
+
expect(collection.maximum_size).to be > 100
|
|
870
1384
|
|
|
871
|
-
transaction_ids = collection.map {|t| t.id }.uniq.compact
|
|
872
|
-
transaction_ids.size.
|
|
1385
|
+
transaction_ids = collection.map { |t| t.id }.uniq.compact
|
|
1386
|
+
expect(transaction_ids.size).to eq(collection.maximum_size)
|
|
873
1387
|
end
|
|
874
1388
|
|
|
875
1389
|
context "text node operations" do
|
|
@@ -880,7 +1394,7 @@ describe Braintree::Transaction, "search" do
|
|
|
880
1394
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
881
1395
|
:expiration_date => "05/2012",
|
|
882
1396
|
:cardholder_name => "Tom Smith"
|
|
883
|
-
}
|
|
1397
|
+
},
|
|
884
1398
|
)
|
|
885
1399
|
end
|
|
886
1400
|
|
|
@@ -890,15 +1404,15 @@ describe Braintree::Transaction, "search" do
|
|
|
890
1404
|
search.credit_card_cardholder_name.is "Tom Smith"
|
|
891
1405
|
end
|
|
892
1406
|
|
|
893
|
-
collection.maximum_size.
|
|
894
|
-
collection.first.id.
|
|
1407
|
+
expect(collection.maximum_size).to eq(1)
|
|
1408
|
+
expect(collection.first.id).to eq(@transaction.id)
|
|
895
1409
|
|
|
896
1410
|
collection = Braintree::Transaction.search do |search|
|
|
897
1411
|
search.id.is @transaction.id
|
|
898
1412
|
search.credit_card_cardholder_name.is "Invalid"
|
|
899
1413
|
end
|
|
900
1414
|
|
|
901
|
-
collection.maximum_size.
|
|
1415
|
+
expect(collection.maximum_size).to eq(0)
|
|
902
1416
|
end
|
|
903
1417
|
|
|
904
1418
|
it "is_not" do
|
|
@@ -907,15 +1421,15 @@ describe Braintree::Transaction, "search" do
|
|
|
907
1421
|
search.credit_card_cardholder_name.is_not "Anybody Else"
|
|
908
1422
|
end
|
|
909
1423
|
|
|
910
|
-
collection.maximum_size.
|
|
911
|
-
collection.first.id.
|
|
1424
|
+
expect(collection.maximum_size).to eq(1)
|
|
1425
|
+
expect(collection.first.id).to eq(@transaction.id)
|
|
912
1426
|
|
|
913
1427
|
collection = Braintree::Transaction.search do |search|
|
|
914
1428
|
search.id.is @transaction.id
|
|
915
1429
|
search.credit_card_cardholder_name.is_not "Tom Smith"
|
|
916
1430
|
end
|
|
917
1431
|
|
|
918
|
-
collection.maximum_size.
|
|
1432
|
+
expect(collection.maximum_size).to eq(0)
|
|
919
1433
|
end
|
|
920
1434
|
|
|
921
1435
|
it "ends_with" do
|
|
@@ -924,15 +1438,15 @@ describe Braintree::Transaction, "search" do
|
|
|
924
1438
|
search.credit_card_cardholder_name.ends_with "m Smith"
|
|
925
1439
|
end
|
|
926
1440
|
|
|
927
|
-
collection.maximum_size.
|
|
928
|
-
collection.first.id.
|
|
1441
|
+
expect(collection.maximum_size).to eq(1)
|
|
1442
|
+
expect(collection.first.id).to eq(@transaction.id)
|
|
929
1443
|
|
|
930
1444
|
collection = Braintree::Transaction.search do |search|
|
|
931
1445
|
search.id.is @transaction.id
|
|
932
1446
|
search.credit_card_cardholder_name.ends_with "Tom S"
|
|
933
1447
|
end
|
|
934
1448
|
|
|
935
|
-
collection.maximum_size.
|
|
1449
|
+
expect(collection.maximum_size).to eq(0)
|
|
936
1450
|
end
|
|
937
1451
|
|
|
938
1452
|
it "starts_with" do
|
|
@@ -941,15 +1455,15 @@ describe Braintree::Transaction, "search" do
|
|
|
941
1455
|
search.credit_card_cardholder_name.starts_with "Tom S"
|
|
942
1456
|
end
|
|
943
1457
|
|
|
944
|
-
collection.maximum_size.
|
|
945
|
-
collection.first.id.
|
|
1458
|
+
expect(collection.maximum_size).to eq(1)
|
|
1459
|
+
expect(collection.first.id).to eq(@transaction.id)
|
|
946
1460
|
|
|
947
1461
|
collection = Braintree::Transaction.search do |search|
|
|
948
1462
|
search.id.is @transaction.id
|
|
949
1463
|
search.credit_card_cardholder_name.starts_with "m Smith"
|
|
950
1464
|
end
|
|
951
1465
|
|
|
952
|
-
collection.maximum_size.
|
|
1466
|
+
expect(collection.maximum_size).to eq(0)
|
|
953
1467
|
end
|
|
954
1468
|
|
|
955
1469
|
it "contains" do
|
|
@@ -958,16 +1472,91 @@ describe Braintree::Transaction, "search" do
|
|
|
958
1472
|
search.credit_card_cardholder_name.contains "m Sm"
|
|
959
1473
|
end
|
|
960
1474
|
|
|
961
|
-
collection.maximum_size.
|
|
962
|
-
collection.first.id.
|
|
1475
|
+
expect(collection.maximum_size).to eq(1)
|
|
1476
|
+
expect(collection.first.id).to eq(@transaction.id)
|
|
963
1477
|
|
|
964
1478
|
collection = Braintree::Transaction.search do |search|
|
|
965
1479
|
search.id.is @transaction.id
|
|
966
1480
|
search.credit_card_cardholder_name.contains "Anybody Else"
|
|
967
1481
|
end
|
|
968
1482
|
|
|
969
|
-
collection.maximum_size.
|
|
1483
|
+
expect(collection.maximum_size).to eq(0)
|
|
1484
|
+
end
|
|
1485
|
+
end
|
|
1486
|
+
|
|
1487
|
+
context "when the search times out" do
|
|
1488
|
+
it "raises a UnexpectedError" do
|
|
1489
|
+
expect {
|
|
1490
|
+
Braintree::Transaction.search do |search|
|
|
1491
|
+
search.amount.is(-10)
|
|
1492
|
+
end
|
|
1493
|
+
}.to raise_error(Braintree::UnexpectedError)
|
|
1494
|
+
end
|
|
1495
|
+
end
|
|
1496
|
+
|
|
1497
|
+
it "searches by payment instrument type meta checkout" do
|
|
1498
|
+
meta_checkout_card_transaction = Braintree::Transaction.sale!(
|
|
1499
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
1500
|
+
:options => {
|
|
1501
|
+
:submit_for_settlement => true
|
|
1502
|
+
},
|
|
1503
|
+
:payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutCard,
|
|
1504
|
+
)
|
|
1505
|
+
|
|
1506
|
+
meta_checkout_token_transaction = Braintree::Transaction.sale!(
|
|
1507
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
1508
|
+
:options => {
|
|
1509
|
+
:submit_for_settlement => true
|
|
1510
|
+
},
|
|
1511
|
+
:payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutToken,
|
|
1512
|
+
)
|
|
1513
|
+
|
|
1514
|
+
collection = Braintree::Transaction.search do |search|
|
|
1515
|
+
search.payment_instrument_type.in ["MetaCheckout"]
|
|
970
1516
|
end
|
|
1517
|
+
|
|
1518
|
+
collection.maximum_size.should == 2
|
|
1519
|
+
txn_ids = collection.map(&:id)
|
|
1520
|
+
expect(txn_ids).to include(meta_checkout_card_transaction.id)
|
|
1521
|
+
expect(txn_ids).to include(meta_checkout_token_transaction.id)
|
|
1522
|
+
end
|
|
1523
|
+
end
|
|
1524
|
+
|
|
1525
|
+
context "pagination" do
|
|
1526
|
+
it "is not affected by new results on the server" do
|
|
1527
|
+
cardholder_name = "Tom Smith #{rand(1_000_000)}"
|
|
1528
|
+
5.times do |index|
|
|
1529
|
+
Braintree::Transaction.sale!(
|
|
1530
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
1531
|
+
:credit_card => {
|
|
1532
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
1533
|
+
:expiration_date => "05/2012",
|
|
1534
|
+
:cardholder_name => "#{cardholder_name} #{index}"
|
|
1535
|
+
},
|
|
1536
|
+
)
|
|
1537
|
+
end
|
|
1538
|
+
|
|
1539
|
+
collection = Braintree::Transaction.search do |search|
|
|
1540
|
+
search.credit_card_cardholder_name.starts_with cardholder_name
|
|
1541
|
+
end
|
|
1542
|
+
|
|
1543
|
+
count_before_new_data = collection.instance_variable_get(:@ids).count
|
|
1544
|
+
|
|
1545
|
+
new_cardholder_name = "#{cardholder_name} shouldn't be included"
|
|
1546
|
+
Braintree::Transaction.sale!(
|
|
1547
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
1548
|
+
:credit_card => {
|
|
1549
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
1550
|
+
:expiration_date => "05/2012",
|
|
1551
|
+
:cardholder_name => new_cardholder_name,
|
|
1552
|
+
},
|
|
1553
|
+
)
|
|
1554
|
+
|
|
1555
|
+
transactions = collection.to_a
|
|
1556
|
+
expect(transactions.count).to eq(count_before_new_data)
|
|
1557
|
+
|
|
1558
|
+
cardholder_names = transactions.map { |transaction| transaction.credit_card_details.cardholder_name }
|
|
1559
|
+
expect(cardholder_names).to_not include(new_cardholder_name)
|
|
971
1560
|
end
|
|
972
1561
|
end
|
|
973
1562
|
end
|