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,193 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::CreditCardVerification, "search" do
|
|
4
|
+
it "correctly returns a result with no matches" do
|
|
5
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
6
|
+
search.credit_card_cardholder_name.is "thisnameisnotreal"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
expect(collection.maximum_size).to eq(0)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "can search on text fields" do
|
|
13
|
+
unsuccessful_result = Braintree::Customer.create(
|
|
14
|
+
:credit_card => {
|
|
15
|
+
:cardholder_name => "Tom Smith",
|
|
16
|
+
:expiration_date => "05/2012",
|
|
17
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
|
18
|
+
:options => {
|
|
19
|
+
:verify_card => true
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
verification = unsuccessful_result.credit_card_verification
|
|
24
|
+
|
|
25
|
+
search_criteria = {
|
|
26
|
+
:credit_card_cardholder_name => "Tom Smith",
|
|
27
|
+
:credit_card_expiration_date => "05/2012",
|
|
28
|
+
:credit_card_number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
search_criteria.each do |criterion, value|
|
|
32
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
33
|
+
search.id.is verification.id
|
|
34
|
+
search.send(criterion).is value
|
|
35
|
+
end
|
|
36
|
+
expect(collection.maximum_size).to eq(1)
|
|
37
|
+
expect(collection.first.id).to eq(verification.id)
|
|
38
|
+
|
|
39
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
40
|
+
search.id.is verification.id
|
|
41
|
+
search.send(criterion).is("invalid_attribute")
|
|
42
|
+
end
|
|
43
|
+
expect(collection).to be_empty
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
47
|
+
search.id.is verification.id
|
|
48
|
+
search_criteria.each do |criterion, value|
|
|
49
|
+
search.send(criterion).is value
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
expect(collection.maximum_size).to eq(1)
|
|
54
|
+
expect(collection.first.id).to eq(verification.id)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "multiple value fields" do
|
|
58
|
+
it "searches on ids" do
|
|
59
|
+
unsuccessful_result1 = Braintree::Customer.create(
|
|
60
|
+
:credit_card => {
|
|
61
|
+
:cardholder_name => "Tom Smith",
|
|
62
|
+
:expiration_date => "05/2012",
|
|
63
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
|
64
|
+
:options => {
|
|
65
|
+
:verify_card => true
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
verification_id1 = unsuccessful_result1.credit_card_verification.id
|
|
70
|
+
|
|
71
|
+
unsuccessful_result2 = Braintree::Customer.create(
|
|
72
|
+
:credit_card => {
|
|
73
|
+
:cardholder_name => "Tom Smith",
|
|
74
|
+
:expiration_date => "05/2012",
|
|
75
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
|
76
|
+
:options => {
|
|
77
|
+
:verify_card => true
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
verification_id2 = unsuccessful_result2.credit_card_verification.id
|
|
82
|
+
|
|
83
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
84
|
+
search.ids.in verification_id1, verification_id2
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
expect(collection.maximum_size).to eq(2)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
context "range fields" do
|
|
92
|
+
it "searches on created_at" do
|
|
93
|
+
unsuccessful_result = Braintree::Customer.create(
|
|
94
|
+
:credit_card => {
|
|
95
|
+
:cardholder_name => "Tom Smith",
|
|
96
|
+
:expiration_date => "05/2012",
|
|
97
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
|
98
|
+
:options => {
|
|
99
|
+
:verify_card => true
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
verification = unsuccessful_result.credit_card_verification
|
|
104
|
+
|
|
105
|
+
created_at = verification.created_at
|
|
106
|
+
|
|
107
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
108
|
+
search.id.is verification.id
|
|
109
|
+
search.created_at.between(
|
|
110
|
+
created_at - 60,
|
|
111
|
+
created_at + 60,
|
|
112
|
+
)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
expect(collection.maximum_size).to eq(1)
|
|
116
|
+
expect(collection.first.id).to eq(verification.id)
|
|
117
|
+
|
|
118
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
119
|
+
search.id.is verification.id
|
|
120
|
+
search.created_at >= created_at - 1
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
expect(collection.maximum_size).to eq(1)
|
|
124
|
+
expect(collection.first.id).to eq(verification.id)
|
|
125
|
+
|
|
126
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
127
|
+
search.id.is verification.id
|
|
128
|
+
search.created_at <= created_at + 1
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
expect(collection.maximum_size).to eq(1)
|
|
132
|
+
expect(collection.first.id).to eq(verification.id)
|
|
133
|
+
|
|
134
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
135
|
+
search.id.is verification.id
|
|
136
|
+
search.created_at.between(
|
|
137
|
+
created_at - 300,
|
|
138
|
+
created_at - 100,
|
|
139
|
+
)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
expect(collection.maximum_size).to eq(0)
|
|
143
|
+
|
|
144
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
145
|
+
search.id.is verification.id
|
|
146
|
+
search.created_at.is created_at
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
expect(collection.maximum_size).to eq(1)
|
|
150
|
+
expect(collection.first.id).to eq(verification.id)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
context "pagination" do
|
|
155
|
+
it "is not affected by new results on the server" do
|
|
156
|
+
cardholder_name = "Tom Smith #{rand(1_000_000)}"
|
|
157
|
+
5.times do |index|
|
|
158
|
+
Braintree::Customer.create(
|
|
159
|
+
:credit_card => {
|
|
160
|
+
:cardholder_name => "#{cardholder_name} #{index}",
|
|
161
|
+
:expiration_date => "05/2012",
|
|
162
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
|
163
|
+
:options => {
|
|
164
|
+
:verify_card => true
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
collection = Braintree::CreditCardVerification.search do |search|
|
|
170
|
+
search.credit_card_cardholder_name.starts_with cardholder_name
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
count_before_new_data = collection.instance_variable_get(:@ids).count
|
|
174
|
+
|
|
175
|
+
new_cardholder_name = "#{cardholder_name} shouldn't be included"
|
|
176
|
+
Braintree::Customer.create(
|
|
177
|
+
:credit_card => {
|
|
178
|
+
:cardholder_name => new_cardholder_name,
|
|
179
|
+
:expiration_date => "05/2012",
|
|
180
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
|
181
|
+
:options => {
|
|
182
|
+
:verify_card => true
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
verifications = collection.to_a
|
|
187
|
+
expect(verifications.count).to eq(count_before_new_data)
|
|
188
|
+
|
|
189
|
+
cardholder_names = verifications.map { |verification| verification.credit_card[:cardholder_name] }
|
|
190
|
+
expect(cardholder_names).to_not include(new_cardholder_name)
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
|
3
|
+
|
|
4
|
+
describe Braintree::CreditCardVerification, "search" do
|
|
5
|
+
|
|
6
|
+
describe "self.create" do
|
|
7
|
+
it "creates a new verification" do
|
|
8
|
+
verification_params = {
|
|
9
|
+
:credit_card => {
|
|
10
|
+
:expiration_date => "05/2012",
|
|
11
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
12
|
+
},
|
|
13
|
+
:options => {
|
|
14
|
+
:amount => "10.00"
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
19
|
+
|
|
20
|
+
expect(result).to be_success
|
|
21
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
|
22
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
23
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
|
24
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
|
25
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
26
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "creates a new verification with network response code/text" do
|
|
30
|
+
verification_params = {
|
|
31
|
+
:credit_card => {
|
|
32
|
+
:expiration_date => "05/2012",
|
|
33
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
34
|
+
},
|
|
35
|
+
:options => {
|
|
36
|
+
:amount => "10.00"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
41
|
+
|
|
42
|
+
expect(result).to be_success
|
|
43
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
44
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
|
45
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
|
46
|
+
expect(result.credit_card_verification.network_response_code).to eq("XX")
|
|
47
|
+
expect(result.credit_card_verification.network_response_text).to eq("sample network response text")
|
|
48
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "creates a new verification for Visa ANI" do
|
|
52
|
+
verification_params = {
|
|
53
|
+
:credit_card => {
|
|
54
|
+
:expiration_date => "05/2012",
|
|
55
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
60
|
+
|
|
61
|
+
expect(result).to be_success
|
|
62
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
63
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
|
64
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
|
65
|
+
expect(result.credit_card_verification.ani_first_name_response_code).to eq("I")
|
|
66
|
+
expect(result.credit_card_verification.ani_last_name_response_code).to eq("I")
|
|
67
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "creates a new verification from external vault param" do
|
|
71
|
+
verification_params = {
|
|
72
|
+
:credit_card => {
|
|
73
|
+
:expiration_date => "05/2029",
|
|
74
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
75
|
+
},
|
|
76
|
+
:external_vault => {
|
|
77
|
+
:status => "will_vault"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
82
|
+
|
|
83
|
+
expect(result).to be_success
|
|
84
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
|
85
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
86
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
|
87
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
|
88
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
89
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "creates a new verification from risk data param" do
|
|
93
|
+
verification_params = {
|
|
94
|
+
:credit_card => {
|
|
95
|
+
:expiration_date => "05/2029",
|
|
96
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
97
|
+
},
|
|
98
|
+
:risk_data => {
|
|
99
|
+
:customer_browser => "IE7",
|
|
100
|
+
:customer_ip => "192.168.0.1"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
105
|
+
|
|
106
|
+
expect(result).to be_success
|
|
107
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
|
108
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
109
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
|
110
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
|
111
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
112
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "returns processor response code and text as well as the additional processor response if declined" do
|
|
116
|
+
verification_params = {
|
|
117
|
+
:credit_card => {
|
|
118
|
+
:expiration_date => "05/2012",
|
|
119
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
|
120
|
+
},
|
|
121
|
+
:options => {
|
|
122
|
+
:amount => "10.00"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
127
|
+
|
|
128
|
+
expect(result.success?).to eq(false)
|
|
129
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
|
130
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::ProcessorDeclined)
|
|
131
|
+
expect(result.credit_card_verification.processor_response_code).to eq("2000")
|
|
132
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Do Not Honor")
|
|
133
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::SoftDeclined)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it "returns validation errors" do
|
|
137
|
+
verification_params = {
|
|
138
|
+
:credit_card => {
|
|
139
|
+
:expiration_date => "05/2012",
|
|
140
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
|
141
|
+
},
|
|
142
|
+
:options => {
|
|
143
|
+
:amount => "-10.00"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
148
|
+
|
|
149
|
+
expect(result.success?).to eq(false)
|
|
150
|
+
expect(result.errors.for(:verification).for(:options).first.code).to eq(Braintree::ErrorCodes::Verification::Options::AmountCannotBeNegative)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it "returns account type with debit" do
|
|
154
|
+
result = Braintree::CreditCardVerification.create(
|
|
155
|
+
:credit_card => {
|
|
156
|
+
:expiration_date => "01/2020",
|
|
157
|
+
:number => Braintree::Test::CreditCardNumbers::Hiper
|
|
158
|
+
},
|
|
159
|
+
:options => {
|
|
160
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
|
161
|
+
:account_type => "debit",
|
|
162
|
+
},
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
expect(result.success?).to eq(true)
|
|
166
|
+
expect(result.credit_card_verification.credit_card[:account_type]).to eq("debit")
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it "returns account type with credit" do
|
|
170
|
+
result = Braintree::CreditCardVerification.create(
|
|
171
|
+
:credit_card => {
|
|
172
|
+
:expiration_date => "01/2020",
|
|
173
|
+
:number => Braintree::Test::CreditCardNumbers::Hiper
|
|
174
|
+
},
|
|
175
|
+
:options => {
|
|
176
|
+
:merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
|
177
|
+
:account_type => "credit",
|
|
178
|
+
},
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
expect(result.success?).to eq(true)
|
|
182
|
+
expect(result.credit_card_verification.credit_card[:account_type]).to eq("credit")
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it "errors with unsupported account type" do
|
|
186
|
+
result = Braintree::CreditCardVerification.create(
|
|
187
|
+
:credit_card => {
|
|
188
|
+
:expiration_date => "01/2020",
|
|
189
|
+
:number => Braintree::Test::CreditCardNumbers::Visa
|
|
190
|
+
},
|
|
191
|
+
:options => {
|
|
192
|
+
:account_type => "credit",
|
|
193
|
+
},
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
expect(result.success?).to eq(false)
|
|
197
|
+
expect(result.errors.for(:verification).for(:options).on(:account_type)[0].code).to eq(Braintree::ErrorCodes::Verification::Options::AccountTypeNotSupported)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
it "errors with invalid account type" do
|
|
201
|
+
result = Braintree::CreditCardVerification.create(
|
|
202
|
+
:credit_card => {
|
|
203
|
+
:expiration_date => "01/2020",
|
|
204
|
+
:number => Braintree::Test::CreditCardNumbers::Hiper
|
|
205
|
+
},
|
|
206
|
+
:options => {
|
|
207
|
+
:merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
|
208
|
+
:account_type => "ach",
|
|
209
|
+
},
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
expect(result.success?).to eq(false)
|
|
213
|
+
expect(result.errors.for(:verification).for(:options).on(:account_type)[0].code).to eq(Braintree::ErrorCodes::Verification::Options::AccountTypeIsInvalid)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
describe "self.find" do
|
|
218
|
+
it "finds the verification with the given id" do
|
|
219
|
+
credit_card_params = {
|
|
220
|
+
:expiration_date => "05/2012",
|
|
221
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
|
222
|
+
:options => {
|
|
223
|
+
:verify_card => true
|
|
224
|
+
},
|
|
225
|
+
}
|
|
226
|
+
credit_card_verification = Braintree::Customer.create(:credit_card => credit_card_params).credit_card_verification
|
|
227
|
+
found_verification = Braintree::CreditCardVerification.find(credit_card_verification.id)
|
|
228
|
+
|
|
229
|
+
expect(found_verification).to eq(credit_card_verification)
|
|
230
|
+
expect(found_verification.graphql_id).not_to be_nil
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
it "raises a NotFoundError exception if verification cannot be found" do
|
|
234
|
+
expect do
|
|
235
|
+
Braintree::CreditCardVerification.find("invalid-id")
|
|
236
|
+
end.to raise_error(Braintree::NotFoundError, 'verification with id "invalid-id" not found')
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
describe "self.search" do
|
|
241
|
+
before(:each) do
|
|
242
|
+
@customer_params = {
|
|
243
|
+
:first_name => "Tom",
|
|
244
|
+
:last_name => "Smith",
|
|
245
|
+
:email => "tom.smith@example.com",
|
|
246
|
+
}
|
|
247
|
+
@billing_address_params = {
|
|
248
|
+
:postal_code => "90210"
|
|
249
|
+
}
|
|
250
|
+
@credit_card_params = {
|
|
251
|
+
:cardholder_name => "Tom Smith",
|
|
252
|
+
:expiration_date => "05/2012",
|
|
253
|
+
:options => {
|
|
254
|
+
:verify_card => true
|
|
255
|
+
},
|
|
256
|
+
:billing_address => @billing_address_params,
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
customer_create_result = Braintree::Customer.create(@customer_params)
|
|
260
|
+
@customer = customer_create_result.customer
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
it "searches and finds verification using verification fields" do
|
|
264
|
+
max_seconds_between_create_and_search = 120
|
|
265
|
+
result = Braintree::CreditCard.create(@credit_card_params.merge({
|
|
266
|
+
:customer_id => @customer.id,
|
|
267
|
+
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
|
268
|
+
}))
|
|
269
|
+
credit_card_verification = result.credit_card_verification
|
|
270
|
+
|
|
271
|
+
found_verifications = Braintree::CreditCardVerification.search do |search|
|
|
272
|
+
search.billing_address_details_postal_code.is @billing_address_params[:postal_code]
|
|
273
|
+
search.created_at >= (Time.now() - max_seconds_between_create_and_search)
|
|
274
|
+
search.credit_card_card_type.in Braintree::CreditCard::CardType::Visa
|
|
275
|
+
search.credit_card_cardholder_name.is @credit_card_params[:cardholder_name]
|
|
276
|
+
search.credit_card_expiration_date.is @credit_card_params[:expiration_date]
|
|
277
|
+
search.credit_card_number.is @credit_card_params[:number]
|
|
278
|
+
search.ids.in credit_card_verification.id
|
|
279
|
+
search.status.in credit_card_verification.status
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
expect(found_verifications).to include(credit_card_verification)
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
it "searches and finds verifications using customer fields" do
|
|
286
|
+
result = Braintree::CreditCard.create(@credit_card_params.merge({
|
|
287
|
+
:customer_id => @customer.id,
|
|
288
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
289
|
+
}))
|
|
290
|
+
credit_card = result.credit_card
|
|
291
|
+
|
|
292
|
+
found_verifications = Braintree::CreditCardVerification.search do |search|
|
|
293
|
+
search.customer_email.is @customer_params[:email]
|
|
294
|
+
search.customer_id.is @customer.id
|
|
295
|
+
search.payment_method_token.is credit_card.token
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
expect(found_verifications.count).to eq(1)
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
describe "card type indicators" do
|
|
302
|
+
it "returns prepaid on a prepaid card" do
|
|
303
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
|
304
|
+
|
|
305
|
+
Braintree::Customer.create(
|
|
306
|
+
:credit_card => {
|
|
307
|
+
:cardholder_name => cardholder_name,
|
|
308
|
+
:expiration_date => "05/2012",
|
|
309
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
|
310
|
+
:cvv => "200",
|
|
311
|
+
:options => {
|
|
312
|
+
:verify_card => true
|
|
313
|
+
}
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
|
317
|
+
search.credit_card_cardholder_name.is cardholder_name
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
verification_id = search_results.first.id
|
|
321
|
+
|
|
322
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
|
323
|
+
expect(found_verification.credit_card[:prepaid]).to eq(Braintree::CreditCard::Prepaid::Yes)
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
it "returns prepaid_reloadable on a prepaid card" do
|
|
327
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
|
328
|
+
|
|
329
|
+
Braintree::Customer.create(
|
|
330
|
+
:credit_card => {
|
|
331
|
+
:cardholder_name => cardholder_name,
|
|
332
|
+
:expiration_date => "05/2012",
|
|
333
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::PrepaidReloadable,
|
|
334
|
+
:cvv => "200",
|
|
335
|
+
:options => {
|
|
336
|
+
:verify_card => true
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
|
341
|
+
search.credit_card_cardholder_name.is cardholder_name
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
verification_id = search_results.first.id
|
|
345
|
+
|
|
346
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
|
347
|
+
expect(found_verification.credit_card[:prepaid_reloadable]).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
describe "intended transaction source" do
|
|
353
|
+
it "creates a new verification with intended transaction source installment" do
|
|
354
|
+
verification_params = {
|
|
355
|
+
:credit_card => {
|
|
356
|
+
:expiration_date => "05/2029",
|
|
357
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
358
|
+
},
|
|
359
|
+
:options => {
|
|
360
|
+
:amount => "10.00"
|
|
361
|
+
},
|
|
362
|
+
:intended_transaction_source => "installment"
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
366
|
+
|
|
367
|
+
expect(result).to be_success
|
|
368
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
|
369
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
370
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
|
371
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
|
372
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
373
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
context "three_d_secure" do
|
|
378
|
+
it "can create a verification with a three_d_secure_authentication_id" do
|
|
379
|
+
three_d_secure_authentication_id = SpecHelper.create_3ds_verification(
|
|
380
|
+
SpecHelper::ThreeDSecureMerchantAccountId,
|
|
381
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
382
|
+
:expiration_month => "12",
|
|
383
|
+
:expiration_year => "2029",
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
verification_params = {
|
|
387
|
+
:credit_card => {
|
|
388
|
+
:expiration_date => "12/2029",
|
|
389
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
390
|
+
},
|
|
391
|
+
:options => {
|
|
392
|
+
:amount => "10.00",
|
|
393
|
+
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
|
|
394
|
+
},
|
|
395
|
+
:three_d_secure_authentication_id => three_d_secure_authentication_id,
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
399
|
+
|
|
400
|
+
expect(result).to be_success
|
|
401
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
|
402
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
403
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
|
404
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
|
405
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
406
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
it "can create a verification with a payment_method_nonce" do
|
|
410
|
+
nonce = nonce_for_new_payment_method(
|
|
411
|
+
:credit_card => {
|
|
412
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
413
|
+
:expiration_month => "11",
|
|
414
|
+
:expiration_year => "2099",
|
|
415
|
+
},
|
|
416
|
+
)
|
|
417
|
+
expect(nonce).not_to be_nil
|
|
418
|
+
|
|
419
|
+
verification_params = {
|
|
420
|
+
:credit_card => {
|
|
421
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
422
|
+
},
|
|
423
|
+
:options => {
|
|
424
|
+
:amount => "10.00",
|
|
425
|
+
:merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
|
|
426
|
+
},
|
|
427
|
+
:payment_method_nonce => nonce,
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
431
|
+
|
|
432
|
+
expect(result).to be_success
|
|
433
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
|
434
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
435
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
|
436
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
|
437
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
438
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
it "can create a verification with a verification_three_d_secure_pass_thru" do
|
|
442
|
+
verification_params = {
|
|
443
|
+
:credit_card => {
|
|
444
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
445
|
+
:expiration_date => "12/12",
|
|
446
|
+
},
|
|
447
|
+
:options => {
|
|
448
|
+
:amount => "10.00",
|
|
449
|
+
},
|
|
450
|
+
:three_d_secure_pass_thru => {
|
|
451
|
+
:eci_flag => "05",
|
|
452
|
+
:cavv => "some_cavv",
|
|
453
|
+
:xid => "some_xid",
|
|
454
|
+
:three_d_secure_version => "1.0.2",
|
|
455
|
+
:authentication_response => "Y",
|
|
456
|
+
:directory_response => "Y",
|
|
457
|
+
:cavv_algorithm => "2",
|
|
458
|
+
:ds_transaction_id => "some_ds_id",
|
|
459
|
+
},
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
463
|
+
|
|
464
|
+
expect(result).to be_success
|
|
465
|
+
expect(result.credit_card_verification.id).to match(/^\w{6,}$/)
|
|
466
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
467
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
|
468
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
|
469
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
470
|
+
expect(result.credit_card_verification.network_transaction_id).not_to be_nil
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
end
|