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,63 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::Transaction::MetaCheckoutTokenDetails do
|
|
4
|
+
let(:attributes) do {
|
|
5
|
+
:bin => "abc1234",
|
|
6
|
+
:container_id => "a-container-id",
|
|
7
|
+
:card_type => "Visa",
|
|
8
|
+
:cardholder_name => "Meta Checkout Card CardHolder",
|
|
9
|
+
:commercial => "NO",
|
|
10
|
+
:country_of_issuance => "US",
|
|
11
|
+
:created_at => "2023-05-05T21:28:37Z",
|
|
12
|
+
:debit => "NO",
|
|
13
|
+
:durbin_regulated => "NO",
|
|
14
|
+
:expiration_month => "05",
|
|
15
|
+
:expiration_year => "2024",
|
|
16
|
+
:healthcare => "NO",
|
|
17
|
+
:last_4 => "1234",
|
|
18
|
+
:payroll => "NO",
|
|
19
|
+
:prepaid => "NO",
|
|
20
|
+
:token => "token1",
|
|
21
|
+
:unique_number_identifier => "abc1234",
|
|
22
|
+
:updated_at => "2023-05-05T21:28:37Z",
|
|
23
|
+
:cryptogram => "AlhlvxmN2ZKuAAESNFZ4GoABFA==",
|
|
24
|
+
:ecommerce_indicator => "07"
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "unit tests" do
|
|
29
|
+
it "initializes with the correct attributes" do
|
|
30
|
+
card = Braintree::Transaction::MetaCheckoutTokenDetails.new(attributes)
|
|
31
|
+
|
|
32
|
+
card.bin.should == "abc1234"
|
|
33
|
+
card.container_id.should == "a-container-id"
|
|
34
|
+
card.card_type.should == "Visa"
|
|
35
|
+
card.cardholder_name.should == "Meta Checkout Card CardHolder"
|
|
36
|
+
card.commercial == "NO"
|
|
37
|
+
card.country_of_issuance == "US"
|
|
38
|
+
card.created_at == "2023-05-05T21:28:37Z"
|
|
39
|
+
card.updated_at == "2023-05-05T21:28:37Z"
|
|
40
|
+
card.debit == "NO"
|
|
41
|
+
card.payroll == "NO"
|
|
42
|
+
card.prepaid == "NO"
|
|
43
|
+
card.healthcare == "NO"
|
|
44
|
+
card.token == "token1"
|
|
45
|
+
card.unique_number_identifier == "abc1234"
|
|
46
|
+
card.expiration_month.should == "05"
|
|
47
|
+
card.expiration_year.should == "2024"
|
|
48
|
+
card.last_4.should == "1234"
|
|
49
|
+
card.cryptogram == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
|
|
50
|
+
card.ecommerce_indicator == "07"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "sets expiration date correctly" do
|
|
54
|
+
card = Braintree::Transaction::MetaCheckoutTokenDetails.new(attributes)
|
|
55
|
+
card.expiration_date.should == "05/2024"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "masks the card number correctly" do
|
|
59
|
+
card = Braintree::Transaction::MetaCheckoutTokenDetails.new(attributes)
|
|
60
|
+
card.masked_number.should == "abc1234******1234"
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::MetaCheckoutToken do
|
|
4
|
+
let(:attributes) do {
|
|
5
|
+
:bin => "abc1234",
|
|
6
|
+
:container_id => "a-container-id",
|
|
7
|
+
:card_type => "Visa",
|
|
8
|
+
:cardholder_name => "Meta Checkout Card CardHolder",
|
|
9
|
+
:commercial => "NO",
|
|
10
|
+
:country_of_issuance => "US",
|
|
11
|
+
:created_at => "2023-05-05T21:28:37Z",
|
|
12
|
+
:debit => "NO",
|
|
13
|
+
:durbin_regulated => "NO",
|
|
14
|
+
:expiration_month => "05",
|
|
15
|
+
:expiration_year => "2024",
|
|
16
|
+
:healthcare => "NO",
|
|
17
|
+
:last_4 => "1234",
|
|
18
|
+
:payroll => "NO",
|
|
19
|
+
:prepaid => "NO",
|
|
20
|
+
:prepaid_reloadable => "NO",
|
|
21
|
+
:token => "token1",
|
|
22
|
+
:unique_number_identifier => "abc1234",
|
|
23
|
+
:updated_at => "2023-05-05T21:28:37Z",
|
|
24
|
+
:cryptogram => "AlhlvxmN2ZKuAAESNFZ4GoABFA==",
|
|
25
|
+
:ecommerce_indicator => "07"
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "unit tests" do
|
|
30
|
+
it "initializes with the correct attributes" do
|
|
31
|
+
card = Braintree::MetaCheckoutToken._new(:gateway, attributes)
|
|
32
|
+
|
|
33
|
+
card.bin.should == "abc1234"
|
|
34
|
+
card.container_id.should == "a-container-id"
|
|
35
|
+
card.card_type.should == "Visa"
|
|
36
|
+
card.cardholder_name.should == "Meta Checkout Card CardHolder"
|
|
37
|
+
card.commercial == "NO"
|
|
38
|
+
card.country_of_issuance == "US"
|
|
39
|
+
card.created_at == "2023-05-05T21:28:37Z"
|
|
40
|
+
card.updated_at == "2023-05-05T21:28:37Z"
|
|
41
|
+
card.debit == "NO"
|
|
42
|
+
card.payroll == "NO"
|
|
43
|
+
card.prepaid == "NO"
|
|
44
|
+
card.prepaid_reloadable == "NO"
|
|
45
|
+
card.healthcare == "NO"
|
|
46
|
+
card.token == "token1"
|
|
47
|
+
card.unique_number_identifier == "abc1234"
|
|
48
|
+
card.expiration_month.should == "05"
|
|
49
|
+
card.expiration_year.should == "2024"
|
|
50
|
+
card.last_4.should == "1234"
|
|
51
|
+
card.cryptogram == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
|
|
52
|
+
card.ecommerce_indicator == "07"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "sets expiration date correctly" do
|
|
56
|
+
card = Braintree::MetaCheckoutToken._new(:gateway, attributes)
|
|
57
|
+
card.expiration_date.should == "05/2024"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "masks the card number correctly" do
|
|
61
|
+
card = Braintree::MetaCheckoutToken._new(:gateway, attributes)
|
|
62
|
+
card.masked_number.should == "abc1234******1234"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
# NEXT_MAJOR_VERSION Remove paypal_tracking_id assertions, use paypal_tracker_id going forward
|
|
4
|
+
describe "Package Tracking Unit Tests" do
|
|
5
|
+
describe "creates and validates requests" do
|
|
6
|
+
let(:gateway) do
|
|
7
|
+
config = Braintree::Configuration.new(
|
|
8
|
+
:merchant_id => "merchant_id",
|
|
9
|
+
:public_key => "public_key",
|
|
10
|
+
:private_key => "private_key",
|
|
11
|
+
)
|
|
12
|
+
Braintree::Gateway.new(config)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "creates transaction gateway package tracking request signature" do
|
|
16
|
+
expect(Braintree::TransactionGateway._package_tracking_request_signature).to match(
|
|
17
|
+
[
|
|
18
|
+
:carrier,
|
|
19
|
+
{:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
|
|
20
|
+
:notify_payer, :tracking_number,
|
|
21
|
+
],
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "raises an ArgumentError if transaction_id is an invalid format" do
|
|
26
|
+
expect do
|
|
27
|
+
Braintree::Transaction.package_tracking("invalid-transaction-id", {})
|
|
28
|
+
end.to raise_error(ArgumentError, "transaction_id is invalid")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "raises an exception if attributes contain an invalid key" do
|
|
32
|
+
expect do
|
|
33
|
+
Braintree::Transaction.package_tracking("txn123", {:invalid_key => "random", :carrier => "UPS", :tracking_number => "123123"})
|
|
34
|
+
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe "handles response" do
|
|
39
|
+
it "parses the packages response correctly" do
|
|
40
|
+
transaction = Braintree::Transaction._new(
|
|
41
|
+
:gateway,
|
|
42
|
+
:shipments => [
|
|
43
|
+
{:id => "id1", :carrier => "UPS", :tracking_number => "tracking_number_1", :paypal_tracking_id => "pp_tracking_number_1", :paypal_tracker_id => "pp_tracking_number_1"},
|
|
44
|
+
{:id => "id2", :carrier => "FEDEX", :tracking_number => "tracking_number_2", :paypal_tracking_id => "pp_tracking_number_2", :paypal_tracker_id => "pp_tracking_number_2"}
|
|
45
|
+
],
|
|
46
|
+
)
|
|
47
|
+
expect(transaction.packages.size).to eq(2)
|
|
48
|
+
expect(transaction.packages[0].id).to eq("id1")
|
|
49
|
+
expect(transaction.packages[0].carrier).to eq("UPS")
|
|
50
|
+
expect(transaction.packages[0].tracking_number).to eq("tracking_number_1")
|
|
51
|
+
expect(transaction.packages[0].paypal_tracking_id).to eq("pp_tracking_number_1")
|
|
52
|
+
expect(transaction.packages[0].paypal_tracker_id).to eq("pp_tracking_number_1")
|
|
53
|
+
|
|
54
|
+
expect(transaction.packages[1].id).to eq("id2")
|
|
55
|
+
expect(transaction.packages[1].carrier).to eq("FEDEX")
|
|
56
|
+
expect(transaction.packages[1].tracking_number).to eq("tracking_number_2")
|
|
57
|
+
expect(transaction.packages[1].paypal_tracking_id).to eq("pp_tracking_number_2")
|
|
58
|
+
expect(transaction.packages[1].paypal_tracker_id).to eq("pp_tracking_number_2")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "doesn't blow up if no shipments are present in the transaction response" do
|
|
62
|
+
transaction = Braintree::Transaction._new(
|
|
63
|
+
:gateway,
|
|
64
|
+
:shipments => [],
|
|
65
|
+
)
|
|
66
|
+
expect(transaction.packages.size).to eq(0)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "doesn't blow up if shipments tag is not present in the transaction response" do
|
|
70
|
+
transaction = Braintree::Transaction._new(
|
|
71
|
+
:gateway,
|
|
72
|
+
{},
|
|
73
|
+
)
|
|
74
|
+
expect(transaction.packages.size).to eq(0)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::PaymentMethodCustomerDataUpdatedMetadata do
|
|
4
|
+
describe "self.new" do
|
|
5
|
+
it "is protected" do
|
|
6
|
+
expect do
|
|
7
|
+
Braintree::PaymentMethodCustomerDataUpdatedMetadata.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
|
+
|
|
15
|
+
params = {
|
|
16
|
+
token: "a-token",
|
|
17
|
+
payment_method: {
|
|
18
|
+
venmo_account: {
|
|
19
|
+
venmo_user_id: "venmo-user-id",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
datetime_updated: "2022-01-01T21:28:37Z",
|
|
23
|
+
enriched_customer_data: {
|
|
24
|
+
fields_updated: ["username"],
|
|
25
|
+
profile_data: {
|
|
26
|
+
username: "a-username",
|
|
27
|
+
first_name: "a-first-name",
|
|
28
|
+
last_name: "a-last-name",
|
|
29
|
+
phone_number: "a-phone-number",
|
|
30
|
+
email: "a-email",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
payment_method_customer_data_updated = Braintree::PaymentMethodCustomerDataUpdatedMetadata._new(:gateway, params)
|
|
36
|
+
|
|
37
|
+
expect(payment_method_customer_data_updated.token).to eq("a-token")
|
|
38
|
+
expect(payment_method_customer_data_updated.datetime_updated).to eq("2022-01-01T21:28:37Z")
|
|
39
|
+
expect(payment_method_customer_data_updated.payment_method).to be_a(Braintree::VenmoAccount)
|
|
40
|
+
expect(payment_method_customer_data_updated.enriched_customer_data.profile_data.first_name).to eq("a-first-name")
|
|
41
|
+
expect(payment_method_customer_data_updated.enriched_customer_data.profile_data.last_name).to eq("a-last-name")
|
|
42
|
+
expect(payment_method_customer_data_updated.enriched_customer_data.fields_updated).to eq(["username"])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::PaymentMethodNonceDetailsPayerInfo do
|
|
4
|
+
let(:payment_method_nonce_details_payer_info) {
|
|
5
|
+
Braintree::PaymentMethodNonceDetailsPayerInfo.new(
|
|
6
|
+
:billing_agreement_id => "billing-agreement-id",
|
|
7
|
+
:country_code => "US",
|
|
8
|
+
:email => "test@example.com",
|
|
9
|
+
:first_name => "First",
|
|
10
|
+
:last_name => "Last",
|
|
11
|
+
:payer_id => "payer-id",
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe "#initialize" do
|
|
16
|
+
it "sets attributes" do
|
|
17
|
+
expect(payment_method_nonce_details_payer_info.billing_agreement_id).to eq("billing-agreement-id")
|
|
18
|
+
expect(payment_method_nonce_details_payer_info.country_code).to eq("US")
|
|
19
|
+
expect(payment_method_nonce_details_payer_info.email).to eq("test@example.com")
|
|
20
|
+
expect(payment_method_nonce_details_payer_info.first_name).to eq("First")
|
|
21
|
+
expect(payment_method_nonce_details_payer_info.last_name).to eq("Last")
|
|
22
|
+
expect(payment_method_nonce_details_payer_info.payer_id).to eq("payer-id")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe "inspect" do
|
|
27
|
+
it "prints the attributes" do
|
|
28
|
+
expect(payment_method_nonce_details_payer_info.inspect).to eq(%(#<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: \"billing-agreement-id\", country_code: \"US\", email: \"test@example.com\", first_name: \"First\", last_name: \"Last\", payer_id: \"payer-id\">))
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::PaymentMethodNonceDetails do
|
|
4
|
+
let(:payment_method_nonce_details) {
|
|
5
|
+
Braintree::PaymentMethodNonceDetails.new(
|
|
6
|
+
:bank_reference_token => "a-bank-reference-token",
|
|
7
|
+
:bin => "bin",
|
|
8
|
+
:card_type => "American Express",
|
|
9
|
+
:expiration_month => "12",
|
|
10
|
+
:expiration_year => "2025",
|
|
11
|
+
:is_network_tokenized => true,
|
|
12
|
+
:last_4 => "abcd",
|
|
13
|
+
:last_two => "11",
|
|
14
|
+
:mandate_type => "ONE_OFF",
|
|
15
|
+
:merchant_or_partner_customer_id => "a-mp-customer-id",
|
|
16
|
+
:payer_info => {
|
|
17
|
+
:billing_agreement_id => "1234",
|
|
18
|
+
:country_code => "US",
|
|
19
|
+
},
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe "#initialize" do
|
|
24
|
+
it "sets attributes" do
|
|
25
|
+
expect(payment_method_nonce_details.bin).to eq("bin")
|
|
26
|
+
expect(payment_method_nonce_details.card_type).to eq("American Express")
|
|
27
|
+
expect(payment_method_nonce_details.expiration_month).to eq("12")
|
|
28
|
+
expect(payment_method_nonce_details.expiration_year).to eq("2025")
|
|
29
|
+
expect(payment_method_nonce_details.is_network_tokenized).to eq(true)
|
|
30
|
+
expect(payment_method_nonce_details.last_two).to eq("11")
|
|
31
|
+
expect(payment_method_nonce_details.payer_info.billing_agreement_id).to eq("1234")
|
|
32
|
+
expect(payment_method_nonce_details.payer_info.country_code).to eq("US")
|
|
33
|
+
expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.bank_reference_token).to eq("a-bank-reference-token")
|
|
34
|
+
expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.last_4).to eq("abcd")
|
|
35
|
+
expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.mandate_type).to eq("ONE_OFF")
|
|
36
|
+
expect(payment_method_nonce_details.sepa_direct_debit_account_nonce_details.merchant_or_partner_customer_id).to eq("a-mp-customer-id")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "inspect" do
|
|
41
|
+
it "prints the attributes" do
|
|
42
|
+
expect(payment_method_nonce_details.inspect).to eq(%(#<PaymentMethodNonceDetails bin: "bin", card_type: "American Express", expiration_month: "12", expiration_year: "2025", is_network_tokenized: true, last_two: "11", payer_info: #<PaymentMethodNonceDetailsPayerInfo billing_agreement_id: "1234", country_code: "US", email: nil, first_name: nil, last_name: nil, payer_id: nil>, sepa_direct_debit_account_nonce_details: #<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">>))
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe "is_network_tokenized" do
|
|
47
|
+
it "is aliased to is_network_tokenized?" do
|
|
48
|
+
expect(payment_method_nonce_details.is_network_tokenized?).to eq(true)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::PaymentMethodNonce do
|
|
4
|
+
let(:payment_method_nonce) {
|
|
5
|
+
Braintree::PaymentMethodNonce._new(
|
|
6
|
+
:gateway,
|
|
7
|
+
:nonce => "some-nonce",
|
|
8
|
+
:type => "CreditCard",
|
|
9
|
+
:default => true,
|
|
10
|
+
:details => {
|
|
11
|
+
:bin => "some-bin"
|
|
12
|
+
},
|
|
13
|
+
:three_d_secure_info => {
|
|
14
|
+
:liability_shift_possible => false,
|
|
15
|
+
:liability_shifted => false
|
|
16
|
+
},
|
|
17
|
+
:bin_data => {
|
|
18
|
+
:country_of_issuance => "USA",
|
|
19
|
+
:prepaid_reloadable => "Yes"
|
|
20
|
+
},
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe "#initialize" do
|
|
25
|
+
it "sets attributes" do
|
|
26
|
+
expect(payment_method_nonce.nonce).to eq("some-nonce")
|
|
27
|
+
expect(payment_method_nonce.type).to eq("CreditCard")
|
|
28
|
+
expect(payment_method_nonce.default).to be true
|
|
29
|
+
expect(payment_method_nonce.details.bin).to eq("some-bin")
|
|
30
|
+
expect(payment_method_nonce.three_d_secure_info.liability_shift_possible).to be false
|
|
31
|
+
expect(payment_method_nonce.three_d_secure_info.liability_shifted).to be false
|
|
32
|
+
expect(payment_method_nonce.bin_data.country_of_issuance).to eq("USA")
|
|
33
|
+
expect(payment_method_nonce.bin_data.prepaid_reloadable).to eq("Yes")
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe "default" do
|
|
39
|
+
it "is aliased to default?" do
|
|
40
|
+
expect(payment_method_nonce.default?).to be true
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::PaymentMethod do
|
|
4
|
+
describe "find" do
|
|
5
|
+
it "handles an unknown payment method type" do
|
|
6
|
+
unknown_response = {:unknown_payment_method => {:token => 1234, :default => true}}
|
|
7
|
+
http_instance = double(:get => unknown_response)
|
|
8
|
+
allow(Braintree::Http).to receive(:new).and_return(http_instance)
|
|
9
|
+
unknown_payment_method = Braintree::PaymentMethod.find("UNKNOWN_PAYMENT_METHOD_TOKEN")
|
|
10
|
+
|
|
11
|
+
expect(unknown_payment_method.token).to eq(1234)
|
|
12
|
+
expect(unknown_payment_method.default?).to be(true)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "update" do
|
|
17
|
+
it "handles an unknown payment method type" do
|
|
18
|
+
unknown_response = {:unknown_payment_method => {:token => 1234, :default => true}}
|
|
19
|
+
http_instance = double(:put => unknown_response)
|
|
20
|
+
allow(Braintree::Http).to receive(:new).and_return(http_instance)
|
|
21
|
+
result = Braintree::PaymentMethod.update(:unknown,
|
|
22
|
+
{:options => {:make_default => true}})
|
|
23
|
+
|
|
24
|
+
expect(result).to be_success
|
|
25
|
+
expect(result.payment_method.token).to eq(1234)
|
|
26
|
+
expect(result.payment_method).to be_instance_of(Braintree::UnknownPaymentMethod)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "delete" do
|
|
31
|
+
let(:http_stub) { double("http_stub").as_null_object }
|
|
32
|
+
it "accepts revoke_all_grants option with value true" do
|
|
33
|
+
allow(Braintree::Http).to receive(:new).and_return http_stub
|
|
34
|
+
expect(http_stub).to receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=true")
|
|
35
|
+
Braintree::PaymentMethod.delete("some_token", {:revoke_all_grants => true})
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "accepts revoke_all_grants option with value false" do
|
|
39
|
+
allow(Braintree::Http).to receive(:new).and_return http_stub
|
|
40
|
+
expect(http_stub).to receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=false")
|
|
41
|
+
Braintree::PaymentMethod.delete("some_token", {:revoke_all_grants => false})
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "throws error when an invalid param is used for options" do
|
|
45
|
+
expect do
|
|
46
|
+
Braintree::PaymentMethod.delete("some_token", {:invalid_key => false})
|
|
47
|
+
end.to raise_error(ArgumentError)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "accepts just the token, revoke_all_grants is optional" do
|
|
51
|
+
allow(Braintree::Http).to receive(:new).and_return http_stub
|
|
52
|
+
expect(http_stub).to receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token")
|
|
53
|
+
Braintree::PaymentMethod.delete("some_token")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "timestamps" do
|
|
58
|
+
it "exposes created_at and updated_at" do
|
|
59
|
+
now = Time.now
|
|
60
|
+
paypal_account = Braintree::PayPalAccount._new(:gateway, :updated_at => now, :created_at => now)
|
|
61
|
+
|
|
62
|
+
expect(paypal_account.created_at).to eq(now)
|
|
63
|
+
expect(paypal_account.updated_at).to eq(now)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "self.grant" do
|
|
68
|
+
it "raises error if passed empty string" do
|
|
69
|
+
expect do
|
|
70
|
+
Braintree::PaymentMethod.grant("")
|
|
71
|
+
end.to raise_error(ArgumentError)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "raises error if passed invalid string" do
|
|
75
|
+
expect do
|
|
76
|
+
Braintree::PaymentMethod.grant("\t", false)
|
|
77
|
+
end.to raise_error(ArgumentError)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "raises error if passed nil" do
|
|
81
|
+
expect do
|
|
82
|
+
Braintree::PaymentMethod.grant(nil, false)
|
|
83
|
+
end.to raise_error(ArgumentError)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "does not raise an error if token does not respond to strip" do
|
|
87
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
88
|
+
expect do
|
|
89
|
+
Braintree::PaymentMethod.grant(8675309, :allow_vaulting => false)
|
|
90
|
+
end.to_not raise_error
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "accepts all options as hash map" do
|
|
94
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
95
|
+
expect do
|
|
96
|
+
Braintree::PaymentMethod.grant("$dummyToken", :allow_vaulting => false, :include_billing_postal_code => true)
|
|
97
|
+
end.to_not raise_error
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "accepts only token as parameter" do
|
|
101
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
102
|
+
expect do
|
|
103
|
+
Braintree::PaymentMethod.grant("$dummyToken")
|
|
104
|
+
end.to_not raise_error
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
describe "self.revoke" do
|
|
110
|
+
it "raises error if passed empty string" do
|
|
111
|
+
expect do
|
|
112
|
+
Braintree::PaymentMethod.revoke("")
|
|
113
|
+
end.to raise_error(ArgumentError)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it "raises error if passed invalid string" do
|
|
117
|
+
expect do
|
|
118
|
+
Braintree::PaymentMethod.revoke("\t")
|
|
119
|
+
end.to raise_error(ArgumentError)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "raises error if passed nil" do
|
|
123
|
+
expect do
|
|
124
|
+
Braintree::PaymentMethod.revoke(nil)
|
|
125
|
+
end.to raise_error(ArgumentError)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "does not raise an error if token does not respond to strip" do
|
|
129
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
|
130
|
+
expect do
|
|
131
|
+
Braintree::PaymentMethod.revoke(8675309)
|
|
132
|
+
end.to_not raise_error
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::PayPalAccount do
|
|
4
|
+
describe "self.create" do
|
|
5
|
+
it "raises an exception if attributes contain an invalid key" do
|
|
6
|
+
expect do
|
|
7
|
+
Braintree::PayPalAccount.create(
|
|
8
|
+
:invalid_key => "bad stuff",
|
|
9
|
+
:options => {
|
|
10
|
+
:invalid_option => "bad option",
|
|
11
|
+
},
|
|
12
|
+
)
|
|
13
|
+
end.to raise_error(ArgumentError, "invalid keys: invalid_key, options[invalid_option]")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "self.update" do
|
|
18
|
+
it "raises an exception if attributes contain an invalid key" do
|
|
19
|
+
expect do
|
|
20
|
+
Braintree::PayPalAccount.update("some_token", :invalid_key => "val")
|
|
21
|
+
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "default?" do
|
|
26
|
+
it "is true if the paypal account is the default payment method for the customer" do
|
|
27
|
+
expect(Braintree::PayPalAccount._new(:gateway, :default => true).default?).to eq(true)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "is false if the paypal account is not the default payment methodfor the customer" do
|
|
31
|
+
expect(Braintree::PayPalAccount._new(:gateway, :default => false).default?).to eq(false)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "timestamps" do
|
|
36
|
+
it "exposes created_at and updated_at" do
|
|
37
|
+
now = Time.now
|
|
38
|
+
paypal_account = Braintree::PayPalAccount._new(:gateway, :updated_at => now, :created_at => now)
|
|
39
|
+
|
|
40
|
+
expect(paypal_account.created_at).to eq(now)
|
|
41
|
+
expect(paypal_account.updated_at).to eq(now)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "edit_paypal_vault_id" do
|
|
46
|
+
it "exposes edit_paypal_vault_id" do
|
|
47
|
+
mock_edit_paypal_vault_id = "ENCR-BA-ID1"
|
|
48
|
+
paypal_account = Braintree::PayPalAccount._new(:gateway, :edit_paypal_vault_id => mock_edit_paypal_vault_id)
|
|
49
|
+
|
|
50
|
+
expect(paypal_account.edit_paypal_vault_id).to eq(mock_edit_paypal_vault_id)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|