braintree 2.98.0 → 4.23.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 +4 -4
- data/LICENSE +1 -1
- data/braintree.gemspec +7 -4
- data/lib/braintree/account_updater_daily_report.rb +4 -4
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +7 -27
- data/lib/braintree/address_gateway.rb +8 -7
- data/lib/braintree/advanced_search.rb +11 -12
- data/lib/braintree/apple_pay.rb +4 -4
- data/lib/braintree/apple_pay_card.rb +18 -4
- data/lib/braintree/apple_pay_options.rb +4 -4
- data/lib/braintree/authorization_adjustment.rb +4 -4
- data/lib/braintree/base_module.rb +11 -1
- data/lib/braintree/bin_data.rb +10 -3
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/client_token_gateway.rb +4 -3
- data/lib/braintree/configuration.rb +35 -35
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +2 -2
- data/lib/braintree/connected_merchant_status_transitioned.rb +2 -2
- data/lib/braintree/credit_card.rb +40 -86
- data/lib/braintree/credit_card_gateway.rb +58 -44
- data/lib/braintree/credit_card_verification.rb +39 -20
- data/lib/braintree/credit_card_verification_gateway.rb +35 -5
- data/lib/braintree/credit_card_verification_search.rb +2 -2
- data/lib/braintree/customer.rb +23 -88
- data/lib/braintree/customer_gateway.rb +17 -32
- data/lib/braintree/customer_search.rb +2 -2
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +7 -7
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
- data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
- data/lib/braintree/dispute/transaction.rb +3 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +47 -6
- data/lib/braintree/dispute_gateway.rb +5 -10
- data/lib/braintree/dispute_search.rb +8 -4
- data/lib/braintree/document_upload.rb +3 -3
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +217 -175
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +6 -5
- 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 +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/gateway.rb +6 -12
- data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +18 -5
- data/lib/braintree/granted_payment_instrument_update.rb +2 -2
- data/lib/braintree/graphql_client.rb +14 -8
- data/lib/braintree/http.rb +9 -10
- data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
- data/lib/braintree/local_payment_completed.rb +10 -5
- 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 +4 -4
- data/lib/braintree/merchant_account.rb +3 -3
- data/lib/braintree/merchant_account_gateway.rb +10 -8
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +4 -4
- data/lib/braintree/oauth_credentials.rb +4 -4
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +14 -13
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +52 -22
- data/lib/braintree/payment_method_nonce.rb +12 -7
- 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 +14 -3
- data/lib/braintree/payment_method_parser.rb +4 -7
- data/lib/braintree/paypal_account.rb +3 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +22 -2
- data/lib/braintree/plan_gateway.rb +101 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/resource_collection.rb +10 -5
- data/lib/braintree/revoked_payment_method_metadata.rb +2 -2
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +10 -3
- data/lib/braintree/samsung_pay_card.rb +8 -6
- 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 +2 -2
- data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
- data/lib/braintree/sha256_digest.rb +1 -1
- data/lib/braintree/subscription/status_details.rb +1 -1
- data/lib/braintree/subscription.rb +13 -13
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +5 -4
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +9 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +27 -20
- data/lib/braintree/test/transaction_amounts.rb +2 -3
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/testing_gateway.rb +1 -1
- data/lib/braintree/three_d_secure_info.rb +23 -11
- data/lib/braintree/transaction/address_details.rb +14 -1
- data/lib/braintree/transaction/apple_pay_details.rb +13 -10
- data/lib/braintree/transaction/credit_card_details.rb +8 -1
- data/lib/braintree/transaction/customer_details.rb +3 -2
- data/lib/braintree/transaction/disbursement_details.rb +2 -1
- data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +6 -1
- 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 +3 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -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 +5 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +3 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +3 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +2 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +119 -128
- data/lib/braintree/transaction_gateway.rb +138 -64
- data/lib/braintree/transaction_line_item.rb +14 -11
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +11 -7
- data/lib/braintree/unknown_payment_method.rb +2 -2
- data/lib/braintree/us_bank_account.rb +5 -5
- data/lib/braintree/us_bank_account_verification.rb +24 -16
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +25 -10
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +4 -4
- data/lib/braintree/venmo_profile_data.rb +25 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +8 -8
- data/lib/braintree/webhook_notification.rb +55 -33
- data/lib/braintree/webhook_notification_gateway.rb +9 -9
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +569 -46
- data/lib/braintree/xml/generator.rb +6 -5
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +24 -37
- data/lib/braintree/xml/rexml.rb +6 -7
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +41 -24
- data/lib/ssl/api_braintreegateway_com.ca.crt +401 -168
- data/spec/integration/braintree/add_on_spec.rb +10 -10
- data/spec/integration/braintree/address_spec.rb +101 -178
- data/spec/integration/braintree/advanced_search_spec.rb +93 -93
- data/spec/integration/braintree/apple_pay_spec.rb +12 -12
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +279 -62
- data/spec/integration/braintree/client_api/spec_helper.rb +99 -73
- data/spec/integration/braintree/credit_card_spec.rb +522 -821
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/credit_card_verification_spec.rb +219 -30
- data/spec/integration/braintree/customer_search_spec.rb +28 -28
- data/spec/integration/braintree/customer_spec.rb +840 -757
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_search_spec.rb +45 -9
- data/spec/integration/braintree/dispute_spec.rb +109 -82
- data/spec/integration/braintree/document_upload_spec.rb +29 -17
- 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 +0 -2
- data/spec/integration/braintree/http_spec.rb +31 -33
- data/spec/integration/braintree/merchant_account_spec.rb +155 -156
- data/spec/integration/braintree/merchant_spec.rb +71 -192
- data/spec/integration/braintree/oauth_spec.rb +72 -72
- data/spec/integration/braintree/package_tracking_spec.rb +130 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +173 -78
- data/spec/integration/braintree/payment_method_spec.rb +953 -501
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +147 -234
- data/spec/integration/braintree/paypal_account_spec.rb +74 -72
- data/spec/integration/braintree/plan_spec.rb +96 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +75 -73
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +194 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +18 -18
- data/spec/integration/braintree/subscription_spec.rb +507 -513
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +4 -4
- data/spec/integration/braintree/test_transaction_spec.rb +29 -29
- data/spec/integration/braintree/transaction_line_item_spec.rb +12 -6
- data/spec/integration/braintree/transaction_search_spec.rb +410 -217
- data/spec/integration/braintree/transaction_spec.rb +3252 -2102
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +42 -278
- data/spec/integration/braintree/us_bank_account_spec.rb +36 -36
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +25 -25
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +41 -41
- data/spec/integration/braintree/visa_checkout_card_spec.rb +62 -62
- data/spec/integration/spec_helper.rb +22 -7
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +15 -20
- data/spec/unit/braintree/address_spec.rb +9 -17
- data/spec/unit/braintree/apple_pay_card_spec.rb +110 -7
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +6 -6
- data/spec/unit/braintree/configuration_spec.rb +84 -84
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +91 -58
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +56 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +10 -10
- data/spec/unit/braintree/credit_card_verification_spec.rb +40 -18
- data/spec/unit/braintree/customer_spec.rb +102 -57
- data/spec/unit/braintree/digest_spec.rb +5 -6
- data/spec/unit/braintree/disbursement_spec.rb +14 -14
- data/spec/unit/braintree/dispute_search_spec.rb +6 -2
- data/spec/unit/braintree/dispute_spec.rb +144 -66
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- 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/http_spec.rb +19 -17
- data/spec/unit/braintree/local_payment_completed_spec.rb +62 -8
- 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 +5 -5
- data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
- data/spec/unit/braintree/modification_spec.rb +1 -1
- 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 +40 -0
- data/spec/unit/braintree/payment_method_spec.rb +20 -20
- data/spec/unit/braintree/paypal_account_spec.rb +16 -7
- data/spec/unit/braintree/resource_collection_spec.rb +34 -5
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +38 -8
- 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 +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +18 -18
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +6 -6
- data/spec/unit/braintree/three_d_secure_info_spec.rb +37 -17
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +22 -6
- data/spec/unit/braintree/transaction/customer_details_spec.rb +3 -2
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +4 -4
- 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/payment_receipt_spec.rb +73 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -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 +221 -124
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +12 -7
- data/spec/unit/braintree/util_spec.rb +78 -44
- data/spec/unit/braintree/validation_error_collection_spec.rb +62 -62
- 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/webhook_notification_spec.rb +434 -197
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +27 -22
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +38 -38
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +91 -30
- data/lib/braintree/amex_express_checkout_card.rb +0 -38
- data/lib/braintree/coinbase_account.rb +0 -34
- data/lib/braintree/europe_bank_account.rb +0 -36
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -61
- data/lib/braintree/ideal_payment_gateway.rb +0 -19
- data/lib/braintree/masterpass_card.rb +0 -81
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
- data/lib/braintree/transaction/masterpass_card_details.rb +0 -47
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/integration/braintree/coinbase_spec.rb +0 -34
- data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -0,0 +1,130 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
3
|
+
|
4
|
+
# NEXT_MAJOR_VERSION Remove paypal_tracking_id assertions, use paypal_tracker_id going forward
|
5
|
+
describe Braintree::Transaction do
|
6
|
+
describe "self.package_tracking" do
|
7
|
+
let(:customer) { Braintree::Customer.create! }
|
8
|
+
it "returns validation error message from gateway api" do
|
9
|
+
result = Braintree::Transaction.sale(
|
10
|
+
:amount => "100",
|
11
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
12
|
+
:options => {
|
13
|
+
:submit_for_settlement => true
|
14
|
+
},
|
15
|
+
)
|
16
|
+
|
17
|
+
expect(result.success?).to eq(true)
|
18
|
+
|
19
|
+
# Carrier name is required
|
20
|
+
invalidResult = Braintree::Transaction.package_tracking(result.transaction.id, {tracking_number: "tracking_number_1"})
|
21
|
+
expect(invalidResult.message).to eq("Carrier name is required.")
|
22
|
+
|
23
|
+
# Tracking number is required
|
24
|
+
invalidResult = Braintree::Transaction.package_tracking(result.transaction.id, {carrier: "UPS"})
|
25
|
+
expect(invalidResult.message).to eq("Tracking number is required.")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "successfully calls gateway API and adds package tracking information" do
|
29
|
+
result = Braintree::Transaction.sale(
|
30
|
+
:amount => "100",
|
31
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
32
|
+
:options => {
|
33
|
+
:submit_for_settlement => true
|
34
|
+
},
|
35
|
+
)
|
36
|
+
|
37
|
+
expect(result.success?).to eq(true)
|
38
|
+
|
39
|
+
# Create First Package with 2 products
|
40
|
+
firstPackageResult = Braintree::Transaction.package_tracking(
|
41
|
+
result.transaction.id,
|
42
|
+
{
|
43
|
+
carrier: "UPS",
|
44
|
+
notify_payer: true,
|
45
|
+
tracking_number: "tracking_number_1",
|
46
|
+
line_items: [
|
47
|
+
{
|
48
|
+
product_code: "ABC 01",
|
49
|
+
name: "Best Product Ever",
|
50
|
+
quantity: "1",
|
51
|
+
description: "Best Description Ever",
|
52
|
+
upc_code: "51234567890",
|
53
|
+
upc_type: "UPC-A",
|
54
|
+
image_url: "https://example.com/image.png",
|
55
|
+
},
|
56
|
+
{
|
57
|
+
product_code: "ABC 02",
|
58
|
+
name: "Best Product Ever",
|
59
|
+
quantity: "1",
|
60
|
+
description: "Best Description Ever",
|
61
|
+
upc_code: "51234567891",
|
62
|
+
upc_type: "UPC-A",
|
63
|
+
image_url: "https://example.com/image.png",
|
64
|
+
},
|
65
|
+
],
|
66
|
+
},
|
67
|
+
)
|
68
|
+
|
69
|
+
# First package is shipped by the merchant
|
70
|
+
expect(firstPackageResult.success?).to eq(true)
|
71
|
+
expect(firstPackageResult.transaction.packages[0].id).not_to be_nil
|
72
|
+
expect(firstPackageResult.transaction.packages[0].carrier).to eq("UPS")
|
73
|
+
expect(firstPackageResult.transaction.packages[0].tracking_number).to eq("tracking_number_1")
|
74
|
+
expect(firstPackageResult.transaction.packages[0].paypal_tracker_id).to be_nil
|
75
|
+
expect(firstPackageResult.transaction.packages[0].paypal_tracking_id).to be_nil
|
76
|
+
|
77
|
+
# Create second package with 1 product
|
78
|
+
secondPackageResult = Braintree::Transaction.package_tracking(
|
79
|
+
result.transaction.id,
|
80
|
+
{
|
81
|
+
carrier: "FEDEX",
|
82
|
+
notify_payer: true,
|
83
|
+
tracking_number: "tracking_number_2",
|
84
|
+
line_items: [
|
85
|
+
{
|
86
|
+
product_code: "ABC 03",
|
87
|
+
name: "Best Product Ever",
|
88
|
+
quantity: "1",
|
89
|
+
description: "Best Description Ever",
|
90
|
+
},
|
91
|
+
]
|
92
|
+
},
|
93
|
+
)
|
94
|
+
|
95
|
+
# Second package is shipped by the merchant
|
96
|
+
expect(secondPackageResult.success?).to eq(true)
|
97
|
+
expect(secondPackageResult.transaction.packages[1].id).not_to be_nil
|
98
|
+
expect(secondPackageResult.transaction.packages[1].carrier).to eq("FEDEX")
|
99
|
+
expect(secondPackageResult.transaction.packages[1].tracking_number).to eq("tracking_number_2")
|
100
|
+
expect(secondPackageResult.transaction.packages[1].paypal_tracker_id).to be_nil
|
101
|
+
expect(secondPackageResult.transaction.packages[1].paypal_tracking_id).to be_nil
|
102
|
+
|
103
|
+
# Find transaction gives both packages
|
104
|
+
transaction = Braintree::Transaction.find(result.transaction.id)
|
105
|
+
expect(transaction.packages.length).to eq(2)
|
106
|
+
expect(transaction.packages[0].id).not_to be_nil
|
107
|
+
expect(transaction.packages[0].carrier).to eq("UPS")
|
108
|
+
expect(transaction.packages[0].tracking_number).to eq("tracking_number_1")
|
109
|
+
#In test environment, since we do not have jobstream setup paypal tracker id is going to be nil, this is just to access we could access it
|
110
|
+
expect(transaction.packages[0].paypal_tracker_id).to be_nil
|
111
|
+
expect(transaction.packages[0].paypal_tracking_id).to be_nil
|
112
|
+
|
113
|
+
expect(transaction.packages[1].id).not_to be_nil
|
114
|
+
expect(transaction.packages[1].carrier).to eq("FEDEX")
|
115
|
+
expect(transaction.packages[1].tracking_number).to eq("tracking_number_2")
|
116
|
+
expect(transaction.packages[1].paypal_tracker_id).to be_nil
|
117
|
+
expect(transaction.packages[1].paypal_tracking_id).to be_nil
|
118
|
+
end
|
119
|
+
|
120
|
+
it "retrieves paypal_tracker_id successfully" do
|
121
|
+
transaction = Braintree::Transaction.find("package_tracking_tx")
|
122
|
+
expect(transaction.packages.length).to eq(2)
|
123
|
+
expect(transaction.packages[0].paypal_tracker_id).to eq("paypal_tracker_id_1")
|
124
|
+
expect(transaction.packages[0].paypal_tracking_id).to be_nil
|
125
|
+
|
126
|
+
expect(transaction.packages[1].paypal_tracker_id).to eq("paypal_tracker_id_2")
|
127
|
+
expect(transaction.packages[1].paypal_tracking_id).to be_nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
3
|
+
require "date"
|
3
4
|
|
4
5
|
describe Braintree::PaymentMethodNonce do
|
5
6
|
let(:config) { Braintree::Configuration.instantiate }
|
@@ -12,26 +13,27 @@ describe Braintree::PaymentMethodNonce do
|
|
12
13
|
:number => "4111111111111111",
|
13
14
|
:expiration_month => "11",
|
14
15
|
:expiration_year => "2099",
|
15
|
-
}
|
16
|
+
},
|
16
17
|
)
|
17
18
|
|
18
19
|
result = Braintree::PaymentMethod.create(
|
19
20
|
:payment_method_nonce => nonce,
|
20
|
-
:customer_id => customer.id
|
21
|
+
:customer_id => customer.id,
|
21
22
|
)
|
22
23
|
|
23
|
-
result.
|
24
|
-
result.payment_method.
|
24
|
+
expect(result).to be_success
|
25
|
+
expect(result.payment_method).to be_a(Braintree::CreditCard)
|
25
26
|
token = result.payment_method.token
|
26
27
|
|
27
28
|
found_credit_card = Braintree::CreditCard.find(token)
|
28
|
-
found_credit_card.
|
29
|
+
expect(found_credit_card).not_to be_nil
|
29
30
|
|
30
31
|
result = Braintree::PaymentMethodNonce.create(found_credit_card.token)
|
31
|
-
result.
|
32
|
-
result.payment_method_nonce.
|
33
|
-
result.payment_method_nonce.nonce.
|
34
|
-
result.payment_method_nonce.details.
|
32
|
+
expect(result).to be_success
|
33
|
+
expect(result.payment_method_nonce).not_to be_nil
|
34
|
+
expect(result.payment_method_nonce.nonce).not_to be_nil
|
35
|
+
expect(result.payment_method_nonce.details).not_to be_nil
|
36
|
+
expect(result.payment_method_nonce.default?).to be_truthy
|
35
37
|
end
|
36
38
|
|
37
39
|
it "correctly raises and exception for a non existent token" do
|
@@ -49,24 +51,25 @@ describe Braintree::PaymentMethodNonce do
|
|
49
51
|
:number => "4111111111111111",
|
50
52
|
:expiration_month => "11",
|
51
53
|
:expiration_year => "2099",
|
52
|
-
}
|
54
|
+
},
|
53
55
|
)
|
54
56
|
|
55
57
|
payment_method = Braintree::PaymentMethod.create!(
|
56
58
|
:payment_method_nonce => nonce,
|
57
|
-
:customer_id => customer.id
|
59
|
+
:customer_id => customer.id,
|
58
60
|
)
|
59
61
|
|
60
|
-
payment_method.
|
62
|
+
expect(payment_method).to be_a(Braintree::CreditCard)
|
61
63
|
token = payment_method.token
|
62
64
|
|
63
65
|
found_credit_card = Braintree::CreditCard.find(token)
|
64
|
-
found_credit_card.
|
66
|
+
expect(found_credit_card).not_to be_nil
|
65
67
|
|
66
68
|
payment_method_nonce = Braintree::PaymentMethodNonce.create!(found_credit_card.token)
|
67
|
-
payment_method_nonce.
|
68
|
-
payment_method_nonce.nonce.
|
69
|
-
payment_method_nonce.details.
|
69
|
+
expect(payment_method_nonce).not_to be_nil
|
70
|
+
expect(payment_method_nonce.nonce).not_to be_nil
|
71
|
+
expect(payment_method_nonce.details).not_to be_nil
|
72
|
+
expect(payment_method_nonce.default?).to be_truthy
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
@@ -76,32 +79,47 @@ describe Braintree::PaymentMethodNonce do
|
|
76
79
|
|
77
80
|
nonce = result.payment_method_nonce
|
78
81
|
|
79
|
-
result.
|
80
|
-
nonce.nonce.
|
81
|
-
nonce.type.
|
82
|
-
nonce.details.
|
83
|
-
nonce.details.
|
82
|
+
expect(result).to be_success
|
83
|
+
expect(nonce.nonce).to eq("fake-valid-nonce")
|
84
|
+
expect(nonce.type).to eq("CreditCard")
|
85
|
+
expect(nonce.details.bin).to eq("401288")
|
86
|
+
expect(nonce.details.card_type).to eq("Visa")
|
87
|
+
expect(nonce.details.expiration_month).to eq("12")
|
88
|
+
expect(nonce.details.expiration_year).to eq(Date.today.next_year.year.to_s)
|
89
|
+
expect(nonce.details.is_network_tokenized?).to be_nil
|
90
|
+
expect(nonce.details.last_two).to eq("81")
|
91
|
+
expect(nonce.details.payer_info).to be_nil
|
84
92
|
end
|
85
93
|
|
86
|
-
it "return
|
87
|
-
result = Braintree::PaymentMethodNonce.find(
|
88
|
-
|
94
|
+
it "return meta_checkout_card_details nonce if exist" do
|
95
|
+
result = Braintree::PaymentMethodNonce.find(Braintree::Test::Nonce::MetaCheckoutCard)
|
89
96
|
nonce = result.payment_method_nonce
|
90
|
-
|
91
|
-
nonce.details.
|
92
|
-
nonce.details.
|
93
|
-
nonce.details.
|
94
|
-
nonce.details.
|
97
|
+
nonce.details.bin.should == "401288"
|
98
|
+
nonce.details.last_two.should == "81"
|
99
|
+
nonce.details.card_type.should == "Visa"
|
100
|
+
nonce.details.expiration_year.should == Date.today().next_year().year.to_s
|
101
|
+
nonce.details.expiration_month.should == "12"
|
95
102
|
end
|
96
103
|
|
97
|
-
it "return
|
98
|
-
result = Braintree::PaymentMethodNonce.find(
|
99
|
-
|
104
|
+
it "return meta_checkout_token_details nonce if exist" do
|
105
|
+
result = Braintree::PaymentMethodNonce.find(Braintree::Test::Nonce::MetaCheckoutToken)
|
100
106
|
nonce = result.payment_method_nonce
|
107
|
+
nonce.details.bin.should == "401288"
|
108
|
+
nonce.details.last_two.should == "81"
|
109
|
+
nonce.details.card_type.should == "Visa"
|
110
|
+
nonce.details.expiration_year.should == Date.today().next_year().year.to_s
|
111
|
+
nonce.details.expiration_month.should == "12"
|
112
|
+
end
|
101
113
|
|
102
|
-
|
103
|
-
|
104
|
-
nonce
|
114
|
+
it "return paypal details if details exist" do
|
115
|
+
result = Braintree::PaymentMethodNonce.find("fake-paypal-one-time-nonce")
|
116
|
+
nonce = result.payment_method_nonce
|
117
|
+
expect(nonce.details.payer_info.billing_agreement_id).to be_nil
|
118
|
+
expect(nonce.details.payer_info.country_code).to be_nil
|
119
|
+
expect(nonce.details.payer_info.email).not_to be_nil
|
120
|
+
expect(nonce.details.payer_info.first_name).not_to be_nil
|
121
|
+
expect(nonce.details.payer_info.last_name).not_to be_nil
|
122
|
+
expect(nonce.details.payer_info.payer_id).not_to be_nil
|
105
123
|
end
|
106
124
|
|
107
125
|
it "returns null 3ds_info if there isn't any" do
|
@@ -110,24 +128,24 @@ describe Braintree::PaymentMethodNonce do
|
|
110
128
|
:number => "4111111111111111",
|
111
129
|
:expiration_month => "11",
|
112
130
|
:expiration_year => "2099",
|
113
|
-
}
|
131
|
+
},
|
114
132
|
)
|
115
133
|
|
116
134
|
result = Braintree::PaymentMethodNonce.find(nonce)
|
117
135
|
|
118
136
|
nonce = result.payment_method_nonce
|
119
137
|
|
120
|
-
result.
|
121
|
-
nonce.three_d_secure_info.
|
138
|
+
expect(result).to be_success
|
139
|
+
expect(nonce.three_d_secure_info).to be_nil
|
122
140
|
end
|
123
141
|
|
124
142
|
it "returns the bin" do
|
125
143
|
result = Braintree::PaymentMethodNonce.find("fake-valid-visa-nonce")
|
126
144
|
|
127
145
|
nonce = result.payment_method_nonce
|
128
|
-
result.
|
129
|
-
nonce.details.
|
130
|
-
nonce.details
|
146
|
+
expect(result).to be_success
|
147
|
+
expect(nonce.details).not_to be_nil
|
148
|
+
expect(nonce.details.bin).to eq("401288")
|
131
149
|
end
|
132
150
|
|
133
151
|
it "returns bin_data with commercial set to Yes" do
|
@@ -135,9 +153,9 @@ describe Braintree::PaymentMethodNonce do
|
|
135
153
|
|
136
154
|
nonce = result.payment_method_nonce
|
137
155
|
|
138
|
-
result.
|
139
|
-
nonce.bin_data.
|
140
|
-
nonce.bin_data.commercial.
|
156
|
+
expect(result).to be_success
|
157
|
+
expect(nonce.bin_data).not_to be_nil
|
158
|
+
expect(nonce.bin_data.commercial).to eq(Braintree::CreditCard::Commercial::Yes)
|
141
159
|
end
|
142
160
|
|
143
161
|
it "returns bin_data with country_of_issuance set to CAN" do
|
@@ -145,9 +163,9 @@ describe Braintree::PaymentMethodNonce do
|
|
145
163
|
|
146
164
|
nonce = result.payment_method_nonce
|
147
165
|
|
148
|
-
result.
|
149
|
-
nonce.bin_data.
|
150
|
-
nonce.bin_data.country_of_issuance.
|
166
|
+
expect(result).to be_success
|
167
|
+
expect(nonce.bin_data).not_to be_nil
|
168
|
+
expect(nonce.bin_data.country_of_issuance).to eq("CAN")
|
151
169
|
end
|
152
170
|
|
153
171
|
it "returns bin_data with debit set to Yes" do
|
@@ -155,9 +173,9 @@ describe Braintree::PaymentMethodNonce do
|
|
155
173
|
|
156
174
|
nonce = result.payment_method_nonce
|
157
175
|
|
158
|
-
result.
|
159
|
-
nonce.bin_data.
|
160
|
-
nonce.bin_data.debit.
|
176
|
+
expect(result).to be_success
|
177
|
+
expect(nonce.bin_data).not_to be_nil
|
178
|
+
expect(nonce.bin_data.debit).to eq(Braintree::CreditCard::Debit::Yes)
|
161
179
|
end
|
162
180
|
|
163
181
|
it "returns bin_data with durbin_regulated set to Yes" do
|
@@ -165,9 +183,9 @@ describe Braintree::PaymentMethodNonce do
|
|
165
183
|
|
166
184
|
nonce = result.payment_method_nonce
|
167
185
|
|
168
|
-
result.
|
169
|
-
nonce.bin_data.
|
170
|
-
nonce.bin_data.durbin_regulated.
|
186
|
+
expect(result).to be_success
|
187
|
+
expect(nonce.bin_data).not_to be_nil
|
188
|
+
expect(nonce.bin_data.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Yes)
|
171
189
|
end
|
172
190
|
|
173
191
|
it "returns bin_data with healthcare set to Yes" do
|
@@ -175,10 +193,10 @@ describe Braintree::PaymentMethodNonce do
|
|
175
193
|
|
176
194
|
nonce = result.payment_method_nonce
|
177
195
|
|
178
|
-
result.
|
179
|
-
nonce.bin_data.
|
180
|
-
nonce.bin_data.healthcare.
|
181
|
-
nonce.bin_data.product_id.
|
196
|
+
expect(result).to be_success
|
197
|
+
expect(nonce.bin_data).not_to be_nil
|
198
|
+
expect(nonce.bin_data.healthcare).to eq(Braintree::CreditCard::Healthcare::Yes)
|
199
|
+
expect(nonce.bin_data.product_id).to eq("J3")
|
182
200
|
end
|
183
201
|
|
184
202
|
it "returns bin_data with issuing_bank set to Network Only" do
|
@@ -186,9 +204,9 @@ describe Braintree::PaymentMethodNonce do
|
|
186
204
|
|
187
205
|
nonce = result.payment_method_nonce
|
188
206
|
|
189
|
-
result.
|
190
|
-
nonce.bin_data.
|
191
|
-
nonce.bin_data.issuing_bank.
|
207
|
+
expect(result).to be_success
|
208
|
+
expect(nonce.bin_data).not_to be_nil
|
209
|
+
expect(nonce.bin_data.issuing_bank).to eq("NETWORK ONLY")
|
192
210
|
end
|
193
211
|
|
194
212
|
it "returns bin_data with payroll set to Yes" do
|
@@ -196,10 +214,10 @@ describe Braintree::PaymentMethodNonce do
|
|
196
214
|
|
197
215
|
nonce = result.payment_method_nonce
|
198
216
|
|
199
|
-
result.
|
200
|
-
nonce.bin_data.
|
201
|
-
nonce.bin_data.payroll.
|
202
|
-
nonce.bin_data.product_id.
|
217
|
+
expect(result).to be_success
|
218
|
+
expect(nonce.bin_data).not_to be_nil
|
219
|
+
expect(nonce.bin_data.payroll).to eq(Braintree::CreditCard::Payroll::Yes)
|
220
|
+
expect(nonce.bin_data.product_id).to eq("MSA")
|
203
221
|
end
|
204
222
|
|
205
223
|
it "returns bin_data with prepaid set to Yes" do
|
@@ -207,9 +225,9 @@ describe Braintree::PaymentMethodNonce do
|
|
207
225
|
|
208
226
|
nonce = result.payment_method_nonce
|
209
227
|
|
210
|
-
result.
|
211
|
-
nonce.bin_data.
|
212
|
-
nonce.bin_data.prepaid.
|
228
|
+
expect(result).to be_success
|
229
|
+
expect(nonce.bin_data).not_to be_nil
|
230
|
+
expect(nonce.bin_data.prepaid).to eq(Braintree::CreditCard::Prepaid::Yes)
|
213
231
|
end
|
214
232
|
|
215
233
|
it "returns bin_data with unknown indicators" do
|
@@ -217,17 +235,17 @@ describe Braintree::PaymentMethodNonce do
|
|
217
235
|
|
218
236
|
nonce = result.payment_method_nonce
|
219
237
|
|
220
|
-
result.
|
221
|
-
nonce.bin_data.
|
222
|
-
nonce.bin_data.commercial.
|
223
|
-
nonce.bin_data.country_of_issuance.
|
224
|
-
nonce.bin_data.debit.
|
225
|
-
nonce.bin_data.durbin_regulated.
|
226
|
-
nonce.bin_data.healthcare.
|
227
|
-
nonce.bin_data.issuing_bank.
|
228
|
-
nonce.bin_data.payroll.
|
229
|
-
nonce.bin_data.prepaid.
|
230
|
-
nonce.bin_data.product_id.
|
238
|
+
expect(result).to be_success
|
239
|
+
expect(nonce.bin_data).not_to be_nil
|
240
|
+
expect(nonce.bin_data.commercial).to eq(Braintree::CreditCard::Commercial::Unknown)
|
241
|
+
expect(nonce.bin_data.country_of_issuance).to eq(Braintree::CreditCard::CountryOfIssuance::Unknown)
|
242
|
+
expect(nonce.bin_data.debit).to eq(Braintree::CreditCard::Debit::Unknown)
|
243
|
+
expect(nonce.bin_data.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Unknown)
|
244
|
+
expect(nonce.bin_data.healthcare).to eq(Braintree::CreditCard::Healthcare::Unknown)
|
245
|
+
expect(nonce.bin_data.issuing_bank).to eq(Braintree::CreditCard::IssuingBank::Unknown)
|
246
|
+
expect(nonce.bin_data.payroll).to eq(Braintree::CreditCard::Payroll::Unknown)
|
247
|
+
expect(nonce.bin_data.prepaid).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
248
|
+
expect(nonce.bin_data.product_id).to eq(Braintree::CreditCard::ProductId::Unknown)
|
231
249
|
end
|
232
250
|
|
233
251
|
it "correctly raises and exception for a non existent token" do
|
@@ -235,5 +253,82 @@ describe Braintree::PaymentMethodNonce do
|
|
235
253
|
Braintree::PaymentMethodNonce.find("not_a_nonce")
|
236
254
|
end.to raise_error(Braintree::NotFoundError)
|
237
255
|
end
|
256
|
+
|
257
|
+
context "authentication insights" do
|
258
|
+
let(:indian_payment_token) { "india_visa_credit" }
|
259
|
+
let(:european_payment_token) { "european_visa_credit" }
|
260
|
+
let(:indian_merchant_token) { "india_three_d_secure_merchant_account" }
|
261
|
+
let(:european_merchant_token) { "european_three_d_secure_merchant_account" }
|
262
|
+
|
263
|
+
describe "self.create" do
|
264
|
+
it "raises an exception if hash includes an invalid key" do
|
265
|
+
expect do
|
266
|
+
Braintree::PaymentMethodNonce.create("european_visa_credit", :invalid_key => "foo")
|
267
|
+
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
context "regulation environments" do
|
272
|
+
it "can get unregulated" do
|
273
|
+
expect(
|
274
|
+
request_authentication_insights(european_merchant_token, indian_payment_token)[:regulation_environment],
|
275
|
+
).to eq "unregulated"
|
276
|
+
end
|
277
|
+
|
278
|
+
it "can get psd2" do
|
279
|
+
expect(
|
280
|
+
request_authentication_insights(european_merchant_token, european_payment_token)[:regulation_environment],
|
281
|
+
).to eq "psd2"
|
282
|
+
end
|
283
|
+
|
284
|
+
it "can get rbi" do
|
285
|
+
expect(
|
286
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token)[:regulation_environment],
|
287
|
+
).to eq "rbi"
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
context "sca_indicator" do
|
292
|
+
it "can get unavailable" do
|
293
|
+
expect(
|
294
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token)[:sca_indicator],
|
295
|
+
).to eq "unavailable"
|
296
|
+
end
|
297
|
+
|
298
|
+
it "can get sca_required" do
|
299
|
+
expect(
|
300
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2001})[:sca_indicator],
|
301
|
+
).to eq "sca_required"
|
302
|
+
end
|
303
|
+
|
304
|
+
it "can get sca_optional" do
|
305
|
+
expect(
|
306
|
+
request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2000, recurring_customer_consent: true, recurring_max_amount: 2000})[:sca_indicator],
|
307
|
+
|
308
|
+
).to eq "sca_optional"
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
def request_authentication_insights(merchant_token, payment_method_token, options = {})
|
313
|
+
authentication_insight_options = {
|
314
|
+
amount: options[:amount],
|
315
|
+
recurring_customer_consent: options[:recurring_customer_consent],
|
316
|
+
recurring_max_amount: options[:recurring_max_amount],
|
317
|
+
}
|
318
|
+
nonce_request = {
|
319
|
+
merchant_account_id: merchant_token,
|
320
|
+
authentication_insight: true,
|
321
|
+
authentication_insight_options: authentication_insight_options,
|
322
|
+
}
|
323
|
+
|
324
|
+
result = Braintree::PaymentMethodNonce.create(
|
325
|
+
payment_method_token,
|
326
|
+
payment_method_nonce: nonce_request,
|
327
|
+
)
|
328
|
+
expect(result).to be_success
|
329
|
+
|
330
|
+
return result.payment_method_nonce.authentication_insight
|
331
|
+
end
|
332
|
+
end
|
238
333
|
end
|
239
334
|
end
|