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
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
class CustomerGateway
|
|
2
|
+
class CustomerGateway
|
|
3
|
+
include BaseModule
|
|
4
|
+
|
|
3
5
|
def initialize(gateway)
|
|
4
6
|
@gateway = gateway
|
|
5
7
|
@config = gateway.config
|
|
8
|
+
@config.assert_has_access_token_or_keys
|
|
6
9
|
end
|
|
7
10
|
|
|
8
11
|
def all
|
|
9
|
-
response = @config.http.post
|
|
12
|
+
response = @config.http.post("#{@config.base_merchant_path}/customers/advanced_search_ids")
|
|
10
13
|
ResourceCollection.new(response) { |ids| _fetch_customers(CustomerSearch.new, ids) }
|
|
11
14
|
end
|
|
12
15
|
|
|
@@ -15,26 +18,21 @@ module Braintree
|
|
|
15
18
|
_do_create "/customers", :customer => attributes
|
|
16
19
|
end
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"#{@config.base_merchant_url}/customers/all/create_via_transparent_redirect_request"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Deprecated
|
|
24
|
-
def create_from_transparent_redirect(query_string)
|
|
25
|
-
params = @gateway.transparent_redirect.parse_and_validate_query_string query_string
|
|
26
|
-
_do_create("/customers/all/confirm_transparent_redirect_request", :id => params[:id])
|
|
21
|
+
def create!(*args)
|
|
22
|
+
return_object_or_raise(:customer) { create(*args) }
|
|
27
23
|
end
|
|
28
24
|
|
|
29
25
|
def delete(customer_id)
|
|
30
|
-
@config.http.delete("/customers/#{customer_id}")
|
|
26
|
+
@config.http.delete("#{@config.base_merchant_path}/customers/#{customer_id}")
|
|
31
27
|
SuccessfulResult.new
|
|
32
28
|
end
|
|
33
29
|
|
|
34
|
-
def find(customer_id)
|
|
30
|
+
def find(customer_id, options = {})
|
|
35
31
|
raise ArgumentError, "customer_id contains invalid characters" unless customer_id.to_s =~ /\A[\w-]+\z/
|
|
36
|
-
raise ArgumentError, "customer_id cannot be blank" if customer_id.to_s == ""
|
|
37
|
-
|
|
32
|
+
raise ArgumentError, "customer_id cannot be blank" if customer_id.nil?|| customer_id.to_s.strip == ""
|
|
33
|
+
|
|
34
|
+
query_params = options[:association_filter_id].nil? ? "" : "?association_filter_id=#{options[:association_filter_id]}"
|
|
35
|
+
response = @config.http.get("#{@config.base_merchant_path}/customers/#{customer_id}#{query_params}")
|
|
38
36
|
Customer._new(@gateway, response[:customer])
|
|
39
37
|
rescue NotFoundError
|
|
40
38
|
raise NotFoundError, "customer with id #{customer_id.inspect} not found"
|
|
@@ -44,12 +42,12 @@ module Braintree
|
|
|
44
42
|
search = CustomerSearch.new
|
|
45
43
|
block.call(search) if block
|
|
46
44
|
|
|
47
|
-
response = @config.http.post
|
|
45
|
+
response = @config.http.post("#{@config.base_merchant_path}/customers/advanced_search_ids", {:search => search.to_hash})
|
|
48
46
|
ResourceCollection.new(response) { |ids| _fetch_customers(search, ids) }
|
|
49
47
|
end
|
|
50
48
|
|
|
51
49
|
def transactions(customer_id, options = {})
|
|
52
|
-
response = @config.http.post
|
|
50
|
+
response = @config.http.post("#{@config.base_merchant_path}/customers/#{customer_id}/transaction_ids")
|
|
53
51
|
ResourceCollection.new(response) { |ids| _fetch_transactions(customer_id, ids) }
|
|
54
52
|
end
|
|
55
53
|
|
|
@@ -58,29 +56,42 @@ module Braintree
|
|
|
58
56
|
_do_update(:put, "/customers/#{customer_id}", :customer => attributes)
|
|
59
57
|
end
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
warn "[DEPRECATED] Customer.update_customer_url is deprecated. Please use TransparentRedirect.url"
|
|
64
|
-
"#{@config.base_merchant_url}/customers/all/update_via_transparent_redirect_request"
|
|
59
|
+
def update!(*args)
|
|
60
|
+
return_object_or_raise(:customer) { update(*args) }
|
|
65
61
|
end
|
|
66
62
|
|
|
67
|
-
|
|
68
|
-
def update_from_transparent_redirect(query_string)
|
|
69
|
-
params = @gateway.transparent_redirect.parse_and_validate_query_string(query_string)
|
|
70
|
-
_do_update(:post, "/customers/all/confirm_transparent_redirect_request", :id => params[:id])
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def self._create_signature # :nodoc:
|
|
63
|
+
def self._create_signature
|
|
74
64
|
credit_card_signature = CreditCardGateway._create_signature - [:customer_id]
|
|
65
|
+
credit_card_options = credit_card_signature.find { |item| item.respond_to?(:keys) && item.keys == [:options] }
|
|
66
|
+
credit_card_options[:options].delete_if { |option| option == :fail_on_duplicate_payment_method_for_customer }
|
|
67
|
+
paypal_account_signature = PayPalAccountGateway._create_nested_signature
|
|
68
|
+
paypal_options_shipping_signature = AddressGateway._shared_signature
|
|
69
|
+
options = [
|
|
70
|
+
:paypal => [
|
|
71
|
+
:payee_email,
|
|
72
|
+
:order_id,
|
|
73
|
+
:custom_field,
|
|
74
|
+
:description,
|
|
75
|
+
:amount,
|
|
76
|
+
{:shipping => paypal_options_shipping_signature}
|
|
77
|
+
],
|
|
78
|
+
]
|
|
75
79
|
[
|
|
76
|
-
:company, :email, :fax, :first_name, :id,
|
|
80
|
+
:company, :email, :fax, :first_name, :id,
|
|
81
|
+
{:international_phone => [:country_code, :national_number]},
|
|
82
|
+
:last_name, :phone, :website,
|
|
83
|
+
:device_data, :payment_method_nonce,
|
|
84
|
+
{:risk_data => [:customer_browser, :customer_ip]},
|
|
77
85
|
{:credit_card => credit_card_signature},
|
|
86
|
+
{:paypal_account => paypal_account_signature},
|
|
87
|
+
{:tax_identifiers => [:country_code, :identifier]},
|
|
88
|
+
{:options => options},
|
|
78
89
|
{:custom_fields => :_any_key_}
|
|
79
90
|
]
|
|
80
91
|
end
|
|
81
92
|
|
|
82
|
-
def _do_create(
|
|
83
|
-
response = @config.http.post
|
|
93
|
+
def _do_create(path, params=nil)
|
|
94
|
+
response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
|
|
84
95
|
if response[:customer]
|
|
85
96
|
SuccessfulResult.new(:customer => Customer._new(@gateway, response[:customer]))
|
|
86
97
|
elsif response[:api_error_response]
|
|
@@ -90,8 +101,8 @@ module Braintree
|
|
|
90
101
|
end
|
|
91
102
|
end
|
|
92
103
|
|
|
93
|
-
def _do_update(http_verb,
|
|
94
|
-
response = @config.http.send
|
|
104
|
+
def _do_update(http_verb, path, params)
|
|
105
|
+
response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params)
|
|
95
106
|
if response[:customer]
|
|
96
107
|
SuccessfulResult.new(:customer => Customer._new(@gateway, response[:customer]))
|
|
97
108
|
elsif response[:api_error_response]
|
|
@@ -101,28 +112,44 @@ module Braintree
|
|
|
101
112
|
end
|
|
102
113
|
end
|
|
103
114
|
|
|
104
|
-
def _fetch_customers(search, ids)
|
|
115
|
+
def _fetch_customers(search, ids)
|
|
105
116
|
search.ids.in ids
|
|
106
|
-
response = @config.http.post
|
|
117
|
+
response = @config.http.post("#{@config.base_merchant_path}/customers/advanced_search", {:search => search.to_hash})
|
|
107
118
|
attributes = response[:customers]
|
|
108
119
|
Util.extract_attribute_as_array(attributes, :customer).map { |attrs| Customer._new(@gateway, attrs) }
|
|
109
120
|
end
|
|
110
121
|
|
|
111
|
-
def _fetch_transactions(customer_id, ids)
|
|
112
|
-
response = @config.http.post
|
|
122
|
+
def _fetch_transactions(customer_id, ids)
|
|
123
|
+
response = @config.http.post("#{@config.base_merchant_path}/customers/#{customer_id}/transactions", :search => {:ids => ids})
|
|
113
124
|
attributes = response[:credit_card_transactions]
|
|
114
125
|
Util.extract_attribute_as_array(attributes, :transaction).map do |transaction_attributes|
|
|
115
126
|
Transaction._new @gateway, transaction_attributes
|
|
116
127
|
end
|
|
117
128
|
end
|
|
118
129
|
|
|
119
|
-
def self._update_signature
|
|
130
|
+
def self._update_signature
|
|
120
131
|
credit_card_signature = CreditCardGateway._update_signature - [:customer_id]
|
|
121
132
|
credit_card_options = credit_card_signature.find { |item| item.respond_to?(:keys) && item.keys == [:options] }
|
|
122
133
|
credit_card_options[:options] << :update_existing_token
|
|
134
|
+
paypal_options_shipping_signature = AddressGateway._shared_signature
|
|
135
|
+
options = [
|
|
136
|
+
:paypal => [
|
|
137
|
+
:payee_email,
|
|
138
|
+
:order_id,
|
|
139
|
+
:custom_field,
|
|
140
|
+
:description,
|
|
141
|
+
:amount,
|
|
142
|
+
{:shipping => paypal_options_shipping_signature}
|
|
143
|
+
],
|
|
144
|
+
]
|
|
123
145
|
[
|
|
124
|
-
:company, :email, :fax, :first_name, :id,
|
|
146
|
+
:company, :email, :fax, :first_name, :id,
|
|
147
|
+
{:international_phone => [:country_code, :national_number]},
|
|
148
|
+
:last_name, :phone, :website,
|
|
149
|
+
:device_data, :payment_method_nonce, :default_payment_method_token,
|
|
125
150
|
{:credit_card => credit_card_signature},
|
|
151
|
+
{:tax_identifiers => [:country_code, :identifier]},
|
|
152
|
+
{:options => options},
|
|
126
153
|
{:custom_fields => :_any_key_}
|
|
127
154
|
]
|
|
128
155
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
class CustomerSearch < AdvancedSearch
|
|
2
|
+
class CustomerSearch < AdvancedSearch
|
|
3
3
|
text_fields(
|
|
4
4
|
:address_country_name,
|
|
5
5
|
:address_extended_address,
|
|
@@ -17,10 +17,13 @@ module Braintree
|
|
|
17
17
|
:id,
|
|
18
18
|
:last_name,
|
|
19
19
|
:payment_method_token,
|
|
20
|
+
:paypal_account_email,
|
|
20
21
|
:phone,
|
|
21
|
-
:website
|
|
22
|
+
:website,
|
|
22
23
|
)
|
|
23
24
|
|
|
25
|
+
is_fields :payment_method_token_with_duplicates
|
|
26
|
+
|
|
24
27
|
equality_fields :credit_card_expiration_date
|
|
25
28
|
|
|
26
29
|
partial_match_fields :credit_card_number
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Creates and manages PayPal customer sessions.
|
|
2
|
+
|
|
3
|
+
module Braintree
|
|
4
|
+
class CustomerSessionGateway
|
|
5
|
+
CREATE_CUSTOMER_SESSION = <<~GRAPHQL
|
|
6
|
+
mutation CreateCustomerSession($input: CreateCustomerSessionInput!) {
|
|
7
|
+
createCustomerSession(input: $input) {
|
|
8
|
+
sessionId
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
GRAPHQL
|
|
12
|
+
|
|
13
|
+
UPDATE_CUSTOMER_SESSION = <<~GRAPHQL
|
|
14
|
+
mutation UpdateCustomerSession($input: UpdateCustomerSessionInput!) {
|
|
15
|
+
updateCustomerSession(input: $input) {
|
|
16
|
+
sessionId
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
GRAPHQL
|
|
20
|
+
|
|
21
|
+
GET_CUSTOMER_RECOMMENDATIONS = <<~GRAPHQL
|
|
22
|
+
query CustomerRecommendations($input: CustomerRecommendationsInput!) {
|
|
23
|
+
customerRecommendations(input: $input) {
|
|
24
|
+
isInPayPalNetwork
|
|
25
|
+
recommendations {
|
|
26
|
+
... on PaymentRecommendations {
|
|
27
|
+
paymentOptions {
|
|
28
|
+
paymentOption
|
|
29
|
+
recommendedPriority
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
GRAPHQL
|
|
36
|
+
|
|
37
|
+
def initialize(gateway, graphql_client)
|
|
38
|
+
@gateway = gateway
|
|
39
|
+
@graphql_client = graphql_client
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Creates a new customer session.
|
|
43
|
+
#
|
|
44
|
+
# Example:
|
|
45
|
+
# customer = {
|
|
46
|
+
# email: "test@example.com",
|
|
47
|
+
# device_fingerprint_id: "1234",
|
|
48
|
+
# phone: {country_phone_code: "1", phone_number: "5555555555"},
|
|
49
|
+
# paypal_app_installed: true,
|
|
50
|
+
# venmo_app_installed: true,
|
|
51
|
+
# }
|
|
52
|
+
# input = Braintree::CreateCustomerSessionInput.new(
|
|
53
|
+
# customer: customer,
|
|
54
|
+
# )
|
|
55
|
+
# result = gateway.customer_session.create_customer_session(input)
|
|
56
|
+
# if result.success?
|
|
57
|
+
# puts "Created session #{result.session_id}"
|
|
58
|
+
# else
|
|
59
|
+
# puts "Validations failed"
|
|
60
|
+
# puts result.errors.first.message
|
|
61
|
+
# end
|
|
62
|
+
#
|
|
63
|
+
# @param input [CreateCustomerSessionInput] The input parameters for creating a customer session.
|
|
64
|
+
#
|
|
65
|
+
# @return [(Successful|Error)Result] A result object with session ID if successful, or errors otherwise.
|
|
66
|
+
#
|
|
67
|
+
# @raise [UnexpectedError] If there is an unexpected error during the process.
|
|
68
|
+
def create_customer_session(input)
|
|
69
|
+
execute_mutation(CREATE_CUSTOMER_SESSION, input, :createCustomerSession)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# Updates an existing customer session.
|
|
74
|
+
#
|
|
75
|
+
# Example:
|
|
76
|
+
# customer = {
|
|
77
|
+
# email: "test@example.com",
|
|
78
|
+
# device_fingerprint_id: "1234",
|
|
79
|
+
# phone: {country_phone_code: "1", phone_number: "5555555555"},
|
|
80
|
+
# paypal_app_installed: true,
|
|
81
|
+
# venmo_app_installed: true,
|
|
82
|
+
# }
|
|
83
|
+
# input = Braintree::UpdateCustomerSessionInput.new(
|
|
84
|
+
# session_id: "11EF-34BC-2702904B-9026-555555555555",
|
|
85
|
+
# customer: customer,
|
|
86
|
+
# )
|
|
87
|
+
# result = gateway.customer_session.updated_customer_session(input)
|
|
88
|
+
# if result.success?
|
|
89
|
+
# puts "Updated session #{result.session_id}"
|
|
90
|
+
# else
|
|
91
|
+
# puts "Validations failed"
|
|
92
|
+
# puts result.errors.first.message
|
|
93
|
+
# end
|
|
94
|
+
#
|
|
95
|
+
# @param input [UpdateCustomerSessionInput] The input parameters for updating a customer session.
|
|
96
|
+
#
|
|
97
|
+
# @return [(Successful|Error)Result] A result object with session ID if successful, or errors otherwise.
|
|
98
|
+
#
|
|
99
|
+
# @raise [UnexpectedError] If there is an unexpected error during the process.
|
|
100
|
+
def update_customer_session(input)
|
|
101
|
+
execute_mutation(UPDATE_CUSTOMER_SESSION, input, :updateCustomerSession)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Retrieves customer recommendations associated with a customer session.
|
|
105
|
+
#
|
|
106
|
+
# Example:
|
|
107
|
+
# customer = {
|
|
108
|
+
# email: "test@example.com",
|
|
109
|
+
# device_fingerprint_id: "1234",
|
|
110
|
+
# phone: {country_phone_code: "1", phone_number: "5555555555"},
|
|
111
|
+
# paypal_app_installed: true,
|
|
112
|
+
# venmo_app_installed: true,
|
|
113
|
+
# }
|
|
114
|
+
# input = Braintree::CustomerRecommendationsInput.new(
|
|
115
|
+
# session_id: "11EF-34BC-2702904B-9026-555555555555",
|
|
116
|
+
# customer: customer,
|
|
117
|
+
# recommendations: [Braintree::Recommendations::PAYMENT_RECOMMENDATIONS]
|
|
118
|
+
# )
|
|
119
|
+
# result = gateway.customer_session.get_customer_recommendations(input)
|
|
120
|
+
# if result.success?
|
|
121
|
+
# puts "Fetched customer recommendations"
|
|
122
|
+
# payload = result.customer_recommendations
|
|
123
|
+
# puts payload
|
|
124
|
+
# else
|
|
125
|
+
# puts "Validations failed"
|
|
126
|
+
# puts result.errors.first.message
|
|
127
|
+
# end
|
|
128
|
+
#
|
|
129
|
+
# @param input [CustomerRecommendationsInput] The input parameters for retrieving customer recommendations.
|
|
130
|
+
#
|
|
131
|
+
# @return [Result\Error|Result\Successful] A result object containing the customer recommendations if successful, or errors otherwise.
|
|
132
|
+
#
|
|
133
|
+
# @raise [UnexpectedError] If there is an unexpected error during the process.
|
|
134
|
+
def get_customer_recommendations(customer_recommendations_input)
|
|
135
|
+
variables = {"input" => customer_recommendations_input.to_graphql_variables}
|
|
136
|
+
|
|
137
|
+
begin
|
|
138
|
+
response = @graphql_client.query(GET_CUSTOMER_RECOMMENDATIONS, variables)
|
|
139
|
+
errors = GraphQLClient.get_validation_errors(response)
|
|
140
|
+
if errors
|
|
141
|
+
ErrorResult.new(@gateway, {errors:errors})
|
|
142
|
+
else
|
|
143
|
+
SuccessfulResult.new(:customer_recommendations => extract_customer_recommendations_payload(response))
|
|
144
|
+
end
|
|
145
|
+
rescue StandardError => e
|
|
146
|
+
raise UnexpectedError, e.message
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
private
|
|
151
|
+
|
|
152
|
+
def execute_mutation(query, input, operation_name)
|
|
153
|
+
variables = {"input" => input.to_graphql_variables}
|
|
154
|
+
begin
|
|
155
|
+
response = @graphql_client.query(query, variables)
|
|
156
|
+
errors = GraphQLClient.get_validation_errors(response)
|
|
157
|
+
if errors
|
|
158
|
+
ErrorResult.new(@gateway, {errors:errors})
|
|
159
|
+
else
|
|
160
|
+
session_id = get_value(response, "data.#{operation_name}.sessionId")
|
|
161
|
+
SuccessfulResult.new(:session_id => session_id)
|
|
162
|
+
end
|
|
163
|
+
rescue StandardError => e
|
|
164
|
+
raise UnexpectedError, e.message
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def get_value(response, key)
|
|
169
|
+
map = response
|
|
170
|
+
key_parts = key.split(".")
|
|
171
|
+
|
|
172
|
+
key_parts[0..-2].each do |sub_key|
|
|
173
|
+
map = pop_value(map, sub_key)
|
|
174
|
+
raise UnexpectedError, "Couldn't parse response" unless map.is_a?(Hash)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
pop_value(map, key_parts.last)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def pop_value(map, key)
|
|
181
|
+
key = key.to_sym
|
|
182
|
+
if map.key?(key)
|
|
183
|
+
map[key]
|
|
184
|
+
else
|
|
185
|
+
raise UnexpectedError, "Couldn't parse response"
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def extract_customer_recommendations_payload(data)
|
|
190
|
+
customer_recommendations_hash = get_value(data, "data.customerRecommendations")
|
|
191
|
+
Braintree::CustomerRecommendationsPayload._new(customer_recommendations_hash)
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
data/lib/braintree/descriptor.rb
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
class Descriptor
|
|
2
|
+
class Descriptor
|
|
3
3
|
include BaseModule
|
|
4
4
|
|
|
5
|
-
attr_reader :name
|
|
5
|
+
attr_reader :name
|
|
6
|
+
attr_reader :phone
|
|
7
|
+
attr_reader :url
|
|
6
8
|
|
|
7
9
|
def initialize(attributes)
|
|
8
10
|
set_instance_variables_from_hash attributes unless attributes.nil?
|
data/lib/braintree/digest.rb
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
module Braintree
|
|
2
|
-
module Digest
|
|
2
|
+
module Digest
|
|
3
3
|
def self.hexdigest(private_key, string)
|
|
4
4
|
_hmac_sha1(private_key, string)
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
+
def self.secure_compare(left, right)
|
|
8
|
+
return false unless left && right
|
|
9
|
+
|
|
10
|
+
left_bytes = left.unpack("C*")
|
|
11
|
+
right_bytes = right.unpack("C*")
|
|
12
|
+
return false if left_bytes.size != right_bytes.size
|
|
13
|
+
|
|
14
|
+
result = 0
|
|
15
|
+
left_bytes.zip(right_bytes).each do |left_byte, right_byte|
|
|
16
|
+
result |= left_byte ^ right_byte
|
|
17
|
+
end
|
|
18
|
+
result == 0
|
|
19
|
+
end
|
|
20
|
+
|
|
7
21
|
def self._hmac_sha1(key, message)
|
|
8
22
|
key_digest = ::Digest::SHA1.digest(key)
|
|
9
|
-
sha1 = OpenSSL::Digest
|
|
23
|
+
sha1 = OpenSSL::Digest.new("sha1")
|
|
10
24
|
OpenSSL::HMAC.hexdigest(sha1, key_digest, message.to_s)
|
|
11
25
|
end
|
|
12
26
|
end
|
|
13
27
|
end
|
|
14
|
-
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class Disbursement
|
|
3
|
+
include BaseModule
|
|
4
|
+
|
|
5
|
+
module Types
|
|
6
|
+
Credit = "credit"
|
|
7
|
+
Debit = "debit"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
attr_reader :amount
|
|
11
|
+
attr_reader :disbursement_date
|
|
12
|
+
attr_reader :disbursement_type
|
|
13
|
+
attr_reader :exception_message
|
|
14
|
+
attr_reader :follow_up_action
|
|
15
|
+
attr_reader :id
|
|
16
|
+
attr_reader :merchant_account
|
|
17
|
+
attr_reader :retry
|
|
18
|
+
attr_reader :success
|
|
19
|
+
attr_reader :transaction_ids
|
|
20
|
+
|
|
21
|
+
alias_method :success?, :success
|
|
22
|
+
|
|
23
|
+
def initialize(gateway, attributes)
|
|
24
|
+
@gateway = gateway
|
|
25
|
+
set_instance_variables_from_hash(attributes)
|
|
26
|
+
@amount = Util.to_big_decimal(amount)
|
|
27
|
+
@disbursement_date = Date.parse(disbursement_date)
|
|
28
|
+
@merchant_account = MerchantAccount._new(gateway, @merchant_account)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def transactions
|
|
32
|
+
@gateway.transaction.search do |search|
|
|
33
|
+
search.ids.in transaction_ids
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def inspect
|
|
38
|
+
nice_attributes = self.class._inspect_attributes.map { |attr| "#{attr}: #{send(attr).inspect}" }
|
|
39
|
+
nice_attributes << "amount: #{self.amount.to_s("F").inspect}"
|
|
40
|
+
nice_attributes << "disbursement_date: #{self.disbursement_date}"
|
|
41
|
+
"#<#{self.class} #{nice_attributes.join(', ')}>"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def debit?
|
|
45
|
+
disbursement_type == Types::Debit
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def credit?
|
|
49
|
+
disbursement_type == Types::Credit
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class << self
|
|
53
|
+
protected :new
|
|
54
|
+
def _new(*args)
|
|
55
|
+
self.new(*args)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def self._inspect_attributes
|
|
60
|
+
[:id, :exception_message, :follow_up_action, :merchant_account, :transaction_ids, :retry, :success]
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/braintree/discount.rb
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class DiscountGateway
|
|
3
|
+
def initialize(gateway)
|
|
4
|
+
@gateway = gateway
|
|
5
|
+
@config = gateway.config
|
|
6
|
+
@config.assert_has_access_token_or_keys
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def all
|
|
10
|
+
response = @config.http.get("#{@config.base_merchant_path}/discounts")
|
|
11
|
+
attributes_collection = response[:discounts]
|
|
12
|
+
attributes_collection.map do |attributes|
|
|
13
|
+
Discount._new(attributes)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class Dispute
|
|
3
|
+
class Evidence
|
|
4
|
+
include BaseModule
|
|
5
|
+
|
|
6
|
+
attr_reader :category,
|
|
7
|
+
:comment,
|
|
8
|
+
:created_at,
|
|
9
|
+
:id,
|
|
10
|
+
:sent_to_processor_at,
|
|
11
|
+
:url,
|
|
12
|
+
:tag,
|
|
13
|
+
:sequence_number
|
|
14
|
+
|
|
15
|
+
def initialize(attributes)
|
|
16
|
+
unless attributes.nil?
|
|
17
|
+
@tag = attributes[:category]
|
|
18
|
+
set_instance_variables_from_hash attributes
|
|
19
|
+
end
|
|
20
|
+
@sent_to_processor_at = Date.parse(sent_to_processor_at) unless sent_to_processor_at.nil?
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class Dispute
|
|
3
|
+
class PayPalMessage
|
|
4
|
+
include BaseModule
|
|
5
|
+
|
|
6
|
+
attr_reader :message,
|
|
7
|
+
:sender,
|
|
8
|
+
:sent_at
|
|
9
|
+
|
|
10
|
+
def initialize(attributes)
|
|
11
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class Dispute
|
|
3
|
+
class StatusHistory
|
|
4
|
+
include BaseModule
|
|
5
|
+
|
|
6
|
+
attr_reader :disbursement_date
|
|
7
|
+
attr_reader :effective_date
|
|
8
|
+
attr_reader :status
|
|
9
|
+
attr_reader :timestamp
|
|
10
|
+
|
|
11
|
+
def initialize(attributes)
|
|
12
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
|
13
|
+
@disbursement_date = Date.parse(disbursement_date) unless disbursement_date.nil?
|
|
14
|
+
@effective_date = Date.parse(effective_date) unless effective_date.nil?
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class Dispute
|
|
3
|
+
class Transaction
|
|
4
|
+
include BaseModule
|
|
5
|
+
|
|
6
|
+
attr_reader :amount
|
|
7
|
+
attr_reader :created_at
|
|
8
|
+
attr_reader :id
|
|
9
|
+
attr_reader :installment_count
|
|
10
|
+
attr_reader :order_id
|
|
11
|
+
attr_reader :purchase_order_number
|
|
12
|
+
attr_reader :payment_instrument_subtype
|
|
13
|
+
|
|
14
|
+
def initialize(attributes)
|
|
15
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
|
16
|
+
@amount = Util.to_big_decimal(amount)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Braintree
|
|
2
|
+
class Dispute
|
|
3
|
+
class TransactionDetails
|
|
4
|
+
include BaseModule
|
|
5
|
+
|
|
6
|
+
attr_reader :amount
|
|
7
|
+
attr_reader :id
|
|
8
|
+
|
|
9
|
+
def initialize(attributes)
|
|
10
|
+
set_instance_variables_from_hash attributes unless attributes.nil?
|
|
11
|
+
@amount = Util.to_big_decimal(amount)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|