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,125 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::PayPalPaymentResource do
|
|
4
|
+
|
|
5
|
+
describe "#update" do
|
|
6
|
+
it "successfully updates a paypal payment request" do
|
|
7
|
+
paypal_payment_resource_request = {
|
|
8
|
+
:amount => 55.00,
|
|
9
|
+
:amount_breakdown => {
|
|
10
|
+
:discount => 15_00,
|
|
11
|
+
:handling => 0,
|
|
12
|
+
:insurance => 5_00,
|
|
13
|
+
:item_total => 45_00,
|
|
14
|
+
:shipping => 10_00,
|
|
15
|
+
:shipping_discount => 0,
|
|
16
|
+
:tax_total => 10_00
|
|
17
|
+
},
|
|
18
|
+
:currency_iso_code => "USD",
|
|
19
|
+
:description => "This is a test",
|
|
20
|
+
:custom_field => "0437",
|
|
21
|
+
:line_items => [{
|
|
22
|
+
:description => "Shoes",
|
|
23
|
+
:image_url => "https://example.com/products/23434/pic.png",
|
|
24
|
+
:kind => "debit",
|
|
25
|
+
:name => "Name #1",
|
|
26
|
+
:product_code => "23434",
|
|
27
|
+
:quantity => 1_00,
|
|
28
|
+
:total_amount => 45_00,
|
|
29
|
+
:unit_amount => 45_00,
|
|
30
|
+
:unit_tax_amount => 10_00,
|
|
31
|
+
:url => "https://example.com/products/23434",
|
|
32
|
+
}],
|
|
33
|
+
:order_id => "order-123456789",
|
|
34
|
+
:payee_email => "bt_buyer_us@paypal.com",
|
|
35
|
+
:payment_method_nonce => "1234",
|
|
36
|
+
:shipping => {
|
|
37
|
+
:country_name => "United States",
|
|
38
|
+
:country_code_alpha2 => "US",
|
|
39
|
+
:country_code_alpha3 => "USA",
|
|
40
|
+
:country_code_numeric => "484",
|
|
41
|
+
:extended_address => "Apt. #1",
|
|
42
|
+
:first_name => "John",
|
|
43
|
+
:international_phone => {
|
|
44
|
+
:country_code => "1",
|
|
45
|
+
:national_number => "4081111111",
|
|
46
|
+
},
|
|
47
|
+
:last_name => "Doe",
|
|
48
|
+
:locality => "Chicago",
|
|
49
|
+
:postal_code => "60618",
|
|
50
|
+
:region => "IL",
|
|
51
|
+
:street_address => "123 Division Street",
|
|
52
|
+
},
|
|
53
|
+
:shipping_options => [{
|
|
54
|
+
:amount => "10.00",
|
|
55
|
+
:id => "option1",
|
|
56
|
+
:label => "fast",
|
|
57
|
+
:selected => true,
|
|
58
|
+
:type => "SHIPPING"
|
|
59
|
+
}]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
unknown_response = {:payment_method_nonce => {}}
|
|
63
|
+
http_instance = double(:put => unknown_response)
|
|
64
|
+
allow(Braintree::Http).to receive(:new).and_return(http_instance)
|
|
65
|
+
result = Braintree::PayPalPaymentResource.update(paypal_payment_resource_request)
|
|
66
|
+
expect(result).to be_success
|
|
67
|
+
end
|
|
68
|
+
it "should match the update signature" do
|
|
69
|
+
expect(Braintree::PayPalPaymentResourceGateway._update_signature).to match([
|
|
70
|
+
:amount,
|
|
71
|
+
{:amount_breakdown => [
|
|
72
|
+
:discount,
|
|
73
|
+
:handling,
|
|
74
|
+
:insurance,
|
|
75
|
+
:item_total,
|
|
76
|
+
:shipping,
|
|
77
|
+
:shipping_discount,
|
|
78
|
+
:tax_total
|
|
79
|
+
]},
|
|
80
|
+
:currency_iso_code,
|
|
81
|
+
:custom_field,
|
|
82
|
+
:description,
|
|
83
|
+
{:line_items => [
|
|
84
|
+
:description,
|
|
85
|
+
:image_url,
|
|
86
|
+
:kind,
|
|
87
|
+
:name,
|
|
88
|
+
:product_code,
|
|
89
|
+
:quantity,
|
|
90
|
+
:total_amount,
|
|
91
|
+
:unit_amount,
|
|
92
|
+
:unit_tax_amount,
|
|
93
|
+
:url,
|
|
94
|
+
]},
|
|
95
|
+
:order_id,
|
|
96
|
+
:payee_email,
|
|
97
|
+
:payment_method_nonce,
|
|
98
|
+
{:shipping => [
|
|
99
|
+
:country_name,
|
|
100
|
+
:country_code_alpha2,
|
|
101
|
+
:country_code_alpha3,
|
|
102
|
+
:country_code_numeric,
|
|
103
|
+
:extended_address,
|
|
104
|
+
:first_name,
|
|
105
|
+
{:international_phone => [
|
|
106
|
+
:country_code,
|
|
107
|
+
:national_number]},
|
|
108
|
+
:last_name,
|
|
109
|
+
:locality,
|
|
110
|
+
:postal_code,
|
|
111
|
+
:region,
|
|
112
|
+
:street_address,
|
|
113
|
+
]},
|
|
114
|
+
{:shipping_options => [
|
|
115
|
+
:amount,
|
|
116
|
+
:id,
|
|
117
|
+
:label,
|
|
118
|
+
:selected,
|
|
119
|
+
:type
|
|
120
|
+
]},
|
|
121
|
+
],
|
|
122
|
+
)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -5,16 +5,57 @@ describe "Braintree::ResourceCollection" do
|
|
|
5
5
|
it "iterates over the elements, yielding to the block in pages" do
|
|
6
6
|
values = %w(a b c d e)
|
|
7
7
|
collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2}) do |ids|
|
|
8
|
-
ids.map {|id| values[id] }
|
|
8
|
+
ids.map { |id| values[id] }
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
count = 0
|
|
12
12
|
collection.each_with_index do |item, index|
|
|
13
|
-
item.
|
|
13
|
+
expect(item).to eq(values[index])
|
|
14
14
|
count += 1
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
count.
|
|
17
|
+
expect(count).to eq(5)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
describe "#first" do
|
|
22
|
+
it "returns nil with no results" do
|
|
23
|
+
values = %w(a b c d e)
|
|
24
|
+
collection = Braintree::ResourceCollection.new(:search_results => {:ids => [], :page_size => 2}) do |ids|
|
|
25
|
+
ids.map { |id| values[id] }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
expect(collection.first).to eq(nil)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "with results" do
|
|
32
|
+
let(:collection) do
|
|
33
|
+
values = %w(a b c d e)
|
|
34
|
+
|
|
35
|
+
Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2}) do |ids|
|
|
36
|
+
ids.map { |id| values[id] }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "returns the first occourence" do
|
|
41
|
+
expect(collection.first).to eq("a")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "returns the first N occourences" do
|
|
45
|
+
expect(collection.first(4)).to eq(["a","b","c","d"])
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe "#ids" do
|
|
51
|
+
it "returns a list of the resource collection ids" do
|
|
52
|
+
collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2})
|
|
53
|
+
expect(collection.ids).to eq([0,1,2,3,4])
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "returns an empty array when the collection is empty" do
|
|
58
|
+
collection = Braintree::ResourceCollection.new(:search_results => {:page_size => 2})
|
|
59
|
+
expect(collection.ids).to eq([])
|
|
60
|
+
end
|
|
20
61
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::Transaction::LiabilityShift do
|
|
4
|
+
describe "#initialize" do
|
|
5
|
+
it "sets responsible party and conditions" do
|
|
6
|
+
liability_shift = Braintree::Transaction::LiabilityShift.new(
|
|
7
|
+
:responsible_party => "paypal",
|
|
8
|
+
:conditions => ["unauthorized","item_not_received"],
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
expect(liability_shift.responsible_party).to eql "paypal"
|
|
12
|
+
expect(liability_shift.conditions.first).to eql "unauthorized"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "inspect" do
|
|
17
|
+
it "prints the attributes" do
|
|
18
|
+
details = Braintree::Transaction::LiabilityShift.new(
|
|
19
|
+
:responsible_party => "paypal",
|
|
20
|
+
:conditions => ["unauthorized","item_not_received"],
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
expect(details.inspect).to eql %(#<LiabilityShift responsible_party: "paypal", conditions: ["unauthorized", "item_not_received"]>)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::RiskData do
|
|
4
|
+
describe "#initialize" do
|
|
5
|
+
it "sets id, decision, device_data_captured, decision_reasons and transaction_risk_score" do
|
|
6
|
+
risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS", :device_data_captured => true, :fraud_service_provider => "fraud_protection", :decision_reasons => ["reason"], :transaction_risk_score => "12")
|
|
7
|
+
expect(risk_data.id).to eql "123"
|
|
8
|
+
expect(risk_data.decision).to eql "YOU WON $1000 DOLLARS"
|
|
9
|
+
expect(risk_data.device_data_captured).to be_truthy
|
|
10
|
+
expect(risk_data.fraud_service_provider).to eql "fraud_protection"
|
|
11
|
+
expect(risk_data.decision_reasons).to eql ["reason"]
|
|
12
|
+
expect(risk_data.transaction_risk_score).to eql "12"
|
|
13
|
+
expect(risk_data.liability_shift).to be_nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "sets liability shift info" do
|
|
17
|
+
risk_data = Braintree::RiskData.new(
|
|
18
|
+
:id => "123",
|
|
19
|
+
:decision => "YOU WON $1000 DOLLARS",
|
|
20
|
+
:device_data_captured => true,
|
|
21
|
+
:fraud_service_provider => "fraud_protection",
|
|
22
|
+
:decision_reasons => ["reason"],
|
|
23
|
+
:transaction_risk_score => "12",
|
|
24
|
+
:liability_shift => {
|
|
25
|
+
:responsible_party => "paypal",
|
|
26
|
+
:conditions => ["unauthorized"]},
|
|
27
|
+
)
|
|
28
|
+
expect(risk_data.liability_shift.responsible_party).to eql "paypal"
|
|
29
|
+
expect(risk_data.liability_shift.conditions).to eql ["unauthorized"]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "inspect" do
|
|
34
|
+
it "prints the attributes" do
|
|
35
|
+
details = Braintree::RiskData.new(
|
|
36
|
+
:id => "123",
|
|
37
|
+
:decision => "YOU WON $1000 DOLLARS",
|
|
38
|
+
:decision_reasons => ["reason"],
|
|
39
|
+
:device_data_captured => true,
|
|
40
|
+
:fraud_service_provider => "fraud_protection",
|
|
41
|
+
:transaction_risk_score => "12",
|
|
42
|
+
)
|
|
43
|
+
expect(details.inspect).to eql %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", decision_reasons: ["reason"], device_data_captured: true, fraud_service_provider: "fraud_protection", liability_shift: nil, transaction_risk_score: "12">)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "prints liability shift attributes, too" do
|
|
47
|
+
details = Braintree::RiskData.new(
|
|
48
|
+
:liability_shift => {
|
|
49
|
+
:responsible_party => "paypal",
|
|
50
|
+
:conditions => ["unauthorized"]},
|
|
51
|
+
)
|
|
52
|
+
expect(details.inspect).to eql %(#<RiskData id: nil, decision: nil, decision_reasons: nil, device_data_captured: nil, fraud_service_provider: nil, liability_shift: #<LiabilityShift responsible_party: "paypal", conditions: ["unauthorized"]>, transaction_risk_score: nil>)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::SepaDirectDebitAccountNonceDetails do
|
|
4
|
+
subject do
|
|
5
|
+
described_class.new(
|
|
6
|
+
:bank_reference_token => "a-bank-reference-token",
|
|
7
|
+
:last_4 => "abcd",
|
|
8
|
+
:mandate_type => "ONE_OFF",
|
|
9
|
+
:merchant_or_partner_customer_id => "a-mp-customer-id",
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#initialize" do
|
|
14
|
+
it "sets attributes" do
|
|
15
|
+
is_expected.to have_attributes(
|
|
16
|
+
:bank_reference_token => "a-bank-reference-token",
|
|
17
|
+
:last_4 => "abcd",
|
|
18
|
+
:mandate_type => "ONE_OFF",
|
|
19
|
+
:merchant_or_partner_customer_id => "a-mp-customer-id",
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "inspect" do
|
|
25
|
+
it "prints the attributes" do
|
|
26
|
+
expect(subject.inspect).to eq(%(#<SepaDirectDebitAccountNonceDetailsbank_reference_token: "a-bank-reference-token", last_4: "abcd", mandate_type: "ONE_OFF", merchant_or_partner_customer_id: "a-mp-customer-id">))
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::SepaDirectDebitAccount do
|
|
4
|
+
describe "self.new" do
|
|
5
|
+
subject do
|
|
6
|
+
-> { described_class.new }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "is protected" do
|
|
10
|
+
is_expected.to raise_error(NoMethodError, /protected method .new/)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "self._new" do
|
|
15
|
+
let(:params) do
|
|
16
|
+
{
|
|
17
|
+
bank_reference_token: "a-reference-token",
|
|
18
|
+
created_at: Time.now,
|
|
19
|
+
customer_global_id: "a-customer-global-id",
|
|
20
|
+
customer_id: "a-customer-id",
|
|
21
|
+
default: true,
|
|
22
|
+
global_id: "a-global-id",
|
|
23
|
+
image_url: "a-image-url",
|
|
24
|
+
last_4: "4321",
|
|
25
|
+
mandate_type: "ONE_OFF",
|
|
26
|
+
merchant_or_partner_customer_id: "a-mp-customer-id",
|
|
27
|
+
subscriptions: [{price: "10.00"}],
|
|
28
|
+
token: "a-token",
|
|
29
|
+
updated_at: Time.now,
|
|
30
|
+
view_mandate_url: "a-view-mandate-url",
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
subject do
|
|
35
|
+
described_class._new(:gateway, params)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "initializes the object with the appropriate attributes set" do
|
|
39
|
+
is_expected.to have_attributes(**params)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe "self.find" do
|
|
44
|
+
let(:token) { "token" }
|
|
45
|
+
|
|
46
|
+
subject do
|
|
47
|
+
described_class.find(token)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "calls gateway find" do
|
|
51
|
+
expect_any_instance_of(Braintree::SepaDirectDebitAccountGateway).to receive(:find).with(token)
|
|
52
|
+
subject
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe "self.delete" do
|
|
57
|
+
let(:token) { "token" }
|
|
58
|
+
|
|
59
|
+
subject do
|
|
60
|
+
described_class.delete(token)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "calls gateway delete" do
|
|
64
|
+
expect_any_instance_of(Braintree::SepaDirectDebitAccountGateway).to receive(:delete).with(token)
|
|
65
|
+
subject
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe "default?" do
|
|
70
|
+
subject do
|
|
71
|
+
described_class._new(:gateway, :default => default).default?
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context "when sepa debit account is the default payment method for the customer" do
|
|
75
|
+
let(:default) { true }
|
|
76
|
+
|
|
77
|
+
it { is_expected.to be true }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
context "when sepa debit account is not the default payment method for the customer" do
|
|
81
|
+
let(:default) { false }
|
|
82
|
+
|
|
83
|
+
it { is_expected.to be false }
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
describe Braintree::SHA256Digest do
|
|
4
|
+
describe "self.hexdigest" do
|
|
5
|
+
it "returns the sha256 hmac of the input string (test case 6 from RFC 2202)" do
|
|
6
|
+
key = "secret-key"
|
|
7
|
+
message = "secret-message"
|
|
8
|
+
expect(Braintree::SHA256Digest.hexdigest(key, message)).to eq("68e7f2ecab71db67b1aca2a638f5122810315c3013f27c2196cd53e88709eecc")
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
|
|
3
|
+
class FakeDigest
|
|
4
|
+
def self.hexdigest(key, string)
|
|
5
|
+
"#{string}_signed_with_#{key}"
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe Braintree::SignatureService do
|
|
10
|
+
describe "sign" do
|
|
11
|
+
it "signs the data with its key" do
|
|
12
|
+
service = Braintree::SignatureService.new("my_key", FakeDigest)
|
|
13
|
+
|
|
14
|
+
expect(service.sign(:foo => "foo bar")).to eq("foo=foo+bar_signed_with_my_key|foo=foo+bar")
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "hash" do
|
|
19
|
+
it "hashes the string with its key" do
|
|
20
|
+
expect(Braintree::SignatureService.new("my_key", FakeDigest).hash("foo")).to eq("foo_signed_with_my_key")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -3,17 +3,17 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
|
3
3
|
module Braintree
|
|
4
4
|
describe SubscriptionSearch do
|
|
5
5
|
context "status" do
|
|
6
|
-
it "allows Active, Canceled and PastDue" do
|
|
6
|
+
it "allows Active, Canceled, Expired, and PastDue" do
|
|
7
7
|
search = SubscriptionSearch.new
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
expect do
|
|
10
10
|
search.status.in(
|
|
11
11
|
Subscription::Status::Active,
|
|
12
12
|
Subscription::Status::Canceled,
|
|
13
13
|
Subscription::Status::Expired,
|
|
14
|
-
Subscription::Status::PastDue
|
|
14
|
+
Subscription::Status::PastDue,
|
|
15
15
|
)
|
|
16
|
-
end.
|
|
16
|
+
end.not_to raise_error
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -22,14 +22,14 @@ module Braintree
|
|
|
22
22
|
search = SubscriptionSearch.new
|
|
23
23
|
search.in_trial_period.is true
|
|
24
24
|
|
|
25
|
-
search.to_hash.
|
|
25
|
+
expect(search.to_hash).to eq({:in_trial_period => [true]})
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "allows false" do
|
|
29
29
|
search = SubscriptionSearch.new
|
|
30
30
|
search.in_trial_period.is false
|
|
31
31
|
|
|
32
|
-
search.to_hash.
|
|
32
|
+
expect(search.to_hash).to eq({:in_trial_period => [false]})
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -38,14 +38,14 @@ module Braintree
|
|
|
38
38
|
search = SubscriptionSearch.new
|
|
39
39
|
search.days_past_due.is "30"
|
|
40
40
|
|
|
41
|
-
search.to_hash.
|
|
41
|
+
expect(search.to_hash).to eq({:days_past_due => {:is => "30"}})
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "coverts ints to strings" do
|
|
45
45
|
search = SubscriptionSearch.new
|
|
46
46
|
search.days_past_due.is 30
|
|
47
47
|
|
|
48
|
-
search.to_hash.
|
|
48
|
+
expect(search.to_hash).to eq({:days_past_due => {:is => "30"}})
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
@@ -54,7 +54,7 @@ module Braintree
|
|
|
54
54
|
search = SubscriptionSearch.new
|
|
55
55
|
search.merchant_account_id.in "ma_id1", "ma_id2"
|
|
56
56
|
|
|
57
|
-
search.to_hash.
|
|
57
|
+
expect(search.to_hash).to eq({:merchant_account_id => ["ma_id1", "ma_id2"]})
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -63,56 +63,63 @@ module Braintree
|
|
|
63
63
|
search = SubscriptionSearch.new
|
|
64
64
|
search.plan_id.starts_with "plan_"
|
|
65
65
|
|
|
66
|
-
search.to_hash.
|
|
66
|
+
expect(search.to_hash).to eq({:plan_id => {:starts_with => "plan_"}})
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it "ends_with" do
|
|
70
70
|
search = SubscriptionSearch.new
|
|
71
71
|
search.plan_id.ends_with "_id"
|
|
72
72
|
|
|
73
|
-
search.to_hash.
|
|
73
|
+
expect(search.to_hash).to eq({:plan_id => {:ends_with => "_id"}})
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "is" do
|
|
77
77
|
search = SubscriptionSearch.new
|
|
78
78
|
search.plan_id.is "p_id"
|
|
79
79
|
|
|
80
|
-
search.to_hash.
|
|
80
|
+
expect(search.to_hash).to eq({:plan_id => {:is => "p_id"}})
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
it "is_not" do
|
|
84
84
|
search = SubscriptionSearch.new
|
|
85
85
|
search.plan_id.is_not "p_id"
|
|
86
86
|
|
|
87
|
-
search.to_hash.
|
|
87
|
+
expect(search.to_hash).to eq({:plan_id => {:is_not => "p_id"}})
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it "contains" do
|
|
91
91
|
search = SubscriptionSearch.new
|
|
92
92
|
search.plan_id.contains "p_id"
|
|
93
93
|
|
|
94
|
-
search.to_hash.
|
|
94
|
+
expect(search.to_hash).to eq({:plan_id => {:contains => "p_id"}})
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
it "in" do
|
|
98
98
|
search = SubscriptionSearch.new
|
|
99
99
|
search.plan_id.in ["plan1", "plan2"]
|
|
100
100
|
|
|
101
|
-
search.to_hash.
|
|
101
|
+
expect(search.to_hash).to eq({:plan_id => ["plan1", "plan2"]})
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
context "days_past_due" do
|
|
106
106
|
it "is a range node" do
|
|
107
107
|
search = SubscriptionSearch.new
|
|
108
|
-
search.days_past_due.
|
|
108
|
+
expect(search.days_past_due).to be_kind_of(Braintree::AdvancedSearch::RangeNode)
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
context "billing_cycles_remaining" do
|
|
113
113
|
it "is a range node" do
|
|
114
114
|
search = SubscriptionSearch.new
|
|
115
|
-
search.billing_cycles_remaining.
|
|
115
|
+
expect(search.billing_cycles_remaining).to be_kind_of(Braintree::AdvancedSearch::RangeNode)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
context "created_at" do
|
|
120
|
+
it "is a range node" do
|
|
121
|
+
search = SubscriptionSearch.new
|
|
122
|
+
expect(search.created_at).to be_kind_of(Braintree::AdvancedSearch::RangeNode)
|
|
116
123
|
end
|
|
117
124
|
end
|
|
118
125
|
|
|
@@ -121,7 +128,7 @@ module Braintree
|
|
|
121
128
|
search = SubscriptionSearch.new
|
|
122
129
|
search.id.is "s_id"
|
|
123
130
|
|
|
124
|
-
search.to_hash.
|
|
131
|
+
expect(search.to_hash).to eq({:id => {:is => "s_id"}})
|
|
125
132
|
end
|
|
126
133
|
end
|
|
127
134
|
end
|
|
@@ -11,8 +11,8 @@ describe Braintree::Subscription do
|
|
|
11
11
|
|
|
12
12
|
context "price" do
|
|
13
13
|
it "accepts price as either a String or a BigDecimal" do
|
|
14
|
-
Braintree::Subscription._new(:gateway, default_params.merge(:price => "12.34")).price.
|
|
15
|
-
Braintree::Subscription._new(:gateway, default_params.merge(:price => BigDecimal
|
|
14
|
+
expect(Braintree::Subscription._new(:gateway, default_params.merge(:price => "12.34")).price).to eq(BigDecimal("12.34"))
|
|
15
|
+
expect(Braintree::Subscription._new(:gateway, default_params.merge(:price => BigDecimal("12.34"))).price).to eq(BigDecimal("12.34"))
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "blows up if price is not a string or BigDecimal" do
|
|
@@ -22,13 +22,40 @@ describe Braintree::Subscription do
|
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
describe "self.find" do
|
|
26
|
+
it "raises error if passed empty string" do
|
|
27
|
+
expect do
|
|
28
|
+
Braintree::Subscription.find("")
|
|
29
|
+
end.to raise_error(ArgumentError)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "raises error if passed empty string wth space" do
|
|
33
|
+
expect do
|
|
34
|
+
Braintree::Subscription.find(" ")
|
|
35
|
+
end.to raise_error(ArgumentError)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "raises error if passed nil" do
|
|
39
|
+
expect do
|
|
40
|
+
Braintree::Subscription.find(nil)
|
|
41
|
+
end.to raise_error(ArgumentError)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "does not raise an error if subscription id does not respond to strip" do
|
|
45
|
+
allow(Braintree::Http).to receive(:new).and_return double(:get => {:subscription => default_params})
|
|
46
|
+
expect do
|
|
47
|
+
Braintree::Subscription.find(8675309)
|
|
48
|
+
end.to_not raise_error
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
25
52
|
describe "self.search" do
|
|
26
53
|
it "only allows specified values for status" do
|
|
27
|
-
|
|
54
|
+
expect do
|
|
28
55
|
Braintree::Subscription.search do |search|
|
|
29
56
|
search.status.in "Hammer"
|
|
30
57
|
end
|
|
31
|
-
end.
|
|
58
|
+
end.to raise_error(ArgumentError)
|
|
32
59
|
end
|
|
33
60
|
end
|
|
34
61
|
|
|
@@ -36,18 +63,18 @@ describe Braintree::Subscription do
|
|
|
36
63
|
it "returns true for subscriptions with the same id" do
|
|
37
64
|
subscription1 = Braintree::Subscription._new(:gateway, default_params.merge(:id => "123"))
|
|
38
65
|
subscription2 = Braintree::Subscription._new(:gateway, default_params.merge(:id => "123"))
|
|
39
|
-
subscription1.
|
|
66
|
+
expect(subscription1).to eq(subscription2)
|
|
40
67
|
end
|
|
41
68
|
|
|
42
69
|
it "returns false for subscriptions with different ids" do
|
|
43
70
|
subscription1 = Braintree::Subscription._new(:gateway, default_params.merge(:id => "123"))
|
|
44
71
|
subscription2 = Braintree::Subscription._new(:gateway, default_params.merge(:id => "not_123"))
|
|
45
|
-
subscription1.
|
|
72
|
+
expect(subscription1).not_to eq(subscription2)
|
|
46
73
|
end
|
|
47
74
|
|
|
48
75
|
it "returns false if not comparing to a subscription" do
|
|
49
76
|
subscription = Braintree::Subscription._new(:gateway, default_params.merge(:id => "123"))
|
|
50
|
-
subscription.
|
|
77
|
+
expect(subscription).not_to eq("not a subscription")
|
|
51
78
|
end
|
|
52
79
|
end
|
|
53
80
|
end
|
|
@@ -2,26 +2,26 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
|
2
2
|
|
|
3
3
|
describe Braintree::SuccessfulResult do
|
|
4
4
|
describe "initialize" do
|
|
5
|
-
it "
|
|
5
|
+
it "sets instance variables from the values in the hash" do
|
|
6
6
|
result = Braintree::SuccessfulResult.new(
|
|
7
|
-
:
|
|
8
|
-
:
|
|
7
|
+
:transaction => "transaction_value",
|
|
8
|
+
:credit_card => "credit_card_value",
|
|
9
9
|
)
|
|
10
|
-
result.success
|
|
11
|
-
result.
|
|
12
|
-
result.
|
|
10
|
+
expect(result.success?).to eq(true)
|
|
11
|
+
expect(result.transaction).to eq("transaction_value")
|
|
12
|
+
expect(result.credit_card).to eq("credit_card_value")
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "can be initialized without any values" do
|
|
16
16
|
result = Braintree::SuccessfulResult.new
|
|
17
|
-
result.success
|
|
17
|
+
expect(result.success?).to eq(true)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
describe "inspect" do
|
|
22
22
|
it "is pretty" do
|
|
23
|
-
result = Braintree::SuccessfulResult.new(:
|
|
24
|
-
result.inspect.
|
|
23
|
+
result = Braintree::SuccessfulResult.new(:transaction => "transaction_value")
|
|
24
|
+
expect(result.inspect).to eq("#<Braintree::SuccessfulResult transaction:\"transaction_value\">")
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|