braintree 4.14.0 → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/braintree/credit_card.rb +13 -0
- data/lib/braintree/credit_card_gateway.rb +15 -3
- data/lib/braintree/payment_method_gateway.rb +15 -3
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +3 -0
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction.rb +5 -4
- data/lib/braintree/transaction_gateway.rb +15 -3
- data/lib/braintree/transaction_search.rb +6 -5
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +17 -0
- 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/credit_card_spec.rb +223 -223
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +313 -313
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- 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/payment_method_nonce_spec.rb +73 -73
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -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 +6 -6
- data/spec/integration/braintree/transaction_search_spec.rb +198 -165
- data/spec/integration/braintree/transaction_spec.rb +1315 -1149
- 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 +28 -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 +2 -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 +8 -8
- 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/modification_spec.rb +1 -1
- 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 +9 -6
- 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 +7 -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 +5 -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 +3 -2
|
@@ -23,22 +23,22 @@ describe Braintree::PaymentMethod do
|
|
|
23
23
|
},
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
-
result.
|
|
26
|
+
expect(result).to be_success
|
|
27
27
|
us_bank_account = result.payment_method
|
|
28
|
-
us_bank_account.
|
|
29
|
-
us_bank_account.routing_number.
|
|
30
|
-
us_bank_account.last_4.
|
|
31
|
-
us_bank_account.account_type.
|
|
32
|
-
us_bank_account.account_holder_name.
|
|
33
|
-
us_bank_account.bank_name.
|
|
34
|
-
us_bank_account.default.
|
|
35
|
-
us_bank_account.ach_mandate.text.
|
|
36
|
-
us_bank_account.ach_mandate.accepted_at.
|
|
37
|
-
|
|
38
|
-
us_bank_account.verifications.count.
|
|
39
|
-
us_bank_account.verified.
|
|
40
|
-
|
|
41
|
-
Braintree::PaymentMethod.find(us_bank_account.token).
|
|
28
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
|
29
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
|
30
|
+
expect(us_bank_account.last_4).to eq("0000")
|
|
31
|
+
expect(us_bank_account.account_type).to eq("checking")
|
|
32
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
|
33
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
|
34
|
+
expect(us_bank_account.default).to eq(true)
|
|
35
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
|
36
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
37
|
+
|
|
38
|
+
expect(us_bank_account.verifications.count).to eq(0)
|
|
39
|
+
expect(us_bank_account.verified).to eq(false)
|
|
40
|
+
|
|
41
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
[
|
|
@@ -56,26 +56,26 @@ describe Braintree::PaymentMethod do
|
|
|
56
56
|
},
|
|
57
57
|
)
|
|
58
58
|
|
|
59
|
-
result.
|
|
59
|
+
expect(result).to be_success
|
|
60
60
|
us_bank_account = result.payment_method
|
|
61
|
-
us_bank_account.
|
|
62
|
-
us_bank_account.routing_number.
|
|
63
|
-
us_bank_account.last_4.
|
|
64
|
-
us_bank_account.account_type.
|
|
65
|
-
us_bank_account.account_holder_name.
|
|
66
|
-
us_bank_account.bank_name.
|
|
67
|
-
us_bank_account.default.
|
|
68
|
-
us_bank_account.ach_mandate.text.
|
|
69
|
-
us_bank_account.ach_mandate.accepted_at.
|
|
70
|
-
|
|
71
|
-
us_bank_account.verifications.count.
|
|
72
|
-
us_bank_account.verifications.first.status.
|
|
73
|
-
us_bank_account.verifications.first.verification_method.
|
|
74
|
-
us_bank_account.verifications.first.id.
|
|
75
|
-
us_bank_account.verifications.first.verification_determined_at.
|
|
76
|
-
us_bank_account.verified.
|
|
77
|
-
|
|
78
|
-
Braintree::PaymentMethod.find(us_bank_account.token).
|
|
61
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
|
62
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
|
63
|
+
expect(us_bank_account.last_4).to eq("0000")
|
|
64
|
+
expect(us_bank_account.account_type).to eq("checking")
|
|
65
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
|
66
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
|
67
|
+
expect(us_bank_account.default).to eq(true)
|
|
68
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
|
69
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
70
|
+
|
|
71
|
+
expect(us_bank_account.verifications.count).to eq(1)
|
|
72
|
+
expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
|
73
|
+
expect(us_bank_account.verifications.first.verification_method).to eq(method)
|
|
74
|
+
expect(us_bank_account.verifications.first.id).not_to be_empty
|
|
75
|
+
expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
|
|
76
|
+
expect(us_bank_account.verified).to eq(true)
|
|
77
|
+
|
|
78
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
end
|
|
@@ -87,8 +87,8 @@ describe Braintree::PaymentMethod do
|
|
|
87
87
|
:customer_id => customer.id,
|
|
88
88
|
)
|
|
89
89
|
|
|
90
|
-
result.
|
|
91
|
-
result.errors.for(:payment_method).on(:payment_method_nonce)[0].code.
|
|
90
|
+
expect(result).not_to be_success
|
|
91
|
+
expect(result.errors.for(:payment_method).on(:payment_method_nonce)[0].code).to eq(Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
@@ -100,8 +100,8 @@ describe Braintree::PaymentMethod do
|
|
|
100
100
|
:customer_id => customer.id,
|
|
101
101
|
)
|
|
102
102
|
|
|
103
|
-
result.
|
|
104
|
-
result.errors.for(:payment_method).on(:payment_method_nonce)[0].code.
|
|
103
|
+
expect(result).not_to be_success
|
|
104
|
+
expect(result.errors.for(:payment_method).on(:payment_method_nonce)[0].code).to eq(Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown)
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
end
|
|
@@ -139,27 +139,27 @@ describe Braintree::PaymentMethod do
|
|
|
139
139
|
},
|
|
140
140
|
)
|
|
141
141
|
|
|
142
|
-
result.
|
|
142
|
+
expect(result).to be_success
|
|
143
143
|
|
|
144
144
|
us_bank_account = result.payment_method
|
|
145
|
-
us_bank_account.
|
|
146
|
-
us_bank_account.routing_number.
|
|
147
|
-
us_bank_account.last_4.
|
|
148
|
-
us_bank_account.account_type.
|
|
149
|
-
us_bank_account.account_holder_name.
|
|
150
|
-
us_bank_account.bank_name.
|
|
151
|
-
us_bank_account.default.
|
|
152
|
-
us_bank_account.ach_mandate.text.
|
|
153
|
-
us_bank_account.ach_mandate.accepted_at.
|
|
154
|
-
|
|
155
|
-
us_bank_account.verifications.count.
|
|
156
|
-
us_bank_account.verifications.first.status.
|
|
157
|
-
us_bank_account.verifications.first.verification_method.
|
|
158
|
-
us_bank_account.verifications.first.id.
|
|
159
|
-
us_bank_account.verifications.first.verification_determined_at.
|
|
160
|
-
us_bank_account.verified.
|
|
161
|
-
|
|
162
|
-
Braintree::PaymentMethod.find(us_bank_account.token).
|
|
145
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
|
146
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
|
147
|
+
expect(us_bank_account.last_4).to eq("0000")
|
|
148
|
+
expect(us_bank_account.account_type).to eq("checking")
|
|
149
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
|
150
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
|
151
|
+
expect(us_bank_account.default).to eq(true)
|
|
152
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
|
153
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
154
|
+
|
|
155
|
+
expect(us_bank_account.verifications.count).to eq(1)
|
|
156
|
+
expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
|
157
|
+
expect(us_bank_account.verifications.first.verification_method).to eq(method)
|
|
158
|
+
expect(us_bank_account.verifications.first.id).not_to be_empty
|
|
159
|
+
expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
|
|
160
|
+
expect(us_bank_account.verified).to eq(true)
|
|
161
|
+
|
|
162
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
|
163
163
|
end
|
|
164
164
|
end
|
|
165
165
|
|
|
@@ -172,8 +172,8 @@ describe Braintree::PaymentMethod do
|
|
|
172
172
|
},
|
|
173
173
|
)
|
|
174
174
|
|
|
175
|
-
result.
|
|
176
|
-
result.errors.for(:options).first.code.
|
|
175
|
+
expect(result).not_to be_success
|
|
176
|
+
expect(result.errors.for(:options).first.code).to eq(Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid)
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
179
|
end
|
|
@@ -210,29 +210,29 @@ describe Braintree::PaymentMethod do
|
|
|
210
210
|
},
|
|
211
211
|
)
|
|
212
212
|
|
|
213
|
-
result.
|
|
213
|
+
expect(result).to be_success
|
|
214
214
|
|
|
215
215
|
us_bank_account = result.payment_method
|
|
216
|
-
us_bank_account.
|
|
217
|
-
us_bank_account.routing_number.
|
|
218
|
-
us_bank_account.last_4.
|
|
219
|
-
us_bank_account.account_type.
|
|
220
|
-
us_bank_account.account_holder_name.
|
|
221
|
-
us_bank_account.bank_name.
|
|
222
|
-
us_bank_account.default.
|
|
223
|
-
us_bank_account.ach_mandate.text.
|
|
224
|
-
us_bank_account.ach_mandate.accepted_at.
|
|
225
|
-
|
|
226
|
-
us_bank_account.verifications.count.
|
|
216
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
|
217
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
|
218
|
+
expect(us_bank_account.last_4).to eq("0000")
|
|
219
|
+
expect(us_bank_account.account_type).to eq("checking")
|
|
220
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
|
221
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
|
222
|
+
expect(us_bank_account.default).to eq(true)
|
|
223
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
|
224
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
225
|
+
|
|
226
|
+
expect(us_bank_account.verifications.count).to eq(2)
|
|
227
227
|
verification = us_bank_account.verifications.find do |verification|
|
|
228
228
|
verification.verification_method == method
|
|
229
229
|
end
|
|
230
|
-
verification.status.
|
|
231
|
-
verification.id.
|
|
232
|
-
verification.verification_determined_at.
|
|
233
|
-
us_bank_account.verified.
|
|
230
|
+
expect(verification.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
|
231
|
+
expect(verification.id).not_to be_empty
|
|
232
|
+
expect(verification.verification_determined_at).to be_a Time
|
|
233
|
+
expect(us_bank_account.verified).to eq(true)
|
|
234
234
|
|
|
235
|
-
Braintree::PaymentMethod.find(us_bank_account.token).
|
|
235
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
|
236
236
|
end
|
|
237
237
|
end
|
|
238
238
|
|
|
@@ -244,8 +244,8 @@ describe Braintree::PaymentMethod do
|
|
|
244
244
|
},
|
|
245
245
|
)
|
|
246
246
|
|
|
247
|
-
result.
|
|
248
|
-
result.errors.for(:options).first.code.
|
|
247
|
+
expect(result).not_to be_success
|
|
248
|
+
expect(result.errors.for(:options).first.code).to eq(Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid)
|
|
249
249
|
end
|
|
250
250
|
end
|
|
251
251
|
end
|
|
@@ -15,17 +15,17 @@ describe Braintree::PayPalAccount do
|
|
|
15
15
|
:payment_method_nonce => nonce,
|
|
16
16
|
:customer_id => customer.id,
|
|
17
17
|
)
|
|
18
|
-
result.
|
|
18
|
+
expect(result).to be_success
|
|
19
19
|
|
|
20
20
|
paypal_account = Braintree::PayPalAccount.find(payment_method_token)
|
|
21
|
-
paypal_account.
|
|
22
|
-
paypal_account.token.
|
|
23
|
-
paypal_account.email.
|
|
24
|
-
paypal_account.image_url.
|
|
25
|
-
paypal_account.created_at.
|
|
26
|
-
paypal_account.updated_at.
|
|
27
|
-
paypal_account.customer_id.
|
|
28
|
-
paypal_account.revoked_at.
|
|
21
|
+
expect(paypal_account).to be_a(Braintree::PayPalAccount)
|
|
22
|
+
expect(paypal_account.token).to eq(payment_method_token)
|
|
23
|
+
expect(paypal_account.email).to eq("jane.doe@example.com")
|
|
24
|
+
expect(paypal_account.image_url).not_to be_nil
|
|
25
|
+
expect(paypal_account.created_at).not_to be_nil
|
|
26
|
+
expect(paypal_account.updated_at).not_to be_nil
|
|
27
|
+
expect(paypal_account.customer_id).to eq(customer.id)
|
|
28
|
+
expect(paypal_account.revoked_at).to be_nil
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "returns a PayPalAccount with a billing agreement id" do
|
|
@@ -37,10 +37,10 @@ describe Braintree::PayPalAccount do
|
|
|
37
37
|
:customer_id => customer.id,
|
|
38
38
|
:token => payment_method_token,
|
|
39
39
|
)
|
|
40
|
-
result.
|
|
40
|
+
expect(result).to be_success
|
|
41
41
|
|
|
42
42
|
paypal_account = Braintree::PayPalAccount.find(payment_method_token)
|
|
43
|
-
paypal_account.billing_agreement_id.
|
|
43
|
+
expect(paypal_account.billing_agreement_id).not_to be_nil
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "raises if the payment method token is not found" do
|
|
@@ -76,7 +76,7 @@ describe Braintree::PayPalAccount do
|
|
|
76
76
|
:payment_method_nonce => nonce,
|
|
77
77
|
:customer_id => customer.id,
|
|
78
78
|
)
|
|
79
|
-
result.
|
|
79
|
+
expect(result).to be_success
|
|
80
80
|
|
|
81
81
|
token = result.payment_method.token
|
|
82
82
|
|
|
@@ -91,7 +91,7 @@ describe Braintree::PayPalAccount do
|
|
|
91
91
|
).subscription
|
|
92
92
|
|
|
93
93
|
paypal_account = Braintree::PayPalAccount.find(token)
|
|
94
|
-
paypal_account.subscriptions.map(&:id).sort.
|
|
94
|
+
expect(paypal_account.subscriptions.map(&:id).sort).to eq([subscription1.id, subscription2.id].sort)
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
|
|
@@ -108,9 +108,9 @@ describe Braintree::PayPalAccount do
|
|
|
108
108
|
},
|
|
109
109
|
)
|
|
110
110
|
|
|
111
|
-
result.
|
|
112
|
-
result.paypal_account.billing_agreement_id.
|
|
113
|
-
result.paypal_account.email.
|
|
111
|
+
expect(result).to be_success
|
|
112
|
+
expect(result.paypal_account.billing_agreement_id).to eq("some_billing_agreement_id")
|
|
113
|
+
expect(result.paypal_account.email).to eq("some@example.com")
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
it "throws an error if customer id is not specified" do
|
|
@@ -119,8 +119,8 @@ describe Braintree::PayPalAccount do
|
|
|
119
119
|
:email => "some@example.com",
|
|
120
120
|
)
|
|
121
121
|
|
|
122
|
-
result.success
|
|
123
|
-
result.errors.first.code.
|
|
122
|
+
expect(result.success?).to eq(false)
|
|
123
|
+
expect(result.errors.first.code).to eq("82905")
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
it "throws an error if billing agreement id is not specified" do
|
|
@@ -130,8 +130,8 @@ describe Braintree::PayPalAccount do
|
|
|
130
130
|
:email => "some@example.com",
|
|
131
131
|
)
|
|
132
132
|
|
|
133
|
-
result.success
|
|
134
|
-
result.errors.map(&:code).
|
|
133
|
+
expect(result.success?).to eq(false)
|
|
134
|
+
expect(result.errors.map(&:code)).to include("82902")
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
137
|
|
|
@@ -143,7 +143,7 @@ describe Braintree::PayPalAccount do
|
|
|
143
143
|
:billing_agreement_id => "first_billing_agreement_id",
|
|
144
144
|
:email => "first@example.com",
|
|
145
145
|
)
|
|
146
|
-
create_result.success
|
|
146
|
+
expect(create_result.success?).to eq(true)
|
|
147
147
|
|
|
148
148
|
update_result = Braintree::PayPalAccount.update(
|
|
149
149
|
create_result.paypal_account.token,
|
|
@@ -151,11 +151,11 @@ describe Braintree::PayPalAccount do
|
|
|
151
151
|
:email => "second@example.com",
|
|
152
152
|
)
|
|
153
153
|
|
|
154
|
-
update_result.success
|
|
154
|
+
expect(update_result.success?).to eq(true)
|
|
155
155
|
paypal_account = update_result.paypal_account
|
|
156
156
|
|
|
157
|
-
paypal_account.billing_agreement_id.
|
|
158
|
-
paypal_account.email.
|
|
157
|
+
expect(paypal_account.billing_agreement_id).to eq("second_billing_agreement_id")
|
|
158
|
+
expect(paypal_account.email).to eq("second@example.com")
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
it "updates a paypal account's token" do
|
|
@@ -177,7 +177,7 @@ describe Braintree::PayPalAccount do
|
|
|
177
177
|
)
|
|
178
178
|
|
|
179
179
|
updated_paypal_account = Braintree::PayPalAccount.find(updated_token)
|
|
180
|
-
updated_paypal_account.email.
|
|
180
|
+
expect(updated_paypal_account.email).to eq(original_result.payment_method.email)
|
|
181
181
|
|
|
182
182
|
expect do
|
|
183
183
|
Braintree::PayPalAccount.find(original_token)
|
|
@@ -192,7 +192,7 @@ describe Braintree::PayPalAccount do
|
|
|
192
192
|
:expiration_date => "05/2009",
|
|
193
193
|
:options => {:make_default => true},
|
|
194
194
|
)
|
|
195
|
-
result.
|
|
195
|
+
expect(result).to be_success
|
|
196
196
|
|
|
197
197
|
nonce = nonce_for_paypal_account(:consent_code => "consent-code")
|
|
198
198
|
original_token = Braintree::PaymentMethod.create(
|
|
@@ -206,7 +206,7 @@ describe Braintree::PayPalAccount do
|
|
|
206
206
|
)
|
|
207
207
|
|
|
208
208
|
updated_paypal_account = Braintree::PayPalAccount.find(original_token)
|
|
209
|
-
updated_paypal_account.
|
|
209
|
+
expect(updated_paypal_account).to be_default
|
|
210
210
|
end
|
|
211
211
|
|
|
212
212
|
it "returns an error if a token for account is used to attempt an update" do
|
|
@@ -237,8 +237,8 @@ describe Braintree::PayPalAccount do
|
|
|
237
237
|
:token => second_token,
|
|
238
238
|
)
|
|
239
239
|
|
|
240
|
-
updated_result.
|
|
241
|
-
updated_result.errors.first.code.
|
|
240
|
+
expect(updated_result).not_to be_success
|
|
241
|
+
expect(updated_result.errors.first.code).to eq("92906")
|
|
242
242
|
end
|
|
243
243
|
end
|
|
244
244
|
|
|
@@ -272,11 +272,11 @@ describe Braintree::PayPalAccount do
|
|
|
272
272
|
|
|
273
273
|
result = Braintree::PayPalAccount.sale(customer.paypal_accounts[0].token, :amount => "100.00")
|
|
274
274
|
|
|
275
|
-
result.success
|
|
276
|
-
result.transaction.amount.
|
|
277
|
-
result.transaction.type.
|
|
278
|
-
result.transaction.customer_details.id.
|
|
279
|
-
result.transaction.paypal_details.token.
|
|
275
|
+
expect(result.success?).to eq(true)
|
|
276
|
+
expect(result.transaction.amount).to eq(BigDecimal("100.00"))
|
|
277
|
+
expect(result.transaction.type).to eq("sale")
|
|
278
|
+
expect(result.transaction.customer_details.id).to eq(customer.id)
|
|
279
|
+
expect(result.transaction.paypal_details.token).to eq(customer.paypal_accounts[0].token)
|
|
280
280
|
end
|
|
281
281
|
end
|
|
282
282
|
|
|
@@ -288,10 +288,10 @@ describe Braintree::PayPalAccount do
|
|
|
288
288
|
|
|
289
289
|
transaction = Braintree::PayPalAccount.sale!(customer.paypal_accounts[0].token, :amount => "100.00")
|
|
290
290
|
|
|
291
|
-
transaction.amount.
|
|
292
|
-
transaction.type.
|
|
293
|
-
transaction.customer_details.id.
|
|
294
|
-
transaction.paypal_details.token.
|
|
291
|
+
expect(transaction.amount).to eq(BigDecimal("100.00"))
|
|
292
|
+
expect(transaction.type).to eq("sale")
|
|
293
|
+
expect(transaction.customer_details.id).to eq(customer.id)
|
|
294
|
+
expect(transaction.paypal_details.token).to eq(customer.paypal_accounts[0].token)
|
|
295
295
|
end
|
|
296
296
|
end
|
|
297
297
|
end
|
|
@@ -26,26 +26,26 @@ describe Braintree::Plan do
|
|
|
26
26
|
|
|
27
27
|
plans = Braintree::Plan.all
|
|
28
28
|
plan = plans.select { |plan| plan.id == plan_token }.first
|
|
29
|
-
plan.
|
|
30
|
-
plan.id.
|
|
31
|
-
plan.billing_day_of_month.
|
|
32
|
-
plan.billing_frequency.
|
|
33
|
-
plan.currency_iso_code.
|
|
34
|
-
plan.description.
|
|
35
|
-
plan.name.
|
|
36
|
-
plan.number_of_billing_cycles.
|
|
37
|
-
plan.price.
|
|
38
|
-
plan.trial_period.
|
|
39
|
-
plan.created_at.
|
|
40
|
-
plan.updated_at.
|
|
41
|
-
plan.add_ons.first.name.
|
|
42
|
-
plan.discounts.first.name.
|
|
29
|
+
expect(plan).not_to be_nil
|
|
30
|
+
expect(plan.id).to eq(attributes[:id])
|
|
31
|
+
expect(plan.billing_day_of_month).to eq(attributes[:billing_day_of_month])
|
|
32
|
+
expect(plan.billing_frequency).to eq(attributes[:billing_frequency])
|
|
33
|
+
expect(plan.currency_iso_code).to eq(attributes[:currency_iso_code])
|
|
34
|
+
expect(plan.description).to eq(attributes[:description])
|
|
35
|
+
expect(plan.name).to eq(attributes[:name])
|
|
36
|
+
expect(plan.number_of_billing_cycles).to eq(attributes[:number_of_billing_cycles])
|
|
37
|
+
expect(plan.price).to eq(Braintree::Util.to_big_decimal("1.00"))
|
|
38
|
+
expect(plan.trial_period).to eq(attributes[:trial_period])
|
|
39
|
+
expect(plan.created_at).not_to be_nil
|
|
40
|
+
expect(plan.updated_at).not_to be_nil
|
|
41
|
+
expect(plan.add_ons.first.name).to eq(add_on_name)
|
|
42
|
+
expect(plan.discounts.first.name).to eq(discount_name)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "returns an empty array if there are no plans" do
|
|
46
46
|
gateway = Braintree::Gateway.new(SpecHelper::TestMerchantConfig)
|
|
47
47
|
plans = gateway.plan.all
|
|
48
|
-
plans.
|
|
48
|
+
expect(plans).to eq([])
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
@@ -21,42 +21,42 @@ describe Braintree::SamsungPayCard do
|
|
|
21
21
|
:country_name => "United States of America"
|
|
22
22
|
},
|
|
23
23
|
)
|
|
24
|
-
result.
|
|
24
|
+
expect(result).to be_success
|
|
25
25
|
|
|
26
26
|
samsung_pay_card = result.payment_method
|
|
27
|
-
samsung_pay_card.
|
|
28
|
-
samsung_pay_card.billing_address.
|
|
29
|
-
samsung_pay_card.bin.
|
|
30
|
-
samsung_pay_card.cardholder_name.
|
|
31
|
-
samsung_pay_card.card_type.
|
|
32
|
-
samsung_pay_card.commercial.
|
|
33
|
-
samsung_pay_card.country_of_issuance.
|
|
34
|
-
samsung_pay_card.created_at.
|
|
35
|
-
samsung_pay_card.customer_id.
|
|
36
|
-
samsung_pay_card.customer_location.
|
|
37
|
-
samsung_pay_card.debit.
|
|
38
|
-
samsung_pay_card.default
|
|
39
|
-
samsung_pay_card.durbin_regulated.
|
|
40
|
-
samsung_pay_card.expiration_date.
|
|
41
|
-
samsung_pay_card.expiration_month.
|
|
42
|
-
samsung_pay_card.expiration_year.
|
|
43
|
-
samsung_pay_card.expired
|
|
44
|
-
samsung_pay_card.healthcare.
|
|
45
|
-
samsung_pay_card.image_url.
|
|
46
|
-
samsung_pay_card.issuing_bank.
|
|
47
|
-
samsung_pay_card.last_4.
|
|
48
|
-
samsung_pay_card.payroll.
|
|
49
|
-
samsung_pay_card.prepaid.
|
|
50
|
-
samsung_pay_card.product_id.
|
|
51
|
-
samsung_pay_card.source_card_last_4.
|
|
52
|
-
samsung_pay_card.subscriptions.
|
|
53
|
-
samsung_pay_card.token.
|
|
54
|
-
samsung_pay_card.unique_number_identifier.
|
|
55
|
-
samsung_pay_card.updated_at.
|
|
27
|
+
expect(samsung_pay_card).to be_a(Braintree::SamsungPayCard)
|
|
28
|
+
expect(samsung_pay_card.billing_address).not_to be_nil
|
|
29
|
+
expect(samsung_pay_card.bin).not_to be_nil
|
|
30
|
+
expect(samsung_pay_card.cardholder_name).not_to be_nil
|
|
31
|
+
expect(samsung_pay_card.card_type).not_to be_nil
|
|
32
|
+
expect(samsung_pay_card.commercial).not_to be_nil
|
|
33
|
+
expect(samsung_pay_card.country_of_issuance).not_to be_nil
|
|
34
|
+
expect(samsung_pay_card.created_at).not_to be_nil
|
|
35
|
+
expect(samsung_pay_card.customer_id).not_to be_nil
|
|
36
|
+
expect(samsung_pay_card.customer_location).not_to be_nil
|
|
37
|
+
expect(samsung_pay_card.debit).not_to be_nil
|
|
38
|
+
expect(samsung_pay_card.default?).not_to be_nil
|
|
39
|
+
expect(samsung_pay_card.durbin_regulated).not_to be_nil
|
|
40
|
+
expect(samsung_pay_card.expiration_date).not_to be_nil
|
|
41
|
+
expect(samsung_pay_card.expiration_month).not_to be_nil
|
|
42
|
+
expect(samsung_pay_card.expiration_year).not_to be_nil
|
|
43
|
+
expect(samsung_pay_card.expired?).not_to be_nil
|
|
44
|
+
expect(samsung_pay_card.healthcare).not_to be_nil
|
|
45
|
+
expect(samsung_pay_card.image_url).not_to be_nil
|
|
46
|
+
expect(samsung_pay_card.issuing_bank).not_to be_nil
|
|
47
|
+
expect(samsung_pay_card.last_4).not_to be_nil
|
|
48
|
+
expect(samsung_pay_card.payroll).not_to be_nil
|
|
49
|
+
expect(samsung_pay_card.prepaid).not_to be_nil
|
|
50
|
+
expect(samsung_pay_card.product_id).not_to be_nil
|
|
51
|
+
expect(samsung_pay_card.source_card_last_4).not_to be_nil
|
|
52
|
+
expect(samsung_pay_card.subscriptions).not_to be_nil
|
|
53
|
+
expect(samsung_pay_card.token).not_to be_nil
|
|
54
|
+
expect(samsung_pay_card.unique_number_identifier).not_to be_nil
|
|
55
|
+
expect(samsung_pay_card.updated_at).not_to be_nil
|
|
56
56
|
|
|
57
57
|
customer = Braintree::Customer.find(customer.id)
|
|
58
|
-
customer.samsung_pay_cards.size.
|
|
59
|
-
customer.samsung_pay_cards.first.
|
|
58
|
+
expect(customer.samsung_pay_cards.size).to eq(1)
|
|
59
|
+
expect(customer.samsung_pay_cards.first).to eq(samsung_pay_card)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it "returns cardholder_name and billing_address" do
|
|
@@ -79,18 +79,18 @@ describe Braintree::SamsungPayCard do
|
|
|
79
79
|
},
|
|
80
80
|
)
|
|
81
81
|
|
|
82
|
-
result.
|
|
83
|
-
result.payment_method.cardholder_name.
|
|
82
|
+
expect(result).to be_success
|
|
83
|
+
expect(result.payment_method.cardholder_name).to eq("Jenny Block")
|
|
84
84
|
|
|
85
85
|
address = result.payment_method.billing_address
|
|
86
|
-
address.first_name.
|
|
87
|
-
address.last_name.
|
|
88
|
-
address.company.
|
|
89
|
-
address.street_address.
|
|
90
|
-
address.extended_address.
|
|
91
|
-
address.locality.
|
|
92
|
-
address.region.
|
|
93
|
-
address.postal_code.
|
|
86
|
+
expect(address.first_name).to eq("New First Name")
|
|
87
|
+
expect(address.last_name).to eq("New Last Name")
|
|
88
|
+
expect(address.company).to eq("New Company")
|
|
89
|
+
expect(address.street_address).to eq("123 New St")
|
|
90
|
+
expect(address.extended_address).to eq("Apt New")
|
|
91
|
+
expect(address.locality).to eq("New City")
|
|
92
|
+
expect(address.region).to eq("New State")
|
|
93
|
+
expect(address.postal_code).to eq("56789")
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
it "can search for transactions" do
|
|
@@ -98,14 +98,14 @@ describe Braintree::SamsungPayCard do
|
|
|
98
98
|
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
|
99
99
|
:amount => "47.00",
|
|
100
100
|
)
|
|
101
|
-
transaction_create_result.
|
|
101
|
+
expect(transaction_create_result).to be_success
|
|
102
102
|
transaction_id = transaction_create_result.transaction.id
|
|
103
103
|
|
|
104
104
|
search_results = Braintree::Transaction.search do |search|
|
|
105
105
|
search.id.is transaction_id
|
|
106
106
|
search.payment_instrument_type.is Braintree::PaymentInstrumentType::SamsungPayCard
|
|
107
107
|
end
|
|
108
|
-
search_results.first.id.
|
|
108
|
+
expect(search_results.first.id).to eq(transaction_id)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
it "can create transaction from nonce and vault" do
|
|
@@ -117,28 +117,28 @@ describe Braintree::SamsungPayCard do
|
|
|
117
117
|
:amount => "47.00",
|
|
118
118
|
:options => {:store_in_vault => true},
|
|
119
119
|
)
|
|
120
|
-
result.
|
|
120
|
+
expect(result).to be_success
|
|
121
121
|
|
|
122
122
|
samsung_pay_card_details = result.transaction.samsung_pay_card_details
|
|
123
|
-
samsung_pay_card_details.bin.
|
|
124
|
-
samsung_pay_card_details.card_type.
|
|
125
|
-
samsung_pay_card_details.commercial.
|
|
126
|
-
samsung_pay_card_details.country_of_issuance.
|
|
127
|
-
samsung_pay_card_details.customer_location.
|
|
128
|
-
samsung_pay_card_details.debit.
|
|
129
|
-
samsung_pay_card_details.durbin_regulated.
|
|
130
|
-
samsung_pay_card_details.expiration_date.
|
|
131
|
-
samsung_pay_card_details.expiration_month.
|
|
132
|
-
samsung_pay_card_details.expiration_year.
|
|
133
|
-
samsung_pay_card_details.healthcare.
|
|
134
|
-
samsung_pay_card_details.image_url.
|
|
135
|
-
samsung_pay_card_details.issuing_bank.
|
|
136
|
-
samsung_pay_card_details.last_4.
|
|
137
|
-
samsung_pay_card_details.payroll.
|
|
138
|
-
samsung_pay_card_details.prepaid.
|
|
139
|
-
samsung_pay_card_details.product_id.
|
|
140
|
-
samsung_pay_card_details.source_card_last_4.
|
|
141
|
-
samsung_pay_card_details.source_card_last_4.
|
|
142
|
-
samsung_pay_card_details.token.
|
|
123
|
+
expect(samsung_pay_card_details.bin).not_to be_nil
|
|
124
|
+
expect(samsung_pay_card_details.card_type).not_to be_nil
|
|
125
|
+
expect(samsung_pay_card_details.commercial).not_to be_nil
|
|
126
|
+
expect(samsung_pay_card_details.country_of_issuance).not_to be_nil
|
|
127
|
+
expect(samsung_pay_card_details.customer_location).not_to be_nil
|
|
128
|
+
expect(samsung_pay_card_details.debit).not_to be_nil
|
|
129
|
+
expect(samsung_pay_card_details.durbin_regulated).not_to be_nil
|
|
130
|
+
expect(samsung_pay_card_details.expiration_date).not_to be_nil
|
|
131
|
+
expect(samsung_pay_card_details.expiration_month).not_to be_nil
|
|
132
|
+
expect(samsung_pay_card_details.expiration_year).not_to be_nil
|
|
133
|
+
expect(samsung_pay_card_details.healthcare).not_to be_nil
|
|
134
|
+
expect(samsung_pay_card_details.image_url).not_to be_nil
|
|
135
|
+
expect(samsung_pay_card_details.issuing_bank).not_to be_nil
|
|
136
|
+
expect(samsung_pay_card_details.last_4).not_to be_nil
|
|
137
|
+
expect(samsung_pay_card_details.payroll).not_to be_nil
|
|
138
|
+
expect(samsung_pay_card_details.prepaid).not_to be_nil
|
|
139
|
+
expect(samsung_pay_card_details.product_id).not_to be_nil
|
|
140
|
+
expect(samsung_pay_card_details.source_card_last_4).not_to be_nil
|
|
141
|
+
expect(samsung_pay_card_details.source_card_last_4).to eq("3333")
|
|
142
|
+
expect(samsung_pay_card_details.token).not_to be_nil
|
|
143
143
|
end
|
|
144
144
|
end
|