braintree 2.104.0 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/braintree.gemspec +7 -4
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +2 -23
- data/lib/braintree/apple_pay.rb +1 -1
- data/lib/braintree/apple_pay_card.rb +11 -1
- data/lib/braintree/apple_pay_options.rb +1 -1
- data/lib/braintree/authorization_adjustment.rb +1 -1
- data/lib/braintree/base_module.rb +6 -0
- data/lib/braintree/bin_data.rb +9 -2
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +12 -12
- 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 +2 -77
- data/lib/braintree/credit_card_gateway.rb +17 -36
- data/lib/braintree/credit_card_verification.rb +18 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +9 -78
- data/lib/braintree/customer_gateway.rb +2 -23
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.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.rb +32 -8
- data/lib/braintree/dispute_gateway.rb +4 -9
- data/lib/braintree/dispute_search.rb +6 -3
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +150 -171
- data/lib/braintree/exceptions.rb +5 -3
- 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/gateway.rb +4 -14
- data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +11 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +7 -7
- data/lib/braintree/http.rb +4 -3
- data/lib/braintree/local_payment_completed.rb +2 -2
- 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 +1 -1
- data/lib/braintree/merchant_account.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +3 -1
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +1 -1
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/payment_instrument_type.rb +10 -14
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +15 -17
- data/lib/braintree/payment_method_nonce.rb +7 -4
- data/lib/braintree/payment_method_nonce_details.rb +37 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/payment_method_parser.rb +1 -8
- data/lib/braintree/plan.rb +21 -1
- data/lib/braintree/plan_gateway.rb +100 -0
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +5 -1
- data/lib/braintree/samsung_pay_card.rb +1 -1
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/subscription.rb +11 -11
- data/lib/braintree/successful_result.rb +3 -2
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/test/nonce.rb +4 -23
- data/lib/braintree/three_d_secure_info.rb +22 -12
- data/lib/braintree/transaction/disbursement_details.rb +1 -0
- data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/paypal_details.rb +3 -0
- data/lib/braintree/transaction/subscription_details.rb +2 -0
- data/lib/braintree/transaction.rb +65 -120
- data/lib/braintree/transaction_gateway.rb +39 -27
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +5 -3
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +3 -3
- data/lib/braintree/us_bank_account_verification.rb +1 -1
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/util.rb +21 -6
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/venmo_profile_data.rb +23 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +44 -30
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +104 -43
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/parser.rb +22 -35
- data/lib/braintree/xml/rexml.rb +4 -5
- data/lib/braintree.rb +28 -23
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +30 -113
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +3 -3
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
- data/spec/integration/braintree/client_api/spec_helper.rb +5 -31
- data/spec/integration/braintree/credit_card_spec.rb +219 -593
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +484 -513
- data/spec/integration/braintree/dispute_search_spec.rb +35 -6
- data/spec/integration/braintree/dispute_spec.rb +6 -7
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- 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 +2 -2
- data/spec/integration/braintree/merchant_account_spec.rb +28 -29
- data/spec/integration/braintree/merchant_spec.rb +14 -14
- data/spec/integration/braintree/oauth_spec.rb +11 -11
- data/spec/integration/braintree/payment_method_nonce_spec.rb +29 -35
- data/spec/integration/braintree/payment_method_spec.rb +535 -270
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
- data/spec/integration/braintree/paypal_account_spec.rb +28 -28
- data/spec/integration/braintree/plan_spec.rb +82 -0
- data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +144 -149
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +10 -10
- data/spec/integration/braintree/transaction_search_spec.rb +175 -70
- data/spec/integration/braintree/transaction_spec.rb +955 -894
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
- data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +16 -7
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +8 -14
- data/spec/unit/braintree/address_spec.rb +1 -9
- data/spec/unit/braintree/apple_pay_card_spec.rb +7 -1
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +42 -42
- data/spec/unit/braintree/credit_card_spec.rb +13 -32
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
- data/spec/unit/braintree/customer_spec.rb +21 -22
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_search_spec.rb +3 -0
- data/spec/unit/braintree/dispute_spec.rb +75 -21
- data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- 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 +10 -8
- data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
- data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
- data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- 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 +43 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +30 -1
- 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/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
- 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/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +7 -1
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +36 -54
- data/spec/unit/braintree/util_spec.rb +55 -21
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +166 -57
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +62 -30
- data/lib/braintree/amex_express_checkout_card.rb +0 -40
- 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 -83
- 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 -49
- 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
@@ -5,7 +5,7 @@ describe Braintree::WebhookNotification do
|
|
5
5
|
it "builds a sample notification and signature given an identifier and kind" do
|
6
6
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
7
7
|
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
|
8
|
-
"my_id"
|
8
|
+
"my_id",
|
9
9
|
)
|
10
10
|
|
11
11
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -18,7 +18,7 @@ describe Braintree::WebhookNotification do
|
|
18
18
|
it "builds a sample notification for a partner merchant connected webhook" do
|
19
19
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
20
20
|
Braintree::WebhookNotification::Kind::PartnerMerchantConnected,
|
21
|
-
"my_id"
|
21
|
+
"my_id",
|
22
22
|
)
|
23
23
|
|
24
24
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -35,7 +35,7 @@ describe Braintree::WebhookNotification do
|
|
35
35
|
it "builds a sample notification for a partner merchant disconnected webhook" do
|
36
36
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
37
37
|
Braintree::WebhookNotification::Kind::PartnerMerchantDisconnected,
|
38
|
-
"my_id"
|
38
|
+
"my_id",
|
39
39
|
)
|
40
40
|
|
41
41
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -48,7 +48,7 @@ describe Braintree::WebhookNotification do
|
|
48
48
|
it "builds a sample notification for a partner merchant declined webhook" do
|
49
49
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
50
50
|
Braintree::WebhookNotification::Kind::PartnerMerchantDeclined,
|
51
|
-
"my_id"
|
51
|
+
"my_id",
|
52
52
|
)
|
53
53
|
|
54
54
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -62,7 +62,7 @@ describe Braintree::WebhookNotification do
|
|
62
62
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
63
63
|
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
|
64
64
|
"my_id",
|
65
|
-
"my_source_merchant_id"
|
65
|
+
"my_source_merchant_id",
|
66
66
|
)
|
67
67
|
|
68
68
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -73,7 +73,7 @@ describe Braintree::WebhookNotification do
|
|
73
73
|
it "doesn't include source merchant IDs if not supplied" do
|
74
74
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
75
75
|
Braintree::WebhookNotification::Kind::PartnerMerchantDeclined,
|
76
|
-
"my_id"
|
76
|
+
"my_id",
|
77
77
|
)
|
78
78
|
|
79
79
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -85,7 +85,7 @@ describe Braintree::WebhookNotification do
|
|
85
85
|
it "builds a sample notification for a status transitioned webhook" do
|
86
86
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
87
87
|
Braintree::WebhookNotification::Kind::ConnectedMerchantStatusTransitioned,
|
88
|
-
"my_id"
|
88
|
+
"my_id",
|
89
89
|
)
|
90
90
|
|
91
91
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -102,7 +102,7 @@ describe Braintree::WebhookNotification do
|
|
102
102
|
it "builds a sample notification for a paypal status changed webhook" do
|
103
103
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
104
104
|
Braintree::WebhookNotification::Kind::ConnectedMerchantPayPalStatusChanged,
|
105
|
-
"my_id"
|
105
|
+
"my_id",
|
106
106
|
)
|
107
107
|
|
108
108
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -116,10 +116,10 @@ describe Braintree::WebhookNotification do
|
|
116
116
|
paypal_status_changed.action.should == "link"
|
117
117
|
end
|
118
118
|
|
119
|
-
it
|
119
|
+
it "builds a sample notification for OAuth application revocation" do
|
120
120
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
121
121
|
Braintree::WebhookNotification::Kind::OAuthAccessRevoked,
|
122
|
-
|
122
|
+
"my_id",
|
123
123
|
)
|
124
124
|
|
125
125
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -139,7 +139,7 @@ describe Braintree::WebhookNotification do
|
|
139
139
|
it "builds a sample notification for a dispute opened webhook" do
|
140
140
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
141
141
|
Braintree::WebhookNotification::Kind::DisputeOpened,
|
142
|
-
dispute_id
|
142
|
+
dispute_id,
|
143
143
|
)
|
144
144
|
|
145
145
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -155,7 +155,7 @@ describe Braintree::WebhookNotification do
|
|
155
155
|
it "builds a sample notification for a dispute lost webhook" do
|
156
156
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
157
157
|
Braintree::WebhookNotification::Kind::DisputeLost,
|
158
|
-
dispute_id
|
158
|
+
dispute_id,
|
159
159
|
)
|
160
160
|
|
161
161
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -171,7 +171,7 @@ describe Braintree::WebhookNotification do
|
|
171
171
|
it "builds a sample notification for a dispute won webhook" do
|
172
172
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
173
173
|
Braintree::WebhookNotification::Kind::DisputeWon,
|
174
|
-
dispute_id
|
174
|
+
dispute_id,
|
175
175
|
)
|
176
176
|
|
177
177
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -187,7 +187,7 @@ describe Braintree::WebhookNotification do
|
|
187
187
|
it "builds a sample notification for a dispute accepted webhook" do
|
188
188
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
189
189
|
Braintree::WebhookNotification::Kind::DisputeAccepted,
|
190
|
-
dispute_id
|
190
|
+
dispute_id,
|
191
191
|
)
|
192
192
|
|
193
193
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -203,7 +203,7 @@ describe Braintree::WebhookNotification do
|
|
203
203
|
it "builds a sample notification for a dispute disputed webhook" do
|
204
204
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
205
205
|
Braintree::WebhookNotification::Kind::DisputeDisputed,
|
206
|
-
dispute_id
|
206
|
+
dispute_id,
|
207
207
|
)
|
208
208
|
|
209
209
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -219,7 +219,7 @@ describe Braintree::WebhookNotification do
|
|
219
219
|
it "builds a sample notification for a dispute expired webhook" do
|
220
220
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
221
221
|
Braintree::WebhookNotification::Kind::DisputeExpired,
|
222
|
-
dispute_id
|
222
|
+
dispute_id,
|
223
223
|
)
|
224
224
|
|
225
225
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -235,7 +235,7 @@ describe Braintree::WebhookNotification do
|
|
235
235
|
it "is compatible with the previous dispute won webhook interface" do
|
236
236
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
237
237
|
Braintree::WebhookNotification::Kind::DisputeWon,
|
238
|
-
dispute_id
|
238
|
+
dispute_id,
|
239
239
|
)
|
240
240
|
|
241
241
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -267,7 +267,7 @@ describe Braintree::WebhookNotification do
|
|
267
267
|
it "builds a sample notification for a transaction disbursed webhook" do
|
268
268
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
269
269
|
Braintree::WebhookNotification::Kind::TransactionDisbursed,
|
270
|
-
"my_id"
|
270
|
+
"my_id",
|
271
271
|
)
|
272
272
|
|
273
273
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -275,13 +275,13 @@ describe Braintree::WebhookNotification do
|
|
275
275
|
notification.kind.should == Braintree::WebhookNotification::Kind::TransactionDisbursed
|
276
276
|
notification.transaction.id.should == "my_id"
|
277
277
|
notification.transaction.amount.should == 1_00
|
278
|
-
notification.transaction.disbursement_details.disbursement_date.should == "2013-07-09"
|
278
|
+
notification.transaction.disbursement_details.disbursement_date.should == Date.parse("2013-07-09")
|
279
279
|
end
|
280
280
|
|
281
281
|
it "builds a sample notification for a disbursement_exception webhook" do
|
282
282
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
283
283
|
Braintree::WebhookNotification::Kind::DisbursementException,
|
284
|
-
"my_id"
|
284
|
+
"my_id",
|
285
285
|
)
|
286
286
|
|
287
287
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -300,7 +300,7 @@ describe Braintree::WebhookNotification do
|
|
300
300
|
it "builds a sample notification for a disbursement webhook" do
|
301
301
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
302
302
|
Braintree::WebhookNotification::Kind::Disbursement,
|
303
|
-
"my_id"
|
303
|
+
"my_id",
|
304
304
|
)
|
305
305
|
|
306
306
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -317,11 +317,29 @@ describe Braintree::WebhookNotification do
|
|
317
317
|
end
|
318
318
|
end
|
319
319
|
|
320
|
+
context "transaction review" do
|
321
|
+
it " builds a sample notification for a transaction reviewed webhook" do
|
322
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
323
|
+
Braintree::WebhookNotification::Kind::TransactionReviewed,
|
324
|
+
"my_id",
|
325
|
+
)
|
326
|
+
|
327
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
328
|
+
|
329
|
+
expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::TransactionReviewed)
|
330
|
+
expect(notification.transaction_review.transaction_id).to eq("my_id")
|
331
|
+
expect(notification.transaction_review.decision).to eq("decision")
|
332
|
+
expect(notification.transaction_review.reviewer_email).to eq("hey@girl.com")
|
333
|
+
expect(notification.transaction_review.reviewer_note).to eq("i reviewed this")
|
334
|
+
expect(notification.transaction_review.reviewed_time).to_not be_nil
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
320
338
|
context "us bank account transactions" do
|
321
339
|
it "builds a sample notification for a settlement webhook" do
|
322
340
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
323
341
|
Braintree::WebhookNotification::Kind::TransactionSettled,
|
324
|
-
"my_id"
|
342
|
+
"my_id",
|
325
343
|
)
|
326
344
|
|
327
345
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -338,7 +356,7 @@ describe Braintree::WebhookNotification do
|
|
338
356
|
it "builds a sample notification for a settlement declined webhook" do
|
339
357
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
340
358
|
Braintree::WebhookNotification::Kind::TransactionSettlementDeclined,
|
341
|
-
"my_id"
|
359
|
+
"my_id",
|
342
360
|
)
|
343
361
|
|
344
362
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -357,7 +375,7 @@ describe Braintree::WebhookNotification do
|
|
357
375
|
it "builds a sample notification for a merchant account approved webhook" do
|
358
376
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
359
377
|
Braintree::WebhookNotification::Kind::SubMerchantAccountApproved,
|
360
|
-
"my_id"
|
378
|
+
"my_id",
|
361
379
|
)
|
362
380
|
|
363
381
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -372,7 +390,7 @@ describe Braintree::WebhookNotification do
|
|
372
390
|
it "builds a sample notification for a merchant account declined webhook" do
|
373
391
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
374
392
|
Braintree::WebhookNotification::Kind::SubMerchantAccountDeclined,
|
375
|
-
"my_id"
|
393
|
+
"my_id",
|
376
394
|
)
|
377
395
|
|
378
396
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -391,7 +409,7 @@ describe Braintree::WebhookNotification do
|
|
391
409
|
it "builds a sample notification for a subscription charged successfully webhook" do
|
392
410
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
393
411
|
Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfully,
|
394
|
-
"my_id"
|
412
|
+
"my_id",
|
395
413
|
)
|
396
414
|
|
397
415
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -406,7 +424,7 @@ describe Braintree::WebhookNotification do
|
|
406
424
|
it "builds a sample notification for a subscription charged unsuccessfully webhook" do
|
407
425
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
408
426
|
Braintree::WebhookNotification::Kind::SubscriptionChargedUnsuccessfully,
|
409
|
-
"my_id"
|
427
|
+
"my_id",
|
410
428
|
)
|
411
429
|
|
412
430
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -422,7 +440,7 @@ describe Braintree::WebhookNotification do
|
|
422
440
|
it "includes a valid signature" do
|
423
441
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
424
442
|
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
|
425
|
-
"my_id"
|
443
|
+
"my_id",
|
426
444
|
)
|
427
445
|
expected_signature = Braintree::Digest.hexdigest(Braintree::Configuration.private_key, sample_notification[:bt_payload])
|
428
446
|
|
@@ -434,7 +452,7 @@ describe Braintree::WebhookNotification do
|
|
434
452
|
it "builds a sample notification for an account_updater_daily_report webhook" do
|
435
453
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
436
454
|
Braintree::WebhookNotification::Kind::AccountUpdaterDailyReport,
|
437
|
-
"my_id"
|
455
|
+
"my_id",
|
438
456
|
)
|
439
457
|
|
440
458
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -449,44 +467,44 @@ describe Braintree::WebhookNotification do
|
|
449
467
|
it "builds a sample notification for a GrantorUpdatedGrantedPaymentMethod webhook" do
|
450
468
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
451
469
|
Braintree::WebhookNotification::Kind::GrantorUpdatedGrantedPaymentMethod,
|
452
|
-
"my_id"
|
470
|
+
"my_id",
|
453
471
|
)
|
454
472
|
|
455
473
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
456
474
|
update = notification.granted_payment_instrument_update
|
457
475
|
|
458
476
|
notification.kind.should == Braintree::WebhookNotification::Kind::GrantorUpdatedGrantedPaymentMethod
|
459
|
-
update.grant_owner_merchant_id.should ==
|
460
|
-
update.grant_recipient_merchant_id.should ==
|
461
|
-
update.payment_method_nonce.should ==
|
462
|
-
update.token.should ==
|
463
|
-
update.updated_fields.should == [
|
477
|
+
update.grant_owner_merchant_id.should == "vczo7jqrpwrsi2px"
|
478
|
+
update.grant_recipient_merchant_id.should == "cf0i8wgarszuy6hc"
|
479
|
+
update.payment_method_nonce.should == "ee257d98-de40-47e8-96b3-a6954ea7a9a4"
|
480
|
+
update.token.should == "abc123z"
|
481
|
+
update.updated_fields.should == ["expiration-month", "expiration-year"]
|
464
482
|
end
|
465
483
|
|
466
484
|
it "builds a sample notification for a RecipientUpdatedGrantedPaymentMethod webhook" do
|
467
485
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
468
486
|
Braintree::WebhookNotification::Kind::RecipientUpdatedGrantedPaymentMethod,
|
469
|
-
"my_id"
|
487
|
+
"my_id",
|
470
488
|
)
|
471
489
|
|
472
490
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
473
491
|
update = notification.granted_payment_instrument_update
|
474
492
|
|
475
493
|
notification.kind.should == Braintree::WebhookNotification::Kind::RecipientUpdatedGrantedPaymentMethod
|
476
|
-
update.grant_owner_merchant_id.should ==
|
477
|
-
update.grant_recipient_merchant_id.should ==
|
478
|
-
update.payment_method_nonce.should ==
|
479
|
-
update.token.should ==
|
480
|
-
update.updated_fields.should == [
|
494
|
+
update.grant_owner_merchant_id.should == "vczo7jqrpwrsi2px"
|
495
|
+
update.grant_recipient_merchant_id.should == "cf0i8wgarszuy6hc"
|
496
|
+
update.payment_method_nonce.should == "ee257d98-de40-47e8-96b3-a6954ea7a9a4"
|
497
|
+
update.token.should == "abc123z"
|
498
|
+
update.updated_fields.should == ["expiration-month", "expiration-year"]
|
481
499
|
end
|
482
500
|
end
|
483
501
|
|
484
502
|
context "granted_payment_instrument_revoked" do
|
485
503
|
let(:gateway) do
|
486
504
|
config = Braintree::Configuration.new(
|
487
|
-
:merchant_id =>
|
488
|
-
:public_key =>
|
489
|
-
:private_key =>
|
505
|
+
:merchant_id => "merchant_id",
|
506
|
+
:public_key => "wrong_public_key",
|
507
|
+
:private_key => "wrong_private_key",
|
490
508
|
)
|
491
509
|
Braintree::Gateway.new(config)
|
492
510
|
end
|
@@ -611,6 +629,22 @@ describe Braintree::WebhookNotification do
|
|
611
629
|
metadata.token.should == "venmo_token"
|
612
630
|
metadata.revoked_payment_method.class.should == Braintree::VenmoAccount
|
613
631
|
end
|
632
|
+
|
633
|
+
it "builds a sample notification for a GrantedPaymentMethodRevoked webhook" do
|
634
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
635
|
+
Braintree::WebhookNotification::Kind::GrantedPaymentMethodRevoked,
|
636
|
+
"my_id",
|
637
|
+
)
|
638
|
+
|
639
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
640
|
+
expect(notification.kind).to eq Braintree::WebhookNotification::Kind::GrantedPaymentMethodRevoked
|
641
|
+
|
642
|
+
metadata = notification.revoked_payment_method_metadata
|
643
|
+
|
644
|
+
expect(metadata.customer_id).to eq "venmo_customer_id"
|
645
|
+
expect(metadata.token).to eq "my_id"
|
646
|
+
expect(metadata.revoked_payment_method.class).to eq Braintree::VenmoAccount
|
647
|
+
end
|
614
648
|
end
|
615
649
|
end
|
616
650
|
|
@@ -618,7 +652,7 @@ describe Braintree::WebhookNotification do
|
|
618
652
|
it "builds a sample notification for a payment_method_revoked_by_customer webhook" do
|
619
653
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
620
654
|
Braintree::WebhookNotification::Kind::PaymentMethodRevokedByCustomer,
|
621
|
-
"my_payment_method_token"
|
655
|
+
"my_payment_method_token",
|
622
656
|
)
|
623
657
|
|
624
658
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -635,7 +669,7 @@ describe Braintree::WebhookNotification do
|
|
635
669
|
it "builds a sample notification for a local_payment webhook" do
|
636
670
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
637
671
|
Braintree::WebhookNotification::Kind::LocalPaymentCompleted,
|
638
|
-
"my_id"
|
672
|
+
"my_id",
|
639
673
|
)
|
640
674
|
|
641
675
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
@@ -652,6 +686,81 @@ describe Braintree::WebhookNotification do
|
|
652
686
|
end
|
653
687
|
end
|
654
688
|
|
689
|
+
context "local_payment_expired" do
|
690
|
+
it "builds a sample notification for a local_payment_expired webhook" do
|
691
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
692
|
+
Braintree::WebhookNotification::Kind::LocalPaymentExpired,
|
693
|
+
"my_id",
|
694
|
+
)
|
695
|
+
|
696
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
697
|
+
notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentExpired
|
698
|
+
|
699
|
+
local_payment_expired = notification.local_payment_expired
|
700
|
+
local_payment_expired.payment_id.should == "PAY-XYZ123"
|
701
|
+
local_payment_expired.payment_context_id.should == "cG5b="
|
702
|
+
end
|
703
|
+
end
|
704
|
+
|
705
|
+
context "local_payment_funded" do
|
706
|
+
it "builds a sample notification for a local_payment_funded webhook" do
|
707
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
708
|
+
Braintree::WebhookNotification::Kind::LocalPaymentFunded,
|
709
|
+
"my_id",
|
710
|
+
)
|
711
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
712
|
+
notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentFunded
|
713
|
+
|
714
|
+
local_payment_funded = notification.local_payment_funded
|
715
|
+
local_payment_funded.payment_id.should == "PAY-XYZ123"
|
716
|
+
local_payment_funded.payment_context_id.should == "cG5b="
|
717
|
+
local_payment_funded.transaction.id.should == "my_id"
|
718
|
+
local_payment_funded.transaction.status.should == Braintree::Transaction::Status::Settled
|
719
|
+
local_payment_funded.transaction.amount.should == 49.99
|
720
|
+
local_payment_funded.transaction.order_id.should == "order4567"
|
721
|
+
end
|
722
|
+
end
|
723
|
+
|
724
|
+
context "local_payment_reversed" do
|
725
|
+
it "builds a sample notification for a local_payment webhook" do
|
726
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
727
|
+
Braintree::WebhookNotification::Kind::LocalPaymentReversed,
|
728
|
+
"my_id",
|
729
|
+
)
|
730
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
731
|
+
notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentReversed
|
732
|
+
|
733
|
+
local_payment_reversed = notification.local_payment_reversed
|
734
|
+
local_payment_reversed.payment_id.should == "PAY-XYZ123"
|
735
|
+
end
|
736
|
+
end
|
737
|
+
|
738
|
+
context "payment_method_customer_data_updated" do
|
739
|
+
it "builds a sample notification for a payment_method_customer_data_updated webhook" do
|
740
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
741
|
+
Braintree::WebhookNotification::Kind::PaymentMethodCustomerDataUpdated,
|
742
|
+
"my_id",
|
743
|
+
)
|
744
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
745
|
+
notification.kind.should == Braintree::WebhookNotification::Kind::PaymentMethodCustomerDataUpdated
|
746
|
+
|
747
|
+
payment_method_customer_data_updated = notification.payment_method_customer_data_updated_metadata
|
748
|
+
|
749
|
+
payment_method_customer_data_updated.token.should eq("TOKEN-12345")
|
750
|
+
payment_method_customer_data_updated.datetime_updated.should eq("2022-01-01T21:28:37Z")
|
751
|
+
|
752
|
+
enriched_customer_data = payment_method_customer_data_updated.enriched_customer_data
|
753
|
+
enriched_customer_data.fields_updated.should eq(["username"])
|
754
|
+
|
755
|
+
profile_data = enriched_customer_data.profile_data
|
756
|
+
profile_data.first_name.should eq("John")
|
757
|
+
profile_data.last_name.should eq("Doe")
|
758
|
+
profile_data.username.should eq("venmo_username")
|
759
|
+
profile_data.phone_number.should eq("1231231234")
|
760
|
+
profile_data.email.should eq("john.doe@paypal.com")
|
761
|
+
end
|
762
|
+
end
|
763
|
+
|
655
764
|
describe "parse" do
|
656
765
|
it "raises InvalidSignature error when the signature is nil" do
|
657
766
|
expect do
|
@@ -668,7 +777,7 @@ describe Braintree::WebhookNotification do
|
|
668
777
|
it "raises InvalidSignature error when the signature is completely invalid" do
|
669
778
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
670
779
|
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
|
671
|
-
"my_id"
|
780
|
+
"my_id",
|
672
781
|
)
|
673
782
|
|
674
783
|
expect do
|
@@ -679,13 +788,13 @@ describe Braintree::WebhookNotification do
|
|
679
788
|
it "raises InvalidSignature error with a message when the public key is not found" do
|
680
789
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
681
790
|
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
|
682
|
-
"my_id"
|
791
|
+
"my_id",
|
683
792
|
)
|
684
793
|
|
685
794
|
config = Braintree::Configuration.new(
|
686
|
-
:merchant_id =>
|
687
|
-
:public_key =>
|
688
|
-
:private_key =>
|
795
|
+
:merchant_id => "merchant_id",
|
796
|
+
:public_key => "wrong_public_key",
|
797
|
+
:private_key => "wrong_private_key",
|
689
798
|
)
|
690
799
|
gateway = Braintree::Gateway.new(config)
|
691
800
|
|
@@ -697,7 +806,7 @@ describe Braintree::WebhookNotification do
|
|
697
806
|
it "raises InvalidSignature error if the payload has been changed" do
|
698
807
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
699
808
|
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
|
700
|
-
"my_id"
|
809
|
+
"my_id",
|
701
810
|
)
|
702
811
|
|
703
812
|
expect do
|
@@ -708,7 +817,7 @@ describe Braintree::WebhookNotification do
|
|
708
817
|
it "raises InvalidSignature error with a message complaining about invalid characters" do
|
709
818
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
710
819
|
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
|
711
|
-
"my_id"
|
820
|
+
"my_id",
|
712
821
|
)
|
713
822
|
|
714
823
|
expect do
|
@@ -719,7 +828,7 @@ describe Braintree::WebhookNotification do
|
|
719
828
|
it "allows all valid characters" do
|
720
829
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
721
830
|
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
|
722
|
-
"my_id"
|
831
|
+
"my_id",
|
723
832
|
)
|
724
833
|
|
725
834
|
sample_notification[:bt_payload] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+=/\n"
|
@@ -736,7 +845,7 @@ describe Braintree::WebhookNotification do
|
|
736
845
|
it "retries a payload with a newline" do
|
737
846
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
738
847
|
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
|
739
|
-
"my_id"
|
848
|
+
"my_id",
|
740
849
|
)
|
741
850
|
|
742
851
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)
|
@@ -751,7 +860,7 @@ describe Braintree::WebhookNotification do
|
|
751
860
|
it "returns true for check webhook kinds" do
|
752
861
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
753
862
|
Braintree::WebhookNotification::Kind::Check,
|
754
|
-
nil
|
863
|
+
nil,
|
755
864
|
)
|
756
865
|
|
757
866
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)
|
@@ -762,7 +871,7 @@ describe Braintree::WebhookNotification do
|
|
762
871
|
it "returns false for non-check webhook kinds" do
|
763
872
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
764
873
|
Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
|
765
|
-
nil
|
874
|
+
nil,
|
766
875
|
)
|
767
876
|
|
768
877
|
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload].rstrip)
|
@@ -57,24 +57,29 @@ describe Braintree::Xml::Parser do
|
|
57
57
|
xml.should parse_to(:root => {:customers => [{:name => "Adam"}, {:name => "Ben"}]})
|
58
58
|
end
|
59
59
|
|
60
|
-
it "parses
|
61
|
-
xml =
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
it "parses an array" do
|
61
|
+
xml = <<-END
|
62
|
+
<root>
|
63
|
+
<customers type="array">
|
64
|
+
<customer><name>Adam</name><customer-id>1</customer-id></customer>
|
65
|
+
<customer><name>Ben</name><customer-id>2</customer-id></customer>
|
66
|
+
</customers>
|
67
|
+
</root>
|
68
|
+
END
|
69
|
+
xml.should parse_to(:root => {:customers => [{:name => "Adam", :customer_id => "1"}, {:name => "Ben", :customer_id => "2"}]})
|
66
70
|
end
|
67
71
|
|
68
|
-
it "parses
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
it "parses nested objects" do
|
73
|
+
xml = <<-END
|
74
|
+
<root>
|
75
|
+
<paypal-details>
|
76
|
+
<deets type="array"><super-secrets><secret-code>1234</secret-code></super-secrets></deets>
|
77
|
+
<payer-email>abc@test.com</payer-email>
|
78
|
+
<payment-id>1234567890</payment-id>
|
79
|
+
</paypal-details>
|
80
|
+
</root>
|
81
|
+
END
|
82
|
+
xml.should parse_to(:root => {:paypal_details => {:deets => [{:secret_code => "1234"}], :payer_email => "abc@test.com", :payment_id => "1234567890"}})
|
78
83
|
end
|
79
84
|
end
|
80
85
|
end
|
@@ -99,34 +99,34 @@ describe Braintree::Xml do
|
|
99
99
|
verify_to_xml_and_back hash
|
100
100
|
end
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
102
|
+
context "Integer" do
|
103
|
+
it "works for integers" do
|
104
|
+
hash = {:root => {:foo => 1}}
|
105
|
+
Braintree::Xml.hash_to_xml(hash).should include("<foo type=\"integer\">1</foo>")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "BigDecimal" do
|
110
|
+
it "works for BigDecimals" do
|
111
|
+
hash = {:root => {:foo => BigDecimal("123.45")}}
|
112
|
+
Braintree::Xml.hash_to_xml(hash).should include("<foo>123.45</foo>")
|
113
|
+
end
|
114
|
+
|
115
|
+
it "works for BigDecimals with fewer than 2 digits" do
|
116
|
+
hash = {:root => {:foo => BigDecimal("1000.0")}}
|
117
|
+
Braintree::Xml.hash_to_xml(hash).should include("<foo>1000.00</foo>")
|
118
|
+
end
|
119
|
+
|
120
|
+
it "works for BigDecimals with more than 2 digits" do
|
121
|
+
hash = {:root => {:foo => BigDecimal("12.345")}}
|
122
|
+
Braintree::Xml.hash_to_xml(hash).should include("<foo>12.345</foo>")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it "works for symbols" do
|
127
|
+
hash = {:root => {:foo => :bar}}
|
128
|
+
Braintree::Xml.hash_to_xml(hash).should include("<foo>bar</foo>")
|
129
|
+
end
|
130
130
|
|
131
131
|
it "type casts booleans" do
|
132
132
|
hash = {:root => {:string_true => "true", :bool_true => true, :bool_false => false, :string_false => "false"}}
|
@@ -154,13 +154,13 @@ describe Braintree::Xml do
|
|
154
154
|
end
|
155
155
|
|
156
156
|
it "escapes keys and values" do
|
157
|
-
hash = {
|
157
|
+
hash = {"ke<y" => "val>ue"}
|
158
158
|
Braintree::Xml.hash_to_xml(hash).should include("<ke<y>val>ue</ke<y>")
|
159
159
|
end
|
160
160
|
|
161
161
|
it "escapes nested keys and values" do
|
162
|
-
hash = {
|
163
|
-
Braintree::Xml.hash_to_xml(hash).gsub(/\s/,
|
162
|
+
hash = {"top<" => {"ke<y" => "val>ue"}}
|
163
|
+
Braintree::Xml.hash_to_xml(hash).gsub(/\s/, "").should include("<top<><ke<y>val>ue</ke<y></top<>")
|
164
164
|
end
|
165
165
|
end
|
166
166
|
end
|