braintree 4.14.0 → 4.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/account_updater_daily_report.rb +3 -3
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +4 -4
- data/lib/braintree/address_gateway.rb +5 -5
- data/lib/braintree/advanced_search.rb +10 -10
- data/lib/braintree/apple_pay.rb +3 -3
- data/lib/braintree/apple_pay_card.rb +3 -3
- data/lib/braintree/apple_pay_options.rb +3 -3
- data/lib/braintree/authorization_adjustment.rb +3 -3
- data/lib/braintree/base_module.rb +1 -1
- data/lib/braintree/bin_data.rb +2 -2
- data/lib/braintree/client_token_gateway.rb +1 -1
- data/lib/braintree/configuration.rb +22 -22
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +22 -9
- data/lib/braintree/credit_card_gateway.rb +23 -11
- data/lib/braintree/credit_card_verification.rb +3 -3
- data/lib/braintree/credit_card_verification_gateway.rb +28 -11
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +5 -9
- data/lib/braintree/customer_gateway.rb +7 -7
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +5 -5
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/dispute/paypal_message.rb +1 -1
- data/lib/braintree/dispute/status_history.rb +1 -1
- data/lib/braintree/dispute/transaction.rb +1 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +3 -3
- data/lib/braintree/dispute_gateway.rb +1 -1
- data/lib/braintree/dispute_search.rb +1 -1
- data/lib/braintree/document_upload.rb +2 -2
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +2 -2
- data/lib/braintree/error_codes.rb +4 -0
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +1 -2
- data/lib/braintree/exchange_rate.rb +2 -2
- data/lib/braintree/exchange_rate_quote.rb +3 -3
- data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
- data/lib/braintree/exchange_rate_quote_input.rb +3 -3
- data/lib/braintree/exchange_rate_quote_request.rb +3 -3
- data/lib/braintree/exchange_rate_quote_response.rb +3 -3
- data/lib/braintree/facilitated_details.rb +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/google_pay_card.rb +3 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +1 -1
- data/lib/braintree/http.rb +5 -5
- data/lib/braintree/local_payment_completed.rb +2 -2
- data/lib/braintree/local_payment_expired.rb +2 -2
- data/lib/braintree/local_payment_funded.rb +2 -2
- data/lib/braintree/local_payment_reversed.rb +2 -2
- data/lib/braintree/merchant.rb +3 -3
- data/lib/braintree/merchant_account.rb +2 -2
- data/lib/braintree/merchant_account_gateway.rb +9 -9
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +3 -3
- data/lib/braintree/oauth_credentials.rb +3 -3
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +2 -0
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
- data/lib/braintree/payment_method_gateway.rb +23 -10
- data/lib/braintree/payment_method_nonce.rb +4 -4
- data/lib/braintree/payment_method_nonce_details.rb +1 -1
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/paypal_account.rb +1 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/plan_gateway.rb +2 -2
- data/lib/braintree/resource_collection.rb +2 -2
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +1 -1
- data/lib/braintree/samsung_pay_card.rb +5 -5
- data/lib/braintree/sepa_direct_debit_account.rb +2 -2
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
- 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 +2 -2
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +2 -2
- data/lib/braintree/test/credit_card.rb +7 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +4 -0
- 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 +1 -1
- data/lib/braintree/transaction/address_details.rb +2 -1
- data/lib/braintree/transaction/credit_card_details.rb +4 -1
- data/lib/braintree/transaction/customer_details.rb +1 -1
- data/lib/braintree/transaction/disbursement_details.rb +1 -1
- data/lib/braintree/transaction/local_payment_details.rb +2 -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 +16 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +1 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +37 -20
- data/lib/braintree/transaction_gateway.rb +44 -15
- data/lib/braintree/transaction_line_item.rb +13 -10
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +1 -1
- data/lib/braintree/transaction_search.rb +7 -6
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +2 -2
- data/lib/braintree/us_bank_account_verification.rb +23 -15
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +3 -3
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +3 -3
- data/lib/braintree/venmo_profile_data.rb +6 -4
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +7 -7
- data/lib/braintree/webhook_notification.rb +3 -2
- data/lib/braintree/webhook_notification_gateway.rb +4 -4
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +18 -1
- data/lib/braintree/xml/generator.rb +1 -1
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +3 -3
- data/lib/braintree/xml/rexml.rb +2 -2
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +5 -1
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/client_api/spec_helper.rb +2 -2
- data/spec/integration/braintree/credit_card_spec.rb +227 -228
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +98 -53
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +317 -317
- 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 +0 -1
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/package_tracking_spec.rb +111 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +89 -69
- data/spec/integration/braintree/payment_method_spec.rb +391 -391
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +150 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +12 -6
- data/spec/integration/braintree/transaction_search_spec.rb +225 -165
- data/spec/integration/braintree/transaction_spec.rb +1606 -1230
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +33 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +11 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +9 -9
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- 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 +74 -0
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- 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 +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +41 -9
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- 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 +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +16 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +14 -2
@@ -10,9 +10,9 @@ describe Braintree::WebhookNotification do
|
|
10
10
|
|
11
11
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
12
12
|
|
13
|
-
notification.kind.
|
14
|
-
notification.subscription.id.
|
15
|
-
notification.timestamp.
|
13
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::SubscriptionWentPastDue)
|
14
|
+
expect(notification.subscription.id).to eq("my_id")
|
15
|
+
expect(notification.timestamp).to be_within(10).of(Time.now.utc)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "builds a sample notification for a partner merchant connected webhook" do
|
@@ -23,13 +23,13 @@ describe Braintree::WebhookNotification do
|
|
23
23
|
|
24
24
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
25
25
|
|
26
|
-
notification.kind.
|
27
|
-
notification.partner_merchant.merchant_public_id.
|
28
|
-
notification.partner_merchant.public_key.
|
29
|
-
notification.partner_merchant.private_key.
|
30
|
-
notification.partner_merchant.partner_merchant_id.
|
31
|
-
notification.partner_merchant.client_side_encryption_key.
|
32
|
-
notification.timestamp.
|
26
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::PartnerMerchantConnected)
|
27
|
+
expect(notification.partner_merchant.merchant_public_id).to eq("public_id")
|
28
|
+
expect(notification.partner_merchant.public_key).to eq("public_key")
|
29
|
+
expect(notification.partner_merchant.private_key).to eq("private_key")
|
30
|
+
expect(notification.partner_merchant.partner_merchant_id).to eq("abc123")
|
31
|
+
expect(notification.partner_merchant.client_side_encryption_key).to eq("cse_key")
|
32
|
+
expect(notification.timestamp).to be_within(10).of(Time.now.utc)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "builds a sample notification for a partner merchant disconnected webhook" do
|
@@ -40,9 +40,9 @@ describe Braintree::WebhookNotification do
|
|
40
40
|
|
41
41
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
42
42
|
|
43
|
-
notification.kind.
|
44
|
-
notification.partner_merchant.partner_merchant_id.
|
45
|
-
notification.timestamp.
|
43
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::PartnerMerchantDisconnected)
|
44
|
+
expect(notification.partner_merchant.partner_merchant_id).to eq("abc123")
|
45
|
+
expect(notification.timestamp).to be_within(10).of(Time.now.utc)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "builds a sample notification for a partner merchant declined webhook" do
|
@@ -53,9 +53,9 @@ describe Braintree::WebhookNotification do
|
|
53
53
|
|
54
54
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
55
55
|
|
56
|
-
notification.kind.
|
57
|
-
notification.partner_merchant.partner_merchant_id.
|
58
|
-
notification.timestamp.
|
56
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::PartnerMerchantDeclined)
|
57
|
+
expect(notification.partner_merchant.partner_merchant_id).to eq("abc123")
|
58
|
+
expect(notification.timestamp).to be_within(10).of(Time.now.utc)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "builds a sample notification with a source merchant ID" do
|
@@ -67,7 +67,7 @@ describe Braintree::WebhookNotification do
|
|
67
67
|
|
68
68
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
69
69
|
|
70
|
-
notification.source_merchant_id.
|
70
|
+
expect(notification.source_merchant_id).to eq("my_source_merchant_id")
|
71
71
|
end
|
72
72
|
|
73
73
|
it "doesn't include source merchant IDs if not supplied" do
|
@@ -78,7 +78,7 @@ describe Braintree::WebhookNotification do
|
|
78
78
|
|
79
79
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
80
80
|
|
81
|
-
notification.source_merchant_id.
|
81
|
+
expect(notification.source_merchant_id).to be_nil
|
82
82
|
end
|
83
83
|
|
84
84
|
context "auth" do
|
@@ -90,13 +90,13 @@ describe Braintree::WebhookNotification do
|
|
90
90
|
|
91
91
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
92
92
|
|
93
|
-
notification.kind.
|
93
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::ConnectedMerchantStatusTransitioned)
|
94
94
|
|
95
95
|
status_transitioned = notification.connected_merchant_status_transitioned
|
96
|
-
status_transitioned.merchant_public_id.
|
97
|
-
status_transitioned.merchant_id.
|
98
|
-
status_transitioned.oauth_application_client_id.
|
99
|
-
status_transitioned.status.
|
96
|
+
expect(status_transitioned.merchant_public_id).to eq("my_id")
|
97
|
+
expect(status_transitioned.merchant_id).to eq("my_id")
|
98
|
+
expect(status_transitioned.oauth_application_client_id).to eq("oauth_application_client_id")
|
99
|
+
expect(status_transitioned.status).to eq("new_status")
|
100
100
|
end
|
101
101
|
|
102
102
|
it "builds a sample notification for a paypal status changed webhook" do
|
@@ -107,13 +107,13 @@ describe Braintree::WebhookNotification do
|
|
107
107
|
|
108
108
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
109
109
|
|
110
|
-
notification.kind.
|
110
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::ConnectedMerchantPayPalStatusChanged)
|
111
111
|
|
112
112
|
paypal_status_changed = notification.connected_merchant_paypal_status_changed
|
113
|
-
paypal_status_changed.merchant_public_id.
|
114
|
-
paypal_status_changed.merchant_id.
|
115
|
-
paypal_status_changed.oauth_application_client_id.
|
116
|
-
paypal_status_changed.action.
|
113
|
+
expect(paypal_status_changed.merchant_public_id).to eq("my_id")
|
114
|
+
expect(paypal_status_changed.merchant_id).to eq("my_id")
|
115
|
+
expect(paypal_status_changed.oauth_application_client_id).to eq("oauth_application_client_id")
|
116
|
+
expect(paypal_status_changed.action).to eq("link")
|
117
117
|
end
|
118
118
|
|
119
119
|
it "builds a sample notification for OAuth application revocation" do
|
@@ -124,10 +124,10 @@ describe Braintree::WebhookNotification do
|
|
124
124
|
|
125
125
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
126
126
|
|
127
|
-
notification.kind.
|
128
|
-
notification.oauth_access_revocation.merchant_id.
|
129
|
-
notification.oauth_access_revocation.oauth_application_client_id.
|
130
|
-
notification.timestamp.
|
127
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::OAuthAccessRevoked)
|
128
|
+
expect(notification.oauth_access_revocation.merchant_id).to eq("my_id")
|
129
|
+
expect(notification.oauth_access_revocation.oauth_application_client_id).to eq("oauth_application_client_id")
|
130
|
+
expect(notification.timestamp).to be_within(10).of(Time.now.utc)
|
131
131
|
end
|
132
132
|
|
133
133
|
end
|
@@ -144,12 +144,12 @@ describe Braintree::WebhookNotification do
|
|
144
144
|
|
145
145
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
146
146
|
|
147
|
-
notification.kind.
|
147
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisputeOpened)
|
148
148
|
|
149
149
|
dispute = notification.dispute
|
150
|
-
dispute.status.
|
151
|
-
dispute.id.
|
152
|
-
dispute.kind.
|
150
|
+
expect(dispute.status).to eq(Braintree::Dispute::Status::Open)
|
151
|
+
expect(dispute.id).to eq(dispute_id)
|
152
|
+
expect(dispute.kind).to eq(Braintree::Dispute::Kind::Chargeback)
|
153
153
|
end
|
154
154
|
|
155
155
|
it "builds a sample notification for a dispute lost webhook" do
|
@@ -160,12 +160,12 @@ describe Braintree::WebhookNotification do
|
|
160
160
|
|
161
161
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
162
162
|
|
163
|
-
notification.kind.
|
163
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisputeLost)
|
164
164
|
|
165
165
|
dispute = notification.dispute
|
166
|
-
dispute.status.
|
167
|
-
dispute.id.
|
168
|
-
dispute.kind.
|
166
|
+
expect(dispute.status).to eq(Braintree::Dispute::Status::Lost)
|
167
|
+
expect(dispute.id).to eq(dispute_id)
|
168
|
+
expect(dispute.kind).to eq(Braintree::Dispute::Kind::Chargeback)
|
169
169
|
end
|
170
170
|
|
171
171
|
it "builds a sample notification for a dispute won webhook" do
|
@@ -176,12 +176,12 @@ describe Braintree::WebhookNotification do
|
|
176
176
|
|
177
177
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
178
178
|
|
179
|
-
notification.kind.
|
179
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisputeWon)
|
180
180
|
|
181
181
|
dispute = notification.dispute
|
182
|
-
dispute.status.
|
183
|
-
dispute.id.
|
184
|
-
dispute.kind.
|
182
|
+
expect(dispute.status).to eq(Braintree::Dispute::Status::Won)
|
183
|
+
expect(dispute.id).to eq(dispute_id)
|
184
|
+
expect(dispute.kind).to eq(Braintree::Dispute::Kind::Chargeback)
|
185
185
|
end
|
186
186
|
|
187
187
|
it "builds a sample notification for a dispute accepted webhook" do
|
@@ -192,12 +192,12 @@ describe Braintree::WebhookNotification do
|
|
192
192
|
|
193
193
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
194
194
|
|
195
|
-
notification.kind.
|
195
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisputeAccepted)
|
196
196
|
|
197
197
|
dispute = notification.dispute
|
198
|
-
dispute.status.
|
199
|
-
dispute.id.
|
200
|
-
dispute.kind.
|
198
|
+
expect(dispute.status).to eq(Braintree::Dispute::Status::Accepted)
|
199
|
+
expect(dispute.id).to eq(dispute_id)
|
200
|
+
expect(dispute.kind).to eq(Braintree::Dispute::Kind::Chargeback)
|
201
201
|
end
|
202
202
|
|
203
203
|
it "builds a sample notification for a dispute auto_accepted webhook" do
|
@@ -208,12 +208,12 @@ describe Braintree::WebhookNotification do
|
|
208
208
|
|
209
209
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
210
210
|
|
211
|
-
notification.kind.
|
211
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisputeAutoAccepted)
|
212
212
|
|
213
213
|
dispute = notification.dispute
|
214
|
-
dispute.status.
|
215
|
-
dispute.id.
|
216
|
-
dispute.kind.
|
214
|
+
expect(dispute.status).to eq(Braintree::Dispute::Status::AutoAccepted)
|
215
|
+
expect(dispute.id).to eq(dispute_id)
|
216
|
+
expect(dispute.kind).to eq(Braintree::Dispute::Kind::Chargeback)
|
217
217
|
end
|
218
218
|
|
219
219
|
it "builds a sample notification for a dispute disputed webhook" do
|
@@ -224,12 +224,12 @@ describe Braintree::WebhookNotification do
|
|
224
224
|
|
225
225
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
226
226
|
|
227
|
-
notification.kind.
|
227
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisputeDisputed)
|
228
228
|
|
229
229
|
dispute = notification.dispute
|
230
|
-
dispute.status.
|
231
|
-
dispute.id.
|
232
|
-
dispute.kind.
|
230
|
+
expect(dispute.status).to eq(Braintree::Dispute::Status::Disputed)
|
231
|
+
expect(dispute.id).to eq(dispute_id)
|
232
|
+
expect(dispute.kind).to eq(Braintree::Dispute::Kind::Chargeback)
|
233
233
|
end
|
234
234
|
|
235
235
|
it "builds a sample notification for a dispute expired webhook" do
|
@@ -240,12 +240,12 @@ describe Braintree::WebhookNotification do
|
|
240
240
|
|
241
241
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
242
242
|
|
243
|
-
notification.kind.
|
243
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisputeExpired)
|
244
244
|
|
245
245
|
dispute = notification.dispute
|
246
|
-
dispute.status.
|
247
|
-
dispute.id.
|
248
|
-
dispute.kind.
|
246
|
+
expect(dispute.status).to eq(Braintree::Dispute::Status::Expired)
|
247
|
+
expect(dispute.id).to eq(dispute_id)
|
248
|
+
expect(dispute.kind).to eq(Braintree::Dispute::Kind::Chargeback)
|
249
249
|
end
|
250
250
|
|
251
251
|
it "is compatible with the previous dispute won webhook interface" do
|
@@ -256,15 +256,15 @@ describe Braintree::WebhookNotification do
|
|
256
256
|
|
257
257
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
258
258
|
|
259
|
-
notification.kind.
|
259
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisputeWon)
|
260
260
|
|
261
261
|
dispute = notification.dispute
|
262
|
-
dispute.amount.
|
263
|
-
dispute.id.
|
264
|
-
dispute.date_opened.
|
265
|
-
dispute.date_won.
|
266
|
-
dispute.transaction_details.amount.
|
267
|
-
dispute.transaction_details.id.
|
262
|
+
expect(dispute.amount).to eq(100.00)
|
263
|
+
expect(dispute.id).to eq(dispute_id)
|
264
|
+
expect(dispute.date_opened).to eq(Date.new(2014, 3, 21))
|
265
|
+
expect(dispute.date_won).to eq(Date.new(2014, 3, 22))
|
266
|
+
expect(dispute.transaction_details.amount).to eq(100.00)
|
267
|
+
expect(dispute.transaction_details.id).to eq(dispute_id)
|
268
268
|
end
|
269
269
|
end
|
270
270
|
|
@@ -288,10 +288,10 @@ describe Braintree::WebhookNotification do
|
|
288
288
|
|
289
289
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
290
290
|
|
291
|
-
notification.kind.
|
292
|
-
notification.transaction.id.
|
293
|
-
notification.transaction.amount.
|
294
|
-
notification.transaction.disbursement_details.disbursement_date.
|
291
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::TransactionDisbursed)
|
292
|
+
expect(notification.transaction.id).to eq("my_id")
|
293
|
+
expect(notification.transaction.amount).to eq(1_00)
|
294
|
+
expect(notification.transaction.disbursement_details.disbursement_date).to eq(Date.parse("2013-07-09"))
|
295
295
|
end
|
296
296
|
|
297
297
|
it "builds a sample notification for a disbursement_exception webhook" do
|
@@ -302,15 +302,15 @@ describe Braintree::WebhookNotification do
|
|
302
302
|
|
303
303
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
304
304
|
|
305
|
-
notification.kind.
|
306
|
-
notification.disbursement.id.
|
307
|
-
notification.disbursement.transaction_ids.
|
308
|
-
notification.disbursement.retry.
|
309
|
-
notification.disbursement.success.
|
310
|
-
notification.disbursement.exception_message.
|
311
|
-
notification.disbursement.disbursement_date.
|
312
|
-
notification.disbursement.follow_up_action.
|
313
|
-
notification.disbursement.merchant_account.id.
|
305
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisbursementException)
|
306
|
+
expect(notification.disbursement.id).to eq("my_id")
|
307
|
+
expect(notification.disbursement.transaction_ids).to eq(%W{ afv56j kj8hjk })
|
308
|
+
expect(notification.disbursement.retry).to be(false)
|
309
|
+
expect(notification.disbursement.success).to be(false)
|
310
|
+
expect(notification.disbursement.exception_message).to eq("bank_rejected")
|
311
|
+
expect(notification.disbursement.disbursement_date).to eq(Date.parse("2014-02-10"))
|
312
|
+
expect(notification.disbursement.follow_up_action).to eq("update_funding_information")
|
313
|
+
expect(notification.disbursement.merchant_account.id).to eq("merchant_account_token")
|
314
314
|
end
|
315
315
|
|
316
316
|
it "builds a sample notification for a disbursement webhook" do
|
@@ -321,15 +321,15 @@ describe Braintree::WebhookNotification do
|
|
321
321
|
|
322
322
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
323
323
|
|
324
|
-
notification.kind.
|
325
|
-
notification.disbursement.id.
|
326
|
-
notification.disbursement.transaction_ids.
|
327
|
-
notification.disbursement.retry.
|
328
|
-
notification.disbursement.success.
|
329
|
-
notification.disbursement.exception_message.
|
330
|
-
notification.disbursement.disbursement_date.
|
331
|
-
notification.disbursement.follow_up_action.
|
332
|
-
notification.disbursement.merchant_account.id.
|
324
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::Disbursement)
|
325
|
+
expect(notification.disbursement.id).to eq("my_id")
|
326
|
+
expect(notification.disbursement.transaction_ids).to eq(%W{ afv56j kj8hjk })
|
327
|
+
expect(notification.disbursement.retry).to be(false)
|
328
|
+
expect(notification.disbursement.success).to be(true)
|
329
|
+
expect(notification.disbursement.exception_message).to be_nil
|
330
|
+
expect(notification.disbursement.disbursement_date).to eq(Date.parse("2014-02-10"))
|
331
|
+
expect(notification.disbursement.follow_up_action).to be_nil
|
332
|
+
expect(notification.disbursement.merchant_account.id).to eq("merchant_account_token")
|
333
333
|
end
|
334
334
|
end
|
335
335
|
|
@@ -360,13 +360,13 @@ describe Braintree::WebhookNotification do
|
|
360
360
|
|
361
361
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
362
362
|
|
363
|
-
notification.kind.
|
363
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::TransactionSettled)
|
364
364
|
|
365
|
-
notification.transaction.status.
|
366
|
-
notification.transaction.us_bank_account_details.account_type.
|
367
|
-
notification.transaction.us_bank_account_details.account_holder_name.
|
368
|
-
notification.transaction.us_bank_account_details.routing_number.
|
369
|
-
notification.transaction.us_bank_account_details.last_4.
|
365
|
+
expect(notification.transaction.status).to eq("settled")
|
366
|
+
expect(notification.transaction.us_bank_account_details.account_type).to eq("checking")
|
367
|
+
expect(notification.transaction.us_bank_account_details.account_holder_name).to eq("Dan Schulman")
|
368
|
+
expect(notification.transaction.us_bank_account_details.routing_number).to eq("123456789")
|
369
|
+
expect(notification.transaction.us_bank_account_details.last_4).to eq("1234")
|
370
370
|
end
|
371
371
|
|
372
372
|
it "builds a sample notification for a settlement declined webhook" do
|
@@ -377,13 +377,13 @@ describe Braintree::WebhookNotification do
|
|
377
377
|
|
378
378
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
379
379
|
|
380
|
-
notification.kind.
|
380
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::TransactionSettlementDeclined)
|
381
381
|
|
382
|
-
notification.transaction.status.
|
383
|
-
notification.transaction.us_bank_account_details.account_type.
|
384
|
-
notification.transaction.us_bank_account_details.account_holder_name.
|
385
|
-
notification.transaction.us_bank_account_details.routing_number.
|
386
|
-
notification.transaction.us_bank_account_details.last_4.
|
382
|
+
expect(notification.transaction.status).to eq("settlement_declined")
|
383
|
+
expect(notification.transaction.us_bank_account_details.account_type).to eq("checking")
|
384
|
+
expect(notification.transaction.us_bank_account_details.account_holder_name).to eq("Dan Schulman")
|
385
|
+
expect(notification.transaction.us_bank_account_details.routing_number).to eq("123456789")
|
386
|
+
expect(notification.transaction.us_bank_account_details.last_4).to eq("1234")
|
387
387
|
end
|
388
388
|
end
|
389
389
|
|
@@ -396,11 +396,11 @@ describe Braintree::WebhookNotification do
|
|
396
396
|
|
397
397
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
398
398
|
|
399
|
-
notification.kind.
|
400
|
-
notification.merchant_account.id.
|
401
|
-
notification.merchant_account.status.
|
402
|
-
notification.merchant_account.master_merchant_account.id.
|
403
|
-
notification.merchant_account.master_merchant_account.status.
|
399
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::SubMerchantAccountApproved)
|
400
|
+
expect(notification.merchant_account.id).to eq("my_id")
|
401
|
+
expect(notification.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Active)
|
402
|
+
expect(notification.merchant_account.master_merchant_account.id).to eq("master_ma_for_my_id")
|
403
|
+
expect(notification.merchant_account.master_merchant_account.status).to eq(Braintree::MerchantAccount::Status::Active)
|
404
404
|
end
|
405
405
|
|
406
406
|
it "builds a sample notification for a merchant account declined webhook" do
|
@@ -411,17 +411,32 @@ describe Braintree::WebhookNotification do
|
|
411
411
|
|
412
412
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
413
413
|
|
414
|
-
notification.kind.
|
415
|
-
notification.merchant_account.id.
|
416
|
-
notification.merchant_account.status.
|
417
|
-
notification.merchant_account.master_merchant_account.id.
|
418
|
-
notification.merchant_account.master_merchant_account.status.
|
419
|
-
notification.message.
|
420
|
-
notification.errors.for(:merchant_account).on(:base).first.code.
|
414
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::SubMerchantAccountDeclined)
|
415
|
+
expect(notification.merchant_account.id).to eq("my_id")
|
416
|
+
expect(notification.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Suspended)
|
417
|
+
expect(notification.merchant_account.master_merchant_account.id).to eq("master_ma_for_my_id")
|
418
|
+
expect(notification.merchant_account.master_merchant_account.status).to eq(Braintree::MerchantAccount::Status::Suspended)
|
419
|
+
expect(notification.message).to eq("Credit score is too low")
|
420
|
+
expect(notification.errors.for(:merchant_account).on(:base).first.code).to eq(Braintree::ErrorCodes::MerchantAccount::DeclinedOFAC)
|
421
421
|
end
|
422
422
|
end
|
423
423
|
|
424
424
|
context "subscription" do
|
425
|
+
it "builds a sample notification for a subscription billing skipped webhook" do
|
426
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
427
|
+
Braintree::WebhookNotification::Kind::SubscriptionBillingSkipped,
|
428
|
+
"my_id",
|
429
|
+
)
|
430
|
+
|
431
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
432
|
+
|
433
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::SubscriptionBillingSkipped)
|
434
|
+
expect(notification.subscription.id).to eq("my_id")
|
435
|
+
expect(notification.subscription.transactions.size).to eq(0)
|
436
|
+
expect(notification.subscription.discounts.size).to eq(0)
|
437
|
+
expect(notification.subscription.add_ons.size).to eq(0)
|
438
|
+
end
|
439
|
+
|
425
440
|
it "builds a sample notification for a subscription charged successfully webhook" do
|
426
441
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
427
442
|
Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfully,
|
@@ -430,11 +445,11 @@ describe Braintree::WebhookNotification do
|
|
430
445
|
|
431
446
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
432
447
|
|
433
|
-
notification.kind.
|
434
|
-
notification.subscription.id.
|
435
|
-
notification.subscription.transactions.size.
|
436
|
-
notification.subscription.transactions.first.status.
|
437
|
-
notification.subscription.transactions.first.amount.
|
448
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfully)
|
449
|
+
expect(notification.subscription.id).to eq("my_id")
|
450
|
+
expect(notification.subscription.transactions.size).to eq(1)
|
451
|
+
expect(notification.subscription.transactions.first.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
|
452
|
+
expect(notification.subscription.transactions.first.amount).to eq(BigDecimal("49.99"))
|
438
453
|
end
|
439
454
|
|
440
455
|
it "builds a sample notification for a subscription charged unsuccessfully webhook" do
|
@@ -445,11 +460,11 @@ describe Braintree::WebhookNotification do
|
|
445
460
|
|
446
461
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
447
462
|
|
448
|
-
notification.kind.
|
449
|
-
notification.subscription.id.
|
450
|
-
notification.subscription.transactions.size.
|
451
|
-
notification.subscription.transactions.first.status.
|
452
|
-
notification.subscription.transactions.first.amount.
|
463
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::SubscriptionChargedUnsuccessfully)
|
464
|
+
expect(notification.subscription.id).to eq("my_id")
|
465
|
+
expect(notification.subscription.transactions.size).to eq(1)
|
466
|
+
expect(notification.subscription.transactions.first.status).to eq(Braintree::Transaction::Status::Failed)
|
467
|
+
expect(notification.subscription.transactions.first.amount).to eq(BigDecimal("49.99"))
|
453
468
|
end
|
454
469
|
end
|
455
470
|
|
@@ -460,7 +475,7 @@ describe Braintree::WebhookNotification do
|
|
460
475
|
)
|
461
476
|
expected_signature = Braintree::Digest.hexdigest(Braintree::Configuration.private_key, sample_notification[:bt_payload])
|
462
477
|
|
463
|
-
sample_notification[:bt_signature].
|
478
|
+
expect(sample_notification[:bt_signature]).to eq("#{Braintree::Configuration.public_key}|#{expected_signature}")
|
464
479
|
end
|
465
480
|
end
|
466
481
|
|
@@ -473,9 +488,9 @@ describe Braintree::WebhookNotification do
|
|
473
488
|
|
474
489
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
475
490
|
|
476
|
-
notification.kind.
|
477
|
-
notification.account_updater_daily_report.report_url.
|
478
|
-
notification.account_updater_daily_report.report_date.
|
491
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::AccountUpdaterDailyReport)
|
492
|
+
expect(notification.account_updater_daily_report.report_url).to eq("link-to-csv-report")
|
493
|
+
expect(notification.account_updater_daily_report.report_date).to eq(Date.parse("2016-01-14"))
|
479
494
|
end
|
480
495
|
end
|
481
496
|
|
@@ -489,12 +504,12 @@ describe Braintree::WebhookNotification do
|
|
489
504
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
490
505
|
update = notification.granted_payment_instrument_update
|
491
506
|
|
492
|
-
notification.kind.
|
493
|
-
update.grant_owner_merchant_id.
|
494
|
-
update.grant_recipient_merchant_id.
|
495
|
-
update.payment_method_nonce.
|
496
|
-
update.token.
|
497
|
-
update.updated_fields.
|
507
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::GrantorUpdatedGrantedPaymentMethod)
|
508
|
+
expect(update.grant_owner_merchant_id).to eq("vczo7jqrpwrsi2px")
|
509
|
+
expect(update.grant_recipient_merchant_id).to eq("cf0i8wgarszuy6hc")
|
510
|
+
expect(update.payment_method_nonce).to eq("ee257d98-de40-47e8-96b3-a6954ea7a9a4")
|
511
|
+
expect(update.token).to eq("abc123z")
|
512
|
+
expect(update.updated_fields).to eq(["expiration-month", "expiration-year"])
|
498
513
|
end
|
499
514
|
|
500
515
|
it "builds a sample notification for a RecipientUpdatedGrantedPaymentMethod webhook" do
|
@@ -506,12 +521,12 @@ describe Braintree::WebhookNotification do
|
|
506
521
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
507
522
|
update = notification.granted_payment_instrument_update
|
508
523
|
|
509
|
-
notification.kind.
|
510
|
-
update.grant_owner_merchant_id.
|
511
|
-
update.grant_recipient_merchant_id.
|
512
|
-
update.payment_method_nonce.
|
513
|
-
update.token.
|
514
|
-
update.updated_fields.
|
524
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::RecipientUpdatedGrantedPaymentMethod)
|
525
|
+
expect(update.grant_owner_merchant_id).to eq("vczo7jqrpwrsi2px")
|
526
|
+
expect(update.grant_recipient_merchant_id).to eq("cf0i8wgarszuy6hc")
|
527
|
+
expect(update.payment_method_nonce).to eq("ee257d98-de40-47e8-96b3-a6954ea7a9a4")
|
528
|
+
expect(update.token).to eq("abc123z")
|
529
|
+
expect(update.updated_fields).to eq(["expiration-month", "expiration-year"])
|
515
530
|
end
|
516
531
|
end
|
517
532
|
|
@@ -570,10 +585,10 @@ describe Braintree::WebhookNotification do
|
|
570
585
|
notification = Braintree::WebhookNotification._new(gateway, attributes[:notification])
|
571
586
|
metadata = notification.revoked_payment_method_metadata
|
572
587
|
|
573
|
-
notification.kind.
|
574
|
-
metadata.customer_id.
|
575
|
-
metadata.token.
|
576
|
-
metadata.revoked_payment_method.class.
|
588
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::GrantedPaymentInstrumentRevoked)
|
589
|
+
expect(metadata.customer_id).to eq("credit_card_customer_id")
|
590
|
+
expect(metadata.token).to eq("credit_card_token")
|
591
|
+
expect(metadata.revoked_payment_method.class).to eq(Braintree::CreditCard)
|
577
592
|
end
|
578
593
|
end
|
579
594
|
|
@@ -605,10 +620,10 @@ describe Braintree::WebhookNotification do
|
|
605
620
|
notification = Braintree::WebhookNotification._new(gateway, attributes[:notification])
|
606
621
|
metadata = notification.revoked_payment_method_metadata
|
607
622
|
|
608
|
-
notification.kind.
|
609
|
-
metadata.customer_id.
|
610
|
-
metadata.token.
|
611
|
-
metadata.revoked_payment_method.class.
|
623
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::GrantedPaymentInstrumentRevoked)
|
624
|
+
expect(metadata.customer_id).to eq("paypal_customer_id")
|
625
|
+
expect(metadata.token).to eq("paypal_token")
|
626
|
+
expect(metadata.revoked_payment_method.class).to eq(Braintree::PayPalAccount)
|
612
627
|
end
|
613
628
|
end
|
614
629
|
|
@@ -640,10 +655,10 @@ describe Braintree::WebhookNotification do
|
|
640
655
|
notification = Braintree::WebhookNotification._new(gateway, attributes[:notification])
|
641
656
|
metadata = notification.revoked_payment_method_metadata
|
642
657
|
|
643
|
-
notification.kind.
|
644
|
-
metadata.customer_id.
|
645
|
-
metadata.token.
|
646
|
-
metadata.revoked_payment_method.class.
|
658
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::GrantedPaymentInstrumentRevoked)
|
659
|
+
expect(metadata.customer_id).to eq("venmo_customer_id")
|
660
|
+
expect(metadata.token).to eq("venmo_token")
|
661
|
+
expect(metadata.revoked_payment_method.class).to eq(Braintree::VenmoAccount)
|
647
662
|
end
|
648
663
|
|
649
664
|
it "builds a sample notification for a GrantedPaymentMethodRevoked webhook" do
|
@@ -672,12 +687,12 @@ describe Braintree::WebhookNotification do
|
|
672
687
|
)
|
673
688
|
|
674
689
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
675
|
-
notification.kind.
|
690
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::PaymentMethodRevokedByCustomer)
|
676
691
|
|
677
692
|
metadata = notification.revoked_payment_method_metadata
|
678
|
-
metadata.token.
|
679
|
-
metadata.revoked_payment_method.class.
|
680
|
-
metadata.revoked_payment_method.revoked_at.
|
693
|
+
expect(metadata.token).to eq("my_payment_method_token")
|
694
|
+
expect(metadata.revoked_payment_method.class).to eq(Braintree::PayPalAccount)
|
695
|
+
expect(metadata.revoked_payment_method.revoked_at).not_to be_nil
|
681
696
|
end
|
682
697
|
end
|
683
698
|
|
@@ -689,16 +704,16 @@ describe Braintree::WebhookNotification do
|
|
689
704
|
)
|
690
705
|
|
691
706
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
692
|
-
notification.kind.
|
707
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::LocalPaymentCompleted)
|
693
708
|
|
694
709
|
local_payment_completed = notification.local_payment_completed
|
695
|
-
local_payment_completed.payment_id.
|
696
|
-
local_payment_completed.payer_id.
|
697
|
-
local_payment_completed.payment_method_nonce.
|
698
|
-
local_payment_completed.transaction.id.
|
699
|
-
local_payment_completed.transaction.status.
|
700
|
-
local_payment_completed.transaction.amount.
|
701
|
-
local_payment_completed.transaction.order_id.
|
710
|
+
expect(local_payment_completed.payment_id).to eq("PAY-XYZ123")
|
711
|
+
expect(local_payment_completed.payer_id).to eq("ABCPAYER")
|
712
|
+
expect(local_payment_completed.payment_method_nonce).to eq("ee257d98-de40-47e8-96b3-a6954ea7a9a4")
|
713
|
+
expect(local_payment_completed.transaction.id).to eq("my_id")
|
714
|
+
expect(local_payment_completed.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
|
715
|
+
expect(local_payment_completed.transaction.amount).to eq(49.99)
|
716
|
+
expect(local_payment_completed.transaction.order_id).to eq("order4567")
|
702
717
|
end
|
703
718
|
end
|
704
719
|
|
@@ -710,11 +725,11 @@ describe Braintree::WebhookNotification do
|
|
710
725
|
)
|
711
726
|
|
712
727
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
713
|
-
notification.kind.
|
728
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::LocalPaymentExpired)
|
714
729
|
|
715
730
|
local_payment_expired = notification.local_payment_expired
|
716
|
-
local_payment_expired.payment_id.
|
717
|
-
local_payment_expired.payment_context_id.
|
731
|
+
expect(local_payment_expired.payment_id).to eq("PAY-XYZ123")
|
732
|
+
expect(local_payment_expired.payment_context_id).to eq("cG5b=")
|
718
733
|
end
|
719
734
|
end
|
720
735
|
|
@@ -725,15 +740,15 @@ describe Braintree::WebhookNotification do
|
|
725
740
|
"my_id",
|
726
741
|
)
|
727
742
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
728
|
-
notification.kind.
|
743
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::LocalPaymentFunded)
|
729
744
|
|
730
745
|
local_payment_funded = notification.local_payment_funded
|
731
|
-
local_payment_funded.payment_id.
|
732
|
-
local_payment_funded.payment_context_id.
|
733
|
-
local_payment_funded.transaction.id.
|
734
|
-
local_payment_funded.transaction.status.
|
735
|
-
local_payment_funded.transaction.amount.
|
736
|
-
local_payment_funded.transaction.order_id.
|
746
|
+
expect(local_payment_funded.payment_id).to eq("PAY-XYZ123")
|
747
|
+
expect(local_payment_funded.payment_context_id).to eq("cG5b=")
|
748
|
+
expect(local_payment_funded.transaction.id).to eq("my_id")
|
749
|
+
expect(local_payment_funded.transaction.status).to eq(Braintree::Transaction::Status::Settled)
|
750
|
+
expect(local_payment_funded.transaction.amount).to eq(49.99)
|
751
|
+
expect(local_payment_funded.transaction.order_id).to eq("order4567")
|
737
752
|
end
|
738
753
|
end
|
739
754
|
|
@@ -744,10 +759,10 @@ describe Braintree::WebhookNotification do
|
|
744
759
|
"my_id",
|
745
760
|
)
|
746
761
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
747
|
-
notification.kind.
|
762
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::LocalPaymentReversed)
|
748
763
|
|
749
764
|
local_payment_reversed = notification.local_payment_reversed
|
750
|
-
local_payment_reversed.payment_id.
|
765
|
+
expect(local_payment_reversed.payment_id).to eq("PAY-XYZ123")
|
751
766
|
end
|
752
767
|
end
|
753
768
|
|
@@ -758,22 +773,22 @@ describe Braintree::WebhookNotification do
|
|
758
773
|
"my_id",
|
759
774
|
)
|
760
775
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
761
|
-
notification.kind.
|
776
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::PaymentMethodCustomerDataUpdated)
|
762
777
|
|
763
778
|
payment_method_customer_data_updated = notification.payment_method_customer_data_updated_metadata
|
764
779
|
|
765
|
-
payment_method_customer_data_updated.token.
|
766
|
-
payment_method_customer_data_updated.datetime_updated.
|
780
|
+
expect(payment_method_customer_data_updated.token).to eq("TOKEN-12345")
|
781
|
+
expect(payment_method_customer_data_updated.datetime_updated).to eq("2022-01-01T21:28:37Z")
|
767
782
|
|
768
783
|
enriched_customer_data = payment_method_customer_data_updated.enriched_customer_data
|
769
|
-
enriched_customer_data.fields_updated.
|
784
|
+
expect(enriched_customer_data.fields_updated).to eq(["username"])
|
770
785
|
|
771
786
|
profile_data = enriched_customer_data.profile_data
|
772
|
-
profile_data.first_name.
|
773
|
-
profile_data.last_name.
|
774
|
-
profile_data.username.
|
775
|
-
profile_data.phone_number.
|
776
|
-
profile_data.email.
|
787
|
+
expect(profile_data.first_name).to eq("John")
|
788
|
+
expect(profile_data.last_name).to eq("Doe")
|
789
|
+
expect(profile_data.username).to eq("venmo_username")
|
790
|
+
expect(profile_data.phone_number).to eq("1231231234")
|
791
|
+
expect(profile_data.email).to eq("john.doe@paypal.com")
|
777
792
|
end
|
778
793
|
end
|
779
794
|
|
@@ -855,7 +870,7 @@ describe Braintree::WebhookNotification do
|
|
855
870
|
exception = e
|
856
871
|
end
|
857
872
|
|
858
|
-
exception.message.
|
873
|
+
expect(exception.message).not_to match(/payload contains illegal characters/)
|
859
874
|
end
|
860
875
|
|
861
876
|
it "retries a payload with a newline" do
|
@@ -866,9 +881,9 @@ describe Braintree::WebhookNotification do
|
|
866
881
|
|
867
882
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)
|
868
883
|
|
869
|
-
notification.kind.
|
870
|
-
notification.subscription.id.
|
871
|
-
notification.timestamp.
|
884
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::SubscriptionWentPastDue)
|
885
|
+
expect(notification.subscription.id).to eq("my_id")
|
886
|
+
expect(notification.timestamp).to be_within(10).of(Time.now.utc)
|
872
887
|
end
|
873
888
|
end
|
874
889
|
|
@@ -881,7 +896,7 @@ describe Braintree::WebhookNotification do
|
|
881
896
|
|
882
897
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)
|
883
898
|
|
884
|
-
notification.check
|
899
|
+
expect(notification.check?).to eq(true)
|
885
900
|
end
|
886
901
|
|
887
902
|
it "returns false for non-check webhook kinds" do
|
@@ -892,14 +907,14 @@ describe Braintree::WebhookNotification do
|
|
892
907
|
|
893
908
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)
|
894
909
|
|
895
|
-
notification.check
|
910
|
+
expect(notification.check?).to eq(false)
|
896
911
|
end
|
897
912
|
end
|
898
913
|
|
899
914
|
describe "self.verify" do
|
900
915
|
it "creates a verification string" do
|
901
916
|
response = Braintree::WebhookNotification.verify("20f9f8ed05f77439fe955c977e4c8a53")
|
902
|
-
response.
|
917
|
+
expect(response).to eq("integration_public_key|d9b899556c966b3f06945ec21311865d35df3ce4")
|
903
918
|
end
|
904
919
|
|
905
920
|
it "raises InvalidChallenge error with a message complaining about invalid characters" do
|