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
@@ -13,14 +13,15 @@ describe Braintree::PaymentMethod do
|
|
13
13
|
context "plaid verified nonce" do
|
14
14
|
let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
|
15
15
|
|
16
|
-
|
16
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
17
|
+
xit "succeeds" do
|
17
18
|
customer = Braintree::Customer.create.customer
|
18
19
|
result = Braintree::PaymentMethod.create(
|
19
20
|
:payment_method_nonce => nonce,
|
20
21
|
:customer_id => customer.id,
|
21
22
|
:options => {
|
22
23
|
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
23
|
-
}
|
24
|
+
},
|
24
25
|
)
|
25
26
|
|
26
27
|
result.should be_success
|
@@ -49,7 +50,8 @@ describe Braintree::PaymentMethod do
|
|
49
50
|
Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
|
50
51
|
Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
51
52
|
].each do |method|
|
52
|
-
|
53
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
54
|
+
xit "succeeds and verifies via #{method}" do
|
53
55
|
customer = Braintree::Customer.create.customer
|
54
56
|
result = Braintree::PaymentMethod.create(
|
55
57
|
:payment_method_nonce => nonce,
|
@@ -57,7 +59,7 @@ describe Braintree::PaymentMethod do
|
|
57
59
|
:options => {
|
58
60
|
:us_bank_account_verification_method => method,
|
59
61
|
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
60
|
-
}
|
62
|
+
},
|
61
63
|
)
|
62
64
|
|
63
65
|
result.should be_success
|
@@ -101,7 +103,7 @@ describe Braintree::PaymentMethod do
|
|
101
103
|
:customer_id => customer.id,
|
102
104
|
:options => {
|
103
105
|
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
104
|
-
}
|
106
|
+
},
|
105
107
|
)
|
106
108
|
|
107
109
|
result.should be_success
|
@@ -134,7 +136,7 @@ describe Braintree::PaymentMethod do
|
|
134
136
|
:options => {
|
135
137
|
:us_bank_account_verification_method => method,
|
136
138
|
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
137
|
-
}
|
139
|
+
},
|
138
140
|
)
|
139
141
|
|
140
142
|
result.should be_success
|
@@ -165,7 +167,7 @@ describe Braintree::PaymentMethod do
|
|
165
167
|
customer = Braintree::Customer.create.customer
|
166
168
|
result = Braintree::PaymentMethod.create(
|
167
169
|
:payment_method_nonce => generate_invalid_us_bank_account_nonce,
|
168
|
-
:customer_id => customer.id
|
170
|
+
:customer_id => customer.id,
|
169
171
|
)
|
170
172
|
|
171
173
|
result.should_not be_success
|
@@ -183,14 +185,15 @@ describe Braintree::PaymentMethod do
|
|
183
185
|
|
184
186
|
let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
|
185
187
|
|
186
|
-
|
188
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
189
|
+
xit "succeeds and verifies via independent check" do
|
187
190
|
customer = Braintree::Customer.create.customer
|
188
191
|
result = Braintree::PaymentMethod.create(
|
189
192
|
:payment_method_nonce => nonce,
|
190
193
|
:customer_id => customer.id,
|
191
194
|
:options => {
|
192
195
|
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
193
|
-
}
|
196
|
+
},
|
194
197
|
)
|
195
198
|
|
196
199
|
result.should be_success
|
@@ -219,14 +222,15 @@ describe Braintree::PaymentMethod do
|
|
219
222
|
context "non plaid verified nonce" do
|
220
223
|
let(:nonce) { generate_non_plaid_us_bank_account_nonce }
|
221
224
|
|
222
|
-
|
225
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
226
|
+
xit "succeeds and verifies via independent check" do
|
223
227
|
customer = Braintree::Customer.create.customer
|
224
228
|
result = Braintree::PaymentMethod.create(
|
225
229
|
:payment_method_nonce => nonce,
|
226
230
|
:customer_id => customer.id,
|
227
231
|
:options => {
|
228
232
|
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
229
|
-
}
|
233
|
+
},
|
230
234
|
)
|
231
235
|
|
232
236
|
result.should be_success
|
@@ -256,7 +260,7 @@ describe Braintree::PaymentMethod do
|
|
256
260
|
customer = Braintree::Customer.create.customer
|
257
261
|
result = Braintree::PaymentMethod.create(
|
258
262
|
:payment_method_nonce => generate_invalid_us_bank_account_nonce,
|
259
|
-
:customer_id => customer.id
|
263
|
+
:customer_id => customer.id,
|
260
264
|
)
|
261
265
|
|
262
266
|
result.should_not be_success
|
@@ -352,7 +356,7 @@ describe Braintree::PaymentMethod do
|
|
352
356
|
:customer_id => customer.id,
|
353
357
|
:options => {
|
354
358
|
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
355
|
-
}
|
359
|
+
},
|
356
360
|
).payment_method
|
357
361
|
end
|
358
362
|
|
@@ -9,11 +9,11 @@ describe Braintree::PayPalAccount do
|
|
9
9
|
|
10
10
|
nonce = nonce_for_paypal_account(
|
11
11
|
:consent_code => "consent-code",
|
12
|
-
:token => payment_method_token
|
12
|
+
:token => payment_method_token,
|
13
13
|
)
|
14
14
|
result = Braintree::PaymentMethod.create(
|
15
15
|
:payment_method_nonce => nonce,
|
16
|
-
:customer_id => customer.id
|
16
|
+
:customer_id => customer.id,
|
17
17
|
)
|
18
18
|
result.should be_success
|
19
19
|
|
@@ -35,7 +35,7 @@ describe Braintree::PayPalAccount do
|
|
35
35
|
result = Braintree::PaymentMethod.create(
|
36
36
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
37
37
|
:customer_id => customer.id,
|
38
|
-
:token => payment_method_token
|
38
|
+
:token => payment_method_token,
|
39
39
|
)
|
40
40
|
result.should be_success
|
41
41
|
|
@@ -56,7 +56,7 @@ describe Braintree::PayPalAccount do
|
|
56
56
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
57
57
|
:expiration_date => "05/2009",
|
58
58
|
:cvv => "100",
|
59
|
-
:token => "CREDIT_CARD_TOKEN"
|
59
|
+
:token => "CREDIT_CARD_TOKEN",
|
60
60
|
)
|
61
61
|
|
62
62
|
expect do
|
@@ -70,11 +70,11 @@ describe Braintree::PayPalAccount do
|
|
70
70
|
|
71
71
|
nonce = nonce_for_paypal_account(
|
72
72
|
:consent_code => "consent-code",
|
73
|
-
:token => payment_method_token
|
73
|
+
:token => payment_method_token,
|
74
74
|
)
|
75
75
|
result = Braintree::PaymentMethod.create(
|
76
76
|
:payment_method_nonce => nonce,
|
77
|
-
:customer_id => customer.id
|
77
|
+
:customer_id => customer.id,
|
78
78
|
)
|
79
79
|
result.should be_success
|
80
80
|
|
@@ -82,12 +82,12 @@ describe Braintree::PayPalAccount do
|
|
82
82
|
|
83
83
|
subscription1 = Braintree::Subscription.create(
|
84
84
|
:payment_method_token => token,
|
85
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
85
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
86
86
|
).subscription
|
87
87
|
|
88
88
|
subscription2 = Braintree::Subscription.create(
|
89
89
|
:payment_method_token => token,
|
90
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
90
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
91
91
|
).subscription
|
92
92
|
|
93
93
|
paypal_account = Braintree::PayPalAccount.find(token)
|
@@ -105,7 +105,7 @@ describe Braintree::PayPalAccount do
|
|
105
105
|
:options => {
|
106
106
|
:make_default => true,
|
107
107
|
:fail_on_duplicate_payment_method => true,
|
108
|
-
}
|
108
|
+
},
|
109
109
|
)
|
110
110
|
|
111
111
|
result.should be_success
|
@@ -116,7 +116,7 @@ describe Braintree::PayPalAccount do
|
|
116
116
|
it "throws an error if customer id is not specified" do
|
117
117
|
result = Braintree::PayPalAccount.create(
|
118
118
|
:billing_agreement_id => "some_billing_agreement_id",
|
119
|
-
:email => "some@example.com"
|
119
|
+
:email => "some@example.com",
|
120
120
|
)
|
121
121
|
|
122
122
|
result.success?.should == false
|
@@ -127,7 +127,7 @@ describe Braintree::PayPalAccount do
|
|
127
127
|
customer = Braintree::Customer.create!
|
128
128
|
result = Braintree::PayPalAccount.create(
|
129
129
|
:customer_id => customer.id,
|
130
|
-
:email => "some@example.com"
|
130
|
+
:email => "some@example.com",
|
131
131
|
)
|
132
132
|
|
133
133
|
result.success?.should == false
|
@@ -141,14 +141,14 @@ describe Braintree::PayPalAccount do
|
|
141
141
|
create_result = Braintree::PayPalAccount.create(
|
142
142
|
:customer_id => customer.id,
|
143
143
|
:billing_agreement_id => "first_billing_agreement_id",
|
144
|
-
:email => "first@example.com"
|
144
|
+
:email => "first@example.com",
|
145
145
|
)
|
146
146
|
create_result.success?.should == true
|
147
147
|
|
148
148
|
update_result = Braintree::PayPalAccount.update(
|
149
149
|
create_result.paypal_account.token,
|
150
150
|
:billing_agreement_id => "second_billing_agreement_id",
|
151
|
-
:email => "second@example.com"
|
151
|
+
:email => "second@example.com",
|
152
152
|
)
|
153
153
|
|
154
154
|
update_result.success?.should == true
|
@@ -163,17 +163,17 @@ describe Braintree::PayPalAccount do
|
|
163
163
|
original_token = random_payment_method_token
|
164
164
|
nonce = nonce_for_paypal_account(
|
165
165
|
:consent_code => "consent-code",
|
166
|
-
:token => original_token
|
166
|
+
:token => original_token,
|
167
167
|
)
|
168
168
|
original_result = Braintree::PaymentMethod.create(
|
169
169
|
:payment_method_nonce => nonce,
|
170
|
-
:customer_id => customer.id
|
170
|
+
:customer_id => customer.id,
|
171
171
|
)
|
172
172
|
|
173
173
|
updated_token = "UPDATED_TOKEN-" + rand(36**3).to_s(36)
|
174
174
|
updated_result = Braintree::PayPalAccount.update(
|
175
175
|
original_token,
|
176
|
-
:token => updated_token
|
176
|
+
:token => updated_token,
|
177
177
|
)
|
178
178
|
|
179
179
|
updated_paypal_account = Braintree::PayPalAccount.find(updated_token)
|
@@ -190,19 +190,19 @@ describe Braintree::PayPalAccount do
|
|
190
190
|
:customer_id => customer.id,
|
191
191
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
192
192
|
:expiration_date => "05/2009",
|
193
|
-
:options => {:make_default => true}
|
193
|
+
:options => {:make_default => true},
|
194
194
|
)
|
195
195
|
result.should be_success
|
196
196
|
|
197
197
|
nonce = nonce_for_paypal_account(:consent_code => "consent-code")
|
198
198
|
original_token = Braintree::PaymentMethod.create(
|
199
199
|
:payment_method_nonce => nonce,
|
200
|
-
:customer_id => customer.id
|
200
|
+
:customer_id => customer.id,
|
201
201
|
).payment_method.token
|
202
202
|
|
203
203
|
updated_result = Braintree::PayPalAccount.update(
|
204
204
|
original_token,
|
205
|
-
:options => {:make_default => true}
|
205
|
+
:options => {:make_default => true},
|
206
206
|
)
|
207
207
|
|
208
208
|
updated_paypal_account = Braintree::PayPalAccount.find(original_token)
|
@@ -216,25 +216,25 @@ describe Braintree::PayPalAccount do
|
|
216
216
|
|
217
217
|
first_nonce = nonce_for_paypal_account(
|
218
218
|
:consent_code => "consent-code",
|
219
|
-
:token => first_token
|
219
|
+
:token => first_token,
|
220
220
|
)
|
221
221
|
first_result = Braintree::PaymentMethod.create(
|
222
222
|
:payment_method_nonce => first_nonce,
|
223
|
-
:customer_id => customer.id
|
223
|
+
:customer_id => customer.id,
|
224
224
|
)
|
225
225
|
|
226
226
|
second_nonce = nonce_for_paypal_account(
|
227
227
|
:consent_code => "consent-code",
|
228
|
-
:token => second_token
|
228
|
+
:token => second_token,
|
229
229
|
)
|
230
230
|
second_result = Braintree::PaymentMethod.create(
|
231
231
|
:payment_method_nonce => second_nonce,
|
232
|
-
:customer_id => customer.id
|
232
|
+
:customer_id => customer.id,
|
233
233
|
)
|
234
234
|
|
235
235
|
updated_result = Braintree::PayPalAccount.update(
|
236
236
|
first_token,
|
237
|
-
:token => second_token
|
237
|
+
:token => second_token,
|
238
238
|
)
|
239
239
|
|
240
240
|
updated_result.should_not be_success
|
@@ -249,11 +249,11 @@ describe Braintree::PayPalAccount do
|
|
249
249
|
|
250
250
|
nonce = nonce_for_paypal_account(
|
251
251
|
:consent_code => "consent-code",
|
252
|
-
:token => token
|
252
|
+
:token => token,
|
253
253
|
)
|
254
254
|
Braintree::PaymentMethod.create(
|
255
255
|
:payment_method_nonce => nonce,
|
256
|
-
:customer_id => customer.id
|
256
|
+
:customer_id => customer.id,
|
257
257
|
)
|
258
258
|
|
259
259
|
result = Braintree::PayPalAccount.delete(token)
|
@@ -267,7 +267,7 @@ describe Braintree::PayPalAccount do
|
|
267
267
|
context "self.sale" do
|
268
268
|
it "creates a transaction using a paypal account and returns a result object" do
|
269
269
|
customer = Braintree::Customer.create!(
|
270
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
|
270
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
271
271
|
)
|
272
272
|
|
273
273
|
result = Braintree::PayPalAccount.sale(customer.paypal_accounts[0].token, :amount => "100.00")
|
@@ -283,7 +283,7 @@ describe Braintree::PayPalAccount do
|
|
283
283
|
context "self.sale!" do
|
284
284
|
it "creates a transaction using a paypal account and returns a transaction" do
|
285
285
|
customer = Braintree::Customer.create!(
|
286
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
|
286
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
287
287
|
)
|
288
288
|
|
289
289
|
transaction = Braintree::PayPalAccount.sale!(customer.paypal_accounts[0].token, :amount => "100.00")
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
2
3
|
|
3
4
|
describe Braintree::Plan do
|
4
5
|
|
@@ -48,6 +49,87 @@ describe Braintree::Plan do
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
52
|
+
describe "self.create" do
|
53
|
+
let(:attributes) do
|
54
|
+
{
|
55
|
+
:billing_day_of_month => 12,
|
56
|
+
:billing_frequency => 1,
|
57
|
+
:currency_iso_code => "USD",
|
58
|
+
:description => "description on create",
|
59
|
+
:name => "my new plan name",
|
60
|
+
:number_of_billing_cycles => 1,
|
61
|
+
:price => "9.99",
|
62
|
+
:trial_period => false
|
63
|
+
}
|
64
|
+
|
65
|
+
it "is successful with given params" do
|
66
|
+
result = Braintree::Plan.create(attributes)
|
67
|
+
expect(result.success?).to be_truthy
|
68
|
+
expect(result.plan.billing_day_of_month).to eq 12
|
69
|
+
expect(result.plan.description).to eq "description on create"
|
70
|
+
expect(result.plan.name).to eq "my new plan name"
|
71
|
+
expect(result.plan.price).to eq "9.99"
|
72
|
+
expect(result.plan.billing_frequency).to eq 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "self.find" do
|
78
|
+
it "finds a plan" do
|
79
|
+
plan = Braintree::Plan.create(
|
80
|
+
:billing_day_of_month => 12,
|
81
|
+
:billing_frequency => 1,
|
82
|
+
:currency_iso_code => "USD",
|
83
|
+
:description => "description on create",
|
84
|
+
:name => "my new plan name",
|
85
|
+
:number_of_billing_cycles => 1,
|
86
|
+
:price => "9.99",
|
87
|
+
:trial_period => false,
|
88
|
+
).plan
|
89
|
+
|
90
|
+
found_plan = Braintree::Plan.find(plan.id)
|
91
|
+
expect(found_plan.name).to eq plan.name
|
92
|
+
end
|
93
|
+
|
94
|
+
it "raises Braintree::NotFoundError if it cannot find" do
|
95
|
+
expect {
|
96
|
+
Braintree::Plan.find("noSuchPlan")
|
97
|
+
}.to raise_error(Braintree::NotFoundError, 'plan with id "noSuchPlan" not found')
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "self.update!" do
|
102
|
+
before(:each) do
|
103
|
+
@plan = Braintree::Plan.create(
|
104
|
+
:billing_day_of_month => 12,
|
105
|
+
:billing_frequency => 1,
|
106
|
+
:currency_iso_code => "USD",
|
107
|
+
:description => "description on create",
|
108
|
+
:name => "my new plan name",
|
109
|
+
:number_of_billing_cycles => 1,
|
110
|
+
:price => "9.99",
|
111
|
+
:trial_period => false,
|
112
|
+
).plan
|
113
|
+
end
|
114
|
+
|
115
|
+
it "returns the updated plan if valid" do
|
116
|
+
new_id = rand(36**9).to_s(36)
|
117
|
+
plan = Braintree::Plan.update!(@plan.id,
|
118
|
+
:name => "updated name",
|
119
|
+
:price => 99.88,
|
120
|
+
)
|
121
|
+
|
122
|
+
expect(plan.name).to eq "updated name"
|
123
|
+
expect(plan.price).to eq BigDecimal("99.88")
|
124
|
+
end
|
125
|
+
|
126
|
+
it "raises a ValidationsFailed if invalid" do
|
127
|
+
expect do
|
128
|
+
Braintree::Plan.update!(@plan.id, :number_of_billing_cycles => "number of billing cycles")
|
129
|
+
end.to raise_error(Braintree::ValidationsFailed)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
51
133
|
def create_plan_for_tests(attributes)
|
52
134
|
config = Braintree::Configuration.gateway.config
|
53
135
|
config.http.post("#{config.base_merchant_path}/plans/create_plan_for_tests", :plan => attributes)
|
@@ -8,7 +8,7 @@ describe Braintree::SamsungPayCard do
|
|
8
8
|
result = Braintree::PaymentMethod.create(
|
9
9
|
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
10
10
|
:customer_id => customer.id,
|
11
|
-
:cardholder_name =>
|
11
|
+
:cardholder_name => "Jenny Block",
|
12
12
|
:billing_address => {
|
13
13
|
:first_name => "New First Name",
|
14
14
|
:last_name => "New Last Name",
|
@@ -19,7 +19,7 @@ describe Braintree::SamsungPayCard do
|
|
19
19
|
:region => "New State",
|
20
20
|
:postal_code => "56789",
|
21
21
|
:country_name => "United States of America"
|
22
|
-
}
|
22
|
+
},
|
23
23
|
)
|
24
24
|
result.should be_success
|
25
25
|
|
@@ -65,7 +65,7 @@ describe Braintree::SamsungPayCard do
|
|
65
65
|
result = Braintree::PaymentMethod.create(
|
66
66
|
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
67
67
|
:customer_id => customer.id,
|
68
|
-
:cardholder_name =>
|
68
|
+
:cardholder_name => "Jenny Block",
|
69
69
|
:billing_address => {
|
70
70
|
:first_name => "New First Name",
|
71
71
|
:last_name => "New Last Name",
|
@@ -76,11 +76,11 @@ describe Braintree::SamsungPayCard do
|
|
76
76
|
:region => "New State",
|
77
77
|
:postal_code => "56789",
|
78
78
|
:country_name => "United States of America"
|
79
|
-
}
|
79
|
+
},
|
80
80
|
)
|
81
81
|
|
82
82
|
result.should be_success
|
83
|
-
result.payment_method.cardholder_name.should ==
|
83
|
+
result.payment_method.cardholder_name.should == "Jenny Block"
|
84
84
|
|
85
85
|
address = result.payment_method.billing_address
|
86
86
|
address.first_name.should == "New First Name"
|
@@ -96,7 +96,7 @@ describe Braintree::SamsungPayCard do
|
|
96
96
|
it "can search for transactions" do
|
97
97
|
transaction_create_result = Braintree::Transaction.sale(
|
98
98
|
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
99
|
-
:amount =>
|
99
|
+
:amount => "47.00",
|
100
100
|
)
|
101
101
|
transaction_create_result.should be_success
|
102
102
|
transaction_id = transaction_create_result.transaction.id
|
@@ -114,8 +114,8 @@ describe Braintree::SamsungPayCard do
|
|
114
114
|
result = Braintree::Transaction.sale(
|
115
115
|
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
116
116
|
:customer_id => customer.id,
|
117
|
-
:amount =>
|
118
|
-
:options => {
|
117
|
+
:amount => "47.00",
|
118
|
+
:options => {:store_in_vault => true},
|
119
119
|
)
|
120
120
|
result.should be_success
|
121
121
|
|
@@ -138,7 +138,7 @@ describe Braintree::SamsungPayCard do
|
|
138
138
|
samsung_pay_card_details.prepaid.should_not be_nil
|
139
139
|
samsung_pay_card_details.product_id.should_not be_nil
|
140
140
|
samsung_pay_card_details.source_card_last_4.should_not be_nil
|
141
|
-
samsung_pay_card_details.source_card_last_4.should ==
|
141
|
+
samsung_pay_card_details.source_card_last_4.should == "3333"
|
142
142
|
samsung_pay_card_details.token.should_not be_nil
|
143
143
|
end
|
144
144
|
end
|
@@ -12,7 +12,7 @@ describe Braintree::SettlementBatchSummary do
|
|
12
12
|
it "returns an error response if the date cannot be parsed" do
|
13
13
|
result = Braintree::SettlementBatchSummary.generate("NOT A DATE :(")
|
14
14
|
result.should_not be_success
|
15
|
-
result.errors.for(:settlement_batch_summary).on(:settlement_date).map {|e| e.code}.should include(Braintree::ErrorCodes::SettlementBatchSummary::SettlementDateIsInvalid)
|
15
|
+
result.errors.for(:settlement_batch_summary).on(:settlement_date).map { |e| e.code }.should include(Braintree::ErrorCodes::SettlementBatchSummary::SettlementDateIsInvalid)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "returns transactions settled on a given day" do
|
@@ -23,14 +23,14 @@ describe Braintree::SettlementBatchSummary do
|
|
23
23
|
:expiration_date => "05/2012",
|
24
24
|
:cardholder_name => "Sergio Ramos"
|
25
25
|
},
|
26
|
-
:options => {
|
26
|
+
:options => {:submit_for_settlement => true},
|
27
27
|
)
|
28
28
|
result = SpecHelper.settle_transaction transaction.id
|
29
|
-
settlement_date = result[:transaction][:settlement_batch_id].split(
|
29
|
+
settlement_date = result[:transaction][:settlement_batch_id].split("_").first
|
30
30
|
result = Braintree::SettlementBatchSummary.generate(settlement_date)
|
31
31
|
|
32
32
|
result.should be_success
|
33
|
-
amex_records = result.settlement_batch_summary.records.select {|row| row[:card_type] == Braintree::CreditCard::CardType::AmEx }
|
33
|
+
amex_records = result.settlement_batch_summary.records.select { |row| row[:card_type] == Braintree::CreditCard::CardType::AmEx }
|
34
34
|
amex_records.first[:count].to_i.should >= 1
|
35
35
|
amex_records.first[:amount_settled].to_i.should >= Braintree::Test::TransactionAmounts::Authorize.to_i
|
36
36
|
end
|
@@ -46,14 +46,14 @@ describe Braintree::SettlementBatchSummary do
|
|
46
46
|
:custom_fields => {
|
47
47
|
:store_me => "1"
|
48
48
|
},
|
49
|
-
:options => {
|
49
|
+
:options => {:submit_for_settlement => true},
|
50
50
|
)
|
51
51
|
result = SpecHelper.settle_transaction transaction.id
|
52
|
-
settlement_date = result[:transaction][:settlement_batch_id].split(
|
53
|
-
result = Braintree::SettlementBatchSummary.generate(settlement_date,
|
52
|
+
settlement_date = result[:transaction][:settlement_batch_id].split("_").first
|
53
|
+
result = Braintree::SettlementBatchSummary.generate(settlement_date, "store_me")
|
54
54
|
|
55
55
|
result.should be_success
|
56
|
-
amex_records = result.settlement_batch_summary.records.select {|row| row[:store_me] == "1" }
|
56
|
+
amex_records = result.settlement_batch_summary.records.select { |row| row[:store_me] == "1" }
|
57
57
|
amex_records.should_not be_empty
|
58
58
|
amex_records.first[:count].to_i.should >= 1
|
59
59
|
amex_records.first[:amount_settled].to_i.should >= Braintree::Test::TransactionAmounts::Authorize.to_i
|