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,45 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class ClientTokenGateway
|
|
3
|
+
include BaseModule
|
|
4
|
+
|
|
5
|
+
def initialize(gateway)
|
|
6
|
+
@gateway = gateway
|
|
7
|
+
@config = gateway.config
|
|
8
|
+
@config.assert_has_access_token_or_keys
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def generate(options={})
|
|
12
|
+
_validate_options(options)
|
|
13
|
+
|
|
14
|
+
options[:version] ||= ClientToken::DEFAULT_VERSION
|
|
15
|
+
|
|
16
|
+
Util.verify_keys(ClientTokenGateway._generate_signature, options)
|
|
17
|
+
|
|
18
|
+
params = {:client_token => options}
|
|
19
|
+
result = @config.http.post("#{@config.base_merchant_path}/client_token", params)
|
|
20
|
+
|
|
21
|
+
if result[:client_token]
|
|
22
|
+
result[:client_token][:value]
|
|
23
|
+
else
|
|
24
|
+
raise ArgumentError, result[:api_error_response][:message]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self._generate_signature
|
|
29
|
+
[
|
|
30
|
+
:address_id, :customer_id, :proxy_merchant_id, :merchant_account_id,
|
|
31
|
+
:version,
|
|
32
|
+
{:domains => [:_any_key_]},
|
|
33
|
+
{:options => [:fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :make_default, :verify_card]}
|
|
34
|
+
]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def _validate_options(options)
|
|
38
|
+
[:fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :make_default, :verify_card].each do |credit_card_option|
|
|
39
|
+
if options[credit_card_option]
|
|
40
|
+
raise ArgumentError.new("cannot specify #{credit_card_option} without a customer_id") unless options[:customer_id]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -1,130 +1,322 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
# See http://www.braintreepaymentsolutions.com/docs/ruby
|
|
3
2
|
class Configuration
|
|
4
|
-
API_VERSION = "
|
|
3
|
+
API_VERSION = "6"
|
|
4
|
+
DEFAULT_ENDPOINT = "api"
|
|
5
|
+
# NEXT_MAJOR_VERSION update to the latest version of GraphQL API
|
|
6
|
+
GRAPHQL_API_VERSION = "2018-09-10"
|
|
7
|
+
|
|
8
|
+
READABLE_ATTRIBUTES = [
|
|
9
|
+
:merchant_id,
|
|
10
|
+
:public_key,
|
|
11
|
+
:private_key,
|
|
12
|
+
:client_id,
|
|
13
|
+
:client_secret,
|
|
14
|
+
:access_token,
|
|
15
|
+
:environment
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
NON_REQUIRED_READABLE_ATTRIBUTES = [
|
|
19
|
+
:proxy_address,
|
|
20
|
+
:proxy_port,
|
|
21
|
+
:proxy_user,
|
|
22
|
+
:proxy_pass,
|
|
23
|
+
:ssl_version
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
WRITABLE_ATTRIBUTES = [
|
|
27
|
+
:custom_user_agent,
|
|
28
|
+
:endpoint,
|
|
29
|
+
:http_open_timeout,
|
|
30
|
+
:http_read_timeout,
|
|
31
|
+
:logger,
|
|
32
|
+
:merchant_id,
|
|
33
|
+
:public_key,
|
|
34
|
+
:private_key,
|
|
35
|
+
:environment,
|
|
36
|
+
:proxy_address,
|
|
37
|
+
:proxy_port,
|
|
38
|
+
:proxy_user,
|
|
39
|
+
:proxy_pass,
|
|
40
|
+
:ssl_version
|
|
41
|
+
]
|
|
5
42
|
|
|
6
43
|
class << self
|
|
7
|
-
attr_writer
|
|
44
|
+
attr_writer(*WRITABLE_ATTRIBUTES)
|
|
45
|
+
attr_reader(*NON_REQUIRED_READABLE_ATTRIBUTES)
|
|
8
46
|
end
|
|
9
|
-
attr_reader
|
|
47
|
+
attr_reader(*READABLE_ATTRIBUTES)
|
|
48
|
+
attr_reader(*NON_REQUIRED_READABLE_ATTRIBUTES)
|
|
49
|
+
attr_writer(*WRITABLE_ATTRIBUTES)
|
|
10
50
|
|
|
11
|
-
def self.expectant_reader(*attributes)
|
|
51
|
+
def self.expectant_reader(*attributes)
|
|
12
52
|
attributes.each do |attribute|
|
|
13
53
|
(class << self; self; end).send(:define_method, attribute) do
|
|
14
54
|
attribute_value = instance_variable_get("@#{attribute}")
|
|
15
|
-
raise ConfigurationError.new(attribute
|
|
55
|
+
raise ConfigurationError.new("Braintree::Configuration.#{attribute} needs to be set") if attribute_value.nil? || attribute_value.to_s.empty?
|
|
16
56
|
attribute_value
|
|
17
57
|
end
|
|
18
58
|
end
|
|
19
59
|
end
|
|
20
|
-
expectant_reader
|
|
60
|
+
expectant_reader(*READABLE_ATTRIBUTES)
|
|
21
61
|
|
|
22
|
-
# Sets the Braintree environment to use. Valid values are <tt>:sandbox</tt> and <tt>:production</tt>
|
|
23
62
|
def self.environment=(env)
|
|
63
|
+
env = env.to_sym
|
|
24
64
|
unless [:development, :qa, :sandbox, :production].include?(env)
|
|
25
65
|
raise ArgumentError, "#{env.inspect} is not a valid environment"
|
|
26
66
|
end
|
|
27
67
|
@environment = env
|
|
28
68
|
end
|
|
29
69
|
|
|
30
|
-
def self.gateway
|
|
70
|
+
def self.gateway
|
|
31
71
|
Braintree::Gateway.new(instantiate)
|
|
32
72
|
end
|
|
33
73
|
|
|
34
|
-
def self.instantiate
|
|
35
|
-
|
|
74
|
+
def self.instantiate
|
|
75
|
+
new(
|
|
36
76
|
:custom_user_agent => @custom_user_agent,
|
|
77
|
+
:endpoint => @endpoint,
|
|
37
78
|
:environment => environment,
|
|
79
|
+
:http_open_timeout => http_open_timeout,
|
|
80
|
+
:http_read_timeout => http_read_timeout,
|
|
38
81
|
:logger => logger,
|
|
39
82
|
:merchant_id => merchant_id,
|
|
40
83
|
:private_key => private_key,
|
|
41
|
-
:public_key => public_key
|
|
84
|
+
:public_key => public_key,
|
|
85
|
+
:proxy_address => proxy_address,
|
|
86
|
+
:proxy_port => proxy_port,
|
|
87
|
+
:proxy_user => proxy_user,
|
|
88
|
+
:proxy_pass => proxy_pass,
|
|
89
|
+
:ssl_version => ssl_version,
|
|
42
90
|
)
|
|
43
91
|
end
|
|
44
92
|
|
|
93
|
+
def self.http_open_timeout
|
|
94
|
+
@http_open_timeout ||= 60
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def self.http_read_timeout
|
|
98
|
+
@http_read_timeout ||= 60
|
|
99
|
+
end
|
|
100
|
+
|
|
45
101
|
def self.logger
|
|
46
102
|
@logger ||= _default_logger
|
|
47
103
|
end
|
|
48
104
|
|
|
105
|
+
def self.signature_service
|
|
106
|
+
instantiate.signature_service
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def self.sha256_signature_service
|
|
110
|
+
instantiate.sha256_signature_service
|
|
111
|
+
end
|
|
112
|
+
|
|
49
113
|
def initialize(options = {})
|
|
50
|
-
|
|
114
|
+
WRITABLE_ATTRIBUTES.each do |attr|
|
|
51
115
|
instance_variable_set "@#{attr}", options[attr]
|
|
52
116
|
end
|
|
117
|
+
|
|
118
|
+
@environment = @environment.to_sym if @environment
|
|
119
|
+
|
|
120
|
+
_check_for_mixed_credentials(options)
|
|
121
|
+
|
|
122
|
+
parser = Braintree::CredentialsParser.new
|
|
123
|
+
if options[:client_id] || options[:client_secret]
|
|
124
|
+
parser.parse_client_credentials(options[:client_id], options[:client_secret])
|
|
125
|
+
@client_id = parser.client_id
|
|
126
|
+
@client_secret = parser.client_secret
|
|
127
|
+
@environment = parser.environment
|
|
128
|
+
elsif options[:access_token]
|
|
129
|
+
parser.parse_access_token(options[:access_token])
|
|
130
|
+
|
|
131
|
+
_check_for_mixed_environment(options[:environment], parser.environment)
|
|
132
|
+
|
|
133
|
+
@access_token = parser.access_token
|
|
134
|
+
@environment = parser.environment
|
|
135
|
+
@merchant_id = parser.merchant_id
|
|
136
|
+
else
|
|
137
|
+
@merchant_id = options[:merchant_id] || options[:partner_id]
|
|
138
|
+
end
|
|
53
139
|
end
|
|
54
140
|
|
|
55
|
-
def
|
|
141
|
+
def _check_for_mixed_credentials(options)
|
|
142
|
+
if (options[:client_id] || options[:client_secret]) && (options[:public_key] || options[:private_key])
|
|
143
|
+
raise ConfigurationError.new("Braintree::Gateway cannot be initialized with mixed credential types: client_id and client_secret mixed with public_key and private_key.")
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
if (options[:client_id] || options[:client_secret]) && (options[:access_token])
|
|
147
|
+
raise ConfigurationError.new("Braintree::Gateway cannot be initialized with mixed credential types: client_id and client_secret mixed with access_token.")
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
if (options[:public_key] || options[:private_key]) && (options[:access_token])
|
|
151
|
+
raise ConfigurationError.new("Braintree::Gateway cannot be initialized with mixed credential types: public_key and private_key mixed with access_token.")
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def _check_for_mixed_environment(options_environment, token_environment)
|
|
156
|
+
if options_environment && options_environment.to_sym != token_environment.to_sym
|
|
157
|
+
warn "Braintree::Gateway should not be initialized with mixed environments: environment parameter and access_token do not match, environment from access_token is used."
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def api_version
|
|
56
162
|
API_VERSION
|
|
57
163
|
end
|
|
58
164
|
|
|
59
|
-
def
|
|
165
|
+
def graphql_api_version
|
|
166
|
+
GRAPHQL_API_VERSION
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def base_merchant_path
|
|
60
170
|
"/merchants/#{merchant_id}"
|
|
61
171
|
end
|
|
62
172
|
|
|
63
|
-
def
|
|
64
|
-
"#{protocol}://#{server}:#{port}
|
|
173
|
+
def base_url
|
|
174
|
+
"#{protocol}://#{server}:#{port}"
|
|
65
175
|
end
|
|
66
176
|
|
|
67
|
-
def
|
|
68
|
-
|
|
69
|
-
when :qa, :sandbox
|
|
70
|
-
File.expand_path(File.join(File.dirname(__FILE__), "..", "ssl", "sandbox_braintreegateway_com.ca.crt"))
|
|
71
|
-
when :production
|
|
72
|
-
File.expand_path(File.join(File.dirname(__FILE__), "..", "ssl", "www_braintreegateway_com.ca.crt"))
|
|
73
|
-
end
|
|
177
|
+
def graphql_base_url
|
|
178
|
+
"#{protocol}://#{graphql_server}:#{graphql_port}/graphql"
|
|
74
179
|
end
|
|
75
180
|
|
|
76
|
-
def
|
|
181
|
+
def base_merchant_url
|
|
182
|
+
"#{base_url}#{base_merchant_path}"
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def ca_file
|
|
186
|
+
File.expand_path(File.join(File.dirname(__FILE__), "..", "ssl", "api_braintreegateway_com.ca.crt"))
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def endpoint
|
|
190
|
+
@endpoint || DEFAULT_ENDPOINT
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def http
|
|
77
194
|
Http.new(self)
|
|
78
195
|
end
|
|
79
196
|
|
|
197
|
+
def graphql_client
|
|
198
|
+
GraphQLClient.new(self)
|
|
199
|
+
end
|
|
200
|
+
|
|
80
201
|
def logger
|
|
81
202
|
@logger ||= self.class._default_logger
|
|
82
203
|
end
|
|
83
204
|
|
|
84
|
-
def port
|
|
205
|
+
def port
|
|
206
|
+
case @environment
|
|
207
|
+
when :development, :integration
|
|
208
|
+
ENV["GATEWAY_PORT"] || 3000
|
|
209
|
+
when :production, :qa, :sandbox
|
|
210
|
+
443
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def graphql_port
|
|
85
215
|
case @environment
|
|
86
|
-
when :development
|
|
87
|
-
ENV[
|
|
216
|
+
when :development, :integration
|
|
217
|
+
ENV["GRAPHQL_PORT"] || 8080
|
|
88
218
|
when :production, :qa, :sandbox
|
|
89
219
|
443
|
|
90
220
|
end
|
|
91
221
|
end
|
|
92
222
|
|
|
93
|
-
def protocol
|
|
223
|
+
def protocol
|
|
94
224
|
ssl? ? "https" : "http"
|
|
95
225
|
end
|
|
96
226
|
|
|
97
|
-
def
|
|
227
|
+
def http_open_timeout
|
|
228
|
+
@http_open_timeout
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def http_read_timeout
|
|
232
|
+
@http_read_timeout
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def server
|
|
236
|
+
case @environment
|
|
237
|
+
when :development, :integration
|
|
238
|
+
ENV["GATEWAY_HOST"] || "localhost"
|
|
239
|
+
when :production
|
|
240
|
+
"#{endpoint}.braintreegateway.com"
|
|
241
|
+
when :qa
|
|
242
|
+
"gateway.qa2.braintreepayments.com"
|
|
243
|
+
when :sandbox
|
|
244
|
+
"api.sandbox.braintreegateway.com"
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def graphql_server
|
|
98
249
|
case @environment
|
|
99
|
-
when :development
|
|
100
|
-
"
|
|
250
|
+
when :development, :integration
|
|
251
|
+
ENV["GRAPHQL_HOST"] || "graphql.bt.local"
|
|
101
252
|
when :production
|
|
102
|
-
"
|
|
253
|
+
"payments.braintree-api.com"
|
|
103
254
|
when :qa
|
|
104
|
-
"qa-
|
|
255
|
+
"payments-qa.dev.braintree-api.com"
|
|
105
256
|
when :sandbox
|
|
106
|
-
"sandbox.
|
|
257
|
+
"payments.sandbox.braintree-api.com"
|
|
107
258
|
end
|
|
108
259
|
end
|
|
109
260
|
|
|
110
|
-
def
|
|
261
|
+
def auth_url
|
|
111
262
|
case @environment
|
|
112
|
-
when :development
|
|
263
|
+
when :development, :integration
|
|
264
|
+
"http://auth.venmo.dev:9292"
|
|
265
|
+
when :production
|
|
266
|
+
"https://auth.venmo.com"
|
|
267
|
+
when :qa
|
|
268
|
+
"https://auth.venmo.qa2.braintreegateway.com"
|
|
269
|
+
when :sandbox
|
|
270
|
+
"https://auth.venmo.sandbox.braintreegateway.com"
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def ssl?
|
|
275
|
+
case @environment
|
|
276
|
+
when :development, :integration
|
|
113
277
|
false
|
|
114
278
|
when :production, :qa, :sandbox
|
|
115
279
|
true
|
|
116
280
|
end
|
|
117
281
|
end
|
|
118
282
|
|
|
119
|
-
def user_agent
|
|
283
|
+
def user_agent
|
|
120
284
|
base_user_agent = "Braintree Ruby Gem #{Braintree::Version::String}"
|
|
121
285
|
@custom_user_agent ? "#{base_user_agent} (#{@custom_user_agent})" : base_user_agent
|
|
122
286
|
end
|
|
123
287
|
|
|
124
|
-
def self._default_logger
|
|
288
|
+
def self._default_logger
|
|
125
289
|
logger = Logger.new(STDOUT)
|
|
126
290
|
logger.level = Logger::INFO
|
|
127
291
|
logger
|
|
128
292
|
end
|
|
293
|
+
|
|
294
|
+
def inspect
|
|
295
|
+
super.gsub(/@private_key=\".*\"/, '@private_key="[FILTERED]"')
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def client_credentials?
|
|
299
|
+
!client_id.nil?
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def assert_has_client_credentials
|
|
303
|
+
if client_id.nil? || client_secret.nil?
|
|
304
|
+
raise ConfigurationError.new("Braintree::Gateway client_id and client_secret are required.")
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def assert_has_access_token_or_keys
|
|
309
|
+
if (public_key.nil? || private_key.nil?) && access_token.nil?
|
|
310
|
+
raise ConfigurationError.new("Braintree::Gateway access_token or public_key and private_key are required.")
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def signature_service
|
|
315
|
+
@signature_service ||= SignatureService.new(@private_key)
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def sha256_signature_service
|
|
319
|
+
@sha256_signature_service ||= SignatureService.new(@private_key, SHA256Digest)
|
|
320
|
+
end
|
|
129
321
|
end
|
|
130
322
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class ConnectedMerchantPayPalStatusChanged
|
|
3
|
+
include BaseModule
|
|
4
|
+
|
|
5
|
+
attr_reader :action
|
|
6
|
+
attr_reader :merchant_public_id
|
|
7
|
+
attr_reader :oauth_application_client_id
|
|
8
|
+
|
|
9
|
+
alias_method :merchant_id, :merchant_public_id
|
|
10
|
+
|
|
11
|
+
def initialize(attributes)
|
|
12
|
+
set_instance_variables_from_hash(attributes)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class << self
|
|
16
|
+
protected :new
|
|
17
|
+
def _new(*args)
|
|
18
|
+
self.new(*args)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class ConnectedMerchantStatusTransitioned
|
|
3
|
+
include BaseModule
|
|
4
|
+
|
|
5
|
+
attr_reader :merchant_public_id
|
|
6
|
+
attr_reader :oauth_application_client_id
|
|
7
|
+
attr_reader :status
|
|
8
|
+
|
|
9
|
+
alias_method :merchant_id, :merchant_public_id
|
|
10
|
+
|
|
11
|
+
def initialize(attributes)
|
|
12
|
+
set_instance_variables_from_hash(attributes)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class << self
|
|
16
|
+
protected :new
|
|
17
|
+
def _new(*args)
|
|
18
|
+
self.new(*args)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class CredentialsParser
|
|
3
|
+
attr_reader :access_token
|
|
4
|
+
attr_reader :client_id
|
|
5
|
+
attr_reader :client_secret
|
|
6
|
+
attr_reader :environment
|
|
7
|
+
attr_reader :merchant_id
|
|
8
|
+
|
|
9
|
+
def parse_client_credentials(client_id, client_secret)
|
|
10
|
+
raise ConfigurationError.new("Missing client_id when constructing Braintree::Gateway") if client_id.nil?
|
|
11
|
+
raise ConfigurationError.new("Value passed for client_id is not a client_id") unless client_id.start_with?("client_id")
|
|
12
|
+
|
|
13
|
+
raise ConfigurationError.new("Missing client_secret when constructing Braintree::Gateway") if client_secret.nil?
|
|
14
|
+
raise ConfigurationError.new("Value passed for client_secret is not a client_secret") unless client_secret.start_with?("client_secret")
|
|
15
|
+
client_id_environment = parse_environment(client_id)
|
|
16
|
+
client_secret_environment = parse_environment(client_secret)
|
|
17
|
+
|
|
18
|
+
if client_id_environment != client_secret_environment
|
|
19
|
+
raise ConfigurationError.new("Mismatched credential environments: client_id environment is #{client_id_environment} and client_secret environment is #{client_secret_environment}")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@client_id = client_id
|
|
23
|
+
@client_secret = client_secret
|
|
24
|
+
@environment = client_id_environment
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def parse_access_token(access_token)
|
|
28
|
+
raise ConfigurationError.new("Missing access_token when constructing Braintree::Gateway") if access_token.nil?
|
|
29
|
+
raise ConfigurationError.new("Value passed for access_token is not a valid access_token") unless access_token.start_with?("access_token")
|
|
30
|
+
|
|
31
|
+
@access_token = access_token
|
|
32
|
+
@environment = parse_environment(access_token)
|
|
33
|
+
@merchant_id = parse_merchant_id(access_token)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def parse_environment(credential)
|
|
37
|
+
credential.split("$")[1].to_sym
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def parse_merchant_id(access_token)
|
|
41
|
+
access_token.split("$")[2]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|