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,240 @@
|
|
|
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::UsBankAccountVerification do
|
|
5
|
+
let(:nonce) { generate_non_plaid_us_bank_account_nonce }
|
|
6
|
+
let(:customer) do
|
|
7
|
+
params = {
|
|
8
|
+
:first_name => "Tom",
|
|
9
|
+
:last_name => "Smith",
|
|
10
|
+
:email => "tom.smith@example.com",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Braintree::Customer.create(params).customer
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "self.confirm_micro_transfer_amounts" do
|
|
17
|
+
before do
|
|
18
|
+
Braintree::Configuration.merchant_id = "integration2_merchant_id"
|
|
19
|
+
Braintree::Configuration.public_key = "integration2_public_key"
|
|
20
|
+
Braintree::Configuration.private_key = "integration2_private_key"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
after(:all) do
|
|
24
|
+
Braintree::Configuration.merchant_id = "integration_merchant_id"
|
|
25
|
+
Braintree::Configuration.public_key = "integration_public_key"
|
|
26
|
+
Braintree::Configuration.private_key = "integration_private_key"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "with a micro transfer verification" do
|
|
30
|
+
it "successfully confirms settled amounts" do
|
|
31
|
+
nonce = generate_non_plaid_us_bank_account_nonce("1000000000")
|
|
32
|
+
|
|
33
|
+
result = Braintree::PaymentMethod.create(
|
|
34
|
+
:payment_method_nonce => nonce,
|
|
35
|
+
:customer_id => customer.id,
|
|
36
|
+
:options => {
|
|
37
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
|
38
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
|
|
39
|
+
},
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
expect(result).to be_success
|
|
43
|
+
|
|
44
|
+
verification = result.payment_method.verifications.first
|
|
45
|
+
expect(verification.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers)
|
|
46
|
+
expect(verification.status).to eq(Braintree::UsBankAccountVerification::Status::Pending)
|
|
47
|
+
|
|
48
|
+
response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [17, 29])
|
|
49
|
+
|
|
50
|
+
expect(response).to be_success
|
|
51
|
+
expect(response.us_bank_account_verification.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
|
52
|
+
|
|
53
|
+
us_bank_account = Braintree::UsBankAccount.find(response.us_bank_account_verification.us_bank_account[:token])
|
|
54
|
+
|
|
55
|
+
expect(us_bank_account.verified).to be_truthy
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "successfully confirms not-yet-settled amounts" do
|
|
59
|
+
nonce = generate_non_plaid_us_bank_account_nonce("1000000001")
|
|
60
|
+
|
|
61
|
+
result = Braintree::PaymentMethod.create(
|
|
62
|
+
:payment_method_nonce => nonce,
|
|
63
|
+
:customer_id => customer.id,
|
|
64
|
+
:options => {
|
|
65
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
|
66
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
|
|
67
|
+
},
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
expect(result).to be_success
|
|
71
|
+
|
|
72
|
+
verification = result.payment_method.verifications.first
|
|
73
|
+
expect(verification.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers)
|
|
74
|
+
expect(verification.status).to eq(Braintree::UsBankAccountVerification::Status::Pending)
|
|
75
|
+
|
|
76
|
+
response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [17, 29])
|
|
77
|
+
|
|
78
|
+
expect(response).to be_success
|
|
79
|
+
expect(response.us_bank_account_verification.status).to eq(Braintree::UsBankAccountVerification::Status::Pending)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "attempts to confirm" do
|
|
83
|
+
result = Braintree::PaymentMethod.create(
|
|
84
|
+
:payment_method_nonce => nonce,
|
|
85
|
+
:customer_id => customer.id,
|
|
86
|
+
:options => {
|
|
87
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
|
88
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
|
|
89
|
+
},
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
expect(result).to be_success
|
|
93
|
+
|
|
94
|
+
verification = result.payment_method.verifications.first
|
|
95
|
+
expect(verification.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers)
|
|
96
|
+
expect(verification.status).to eq(Braintree::UsBankAccountVerification::Status::Pending)
|
|
97
|
+
|
|
98
|
+
response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [1, 1])
|
|
99
|
+
|
|
100
|
+
expect(response).not_to be_success
|
|
101
|
+
expect(response.errors.for(:us_bank_account_verification)[0].code).to eq(Braintree::ErrorCodes::UsBankAccountVerification::AmountsDoNotMatch)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "exceeds the confirmation attempt threshold" do
|
|
105
|
+
result = Braintree::PaymentMethod.create(
|
|
106
|
+
:payment_method_nonce => nonce,
|
|
107
|
+
:customer_id => customer.id,
|
|
108
|
+
:options => {
|
|
109
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
|
110
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
|
|
111
|
+
},
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
expect(result).to be_success
|
|
115
|
+
|
|
116
|
+
verification = result.payment_method.verifications.first
|
|
117
|
+
|
|
118
|
+
response = nil
|
|
119
|
+
4.times do
|
|
120
|
+
response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [1, 1])
|
|
121
|
+
|
|
122
|
+
expect(response).not_to be_success
|
|
123
|
+
expect(response.errors.for(:us_bank_account_verification)[0].code).to eq(Braintree::ErrorCodes::UsBankAccountVerification::AmountsDoNotMatch)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [1, 1])
|
|
127
|
+
expect(response).not_to be_success
|
|
128
|
+
expect(response.errors.for(:us_bank_account_verification)[0].code).to eq(Braintree::ErrorCodes::UsBankAccountVerification::TooManyConfirmationAttempts)
|
|
129
|
+
|
|
130
|
+
response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [1, 1])
|
|
131
|
+
expect(response).not_to be_success
|
|
132
|
+
expect(response.errors.for(:us_bank_account_verification)[0].code).to eq(Braintree::ErrorCodes::UsBankAccountVerification::TooManyConfirmationAttempts)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "returns an error for invalid deposit amounts" do
|
|
136
|
+
result = Braintree::PaymentMethod.create(
|
|
137
|
+
:payment_method_nonce => nonce,
|
|
138
|
+
:customer_id => customer.id,
|
|
139
|
+
:options => {
|
|
140
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
|
141
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
|
|
142
|
+
},
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
expect(result).to be_success
|
|
146
|
+
|
|
147
|
+
verification = result.payment_method.verifications.first
|
|
148
|
+
response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, ["abc"])
|
|
149
|
+
|
|
150
|
+
expect(response).not_to be_success
|
|
151
|
+
expect(response.errors.for(:us_bank_account_verification)[0].code).to eq(Braintree::ErrorCodes::UsBankAccountVerification::InvalidDepositAmounts)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
context "non-micro transfer" do
|
|
156
|
+
it "rejects for incorrect verification type" do
|
|
157
|
+
result = Braintree::PaymentMethod.create(
|
|
158
|
+
:payment_method_nonce => nonce,
|
|
159
|
+
:customer_id => customer.id,
|
|
160
|
+
:options => {
|
|
161
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
|
162
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
|
163
|
+
},
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
expect(result).to be_success
|
|
167
|
+
|
|
168
|
+
verification = result.payment_method.verifications.first
|
|
169
|
+
response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [1, 1])
|
|
170
|
+
|
|
171
|
+
expect(response).not_to be_success
|
|
172
|
+
expect(response.errors.for(:us_bank_account_verification)[0].code).to eq(Braintree::ErrorCodes::UsBankAccountVerification::MustBeMicroTransfersVerification)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
describe "self.find" do
|
|
178
|
+
it "finds the verification with the given id" do
|
|
179
|
+
result = Braintree::PaymentMethod.create(
|
|
180
|
+
:payment_method_nonce => nonce,
|
|
181
|
+
:customer_id => customer.id,
|
|
182
|
+
:options => {
|
|
183
|
+
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
|
184
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
|
185
|
+
},
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
expect(result).to be_success
|
|
189
|
+
|
|
190
|
+
created_verification = result.payment_method.verifications.first
|
|
191
|
+
found_verification = Braintree::UsBankAccountVerification.find(created_verification.id)
|
|
192
|
+
|
|
193
|
+
expect(found_verification).to eq(created_verification)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "raises a NotFoundError exception if verification cannot be found" do
|
|
197
|
+
expect do
|
|
198
|
+
Braintree::UsBankAccountVerification.find("invalid-id")
|
|
199
|
+
end.to raise_error(Braintree::NotFoundError, 'verification with id "invalid-id" not found')
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
describe "self.search" do
|
|
204
|
+
let(:payment_method) do
|
|
205
|
+
Braintree::PaymentMethod.create(
|
|
206
|
+
:payment_method_nonce => nonce,
|
|
207
|
+
:customer_id => customer.id,
|
|
208
|
+
:options => {
|
|
209
|
+
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
|
210
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
|
211
|
+
},
|
|
212
|
+
).payment_method
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
let(:created_verification) do
|
|
216
|
+
payment_method.verifications.first
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
it "searches and finds verification using verification fields" do
|
|
220
|
+
found_verifications = Braintree::UsBankAccountVerification.search do |search|
|
|
221
|
+
search.created_at >= (Time.now() - 120)
|
|
222
|
+
search.ids.in created_verification.id
|
|
223
|
+
search.status.in created_verification.status
|
|
224
|
+
search.verification_method.in created_verification.verification_method
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
expect(found_verifications).to include(created_verification)
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it "searches and finds verifications using customer fields" do
|
|
231
|
+
found_verifications = Braintree::UsBankAccountVerification.search do |search|
|
|
232
|
+
search.customer_email.is customer.email
|
|
233
|
+
search.customer_id.is customer.id
|
|
234
|
+
search.payment_method_token.is payment_method.token
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
expect(found_verifications.count).to eq(1)
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
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::VisaCheckoutCard do
|
|
5
|
+
it "can create from payment method nonce" do
|
|
6
|
+
customer = Braintree::Customer.create!
|
|
7
|
+
|
|
8
|
+
result = Braintree::PaymentMethod.create(
|
|
9
|
+
:payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutDiscover,
|
|
10
|
+
:customer_id => customer.id,
|
|
11
|
+
)
|
|
12
|
+
expect(result).to be_success
|
|
13
|
+
|
|
14
|
+
visa_checkout_card = result.payment_method
|
|
15
|
+
expect(visa_checkout_card).to be_a(Braintree::VisaCheckoutCard)
|
|
16
|
+
expect(visa_checkout_card.call_id).to eq("abc123")
|
|
17
|
+
expect(visa_checkout_card.billing_address).not_to be_nil
|
|
18
|
+
expect(visa_checkout_card.bin).not_to be_nil
|
|
19
|
+
expect(visa_checkout_card.card_type).not_to be_nil
|
|
20
|
+
expect(visa_checkout_card.cardholder_name).not_to be_nil
|
|
21
|
+
expect(visa_checkout_card.commercial).not_to be_nil
|
|
22
|
+
expect(visa_checkout_card.country_of_issuance).not_to be_nil
|
|
23
|
+
expect(visa_checkout_card.created_at).not_to be_nil
|
|
24
|
+
expect(visa_checkout_card.customer_id).not_to be_nil
|
|
25
|
+
expect(visa_checkout_card.customer_location).not_to be_nil
|
|
26
|
+
expect(visa_checkout_card.debit).not_to be_nil
|
|
27
|
+
expect(visa_checkout_card.default?).not_to be_nil
|
|
28
|
+
expect(visa_checkout_card.durbin_regulated).not_to be_nil
|
|
29
|
+
expect(visa_checkout_card.expiration_date).not_to be_nil
|
|
30
|
+
expect(visa_checkout_card.expiration_month).not_to be_nil
|
|
31
|
+
expect(visa_checkout_card.expiration_year).not_to be_nil
|
|
32
|
+
expect(visa_checkout_card.expired?).not_to be_nil
|
|
33
|
+
expect(visa_checkout_card.healthcare).not_to be_nil
|
|
34
|
+
expect(visa_checkout_card.image_url).not_to be_nil
|
|
35
|
+
expect(visa_checkout_card.issuing_bank).not_to be_nil
|
|
36
|
+
expect(visa_checkout_card.last_4).not_to be_nil
|
|
37
|
+
expect(visa_checkout_card.payroll).not_to be_nil
|
|
38
|
+
expect(visa_checkout_card.prepaid).not_to be_nil
|
|
39
|
+
expect(visa_checkout_card.product_id).not_to be_nil
|
|
40
|
+
expect(visa_checkout_card.subscriptions).not_to be_nil
|
|
41
|
+
expect(visa_checkout_card.token).not_to be_nil
|
|
42
|
+
expect(visa_checkout_card.unique_number_identifier).not_to be_nil
|
|
43
|
+
expect(visa_checkout_card.updated_at).not_to be_nil
|
|
44
|
+
|
|
45
|
+
customer = Braintree::Customer.find(customer.id)
|
|
46
|
+
expect(customer.visa_checkout_cards.size).to eq(1)
|
|
47
|
+
expect(customer.visa_checkout_cards.first).to eq(visa_checkout_card)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "can create with verification" do
|
|
51
|
+
customer = Braintree::Customer.create!
|
|
52
|
+
|
|
53
|
+
result = Braintree::PaymentMethod.create(
|
|
54
|
+
:payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutDiscover,
|
|
55
|
+
:customer_id => customer.id,
|
|
56
|
+
:options => {:verify_card => true},
|
|
57
|
+
)
|
|
58
|
+
expect(result).to be_success
|
|
59
|
+
expect(result.payment_method.verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "can search for transactions" do
|
|
63
|
+
transaction_create_result = Braintree::Transaction.sale(
|
|
64
|
+
:payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutDiscover,
|
|
65
|
+
:amount => "47.00",
|
|
66
|
+
)
|
|
67
|
+
expect(transaction_create_result).to be_success
|
|
68
|
+
transaction_id = transaction_create_result.transaction.id
|
|
69
|
+
|
|
70
|
+
search_results = Braintree::Transaction.search do |search|
|
|
71
|
+
search.id.is transaction_id
|
|
72
|
+
search.payment_instrument_type.is Braintree::PaymentInstrumentType::VisaCheckoutCard
|
|
73
|
+
end
|
|
74
|
+
expect(search_results.first.id).to eq(transaction_id)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "can create transaction from nonce and vault" do
|
|
78
|
+
customer = Braintree::Customer.create!
|
|
79
|
+
|
|
80
|
+
result = Braintree::Transaction.sale(
|
|
81
|
+
:payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutDiscover,
|
|
82
|
+
:customer_id => customer.id,
|
|
83
|
+
:amount => "47.00",
|
|
84
|
+
:options => {:store_in_vault => true},
|
|
85
|
+
)
|
|
86
|
+
expect(result).to be_success
|
|
87
|
+
|
|
88
|
+
visa_checkout_card_details = result.transaction.visa_checkout_card_details
|
|
89
|
+
expect(visa_checkout_card_details.call_id).to eq("abc123")
|
|
90
|
+
expect(visa_checkout_card_details.bin).not_to be_nil
|
|
91
|
+
expect(visa_checkout_card_details.card_type).not_to be_nil
|
|
92
|
+
expect(visa_checkout_card_details.cardholder_name).not_to be_nil
|
|
93
|
+
expect(visa_checkout_card_details.commercial).not_to be_nil
|
|
94
|
+
expect(visa_checkout_card_details.country_of_issuance).not_to be_nil
|
|
95
|
+
expect(visa_checkout_card_details.customer_location).not_to be_nil
|
|
96
|
+
expect(visa_checkout_card_details.debit).not_to be_nil
|
|
97
|
+
expect(visa_checkout_card_details.durbin_regulated).not_to be_nil
|
|
98
|
+
expect(visa_checkout_card_details.expiration_date).not_to be_nil
|
|
99
|
+
expect(visa_checkout_card_details.expiration_month).not_to be_nil
|
|
100
|
+
expect(visa_checkout_card_details.expiration_year).not_to be_nil
|
|
101
|
+
expect(visa_checkout_card_details.healthcare).not_to be_nil
|
|
102
|
+
expect(visa_checkout_card_details.image_url).not_to be_nil
|
|
103
|
+
expect(visa_checkout_card_details.issuing_bank).not_to be_nil
|
|
104
|
+
expect(visa_checkout_card_details.last_4).not_to be_nil
|
|
105
|
+
expect(visa_checkout_card_details.payroll).not_to be_nil
|
|
106
|
+
expect(visa_checkout_card_details.prepaid).not_to be_nil
|
|
107
|
+
expect(visa_checkout_card_details.product_id).not_to be_nil
|
|
108
|
+
expect(visa_checkout_card_details.token).not_to be_nil
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
require "securerandom"
|
|
2
|
+
|
|
1
3
|
unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
|
|
2
4
|
INTEGRATION_SPEC_HELPER_LOADED = true
|
|
5
|
+
SSL_TEST_PORT = ENV["SSL_TEST_PORT"] || 8444
|
|
3
6
|
|
|
4
7
|
require File.dirname(__FILE__) + "/../spec_helper"
|
|
5
|
-
require File.dirname(__FILE__) + "/../hacks/tcp_socket"
|
|
6
8
|
|
|
7
9
|
def start_ssl_server
|
|
8
10
|
web_server_pid_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "httpsd.pid"))
|
|
@@ -10,11 +12,65 @@ unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
|
|
|
10
12
|
FileUtils.rm(web_server_pid_file) if File.exist?(web_server_pid_file)
|
|
11
13
|
command = File.expand_path(File.join(File.dirname(__FILE__), "..", "script", "httpsd.rb"))
|
|
12
14
|
`#{command} #{web_server_pid_file}`
|
|
13
|
-
TCPSocket.
|
|
14
|
-
|
|
15
|
-
yield
|
|
15
|
+
TCPSocket.new("127.0.0.1",SSL_TEST_PORT)
|
|
16
16
|
|
|
17
|
-
10.times { unless File.
|
|
17
|
+
10.times { unless File.exist?(web_server_pid_file); sleep 1; end }
|
|
18
|
+
ensure
|
|
18
19
|
Process.kill "INT", File.read(web_server_pid_file).to_i
|
|
19
20
|
end
|
|
21
|
+
|
|
22
|
+
def create_modification_for_tests(attributes)
|
|
23
|
+
config = Braintree::Configuration.instantiate
|
|
24
|
+
config.http.post("#{config.base_merchant_path}/modifications/create_modification_for_tests", :modification => attributes)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def with_other_merchant(merchant_id, public_key, private_key, &block)
|
|
28
|
+
old_merchant_id = Braintree::Configuration.merchant_id
|
|
29
|
+
old_public_key = Braintree::Configuration.public_key
|
|
30
|
+
old_private_key = Braintree::Configuration.private_key
|
|
31
|
+
|
|
32
|
+
Braintree::Configuration.merchant_id = merchant_id
|
|
33
|
+
Braintree::Configuration.public_key = public_key
|
|
34
|
+
Braintree::Configuration.private_key = private_key
|
|
35
|
+
|
|
36
|
+
begin
|
|
37
|
+
yield
|
|
38
|
+
ensure
|
|
39
|
+
Braintree::Configuration.merchant_id = old_merchant_id
|
|
40
|
+
Braintree::Configuration.public_key = old_public_key
|
|
41
|
+
Braintree::Configuration.private_key = old_private_key
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def with_advanced_fraud_kount_integration_merchant(&block)
|
|
46
|
+
with_other_merchant("advanced_fraud_integration_merchant_id", "advanced_fraud_integration_public_key", "advanced_fraud_integration_private_key") do
|
|
47
|
+
block.call
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def with_fraud_protection_enterprise_merchant(&block)
|
|
52
|
+
with_other_merchant("fraud_protection_enterprise_integration_merchant_id", "fraud_protection_enterprise_integration_public_key", "fraud_protection_enterprise_integration_private_key") do
|
|
53
|
+
block.call
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def with_chargeback_protection_merchant(&block)
|
|
58
|
+
with_other_merchant("fraud_protection_effortless_chargeback_protection_merchant_id", "effortless_chargeback_protection_public_key", "effortless_chargeback_protection_private_key") do
|
|
59
|
+
block.call
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def with_altpay_merchant(&block)
|
|
64
|
+
with_other_merchant("altpay_merchant", "altpay_merchant_public_key", "altpay_merchant_private_key", &block)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def random_payment_method_token
|
|
68
|
+
"payment-method-token-#{SecureRandom.hex(6)}"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def with_duplicate_checking_merchant(&block)
|
|
72
|
+
with_other_merchant("dup_checking_integration_merchant_id", "dup_checking_integration_public_key", "dup_checking_integration_private_key") do
|
|
73
|
+
block.call
|
|
74
|
+
end
|
|
75
|
+
end
|
|
20
76
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class OAuthTestHelper
|
|
3
|
+
def self.create_grant(gateway, params)
|
|
4
|
+
response = gateway.config.http.post("/oauth_testing/grants", {
|
|
5
|
+
:grant => params
|
|
6
|
+
})
|
|
7
|
+
response[:grant][:code]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.create_token(gateway, params)
|
|
11
|
+
code = create_grant(gateway, params)
|
|
12
|
+
gateway.oauth.create_token_from_code(
|
|
13
|
+
:code => code,
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
data/spec/script/httpsd.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
2
|
+
require "webrick"
|
|
3
|
+
require "webrick/https"
|
|
4
|
+
require "openssl"
|
|
5
5
|
|
|
6
6
|
private_key_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "ssl", "privateKey.key"))
|
|
7
7
|
cert_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "ssl", "certificate.crt"))
|
|
@@ -12,7 +12,7 @@ cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
|
|
|
12
12
|
pid_file = ARGV[0]
|
|
13
13
|
|
|
14
14
|
s = WEBrick::HTTPServer.new(
|
|
15
|
-
:Port =>
|
|
15
|
+
:Port => (ENV["SSL_TEST_PORT"] || 8444),
|
|
16
16
|
:Logger => WEBrick::Log::new(nil, WEBrick::Log::ERROR),
|
|
17
17
|
:DocumentRoot => File.join(File.dirname(__FILE__)),
|
|
18
18
|
:ServerType => WEBrick::Daemon,
|
|
@@ -21,7 +21,7 @@ s = WEBrick::HTTPServer.new(
|
|
|
21
21
|
:SSLCertificate => cert,
|
|
22
22
|
:SSLPrivateKey => pkey,
|
|
23
23
|
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ],
|
|
24
|
-
:StartCallback => proc { File.open(pid_file, "w") { |f| f.write $$.to_s }}
|
|
24
|
+
:StartCallback => proc { File.open(pid_file, "w") { |f| f.write $$.to_s } },
|
|
25
25
|
)
|
|
26
|
-
trap("INT"){ s.shutdown }
|
|
26
|
+
trap("INT") { s.shutdown }
|
|
27
27
|
s.start
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
unless defined?(SPEC_HELPER_LOADED)
|
|
2
2
|
SPEC_HELPER_LOADED = true
|
|
3
|
-
|
|
4
3
|
project_root = File.expand_path(File.dirname(__FILE__) + "/..")
|
|
5
4
|
require "rubygems"
|
|
6
|
-
|
|
5
|
+
require "bundler/setup"
|
|
7
6
|
require "libxml"
|
|
8
|
-
|
|
7
|
+
require "rspec"
|
|
8
|
+
require "pry"
|
|
9
|
+
|
|
9
10
|
braintree_lib = "#{project_root}/lib"
|
|
10
11
|
$LOAD_PATH << braintree_lib
|
|
11
12
|
require "braintree"
|
|
13
|
+
require File.dirname(__FILE__) + "/oauth_test_helper"
|
|
12
14
|
|
|
13
15
|
Braintree::Configuration.environment = :development
|
|
14
16
|
Braintree::Configuration.merchant_id = "integration_merchant_id"
|
|
@@ -28,13 +30,25 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
28
30
|
|
|
29
31
|
module SpecHelper
|
|
30
32
|
|
|
33
|
+
AdyenMerchantAccountId = "adyen_ma"
|
|
34
|
+
AibSwedenMaMerchantAccountId = "aib_swe_ma"
|
|
35
|
+
AnotherUsBankMerchantAccountId = "another_us_bank_merchant_account"
|
|
36
|
+
CardProcessorBRLMerchantAccountId = "card_processor_brl"
|
|
31
37
|
DefaultMerchantAccountId = "sandbox_credit_card"
|
|
38
|
+
FakeAmexDirectMerchantAccountId = "fake_amex_direct_usd"
|
|
39
|
+
FakeFirstDataMerchantAccountId = "fake_first_data_merchant_account"
|
|
40
|
+
FakeVenmoAccountMerchantAccountId = "fake_first_data_venmo_account"
|
|
41
|
+
HiperBRLMerchantAccountId = "hiper_brl"
|
|
32
42
|
NonDefaultMerchantAccountId = "sandbox_credit_card_non_default"
|
|
43
|
+
NonDefaultSubMerchantAccountId = "sandbox_sub_merchant_account"
|
|
44
|
+
PinlessDebitMerchantAccountId = "pinless_debit"
|
|
45
|
+
ThreeDSecureMerchantAccountId = "three_d_secure_merchant_account"
|
|
46
|
+
UsBankMerchantAccountId = "us_bank_merchant_account"
|
|
33
47
|
|
|
34
48
|
TrialPlan = {
|
|
35
49
|
:description => "Plan for integration tests -- with trial",
|
|
36
50
|
:id => "integration_trial_plan",
|
|
37
|
-
:price => BigDecimal
|
|
51
|
+
:price => BigDecimal("43.21"),
|
|
38
52
|
:trial_period => true,
|
|
39
53
|
:trial_duration => 2,
|
|
40
54
|
:trial_duration_unit => Braintree::Subscription::TrialDurationUnit::Day
|
|
@@ -43,14 +57,14 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
43
57
|
TriallessPlan = {
|
|
44
58
|
:description => "Plan for integration tests -- without a trial",
|
|
45
59
|
:id => "integration_trialless_plan",
|
|
46
|
-
:price => BigDecimal
|
|
60
|
+
:price => BigDecimal("12.34"),
|
|
47
61
|
:trial_period => false
|
|
48
62
|
}
|
|
49
63
|
|
|
50
64
|
AddOnDiscountPlan = {
|
|
51
65
|
:description => "Plan for integration tests -- with add-ons and discounts",
|
|
52
66
|
:id => "integration_plan_with_add_ons_and_discounts",
|
|
53
|
-
:price => BigDecimal
|
|
67
|
+
:price => BigDecimal("9.99"),
|
|
54
68
|
:trial_period => true,
|
|
55
69
|
:trial_duration => 2,
|
|
56
70
|
:trial_duration_unit => Braintree::Subscription::TrialDurationUnit::Day
|
|
@@ -59,7 +73,7 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
59
73
|
BillingDayOfMonthPlan = {
|
|
60
74
|
:description => "Plan for integration tests -- with billing day of month",
|
|
61
75
|
:id => "integration_plan_with_billing_day_of_month",
|
|
62
|
-
:price => BigDecimal
|
|
76
|
+
:price => BigDecimal("8.88"),
|
|
63
77
|
:billing_day_of_month => 5
|
|
64
78
|
}
|
|
65
79
|
|
|
@@ -71,14 +85,46 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
71
85
|
Discount11 = "discount_11"
|
|
72
86
|
Discount15 = "discount_15"
|
|
73
87
|
|
|
88
|
+
DefaultOrderId = "ABC123"
|
|
89
|
+
|
|
90
|
+
TestMerchantConfig = Braintree::Configuration.new(
|
|
91
|
+
:logger => Logger.new("/dev/null"),
|
|
92
|
+
:environment => Braintree::Configuration.environment,
|
|
93
|
+
:merchant_id => "test_merchant_id",
|
|
94
|
+
:public_key => "test_public_key",
|
|
95
|
+
:private_key => "test_private_key",
|
|
96
|
+
)
|
|
97
|
+
|
|
74
98
|
def self.make_past_due(subscription, number_of_days_past_due = 1)
|
|
75
|
-
Braintree::Configuration.instantiate
|
|
76
|
-
|
|
99
|
+
config = Braintree::Configuration.instantiate
|
|
100
|
+
config.http.put(
|
|
101
|
+
"#{config.base_merchant_path}/subscriptions/#{subscription.id}/make_past_due?days_past_due=#{number_of_days_past_due}",
|
|
77
102
|
)
|
|
78
103
|
end
|
|
79
104
|
|
|
80
105
|
def self.settle_transaction(transaction_id)
|
|
81
|
-
Braintree::Configuration.instantiate
|
|
106
|
+
config = Braintree::Configuration.instantiate
|
|
107
|
+
config.http.put("#{config.base_merchant_path}/transactions/#{transaction_id}/settle")
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def self.create_3ds_verification(merchant_account_id, params)
|
|
111
|
+
config = Braintree::Configuration.instantiate
|
|
112
|
+
response = config.http.post("#{config.base_merchant_path}/three_d_secure/create_verification/#{merchant_account_id}", :three_d_secure_verification => params)
|
|
113
|
+
response[:three_d_secure_verification][:three_d_secure_authentication_id]
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def self.create_merchant(params={})
|
|
117
|
+
gateway = Braintree::Gateway.new(
|
|
118
|
+
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
|
119
|
+
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
|
120
|
+
:logger => Logger.new("/dev/null"),
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
gateway.merchant.create({
|
|
124
|
+
:email => "name@email.com",
|
|
125
|
+
:country_code_alpha3 => "GBR",
|
|
126
|
+
:payment_methods => ["credit_card", "paypal"],
|
|
127
|
+
}.merge!(params))
|
|
82
128
|
end
|
|
83
129
|
|
|
84
130
|
def self.stub_time_dot_now(desired_time)
|
|
@@ -101,7 +147,10 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
101
147
|
|
|
102
148
|
def self.simulate_form_post_for_tr(tr_data_string, form_data_hash, url = Braintree::TransparentRedirect.url)
|
|
103
149
|
response = nil
|
|
104
|
-
|
|
150
|
+
config = Braintree::Configuration.instantiate
|
|
151
|
+
http = Net::HTTP.new(config.server, config.port)
|
|
152
|
+
http.use_ssl = config.ssl?
|
|
153
|
+
http.start do |http|
|
|
105
154
|
request = Net::HTTP::Post.new("/" + url.split("/", 4)[3])
|
|
106
155
|
request.add_field "Content-Type", "application/x-www-form-urlencoded"
|
|
107
156
|
request.body = Braintree::Util.hash_to_query_string({:tr_data => tr_data_string}.merge(form_data_hash))
|
|
@@ -139,16 +188,11 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
139
188
|
end
|
|
140
189
|
|
|
141
190
|
def matches?(xml_string)
|
|
142
|
-
@libxml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string
|
|
143
|
-
@rexml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string, Braintree::Xml::Rexml)
|
|
191
|
+
@libxml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string)
|
|
144
192
|
if @libxml_parse != @expected_hash
|
|
145
193
|
@results = @libxml_parse
|
|
146
194
|
@failed_parser = "libxml"
|
|
147
195
|
false
|
|
148
|
-
elsif @rexml_parse != @expected_hash
|
|
149
|
-
@results = @rexml_parse
|
|
150
|
-
@failed_parser = "rexml"
|
|
151
|
-
false
|
|
152
196
|
else
|
|
153
197
|
true
|
|
154
198
|
end
|
|
@@ -158,7 +202,7 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
158
202
|
"xml parsing failed for #{@failed_parser}, expected #{@expected_hash.inspect} but was #{@results.inspect}"
|
|
159
203
|
end
|
|
160
204
|
|
|
161
|
-
def
|
|
205
|
+
def failure_message_when_negated
|
|
162
206
|
raise NotImplementedError
|
|
163
207
|
end
|
|
164
208
|
end
|
|
@@ -167,9 +211,21 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
167
211
|
ParseTo.new(hash)
|
|
168
212
|
end
|
|
169
213
|
end
|
|
214
|
+
end
|
|
170
215
|
|
|
171
|
-
|
|
172
|
-
|
|
216
|
+
RSpec.configure do |config|
|
|
217
|
+
config.include CustomMatchers
|
|
218
|
+
|
|
219
|
+
if ENV["JUNIT"] == "1"
|
|
220
|
+
config.add_formatter("RspecJunitFormatter", "tmp/build/braintree-ruby.#{rand}.junit.xml")
|
|
221
|
+
config.add_formatter("progress")
|
|
173
222
|
end
|
|
174
|
-
end
|
|
175
223
|
|
|
224
|
+
config.expect_with :rspec do |expect|
|
|
225
|
+
expect.syntax = [:should, :expect]
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
config.mock_with :rspec do |mock|
|
|
229
|
+
mock.syntax = [:should, :expect]
|
|
230
|
+
end
|
|
231
|
+
end
|