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,93 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe Braintree::UpdateCustomerSessionInput do
|
|
5
|
+
let(:input_data) do
|
|
6
|
+
{
|
|
7
|
+
merchant_account_id: "merchant-account-id",
|
|
8
|
+
session_id: "session-id",
|
|
9
|
+
customer: {email: "test@example.com"}
|
|
10
|
+
}
|
|
11
|
+
end
|
|
12
|
+
describe "#initialize" do
|
|
13
|
+
it "initializes with attributes" do
|
|
14
|
+
input = Braintree::UpdateCustomerSessionInput.new(input_data)
|
|
15
|
+
|
|
16
|
+
expect(input.attrs).to eq(input_data.keys)
|
|
17
|
+
expect(input.merchant_account_id).to eq("merchant-account-id")
|
|
18
|
+
expect(input.session_id).to eq("session-id")
|
|
19
|
+
expect(input.customer).to be_a(Braintree::CustomerSessionInput)
|
|
20
|
+
expect(input.customer.email).to eq("test@example.com")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "disallows nil session id" do
|
|
24
|
+
attributes = {
|
|
25
|
+
merchant_account_id: "merchant-account-id",
|
|
26
|
+
}
|
|
27
|
+
expect do
|
|
28
|
+
Braintree::UpdateCustomerSessionInput.new(attributes)
|
|
29
|
+
end.to raise_error(ArgumentError, "Expected hash to contain a :session_id")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "handles nil customer" do
|
|
33
|
+
attributes = {
|
|
34
|
+
merchant_account_id: "merchant-account-id",
|
|
35
|
+
session_id: "session-id",
|
|
36
|
+
}
|
|
37
|
+
input = Braintree::UpdateCustomerSessionInput.new(attributes)
|
|
38
|
+
|
|
39
|
+
expect(input.customer).to be_nil
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
describe "#inspect" do
|
|
45
|
+
it "returns a string representation of the object" do
|
|
46
|
+
input = Braintree::UpdateCustomerSessionInput.new(input_data)
|
|
47
|
+
expected_string = "#<Braintree::UpdateCustomerSessionInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\" customer:#<Braintree::CustomerSessionInput email:\"test@example.com\">>"
|
|
48
|
+
expect(input.inspect).to eq(expected_string)
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "handles nil values" do
|
|
53
|
+
attributes = {
|
|
54
|
+
merchant_account_id: "merchant-account-id",
|
|
55
|
+
session_id: "session-id",
|
|
56
|
+
}
|
|
57
|
+
input = Braintree::UpdateCustomerSessionInput.new(attributes)
|
|
58
|
+
expected_string = "#<Braintree::UpdateCustomerSessionInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\">"
|
|
59
|
+
|
|
60
|
+
expect(input.inspect).to eq(expected_string)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe "#to_graphql_variables" do
|
|
66
|
+
it "converts the input to graphql variables" do
|
|
67
|
+
input = Braintree::UpdateCustomerSessionInput.new(input_data)
|
|
68
|
+
expected_variables = {
|
|
69
|
+
"merchantAccountId" => "merchant-account-id",
|
|
70
|
+
"sessionId" => "session-id",
|
|
71
|
+
"customer" => {"email" => "test@example.com"},
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
expect(input.to_graphql_variables).to eq(expected_variables)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "handles nil values" do
|
|
78
|
+
attributes = {
|
|
79
|
+
merchant_account_id: "merchant-account-id",
|
|
80
|
+
session_id: "session-id",
|
|
81
|
+
}
|
|
82
|
+
input = Braintree::UpdateCustomerSessionInput.new(attributes)
|
|
83
|
+
|
|
84
|
+
expected_variables = {
|
|
85
|
+
"merchantAccountId" => "merchant-account-id",
|
|
86
|
+
"sessionId" => "session-id",
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
expect(input.to_graphql_variables).to eq(expected_variables)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::GraphQLClient do
|
|
4
|
+
|
|
5
|
+
describe ".get_validation_errors" do
|
|
6
|
+
it "returns nil if no errors" do
|
|
7
|
+
expect(Braintree::GraphQLClient.get_validation_errors({})).to be_nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "returns nil if errors is not an array" do
|
|
11
|
+
expect(Braintree::GraphQLClient.get_validation_errors({:errors => "string"})).to be_nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "returns validation errors" do
|
|
15
|
+
response = {
|
|
16
|
+
:errors => [
|
|
17
|
+
{:message => "Invalid input", :extensions => {:legacyCode => "81803"}},
|
|
18
|
+
{:message => "Another error", :extensions => {:legacyCode => "91903"}}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
expected_errors = {
|
|
22
|
+
:errors => [
|
|
23
|
+
{:attribute => "", :code => "81803", :message => "Invalid input"},
|
|
24
|
+
{:attribute => "", :code => "91903", :message => "Another error"}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
expect(Braintree::GraphQLClient.get_validation_errors(response)).to eq(expected_errors)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
it "handles missing legacyCode" do
|
|
32
|
+
response = {:errors => [{:message => "Invalid input"}]}
|
|
33
|
+
expected_errors = {:errors => [{:attribute => "", :code => nil, :message => "Invalid input"}]}
|
|
34
|
+
expect(Braintree::GraphQLClient.get_validation_errors(response)).to eq(expected_errors)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -15,7 +15,7 @@ END
|
|
|
15
15
|
[Braintree] <last-name>Doe</last-name>
|
|
16
16
|
[Braintree] </customer>
|
|
17
17
|
END
|
|
18
|
-
Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).
|
|
18
|
+
expect(Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml)).to eq(expected_xml)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "sanitizes credit card number and cvv" do
|
|
@@ -25,6 +25,7 @@ END
|
|
|
25
25
|
<last-name>Doe</last-name>
|
|
26
26
|
<number>1234560000001234</number>
|
|
27
27
|
<cvv>123</cvv>
|
|
28
|
+
<encrypted-card-data>8F34DFB312DC79C24FD5320622F3E11682D79E6B0C0FD881</encrypted-card-data>
|
|
28
29
|
</customer>
|
|
29
30
|
END
|
|
30
31
|
|
|
@@ -34,9 +35,170 @@ END
|
|
|
34
35
|
[Braintree] <last-name>Doe</last-name>
|
|
35
36
|
[Braintree] <number>123456******1234</number>
|
|
36
37
|
[Braintree] <cvv>***</cvv>
|
|
38
|
+
[Braintree] <encrypted-card-data>***</encrypted-card-data>
|
|
37
39
|
[Braintree] </customer>
|
|
38
40
|
END
|
|
39
|
-
Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).
|
|
41
|
+
expect(Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml)).to eq(expected_xml)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "sanitizes credit card number and cvv with newlines" do
|
|
45
|
+
input_xml = <<-END
|
|
46
|
+
<customer>
|
|
47
|
+
<first-name>Joe</first-name>
|
|
48
|
+
<last-name>Doe</last-name>
|
|
49
|
+
<number>123456000\n0001234</number>
|
|
50
|
+
<cvv>1\n23</cvv>
|
|
51
|
+
</customer>
|
|
52
|
+
END
|
|
53
|
+
|
|
54
|
+
expected_xml = <<-END
|
|
55
|
+
[Braintree] <customer>
|
|
56
|
+
[Braintree] <first-name>Joe</first-name>
|
|
57
|
+
[Braintree] <last-name>Doe</last-name>
|
|
58
|
+
[Braintree] <number>123456******1234</number>
|
|
59
|
+
[Braintree] <cvv>***</cvv>
|
|
60
|
+
[Braintree] </customer>
|
|
61
|
+
END
|
|
62
|
+
expect(Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml)).to eq(expected_xml)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe "self._http_do" do
|
|
67
|
+
it "connects when proxy address is specified" do
|
|
68
|
+
config = Braintree::Configuration.new(
|
|
69
|
+
:proxy_address => "localhost",
|
|
70
|
+
:proxy_port => 8080,
|
|
71
|
+
:proxy_user => "user",
|
|
72
|
+
:proxy_pass => "test",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
http = Braintree::Http.new(config)
|
|
76
|
+
net_http_instance = instance_double(
|
|
77
|
+
"Net::HTTP",
|
|
78
|
+
:open_timeout= => nil,
|
|
79
|
+
:read_timeout= => nil,
|
|
80
|
+
:start => nil,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
expect(Net::HTTP).to receive(:new).with(nil, nil, "localhost", 8080, "user", "test").and_return(net_http_instance)
|
|
84
|
+
|
|
85
|
+
http._http_do("GET", "/plans")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "accepts a partially specified proxy" do
|
|
89
|
+
config = Braintree::Configuration.new(
|
|
90
|
+
:proxy_address => "localhost",
|
|
91
|
+
:proxy_port => 8080,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
http = Braintree::Http.new(config)
|
|
95
|
+
net_http_instance = instance_double(
|
|
96
|
+
"Net::HTTP",
|
|
97
|
+
:open_timeout= => nil,
|
|
98
|
+
:read_timeout= => nil,
|
|
99
|
+
:start => nil,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
expect(Net::HTTP).to receive(:new).with(nil, nil, "localhost", 8080, nil, nil).and_return(net_http_instance)
|
|
103
|
+
|
|
104
|
+
http._http_do("GET", "/plans")
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "does not specify a proxy if proxy_address is not set" do
|
|
108
|
+
config = Braintree::Configuration.new
|
|
109
|
+
http = Braintree::Http.new(config)
|
|
110
|
+
net_http_instance = instance_double(
|
|
111
|
+
"Net::HTTP",
|
|
112
|
+
:open_timeout= => nil,
|
|
113
|
+
:read_timeout= => nil,
|
|
114
|
+
:start => nil,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
expect(Net::HTTP).to receive(:new).with(nil, nil).and_return(net_http_instance)
|
|
118
|
+
|
|
119
|
+
http._http_do("GET", "/plans")
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
describe "_compose_headers" do
|
|
124
|
+
before(:each) do
|
|
125
|
+
config = Braintree::Configuration.new
|
|
126
|
+
@http = Braintree::Http.new(config)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "returns a hash of default headers" do
|
|
130
|
+
default_headers = @http._compose_headers
|
|
131
|
+
expect(default_headers["Accept"]).to eq("application/xml")
|
|
132
|
+
expect(default_headers["Accept-Encoding"]).to eq("gzip")
|
|
133
|
+
expect(default_headers["Content-Type"]).to eq("application/xml")
|
|
134
|
+
expect(default_headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
|
|
135
|
+
expect(default_headers["X-ApiVersion"]).to eq("6")
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it "overwrites defaults with override headers" do
|
|
139
|
+
override_headers = {
|
|
140
|
+
"Accept" => "application/pdf",
|
|
141
|
+
"Authorization" => "token"
|
|
142
|
+
}
|
|
143
|
+
headers = @http._compose_headers(override_headers)
|
|
144
|
+
expect(headers["Accept"]).to eq("application/pdf")
|
|
145
|
+
expect(headers["Accept-Encoding"]).to eq("gzip")
|
|
146
|
+
expect(headers["Authorization"]).to eq("token")
|
|
147
|
+
expect(headers["Content-Type"]).to eq("application/xml")
|
|
148
|
+
expect(headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
|
|
149
|
+
expect(headers["X-ApiVersion"]).to eq("6")
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
it "extends default headers when new headers are specified" do
|
|
153
|
+
override_headers = {
|
|
154
|
+
"New-Header" => "New Value"
|
|
155
|
+
}
|
|
156
|
+
headers = @http._compose_headers(override_headers)
|
|
157
|
+
expect(headers["Accept"]).to eq("application/xml")
|
|
158
|
+
expect(headers["Accept-Encoding"]).to eq("gzip")
|
|
159
|
+
expect(headers["Content-Type"]).to eq("application/xml")
|
|
160
|
+
expect(headers["User-Agent"]).to match(/Braintree Ruby Gem .*/)
|
|
161
|
+
expect(headers["X-ApiVersion"]).to eq("6")
|
|
162
|
+
expect(headers["New-Header"]).to eq("New Value")
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
describe "_setup_connection" do
|
|
167
|
+
it "creates a new Net::HTTP object using default server and port" do
|
|
168
|
+
config = Braintree::Configuration.new
|
|
169
|
+
http = Braintree::Http.new(config)
|
|
170
|
+
|
|
171
|
+
connection = http._setup_connection
|
|
172
|
+
expect(connection.address).to eq(nil)
|
|
173
|
+
expect(connection.port).to eq(80)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "overrides the default server and port when replacements are specified" do
|
|
177
|
+
config = Braintree::Configuration.new
|
|
178
|
+
http = Braintree::Http.new(config)
|
|
179
|
+
|
|
180
|
+
connection = http._setup_connection("localhost", 3443)
|
|
181
|
+
expect(connection.address).to eq("localhost")
|
|
182
|
+
expect(connection.port).to eq(3443)
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
describe "_build_query_string" do
|
|
187
|
+
it "returns an empty string for empty query params" do
|
|
188
|
+
expect(Braintree::Http.new(:config)._build_query_string({})).to eq("")
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it "returns a proper query string for non-nested hashes" do
|
|
192
|
+
query_params = {:one => 1, :two => 2}
|
|
193
|
+
|
|
194
|
+
expect(Braintree::Http.new(:config)._build_query_string(query_params)).to match(/^\?(one=1&two=2|two=2&one=1)$/)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it "raises ArgumentError for nested hashes" do
|
|
198
|
+
query_params = {:one => 1, :two => {:a => 2.1, :b => 2.2}}
|
|
199
|
+
expect {
|
|
200
|
+
Braintree::Http.new(:config)._build_query_string(query_params)
|
|
201
|
+
}.to raise_error(ArgumentError, /nested hash/i)
|
|
40
202
|
end
|
|
41
203
|
end
|
|
42
204
|
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::LocalPaymentCompleted do
|
|
4
|
+
describe "self.new" do
|
|
5
|
+
it "is protected" do
|
|
6
|
+
expect do
|
|
7
|
+
Braintree::LocalPaymentCompleted.new
|
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "self._new" do
|
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
|
14
|
+
params = {
|
|
15
|
+
bic: "a-bic",
|
|
16
|
+
iban_last_chars: "1234",
|
|
17
|
+
payer_id: "a-payer-id",
|
|
18
|
+
payer_name: "John Doe",
|
|
19
|
+
payment_id: "a-payment-id",
|
|
20
|
+
payment_method_nonce: "a-nonce",
|
|
21
|
+
transaction: {
|
|
22
|
+
id: "a-transaction-id",
|
|
23
|
+
amount: "31.00",
|
|
24
|
+
order_id: "an-order-id",
|
|
25
|
+
status: Braintree::Transaction::Status::Authorized,
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
|
|
29
|
+
|
|
30
|
+
expect(local_payment_completed.bic).to eq("a-bic")
|
|
31
|
+
expect(local_payment_completed.iban_last_chars).to eq("1234")
|
|
32
|
+
expect(local_payment_completed.payer_id).to eq("a-payer-id")
|
|
33
|
+
expect(local_payment_completed.payer_name).to eq("John Doe")
|
|
34
|
+
expect(local_payment_completed.payment_id).to eq("a-payment-id")
|
|
35
|
+
expect(local_payment_completed.payment_method_nonce).to eq("a-nonce")
|
|
36
|
+
expect(local_payment_completed.transaction.amount).to eq(31.0)
|
|
37
|
+
expect(local_payment_completed.transaction.id).to eq("a-transaction-id")
|
|
38
|
+
expect(local_payment_completed.transaction.order_id).to eq("an-order-id")
|
|
39
|
+
expect(local_payment_completed.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "initializes the object with the appropriate attributes set if no transaction is provided" do
|
|
43
|
+
params = {
|
|
44
|
+
bic: "a-bic",
|
|
45
|
+
iban_last_chars: "1234",
|
|
46
|
+
payer_id: "a-payer-id",
|
|
47
|
+
payer_name: "John Doe",
|
|
48
|
+
payment_id: "a-payment-id",
|
|
49
|
+
payment_method_nonce: "a-nonce",
|
|
50
|
+
}
|
|
51
|
+
local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
|
|
52
|
+
|
|
53
|
+
expect(local_payment_completed.bic).to eq("a-bic")
|
|
54
|
+
expect(local_payment_completed.blik_aliases).to be_nil
|
|
55
|
+
expect(local_payment_completed.iban_last_chars).to eq("1234")
|
|
56
|
+
expect(local_payment_completed.payer_id).to eq("a-payer-id")
|
|
57
|
+
expect(local_payment_completed.payer_name).to eq("John Doe")
|
|
58
|
+
expect(local_payment_completed.payment_id).to eq("a-payment-id")
|
|
59
|
+
expect(local_payment_completed.payment_method_nonce).to eq("a-nonce")
|
|
60
|
+
expect(local_payment_completed.transaction).to be_nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "initializes the object with the appropriate attributes when blik_aliases is provided" do
|
|
64
|
+
params = {
|
|
65
|
+
bic: "a-bic",
|
|
66
|
+
blik_aliases: [
|
|
67
|
+
{
|
|
68
|
+
key: "an-alias-key",
|
|
69
|
+
label: "an-alias-label"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
iban_last_chars: "1234",
|
|
73
|
+
payer_id: "a-payer-id",
|
|
74
|
+
payer_name: "John Doe",
|
|
75
|
+
payment_id: "a-payment-id",
|
|
76
|
+
payment_method_nonce: "a-nonce",
|
|
77
|
+
}
|
|
78
|
+
local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
|
|
79
|
+
|
|
80
|
+
expect(local_payment_completed.bic).to eq("a-bic")
|
|
81
|
+
expect(local_payment_completed.blik_aliases).to match_array([{key: "an-alias-key", label: "an-alias-label"}])
|
|
82
|
+
expect(local_payment_completed.iban_last_chars).to eq("1234")
|
|
83
|
+
expect(local_payment_completed.payer_id).to eq("a-payer-id")
|
|
84
|
+
expect(local_payment_completed.payer_name).to eq("John Doe")
|
|
85
|
+
expect(local_payment_completed.payment_id).to eq("a-payment-id")
|
|
86
|
+
expect(local_payment_completed.payment_method_nonce).to eq("a-nonce")
|
|
87
|
+
expect(local_payment_completed.transaction).to be_nil
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::LocalPaymentExpired do
|
|
4
|
+
describe "self.new" do
|
|
5
|
+
it "is protected" do
|
|
6
|
+
expect do
|
|
7
|
+
Braintree::LocalPaymentExpired.new
|
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "self._new" do
|
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
|
14
|
+
params = {
|
|
15
|
+
payment_id: "a-payment-id",
|
|
16
|
+
payment_context_id: "a-payment-context-id",
|
|
17
|
+
}
|
|
18
|
+
local_payment_expired = Braintree::LocalPaymentExpired._new(params)
|
|
19
|
+
|
|
20
|
+
expect(local_payment_expired.payment_id).to eq("a-payment-id")
|
|
21
|
+
expect(local_payment_expired.payment_context_id).to eq("a-payment-context-id")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::LocalPaymentFunded do
|
|
4
|
+
describe "self.new" do
|
|
5
|
+
it "is protected" do
|
|
6
|
+
expect do
|
|
7
|
+
Braintree::LocalPaymentFunded.new
|
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "self._new" do
|
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
|
14
|
+
params = {
|
|
15
|
+
payment_id: "a-payment-id",
|
|
16
|
+
payment_context_id: "a-payment-context-id",
|
|
17
|
+
transaction: {
|
|
18
|
+
id: "a-transaction-id",
|
|
19
|
+
amount: "31.00",
|
|
20
|
+
order_id: "an-order-id",
|
|
21
|
+
status: Braintree::Transaction::Status::Settled,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
local_payment_funded = Braintree::LocalPaymentFunded._new(params)
|
|
25
|
+
|
|
26
|
+
expect(local_payment_funded.payment_id).to eq("a-payment-id")
|
|
27
|
+
expect(local_payment_funded.payment_context_id).to eq("a-payment-context-id")
|
|
28
|
+
expect(local_payment_funded.transaction.id).to eq("a-transaction-id")
|
|
29
|
+
expect(local_payment_funded.transaction.amount).to eq(31.0)
|
|
30
|
+
expect(local_payment_funded.transaction.order_id).to eq("an-order-id")
|
|
31
|
+
expect(local_payment_funded.transaction.status).to eq(Braintree::Transaction::Status::Settled)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::MerchantAccount do
|
|
4
|
+
describe "#inspect" do
|
|
5
|
+
it "is a string representation of the merchant account" do
|
|
6
|
+
account = Braintree::MerchantAccount._new(nil, :id => "merchant_account", :status => "active", :master_merchant_account => nil)
|
|
7
|
+
|
|
8
|
+
expect(account.inspect).to eq("#<Braintree::MerchantAccount: id: \"merchant_account\", status: \"active\", master_merchant_account: nil>")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "handles a master merchant account" do
|
|
12
|
+
account = Braintree::MerchantAccount._new(
|
|
13
|
+
nil,
|
|
14
|
+
:id => "merchant_account",
|
|
15
|
+
:status => "active",
|
|
16
|
+
:master_merchant_account => {:id => "master_merchant_account", :status => "active", :master_merchant_account => nil},
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
master_merchant_account = "#<Braintree::MerchantAccount: id: \"master_merchant_account\", status: \"active\", master_merchant_account: nil>"
|
|
20
|
+
expect(account.inspect).to eq("#<Braintree::MerchantAccount: id: \"merchant_account\", status: \"active\", master_merchant_account: #{master_merchant_account}>")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "default?" do
|
|
25
|
+
it "is an alias of default" do
|
|
26
|
+
account = Braintree::MerchantAccount._new(nil, :default => false)
|
|
27
|
+
expect(account.default?).to eq(false)
|
|
28
|
+
account = Braintree::MerchantAccount._new(nil, :default => true)
|
|
29
|
+
expect(account.default?).to eq(true)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::Transaction::MetaCheckoutCardDetails do
|
|
4
|
+
let(:attributes) do {
|
|
5
|
+
|
|
6
|
+
:bin => "abc1234",
|
|
7
|
+
:container_id => "a-container-id",
|
|
8
|
+
:card_type => "Visa",
|
|
9
|
+
:cardholder_name => "Meta Checkout Card CardHolder",
|
|
10
|
+
:commercial => "NO",
|
|
11
|
+
:country_of_issuance => "US",
|
|
12
|
+
:created_at => "2023-05-05T21:28:37Z",
|
|
13
|
+
:debit => "NO",
|
|
14
|
+
:durbin_regulated => "NO",
|
|
15
|
+
:expiration_month => "05",
|
|
16
|
+
:expiration_year => "2024",
|
|
17
|
+
:healthcare => "NO",
|
|
18
|
+
:last_4 => "1234",
|
|
19
|
+
:payroll => "NO",
|
|
20
|
+
:prepaid => "NO",
|
|
21
|
+
:token => "token1",
|
|
22
|
+
:unique_number_identifier => "abc1234",
|
|
23
|
+
:updated_at => "2023-05-05T21:28:37Z"
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "unit tests" do
|
|
28
|
+
it "initializes with the correct attributes" do
|
|
29
|
+
card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes)
|
|
30
|
+
|
|
31
|
+
card.bin.should == "abc1234"
|
|
32
|
+
card.container_id.should == "a-container-id"
|
|
33
|
+
card.card_type.should == "Visa"
|
|
34
|
+
card.cardholder_name.should == "Meta Checkout Card CardHolder"
|
|
35
|
+
card.commercial == "NO"
|
|
36
|
+
card.country_of_issuance == "US"
|
|
37
|
+
card.created_at == "2023-05-05T21:28:37Z"
|
|
38
|
+
card.updated_at == "2023-05-05T21:28:37Z"
|
|
39
|
+
card.debit == "NO"
|
|
40
|
+
card.payroll == "NO"
|
|
41
|
+
card.prepaid == "NO"
|
|
42
|
+
card.healthcare == "NO"
|
|
43
|
+
card.token == "token1"
|
|
44
|
+
card.unique_number_identifier == "abc1234"
|
|
45
|
+
card.expiration_month.should == "05"
|
|
46
|
+
card.expiration_year.should == "2024"
|
|
47
|
+
card.last_4.should == "1234"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "sets expiration date correctly" do
|
|
51
|
+
card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes)
|
|
52
|
+
card.expiration_date.should == "05/2024"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "masks the card number correctly" do
|
|
56
|
+
card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes)
|
|
57
|
+
card.masked_number.should == "abc1234******1234"
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::MetaCheckoutCard do
|
|
4
|
+
let(:attributes) do {
|
|
5
|
+
|
|
6
|
+
:bin => "abc1234",
|
|
7
|
+
:card_type => "Visa",
|
|
8
|
+
:cardholder_name => "Meta Checkout Card CardHolder",
|
|
9
|
+
:commercial => "NO",
|
|
10
|
+
:container_id => "a-container-id",
|
|
11
|
+
:country_of_issuance => "US",
|
|
12
|
+
:created_at => "2023-05-05T21:28:37Z",
|
|
13
|
+
:debit => "NO",
|
|
14
|
+
:durbin_regulated => "NO",
|
|
15
|
+
:expiration_month => "05",
|
|
16
|
+
:expiration_year => "2024",
|
|
17
|
+
:healthcare => "NO",
|
|
18
|
+
:last_4 => "1234",
|
|
19
|
+
:payroll => "NO",
|
|
20
|
+
:prepaid => "NO",
|
|
21
|
+
:prepaid_reloadable => "NO",
|
|
22
|
+
:token => "token1",
|
|
23
|
+
:unique_number_identifier => "abc1234",
|
|
24
|
+
:updated_at => "2023-05-05T21:28:37Z"
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "unit tests" do
|
|
29
|
+
it "initializes with the correct attributes" do
|
|
30
|
+
card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
|
|
31
|
+
|
|
32
|
+
card.bin.should == "abc1234"
|
|
33
|
+
card.card_type.should == "Visa"
|
|
34
|
+
card.cardholder_name.should == "Meta Checkout Card CardHolder"
|
|
35
|
+
card.commercial == "NO"
|
|
36
|
+
card.container_id.should == "a-container-id"
|
|
37
|
+
card.country_of_issuance == "US"
|
|
38
|
+
card.created_at == "2023-05-05T21:28:37Z"
|
|
39
|
+
card.debit == "NO"
|
|
40
|
+
card.expiration_month.should == "05"
|
|
41
|
+
card.expiration_year.should == "2024"
|
|
42
|
+
card.healthcare == "NO"
|
|
43
|
+
card.last_4.should == "1234"
|
|
44
|
+
card.payroll == "NO"
|
|
45
|
+
card.prepaid == "NO"
|
|
46
|
+
card.prepaid_reloadable == "NO"
|
|
47
|
+
card.token == "token1"
|
|
48
|
+
card.unique_number_identifier == "abc1234"
|
|
49
|
+
card.updated_at == "2023-05-05T21:28:37Z"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "sets expiration date correctly" do
|
|
53
|
+
card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
|
|
54
|
+
card.expiration_date.should == "05/2024"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "masks the card number correctly" do
|
|
58
|
+
card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
|
|
59
|
+
card.masked_number.should == "abc1234******1234"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|