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
@@ -35,8 +35,7 @@ describe Braintree::CreditCard do
|
|
35
35
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
36
36
|
:expiration_date => "05/2009",
|
37
37
|
:cvv => "100",
|
38
|
-
:
|
39
|
-
:fraud_merchant_id => "7"
|
38
|
+
:device_data => "device_data",
|
40
39
|
)
|
41
40
|
result.success?.should == true
|
42
41
|
end
|
@@ -47,7 +46,7 @@ describe Braintree::CreditCard do
|
|
47
46
|
:customer_id => customer.id,
|
48
47
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
49
48
|
:expiration_month => "05",
|
50
|
-
:expiration_year => "2012"
|
49
|
+
:expiration_year => "2012",
|
51
50
|
)
|
52
51
|
result.success?.should == true
|
53
52
|
credit_card = result.credit_card
|
@@ -64,7 +63,7 @@ describe Braintree::CreditCard do
|
|
64
63
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
65
64
|
:expiration_date => "05/2009",
|
66
65
|
:cvv => "100",
|
67
|
-
:token => token
|
66
|
+
:token => token,
|
68
67
|
)
|
69
68
|
result.success?.should == true
|
70
69
|
credit_card = result.credit_card
|
@@ -82,7 +81,7 @@ describe Braintree::CreditCard do
|
|
82
81
|
:customer_id => customer.id,
|
83
82
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
84
83
|
:expiration_date => "05/2009",
|
85
|
-
:billing_address_id => address.id
|
84
|
+
:billing_address_id => address.id,
|
86
85
|
).credit_card
|
87
86
|
|
88
87
|
credit_card.billing_address.id.should == address.id
|
@@ -96,7 +95,7 @@ describe Braintree::CreditCard do
|
|
96
95
|
:customer_id => customer.id,
|
97
96
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
98
97
|
:expiration_date => "05/2009",
|
99
|
-
:options => {}
|
98
|
+
:options => {},
|
100
99
|
)
|
101
100
|
result.success?.should == true
|
102
101
|
end
|
@@ -107,10 +106,10 @@ describe Braintree::CreditCard do
|
|
107
106
|
:customer_id => customer.id,
|
108
107
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
109
108
|
:expiration_date => "05/2009",
|
110
|
-
:options => {:verify_card => true}
|
109
|
+
:options => {:verify_card => true},
|
111
110
|
)
|
112
111
|
result.success?.should == false
|
113
|
-
result.credit_card_verification.status.should == Braintree::
|
112
|
+
result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined
|
114
113
|
result.credit_card_verification.processor_response_code.should == "2000"
|
115
114
|
result.credit_card_verification.processor_response_text.should == "Do Not Honor"
|
116
115
|
result.credit_card_verification.cvv_response_code.should == "I"
|
@@ -125,10 +124,10 @@ describe Braintree::CreditCard do
|
|
125
124
|
:customer_id => customer.id,
|
126
125
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
127
126
|
:expiration_date => "05/2009",
|
128
|
-
:options => {:verify_card => true, :verification_amount => "100.00"}
|
127
|
+
:options => {:verify_card => true, :verification_amount => "100.00"},
|
129
128
|
)
|
130
129
|
result.success?.should == false
|
131
|
-
result.credit_card_verification.status.should == Braintree::
|
130
|
+
result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined
|
132
131
|
result.credit_card_verification.processor_response_code.should == "2000"
|
133
132
|
result.credit_card_verification.processor_response_text.should == "Do Not Honor"
|
134
133
|
result.credit_card_verification.cvv_response_code.should == "I"
|
@@ -138,7 +137,7 @@ describe Braintree::CreditCard do
|
|
138
137
|
end
|
139
138
|
|
140
139
|
it "returns risk data on verification on credit_card create" do
|
141
|
-
|
140
|
+
with_fraud_protection_enterprise_merchant do
|
142
141
|
customer = Braintree::Customer.create!
|
143
142
|
credit_card = Braintree::CreditCard.create!(
|
144
143
|
:cardholder_name => "Original Holder",
|
@@ -146,13 +145,57 @@ describe Braintree::CreditCard do
|
|
146
145
|
:cvv => "123",
|
147
146
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
148
147
|
:expiration_date => "05/2020",
|
149
|
-
:options => {:verify_card => true}
|
148
|
+
:options => {:verify_card => true},
|
150
149
|
)
|
151
150
|
verification = credit_card.verification
|
152
|
-
verification.risk_data.
|
153
|
-
verification.risk_data.
|
154
|
-
verification.risk_data.
|
155
|
-
verification.risk_data.
|
151
|
+
verification.risk_data.id.should_not be_nil
|
152
|
+
verification.risk_data.decision.should_not be_nil
|
153
|
+
verification.risk_data.decision_reasons.should_not be_nil
|
154
|
+
expect(verification.risk_data).to respond_to(:device_data_captured)
|
155
|
+
expect(verification.risk_data).to respond_to(:fraud_service_provider)
|
156
|
+
expect(verification.risk_data).to respond_to(:transaction_risk_score)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
it "includes risk data when skip_advanced_fraud_checking is false" do
|
161
|
+
with_fraud_protection_enterprise_merchant do
|
162
|
+
customer = Braintree::Customer.create!
|
163
|
+
result = Braintree::CreditCard.create(
|
164
|
+
:cardholder_name => "Original Holder",
|
165
|
+
:customer_id => customer.id,
|
166
|
+
:cvv => "123",
|
167
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
168
|
+
:expiration_date => "05/2020",
|
169
|
+
:options => {
|
170
|
+
:skip_advanced_fraud_checking => false,
|
171
|
+
:verify_card => true,
|
172
|
+
},
|
173
|
+
)
|
174
|
+
|
175
|
+
expect(result).to be_success
|
176
|
+
verification = result.credit_card.verification
|
177
|
+
expect(verification.risk_data).not_to be_nil
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it "does not include risk data when skip_advanced_fraud_checking is true" do
|
182
|
+
with_fraud_protection_enterprise_merchant do
|
183
|
+
customer = Braintree::Customer.create!
|
184
|
+
result = Braintree::CreditCard.create(
|
185
|
+
:cardholder_name => "Original Holder",
|
186
|
+
:customer_id => customer.id,
|
187
|
+
:cvv => "123",
|
188
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
189
|
+
:expiration_date => "05/2020",
|
190
|
+
:options => {
|
191
|
+
:skip_advanced_fraud_checking => true,
|
192
|
+
:verify_card => true,
|
193
|
+
},
|
194
|
+
)
|
195
|
+
|
196
|
+
expect(result).to be_success
|
197
|
+
verification = result.credit_card.verification
|
198
|
+
expect(verification.risk_data).to be_nil
|
156
199
|
end
|
157
200
|
end
|
158
201
|
|
@@ -172,10 +215,10 @@ describe Braintree::CreditCard do
|
|
172
215
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
173
216
|
:expiration_date => "05/2009",
|
174
217
|
:cvv => "200",
|
175
|
-
:options => {:verify_card => true}
|
218
|
+
:options => {:verify_card => true},
|
176
219
|
)
|
177
220
|
result.success?.should == false
|
178
|
-
result.credit_card_verification.gateway_rejection_reason.should == Braintree::
|
221
|
+
result.credit_card_verification.gateway_rejection_reason.should == Braintree::CreditCardVerification::GatewayRejectionReason::CVV
|
179
222
|
ensure
|
180
223
|
Braintree::Configuration.merchant_id = old_merchant
|
181
224
|
Braintree::Configuration.public_key = old_public_key
|
@@ -189,10 +232,10 @@ describe Braintree::CreditCard do
|
|
189
232
|
:customer_id => customer.id,
|
190
233
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
191
234
|
:expiration_date => "05/2009",
|
192
|
-
:options => {:verify_card => true, :verification_amount => "1.01"}
|
235
|
+
:options => {:verify_card => true, :verification_amount => "1.01"},
|
193
236
|
)
|
194
237
|
result.success?.should == false
|
195
|
-
result.credit_card_verification.status.should == Braintree::
|
238
|
+
result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined
|
196
239
|
result.credit_card_verification.processor_response_code.should == "2000"
|
197
240
|
result.credit_card_verification.processor_response_text.should == "Do Not Honor"
|
198
241
|
result.credit_card_verification.cvv_response_code.should == "I"
|
@@ -210,7 +253,7 @@ describe Braintree::CreditCard do
|
|
210
253
|
:options => {
|
211
254
|
:verify_card => true,
|
212
255
|
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
213
|
-
}
|
256
|
+
},
|
214
257
|
)
|
215
258
|
result.success?.should == false
|
216
259
|
result.credit_card_verification.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
|
@@ -222,7 +265,7 @@ describe Braintree::CreditCard do
|
|
222
265
|
:customer_id => customer.id,
|
223
266
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
224
267
|
:expiration_date => "05/2009",
|
225
|
-
:options => {:verify_card => false}
|
268
|
+
:options => {:verify_card => false},
|
226
269
|
)
|
227
270
|
result.success?.should == true
|
228
271
|
end
|
@@ -233,15 +276,15 @@ describe Braintree::CreditCard do
|
|
233
276
|
:customer_id => customer.id,
|
234
277
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
235
278
|
:three_d_secure_pass_thru => {
|
236
|
-
:eci_flag =>
|
237
|
-
:cavv =>
|
238
|
-
:xid =>
|
239
|
-
:authentication_response =>
|
240
|
-
:directory_response =>
|
241
|
-
:cavv_algorithm =>
|
242
|
-
:ds_transaction_id =>
|
279
|
+
:eci_flag => "02",
|
280
|
+
:cavv => "some_cavv",
|
281
|
+
:xid => "some_xid",
|
282
|
+
:authentication_response => "Y",
|
283
|
+
:directory_response => "Y",
|
284
|
+
:cavv_algorithm => "2",
|
285
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
243
286
|
},
|
244
|
-
:options => {:verify_card => true}
|
287
|
+
:options => {:verify_card => true},
|
245
288
|
)
|
246
289
|
expect(result).not_to be_success
|
247
290
|
error = result.errors.for(:verification).first
|
@@ -255,16 +298,16 @@ describe Braintree::CreditCard do
|
|
255
298
|
:customer_id => customer.id,
|
256
299
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
257
300
|
:three_d_secure_pass_thru => {
|
258
|
-
:eci_flag =>
|
259
|
-
:cavv =>
|
260
|
-
:xid =>
|
261
|
-
:three_d_secure_version =>
|
262
|
-
:authentication_response =>
|
263
|
-
:directory_response =>
|
264
|
-
:cavv_algorithm =>
|
265
|
-
:ds_transaction_id =>
|
301
|
+
:eci_flag => "02",
|
302
|
+
:cavv => "some_cavv",
|
303
|
+
:xid => "some_xid",
|
304
|
+
:three_d_secure_version => "1.0.2",
|
305
|
+
:authentication_response => "Y",
|
306
|
+
:directory_response => "Y",
|
307
|
+
:cavv_algorithm => "2",
|
308
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
266
309
|
},
|
267
|
-
:options => {:verify_card => true}
|
310
|
+
:options => {:verify_card => true},
|
268
311
|
)
|
269
312
|
result.success?.should == true
|
270
313
|
|
@@ -275,7 +318,7 @@ describe Braintree::CreditCard do
|
|
275
318
|
result = Braintree::CreditCard.create(
|
276
319
|
:customer_id => customer.id,
|
277
320
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
278
|
-
:options => {:verify_card => true}
|
321
|
+
:options => {:verify_card => true},
|
279
322
|
)
|
280
323
|
result.success?.should == true
|
281
324
|
|
@@ -303,7 +346,7 @@ describe Braintree::CreditCard do
|
|
303
346
|
:locality => "Chicago",
|
304
347
|
:region => "Illinois",
|
305
348
|
:postal_code => "60622"
|
306
|
-
}
|
349
|
+
},
|
307
350
|
)
|
308
351
|
result.success?.should == true
|
309
352
|
credit_card = result.credit_card
|
@@ -322,7 +365,7 @@ describe Braintree::CreditCard do
|
|
322
365
|
:country_code_alpha2 => "US",
|
323
366
|
:country_code_alpha3 => "USA",
|
324
367
|
:country_code_numeric => "840"
|
325
|
-
}
|
368
|
+
},
|
326
369
|
)
|
327
370
|
result.success?.should == true
|
328
371
|
credit_card = result.credit_card
|
@@ -341,7 +384,7 @@ describe Braintree::CreditCard do
|
|
341
384
|
:billing_address => {
|
342
385
|
:country_name => "Mexico",
|
343
386
|
:country_code_alpha2 => "US"
|
344
|
-
}
|
387
|
+
},
|
345
388
|
)
|
346
389
|
result.success?.should == false
|
347
390
|
result.errors.for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
|
@@ -352,7 +395,7 @@ describe Braintree::CreditCard do
|
|
352
395
|
result = Braintree::CreditCard.create(
|
353
396
|
:customer_id => customer.id,
|
354
397
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
355
|
-
:expiration_date => "invalid_date"
|
398
|
+
:expiration_date => "invalid_date",
|
356
399
|
)
|
357
400
|
result.success?.should == false
|
358
401
|
result.errors.for(:credit_card).on(:expiration_date)[0].message.should == "Expiration date is invalid."
|
@@ -363,7 +406,7 @@ describe Braintree::CreditCard do
|
|
363
406
|
card1 = Braintree::CreditCard.create(
|
364
407
|
:customer_id => customer.id,
|
365
408
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
366
|
-
:expiration_date => "05/2009"
|
409
|
+
:expiration_date => "05/2009",
|
367
410
|
).credit_card
|
368
411
|
card1.should be_default
|
369
412
|
|
@@ -373,7 +416,7 @@ describe Braintree::CreditCard do
|
|
373
416
|
:expiration_date => "05/2009",
|
374
417
|
:options => {
|
375
418
|
:make_default => true
|
376
|
-
}
|
419
|
+
},
|
377
420
|
).credit_card
|
378
421
|
card2.should be_default
|
379
422
|
|
@@ -402,7 +445,7 @@ describe Braintree::CreditCard do
|
|
402
445
|
:customer_id => customer.id,
|
403
446
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
404
447
|
:expiration_date => "05/2014",
|
405
|
-
:options => {:verify_card => true}
|
448
|
+
:options => {:verify_card => true},
|
406
449
|
)
|
407
450
|
credit_card = result.credit_card
|
408
451
|
credit_card.prepaid.should == Braintree::CreditCard::Prepaid::Yes
|
@@ -414,7 +457,7 @@ describe Braintree::CreditCard do
|
|
414
457
|
:customer_id => customer.id,
|
415
458
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Healthcare,
|
416
459
|
:expiration_date => "05/2014",
|
417
|
-
:options => {:verify_card => true}
|
460
|
+
:options => {:verify_card => true},
|
418
461
|
)
|
419
462
|
credit_card = result.credit_card
|
420
463
|
credit_card.healthcare.should == Braintree::CreditCard::Healthcare::Yes
|
@@ -427,7 +470,7 @@ describe Braintree::CreditCard do
|
|
427
470
|
:customer_id => customer.id,
|
428
471
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::DurbinRegulated,
|
429
472
|
:expiration_date => "05/2014",
|
430
|
-
:options => {:verify_card => true}
|
473
|
+
:options => {:verify_card => true},
|
431
474
|
)
|
432
475
|
credit_card = result.credit_card
|
433
476
|
credit_card.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Yes
|
@@ -439,7 +482,7 @@ describe Braintree::CreditCard do
|
|
439
482
|
:customer_id => customer.id,
|
440
483
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::CountryOfIssuance,
|
441
484
|
:expiration_date => "05/2014",
|
442
|
-
:options => {:verify_card => true}
|
485
|
+
:options => {:verify_card => true},
|
443
486
|
)
|
444
487
|
credit_card = result.credit_card
|
445
488
|
credit_card.country_of_issuance.should == Braintree::Test::CreditCardDefaults::CountryOfIssuance
|
@@ -451,7 +494,7 @@ describe Braintree::CreditCard do
|
|
451
494
|
:customer_id => customer.id,
|
452
495
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::IssuingBank,
|
453
496
|
:expiration_date => "05/2014",
|
454
|
-
:options => {:verify_card => true}
|
497
|
+
:options => {:verify_card => true},
|
455
498
|
)
|
456
499
|
credit_card = result.credit_card
|
457
500
|
credit_card.issuing_bank.should == Braintree::Test::CreditCardDefaults::IssuingBank
|
@@ -463,7 +506,7 @@ describe Braintree::CreditCard do
|
|
463
506
|
:customer_id => customer.id,
|
464
507
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Payroll,
|
465
508
|
:expiration_date => "05/2014",
|
466
|
-
:options => {:verify_card => true}
|
509
|
+
:options => {:verify_card => true},
|
467
510
|
)
|
468
511
|
credit_card = result.credit_card
|
469
512
|
credit_card.payroll.should == Braintree::CreditCard::Payroll::Yes
|
@@ -476,7 +519,7 @@ describe Braintree::CreditCard do
|
|
476
519
|
:customer_id => customer.id,
|
477
520
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Debit,
|
478
521
|
:expiration_date => "05/2014",
|
479
|
-
:options => {:verify_card => true}
|
522
|
+
:options => {:verify_card => true},
|
480
523
|
)
|
481
524
|
credit_card = result.credit_card
|
482
525
|
credit_card.debit.should == Braintree::CreditCard::Debit::Yes
|
@@ -488,7 +531,7 @@ describe Braintree::CreditCard do
|
|
488
531
|
:customer_id => customer.id,
|
489
532
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Commercial,
|
490
533
|
:expiration_date => "05/2014",
|
491
|
-
:options => {:verify_card => true}
|
534
|
+
:options => {:verify_card => true},
|
492
535
|
)
|
493
536
|
credit_card = result.credit_card
|
494
537
|
credit_card.commercial.should == Braintree::CreditCard::Commercial::Yes
|
@@ -500,7 +543,7 @@ describe Braintree::CreditCard do
|
|
500
543
|
:customer_id => customer.id,
|
501
544
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::No,
|
502
545
|
:expiration_date => "05/2014",
|
503
|
-
:options => {:verify_card => true}
|
546
|
+
:options => {:verify_card => true},
|
504
547
|
)
|
505
548
|
credit_card = result.credit_card
|
506
549
|
credit_card.prepaid.should == Braintree::CreditCard::Prepaid::No
|
@@ -518,7 +561,7 @@ describe Braintree::CreditCard do
|
|
518
561
|
:customer_id => customer.id,
|
519
562
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Unknown,
|
520
563
|
:expiration_date => "05/2014",
|
521
|
-
:options => {:verify_card => true}
|
564
|
+
:options => {:verify_card => true},
|
522
565
|
)
|
523
566
|
credit_card = result.credit_card
|
524
567
|
credit_card.prepaid.should == Braintree::CreditCard::Prepaid::Unknown
|
@@ -539,7 +582,7 @@ describe Braintree::CreditCard do
|
|
539
582
|
customer = Braintree::Customer.create!
|
540
583
|
result = Braintree::CreditCard.create(
|
541
584
|
:customer_id => customer.id,
|
542
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
|
585
|
+
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode,
|
543
586
|
)
|
544
587
|
result.success?.should == true
|
545
588
|
result.credit_card.venmo_sdk?.should == false
|
@@ -551,7 +594,7 @@ describe Braintree::CreditCard do
|
|
551
594
|
customer = Braintree::Customer.create!
|
552
595
|
result = Braintree::CreditCard.create(
|
553
596
|
:customer_id => customer.id,
|
554
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode
|
597
|
+
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode,
|
555
598
|
)
|
556
599
|
|
557
600
|
result.success?.should == false
|
@@ -570,7 +613,7 @@ describe Braintree::CreditCard do
|
|
570
613
|
:cvv => "100",
|
571
614
|
:options => {
|
572
615
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
573
|
-
}
|
616
|
+
},
|
574
617
|
)
|
575
618
|
result.success?.should == true
|
576
619
|
result.credit_card.venmo_sdk?.should == false
|
@@ -585,7 +628,7 @@ describe Braintree::CreditCard do
|
|
585
628
|
:cvv => "100",
|
586
629
|
:options => {
|
587
630
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession
|
588
|
-
}
|
631
|
+
},
|
589
632
|
)
|
590
633
|
result.success?.should == true
|
591
634
|
result.credit_card.venmo_sdk?.should == false
|
@@ -601,12 +644,12 @@ describe Braintree::CreditCard do
|
|
601
644
|
:expiration_month => "11",
|
602
645
|
:expiration_year => "2099",
|
603
646
|
},
|
604
|
-
:share => true
|
647
|
+
:share => true,
|
605
648
|
)
|
606
649
|
customer = Braintree::Customer.create!
|
607
650
|
result = Braintree::CreditCard.create(
|
608
651
|
:customer_id => customer.id,
|
609
|
-
:payment_method_nonce => nonce
|
652
|
+
:payment_method_nonce => nonce,
|
610
653
|
)
|
611
654
|
|
612
655
|
result.success?.should == true
|
@@ -643,7 +686,7 @@ describe Braintree::CreditCard do
|
|
643
686
|
:verify_card => true,
|
644
687
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
645
688
|
:verification_account_type => "debit",
|
646
|
-
}
|
689
|
+
},
|
647
690
|
)
|
648
691
|
|
649
692
|
expect(result).to be_success
|
@@ -660,7 +703,7 @@ describe Braintree::CreditCard do
|
|
660
703
|
:verify_card => true,
|
661
704
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
662
705
|
:verification_account_type => "credit",
|
663
|
-
}
|
706
|
+
},
|
664
707
|
)
|
665
708
|
|
666
709
|
expect(result).to be_success
|
@@ -676,7 +719,7 @@ describe Braintree::CreditCard do
|
|
676
719
|
:verify_card => true,
|
677
720
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
678
721
|
:verification_account_type => "ach",
|
679
|
-
}
|
722
|
+
},
|
680
723
|
)
|
681
724
|
|
682
725
|
expect(result).to_not be_success
|
@@ -692,7 +735,7 @@ describe Braintree::CreditCard do
|
|
692
735
|
:options => {
|
693
736
|
:verify_card => true,
|
694
737
|
:verification_account_type => "credit",
|
695
|
-
}
|
738
|
+
},
|
696
739
|
)
|
697
740
|
|
698
741
|
expect(result).to_not be_success
|
@@ -708,7 +751,7 @@ describe Braintree::CreditCard do
|
|
708
751
|
:customer_id => customer.id,
|
709
752
|
:cardholder_name => "Adam Davis",
|
710
753
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
711
|
-
:expiration_date => "05/2009"
|
754
|
+
:expiration_date => "05/2009",
|
712
755
|
)
|
713
756
|
credit_card.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
714
757
|
credit_card.cardholder_name.should == "Adam Davis"
|
@@ -722,7 +765,7 @@ describe Braintree::CreditCard do
|
|
722
765
|
Braintree::CreditCard.create!(
|
723
766
|
:customer_id => customer.id,
|
724
767
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
725
|
-
:expiration_date => "invalid_date"
|
768
|
+
:expiration_date => "invalid_date",
|
726
769
|
)
|
727
770
|
end.to raise_error(Braintree::ValidationsFailed)
|
728
771
|
end
|
@@ -734,11 +777,11 @@ describe Braintree::CreditCard do
|
|
734
777
|
:credit_card => {
|
735
778
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
736
779
|
:expiration_date => "05/2010"
|
737
|
-
}
|
780
|
+
},
|
738
781
|
)
|
739
782
|
result = Braintree::CreditCard.credit(
|
740
783
|
customer.credit_cards[0].token,
|
741
|
-
:amount => "100.00"
|
784
|
+
:amount => "100.00",
|
742
785
|
)
|
743
786
|
result.success?.should == true
|
744
787
|
result.transaction.amount.should == BigDecimal("100.00")
|
@@ -757,11 +800,11 @@ describe Braintree::CreditCard do
|
|
757
800
|
:credit_card => {
|
758
801
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
759
802
|
:expiration_date => "05/2010"
|
760
|
-
}
|
803
|
+
},
|
761
804
|
)
|
762
805
|
transaction = Braintree::CreditCard.credit!(
|
763
806
|
customer.credit_cards[0].token,
|
764
|
-
:amount => "100.00"
|
807
|
+
:amount => "100.00",
|
765
808
|
)
|
766
809
|
transaction.amount.should == BigDecimal("100.00")
|
767
810
|
transaction.type.should == "credit"
|
@@ -773,95 +816,6 @@ describe Braintree::CreditCard do
|
|
773
816
|
end
|
774
817
|
end
|
775
818
|
|
776
|
-
describe "self.create_from_transparent_redirect" do
|
777
|
-
it "returns a successful result if successful" do
|
778
|
-
result = Braintree::Customer.create
|
779
|
-
result.success?.should == true
|
780
|
-
customer = result.customer
|
781
|
-
params = {
|
782
|
-
:credit_card => {
|
783
|
-
:cardholder_name => "Card Holder",
|
784
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
785
|
-
:expiration_date => "05/2012"
|
786
|
-
}
|
787
|
-
}
|
788
|
-
tr_data_params = {
|
789
|
-
:credit_card => {
|
790
|
-
:customer_id => customer.id
|
791
|
-
}
|
792
|
-
}
|
793
|
-
tr_data = Braintree::TransparentRedirect.create_credit_card_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
794
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::CreditCard.create_credit_card_url)
|
795
|
-
result = Braintree::CreditCard.create_from_transparent_redirect(query_string_response)
|
796
|
-
result.success?.should == true
|
797
|
-
credit_card = result.credit_card
|
798
|
-
credit_card.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
799
|
-
credit_card.cardholder_name.should == "Card Holder"
|
800
|
-
credit_card.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
801
|
-
credit_card.expiration_month.should == "05"
|
802
|
-
credit_card.expiration_year.should == "2012"
|
803
|
-
credit_card.expiration_date.should == "05/2012"
|
804
|
-
credit_card.customer_id.should == customer.id
|
805
|
-
end
|
806
|
-
|
807
|
-
it "create card as default" do
|
808
|
-
customer = Braintree::Customer.create!(
|
809
|
-
:credit_card => {
|
810
|
-
:cardholder_name => "Old Cardholder Name",
|
811
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
812
|
-
:expiration_date => "05/2012"
|
813
|
-
}
|
814
|
-
)
|
815
|
-
card1 = customer.credit_cards[0]
|
816
|
-
|
817
|
-
params = {
|
818
|
-
:credit_card => {
|
819
|
-
:cardholder_name => "Card Holder",
|
820
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
821
|
-
:expiration_date => "05/2012",
|
822
|
-
:options => {:make_default => true}
|
823
|
-
}
|
824
|
-
}
|
825
|
-
tr_data_params = {
|
826
|
-
:credit_card => {
|
827
|
-
:customer_id => customer.id
|
828
|
-
}
|
829
|
-
}
|
830
|
-
tr_data = Braintree::TransparentRedirect.create_credit_card_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
831
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::CreditCard.create_credit_card_url)
|
832
|
-
result = Braintree::CreditCard.create_from_transparent_redirect(query_string_response)
|
833
|
-
result.success?.should == true
|
834
|
-
card2 = result.credit_card
|
835
|
-
|
836
|
-
Braintree::CreditCard.find(card1.token).should_not be_default
|
837
|
-
card2.should be_default
|
838
|
-
end
|
839
|
-
|
840
|
-
it "returns xml with nested errors if validation errors" do
|
841
|
-
customer = Braintree::Customer.create.customer
|
842
|
-
params = {
|
843
|
-
:credit_card => {
|
844
|
-
:cardholder_name => "Card Holder",
|
845
|
-
:number => "eleventy",
|
846
|
-
:expiration_date => "y2k"
|
847
|
-
}
|
848
|
-
}
|
849
|
-
tr_data_params = {
|
850
|
-
:credit_card => {
|
851
|
-
:customer_id => customer.id
|
852
|
-
}
|
853
|
-
}
|
854
|
-
tr_data = Braintree::TransparentRedirect.create_credit_card_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
855
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::CreditCard.create_credit_card_url)
|
856
|
-
result = Braintree::CreditCard.create_from_transparent_redirect(query_string_response)
|
857
|
-
result.success?.should == false
|
858
|
-
result.params[:customer_id] == customer.id
|
859
|
-
result.params[:credit_card]["cardholder_name"] == customer.id
|
860
|
-
result.params[:credit_card]["number"] == "eleventy"
|
861
|
-
result.params[:credit_card]["exipiration_date"] == "y2k"
|
862
|
-
end
|
863
|
-
end
|
864
|
-
|
865
819
|
describe "self.update" do
|
866
820
|
it "updates the credit card" do
|
867
821
|
customer = Braintree::Customer.create!
|
@@ -870,13 +824,13 @@ describe Braintree::CreditCard do
|
|
870
824
|
:customer_id => customer.id,
|
871
825
|
:cvv => "123",
|
872
826
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
873
|
-
:expiration_date => "05/2012"
|
827
|
+
:expiration_date => "05/2012",
|
874
828
|
)
|
875
829
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
876
830
|
:cardholder_name => "New Holder",
|
877
831
|
:cvv => "456",
|
878
832
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
879
|
-
:expiration_date => "06/2013"
|
833
|
+
:expiration_date => "06/2013",
|
880
834
|
)
|
881
835
|
update_result.success?.should == true
|
882
836
|
update_result.credit_card.should == credit_card
|
@@ -894,20 +848,20 @@ describe Braintree::CreditCard do
|
|
894
848
|
:customer_id => customer.id,
|
895
849
|
:cvv => "123",
|
896
850
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
897
|
-
:expiration_date => "05/2012"
|
851
|
+
:expiration_date => "05/2012",
|
898
852
|
)
|
899
853
|
result = Braintree::CreditCard.update(credit_card.token,
|
900
854
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
901
855
|
:three_d_secure_pass_thru => {
|
902
|
-
:eci_flag =>
|
903
|
-
:cavv =>
|
904
|
-
:xid =>
|
905
|
-
:authentication_response =>
|
906
|
-
:directory_response =>
|
907
|
-
:cavv_algorithm =>
|
908
|
-
:ds_transaction_id =>
|
856
|
+
:eci_flag => "02",
|
857
|
+
:cavv => "some_cavv",
|
858
|
+
:xid => "some_xid",
|
859
|
+
:authentication_response => "Y",
|
860
|
+
:directory_response => "Y",
|
861
|
+
:cavv_algorithm => "2",
|
862
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
909
863
|
},
|
910
|
-
:options => {:verify_card => true}
|
864
|
+
:options => {:verify_card => true},
|
911
865
|
)
|
912
866
|
expect(result).not_to be_success
|
913
867
|
error = result.errors.for(:verification).first
|
@@ -922,25 +876,72 @@ describe Braintree::CreditCard do
|
|
922
876
|
:customer_id => customer.id,
|
923
877
|
:cvv => "123",
|
924
878
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
925
|
-
:expiration_date => "05/2012"
|
879
|
+
:expiration_date => "05/2012",
|
926
880
|
)
|
927
881
|
result = Braintree::CreditCard.update(credit_card.token,
|
928
882
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
929
883
|
:three_d_secure_pass_thru => {
|
930
|
-
:eci_flag =>
|
931
|
-
:cavv =>
|
884
|
+
:eci_flag => "02",
|
885
|
+
:cavv => "some_cavv",
|
932
886
|
:three_d_secure_version=> "2.1.0",
|
933
|
-
:xid =>
|
934
|
-
:authentication_response =>
|
935
|
-
:directory_response =>
|
936
|
-
:cavv_algorithm =>
|
937
|
-
:ds_transaction_id =>
|
887
|
+
:xid => "some_xid",
|
888
|
+
:authentication_response => "Y",
|
889
|
+
:directory_response => "Y",
|
890
|
+
:cavv_algorithm => "2",
|
891
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
938
892
|
},
|
939
|
-
:options => {:verify_card => true}
|
893
|
+
:options => {:verify_card => true},
|
940
894
|
)
|
941
895
|
|
942
896
|
result.success?.should == true
|
897
|
+
end
|
898
|
+
|
899
|
+
it "includes risk data when skip_advanced_fraud_checking is false" do
|
900
|
+
with_fraud_protection_enterprise_merchant do
|
901
|
+
customer = Braintree::Customer.create!
|
902
|
+
credit_card = Braintree::CreditCard.create!(
|
903
|
+
:cardholder_name => "Original Holder",
|
904
|
+
:customer_id => customer.id,
|
905
|
+
:cvv => "123",
|
906
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
907
|
+
:expiration_date => "05/2020",
|
908
|
+
)
|
909
|
+
updated_result = Braintree::CreditCard.update(credit_card.token,
|
910
|
+
:expiration_date => "05/2021",
|
911
|
+
:options => {
|
912
|
+
:verify_card => true,
|
913
|
+
:skip_advanced_fraud_checking => false,
|
914
|
+
},
|
915
|
+
)
|
916
|
+
|
917
|
+
expect(updated_result).to be_success
|
918
|
+
verification = updated_result.credit_card.verification
|
919
|
+
expect(verification.risk_data).not_to be_nil
|
920
|
+
end
|
921
|
+
end
|
943
922
|
|
923
|
+
it "does not include risk data when skip_advanced_fraud_checking is true" do
|
924
|
+
with_fraud_protection_enterprise_merchant do
|
925
|
+
customer = Braintree::Customer.create!
|
926
|
+
credit_card = Braintree::CreditCard.create!(
|
927
|
+
:cardholder_name => "Original Holder",
|
928
|
+
:customer_id => customer.id,
|
929
|
+
:cvv => "123",
|
930
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
931
|
+
:expiration_date => "05/2020",
|
932
|
+
)
|
933
|
+
updated_result = Braintree::CreditCard.update(credit_card.token,
|
934
|
+
:expiration_date => "05/2021",
|
935
|
+
:options => {
|
936
|
+
:verify_card => true,
|
937
|
+
:skip_advanced_fraud_checking => true,
|
938
|
+
},
|
939
|
+
)
|
940
|
+
|
941
|
+
expect(updated_result).to be_success
|
942
|
+
verification = updated_result.credit_card.verification
|
943
|
+
expect(verification.risk_data).to be_nil
|
944
|
+
end
|
944
945
|
end
|
945
946
|
|
946
947
|
context "billing address" do
|
@@ -952,12 +953,12 @@ describe Braintree::CreditCard do
|
|
952
953
|
:expiration_date => "05/2012",
|
953
954
|
:billing_address => {
|
954
955
|
:street_address => "123 Nigeria Ave"
|
955
|
-
}
|
956
|
+
},
|
956
957
|
)
|
957
958
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
958
959
|
:billing_address => {
|
959
960
|
:region => "IL"
|
960
|
-
}
|
961
|
+
},
|
961
962
|
)
|
962
963
|
update_result.success?.should == true
|
963
964
|
updated_credit_card = update_result.credit_card
|
@@ -974,13 +975,13 @@ describe Braintree::CreditCard do
|
|
974
975
|
:expiration_date => "05/2012",
|
975
976
|
:billing_address => {
|
976
977
|
:street_address => "123 Nigeria Ave"
|
977
|
-
}
|
978
|
+
},
|
978
979
|
)
|
979
980
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
980
981
|
:billing_address => {
|
981
982
|
:region => "IL",
|
982
983
|
:options => {:update_existing => true}
|
983
|
-
}
|
984
|
+
},
|
984
985
|
)
|
985
986
|
update_result.success?.should == true
|
986
987
|
updated_credit_card = update_result.credit_card
|
@@ -997,7 +998,7 @@ describe Braintree::CreditCard do
|
|
997
998
|
:expiration_date => "05/2012",
|
998
999
|
:billing_address => {
|
999
1000
|
:street_address => "123 Nigeria Ave"
|
1000
|
-
}
|
1001
|
+
},
|
1001
1002
|
)
|
1002
1003
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
1003
1004
|
:billing_address => {
|
@@ -1006,7 +1007,7 @@ describe Braintree::CreditCard do
|
|
1006
1007
|
:country_code_alpha3 => "ASM",
|
1007
1008
|
:country_code_numeric => "016",
|
1008
1009
|
:options => {:update_existing => true}
|
1009
|
-
}
|
1010
|
+
},
|
1010
1011
|
)
|
1011
1012
|
update_result.success?.should == true
|
1012
1013
|
updated_credit_card = update_result.credit_card
|
@@ -1022,12 +1023,12 @@ describe Braintree::CreditCard do
|
|
1022
1023
|
credit_card = Braintree::CreditCard.create!(
|
1023
1024
|
:customer_id => customer.id,
|
1024
1025
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1025
|
-
:expiration_date => "05/2012"
|
1026
|
+
:expiration_date => "05/2012",
|
1026
1027
|
)
|
1027
1028
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
1028
1029
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1029
1030
|
:expiration_month => "07",
|
1030
|
-
:expiration_year => "2011"
|
1031
|
+
:expiration_year => "2011",
|
1031
1032
|
)
|
1032
1033
|
update_result.success?.should == true
|
1033
1034
|
update_result.credit_card.should == credit_card
|
@@ -1043,17 +1044,17 @@ describe Braintree::CreditCard do
|
|
1043
1044
|
:customer_id => customer.id,
|
1044
1045
|
:cvv => "123",
|
1045
1046
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1046
|
-
:expiration_date => "05/2012"
|
1047
|
+
:expiration_date => "05/2012",
|
1047
1048
|
)
|
1048
1049
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
1049
1050
|
:cardholder_name => "New Holder",
|
1050
1051
|
:cvv => "456",
|
1051
1052
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
|
1052
1053
|
:expiration_date => "06/2013",
|
1053
|
-
:options => {:verify_card => true}
|
1054
|
+
:options => {:verify_card => true},
|
1054
1055
|
)
|
1055
1056
|
update_result.success?.should == false
|
1056
|
-
update_result.credit_card_verification.status.should == Braintree::
|
1057
|
+
update_result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined
|
1057
1058
|
update_result.credit_card_verification.gateway_rejection_reason.should be_nil
|
1058
1059
|
end
|
1059
1060
|
|
@@ -1075,7 +1076,7 @@ describe Braintree::CreditCard do
|
|
1075
1076
|
:region => "Old State",
|
1076
1077
|
:postal_code => "12345",
|
1077
1078
|
:country_name => "Canada"
|
1078
|
-
}
|
1079
|
+
},
|
1079
1080
|
)
|
1080
1081
|
result = Braintree::CreditCard.update(credit_card.token,
|
1081
1082
|
:options => {:verify_card => false},
|
@@ -1089,7 +1090,7 @@ describe Braintree::CreditCard do
|
|
1089
1090
|
:region => "New State",
|
1090
1091
|
:postal_code => "56789",
|
1091
1092
|
:country_name => "United States of America"
|
1092
|
-
}
|
1093
|
+
},
|
1093
1094
|
)
|
1094
1095
|
result.success?.should == true
|
1095
1096
|
address = result.credit_card.billing_address
|
@@ -1110,12 +1111,12 @@ describe Braintree::CreditCard do
|
|
1110
1111
|
:cardholder_name => "Original Holder",
|
1111
1112
|
:customer_id => customer.id,
|
1112
1113
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1113
|
-
:expiration_date => "05/2012"
|
1114
|
+
:expiration_date => "05/2012",
|
1114
1115
|
)
|
1115
1116
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
1116
1117
|
:cardholder_name => "New Holder",
|
1117
1118
|
:number => "invalid",
|
1118
|
-
:expiration_date => "05/2014"
|
1119
|
+
:expiration_date => "05/2014",
|
1119
1120
|
)
|
1120
1121
|
update_result.success?.should == false
|
1121
1122
|
update_result.errors.for(:credit_card).on(:number)[0].message.should == "Credit card number must be 12-19 digits."
|
@@ -1126,12 +1127,12 @@ describe Braintree::CreditCard do
|
|
1126
1127
|
card1 = Braintree::CreditCard.create(
|
1127
1128
|
:customer_id => customer.id,
|
1128
1129
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1129
|
-
:expiration_date => "05/2009"
|
1130
|
+
:expiration_date => "05/2009",
|
1130
1131
|
).credit_card
|
1131
1132
|
card2 = Braintree::CreditCard.create(
|
1132
1133
|
:customer_id => customer.id,
|
1133
1134
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1134
|
-
:expiration_date => "05/2009"
|
1135
|
+
:expiration_date => "05/2009",
|
1135
1136
|
).credit_card
|
1136
1137
|
|
1137
1138
|
card1.should be_default
|
@@ -1189,12 +1190,12 @@ describe Braintree::CreditCard do
|
|
1189
1190
|
:cardholder_name => "Original Holder",
|
1190
1191
|
:customer_id => customer.id,
|
1191
1192
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1192
|
-
:expiration_date => "05/2012"
|
1193
|
+
:expiration_date => "05/2012",
|
1193
1194
|
)
|
1194
1195
|
updated_credit_card = Braintree::CreditCard.update!(credit_card.token,
|
1195
1196
|
:cardholder_name => "New Holder",
|
1196
1197
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1197
|
-
:expiration_date => "06/2013"
|
1198
|
+
:expiration_date => "06/2013",
|
1198
1199
|
)
|
1199
1200
|
updated_credit_card.token.should == credit_card.token
|
1200
1201
|
updated_credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
@@ -1210,151 +1211,25 @@ describe Braintree::CreditCard do
|
|
1210
1211
|
:cardholder_name => "Original Holder",
|
1211
1212
|
:customer_id => customer.id,
|
1212
1213
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1213
|
-
:expiration_date => "05/2012"
|
1214
|
+
:expiration_date => "05/2012",
|
1214
1215
|
)
|
1215
1216
|
expect do
|
1216
1217
|
Braintree::CreditCard.update!(credit_card.token,
|
1217
1218
|
:cardholder_name => "New Holder",
|
1218
1219
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1219
|
-
:expiration_date => "invalid/date"
|
1220
|
+
:expiration_date => "invalid/date",
|
1220
1221
|
)
|
1221
1222
|
end.to raise_error(Braintree::ValidationsFailed)
|
1222
1223
|
end
|
1223
1224
|
end
|
1224
1225
|
|
1225
|
-
describe "self.update_from_transparent_redirect" do
|
1226
|
-
it "updates the credit card" do
|
1227
|
-
old_token = "token_#{rand(10**10)}"
|
1228
|
-
new_token = "token_#{rand(10**10)}"
|
1229
|
-
customer = Braintree::Customer.create!(
|
1230
|
-
:credit_card => {
|
1231
|
-
:cardholder_name => "Old Cardholder Name",
|
1232
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1233
|
-
:expiration_date => "05/2012",
|
1234
|
-
:token => old_token
|
1235
|
-
}
|
1236
|
-
)
|
1237
|
-
credit_card = customer.credit_cards[0]
|
1238
|
-
params = {
|
1239
|
-
:credit_card => {
|
1240
|
-
:cardholder_name => "New Cardholder Name",
|
1241
|
-
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1242
|
-
:expiration_date => "05/2014"
|
1243
|
-
}
|
1244
|
-
}
|
1245
|
-
tr_data_params = {
|
1246
|
-
:payment_method_token => old_token,
|
1247
|
-
:credit_card => {
|
1248
|
-
:token => new_token
|
1249
|
-
}
|
1250
|
-
}
|
1251
|
-
tr_data = Braintree::TransparentRedirect.update_credit_card_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
1252
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::CreditCard.update_credit_card_url)
|
1253
|
-
result = Braintree::CreditCard.update_from_transparent_redirect(query_string_response)
|
1254
|
-
result.success?.should == true
|
1255
|
-
credit_card = result.credit_card
|
1256
|
-
credit_card.cardholder_name.should == "New Cardholder Name"
|
1257
|
-
credit_card.masked_number.should == "555555******4444"
|
1258
|
-
credit_card.expiration_date.should == "05/2014"
|
1259
|
-
credit_card.token.should == new_token
|
1260
|
-
end
|
1261
|
-
|
1262
|
-
it "updates the default credit card" do
|
1263
|
-
customer = Braintree::Customer.create!(
|
1264
|
-
:credit_card => {
|
1265
|
-
:cardholder_name => "Old Cardholder Name",
|
1266
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1267
|
-
:expiration_date => "05/2012"
|
1268
|
-
}
|
1269
|
-
)
|
1270
|
-
card1 = customer.credit_cards[0]
|
1271
|
-
|
1272
|
-
card2 = Braintree::CreditCard.create(
|
1273
|
-
:customer_id => customer.id,
|
1274
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1275
|
-
:expiration_date => "05/2009"
|
1276
|
-
).credit_card
|
1277
|
-
|
1278
|
-
card1.should be_default
|
1279
|
-
card2.should_not be_default
|
1280
|
-
|
1281
|
-
params = {
|
1282
|
-
:credit_card => {
|
1283
|
-
:options => {:make_default => true}
|
1284
|
-
}
|
1285
|
-
}
|
1286
|
-
tr_data_params = {
|
1287
|
-
:payment_method_token => card2.token
|
1288
|
-
}
|
1289
|
-
tr_data = Braintree::TransparentRedirect.update_credit_card_data({:redirect_url => "http://example.com"}.merge(tr_data_params))
|
1290
|
-
query_string_response = SpecHelper.simulate_form_post_for_tr(tr_data, params, Braintree::CreditCard.update_credit_card_url)
|
1291
|
-
result = Braintree::CreditCard.update_from_transparent_redirect(query_string_response)
|
1292
|
-
|
1293
|
-
Braintree::CreditCard.find(card1.token).should_not be_default
|
1294
|
-
Braintree::CreditCard.find(card2.token).should be_default
|
1295
|
-
end
|
1296
|
-
end
|
1297
|
-
|
1298
|
-
describe "credit" do
|
1299
|
-
it "creates a credit transaction using the customer, returning a result object" do
|
1300
|
-
customer = Braintree::Customer.create!(
|
1301
|
-
:credit_card => {
|
1302
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1303
|
-
:expiration_date => "05/2010"
|
1304
|
-
}
|
1305
|
-
)
|
1306
|
-
result = customer.credit_cards[0].credit(
|
1307
|
-
:amount => "100.00"
|
1308
|
-
)
|
1309
|
-
result.success?.should == true
|
1310
|
-
result.transaction.amount.should == BigDecimal("100.00")
|
1311
|
-
result.transaction.type.should == "credit"
|
1312
|
-
result.transaction.customer_details.id.should == customer.id
|
1313
|
-
result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
|
1314
|
-
result.transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
1315
|
-
result.transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
1316
|
-
result.transaction.credit_card_details.expiration_date.should == "05/2010"
|
1317
|
-
end
|
1318
|
-
end
|
1319
|
-
|
1320
|
-
describe "credit!" do
|
1321
|
-
it "returns the created credit tranaction if valid" do
|
1322
|
-
customer = Braintree::Customer.create!(
|
1323
|
-
:credit_card => {
|
1324
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1325
|
-
:expiration_date => "05/2010"
|
1326
|
-
}
|
1327
|
-
)
|
1328
|
-
transaction = customer.credit_cards[0].credit!(:amount => "100.00")
|
1329
|
-
transaction.amount.should == BigDecimal("100.00")
|
1330
|
-
transaction.type.should == "credit"
|
1331
|
-
transaction.customer_details.id.should == customer.id
|
1332
|
-
transaction.credit_card_details.token.should == customer.credit_cards[0].token
|
1333
|
-
transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
1334
|
-
transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
1335
|
-
transaction.credit_card_details.expiration_date.should == "05/2010"
|
1336
|
-
end
|
1337
|
-
|
1338
|
-
it "raises a ValidationsFailed if invalid" do
|
1339
|
-
customer = Braintree::Customer.create!(
|
1340
|
-
:credit_card => {
|
1341
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1342
|
-
:expiration_date => "05/2010"
|
1343
|
-
}
|
1344
|
-
)
|
1345
|
-
expect do
|
1346
|
-
customer.credit_cards[0].credit!(:amount => "invalid")
|
1347
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
1348
|
-
end
|
1349
|
-
end
|
1350
|
-
|
1351
1226
|
describe "self.delete" do
|
1352
1227
|
it "deletes the credit card" do
|
1353
1228
|
customer = Braintree::Customer.create.customer
|
1354
1229
|
result = Braintree::CreditCard.create(
|
1355
1230
|
:customer_id => customer.id,
|
1356
1231
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1357
|
-
:expiration_date => "05/2012"
|
1232
|
+
:expiration_date => "05/2012",
|
1358
1233
|
)
|
1359
1234
|
|
1360
1235
|
result.success?.should == true
|
@@ -1374,7 +1249,7 @@ describe Braintree::CreditCard do
|
|
1374
1249
|
Braintree::CreditCard.create!(
|
1375
1250
|
:customer_id => customer.id,
|
1376
1251
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1377
|
-
:expiration_date => "01/#{Time.now.year - 3}"
|
1252
|
+
:expiration_date => "01/#{Time.now.year - 3}",
|
1378
1253
|
)
|
1379
1254
|
end
|
1380
1255
|
|
@@ -1405,14 +1280,14 @@ describe Braintree::CreditCard do
|
|
1405
1280
|
Braintree::CreditCard.create!(
|
1406
1281
|
:customer_id => customer.id,
|
1407
1282
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1408
|
-
:expiration_date => "01/2010"
|
1283
|
+
:expiration_date => "01/2010",
|
1409
1284
|
)
|
1410
1285
|
end
|
1411
1286
|
|
1412
1287
|
collection = Braintree::CreditCard.expiring_between(Time.mktime(2010, 1, 1), Time.mktime(2010,3, 1))
|
1413
1288
|
collection.maximum_size.should > 100
|
1414
1289
|
|
1415
|
-
credit_card_ids = collection.map {|c| c.token }.uniq.compact
|
1290
|
+
credit_card_ids = collection.map { |c| c.token }.uniq.compact
|
1416
1291
|
credit_card_ids.size.should == collection.maximum_size
|
1417
1292
|
end
|
1418
1293
|
end
|
@@ -1423,7 +1298,7 @@ describe Braintree::CreditCard do
|
|
1423
1298
|
result = Braintree::CreditCard.create(
|
1424
1299
|
:customer_id => customer.id,
|
1425
1300
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1426
|
-
:expiration_date => "05/2012"
|
1301
|
+
:expiration_date => "05/2012",
|
1427
1302
|
)
|
1428
1303
|
result.success?.should == true
|
1429
1304
|
credit_card = Braintree::CreditCard.find(result.credit_card.token)
|
@@ -1438,13 +1313,13 @@ describe Braintree::CreditCard do
|
|
1438
1313
|
credit_card = Braintree::CreditCard.create(
|
1439
1314
|
:customer_id => customer.id,
|
1440
1315
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1441
|
-
:expiration_date => "05/2012"
|
1316
|
+
:expiration_date => "05/2012",
|
1442
1317
|
).credit_card
|
1443
1318
|
|
1444
1319
|
subscription = Braintree::Subscription.create(
|
1445
1320
|
:payment_method_token => credit_card.token,
|
1446
1321
|
:plan_id => "integration_trialless_plan",
|
1447
|
-
:price => "1.00"
|
1322
|
+
:price => "1.00",
|
1448
1323
|
).subscription
|
1449
1324
|
|
1450
1325
|
found_card = Braintree::CreditCard.find(credit_card.token)
|
@@ -1488,7 +1363,7 @@ describe Braintree::CreditCard do
|
|
1488
1363
|
:expiration_month => "11",
|
1489
1364
|
:expiration_year => "2099",
|
1490
1365
|
},
|
1491
|
-
:client_token_options => {:customer_id => customer.id}
|
1366
|
+
:client_token_options => {:customer_id => customer.id},
|
1492
1367
|
)
|
1493
1368
|
|
1494
1369
|
credit_card = Braintree::CreditCard.from_nonce(nonce)
|
@@ -1502,7 +1377,7 @@ describe Braintree::CreditCard do
|
|
1502
1377
|
:number => "4111111111111111",
|
1503
1378
|
:expiration_month => "11",
|
1504
1379
|
:expiration_year => "2099",
|
1505
|
-
}
|
1380
|
+
},
|
1506
1381
|
)
|
1507
1382
|
expect do
|
1508
1383
|
Braintree::CreditCard.from_nonce(nonce)
|
@@ -1517,7 +1392,7 @@ describe Braintree::CreditCard do
|
|
1517
1392
|
:expiration_month => "11",
|
1518
1393
|
:expiration_year => "2099",
|
1519
1394
|
},
|
1520
|
-
:client_token_options => {:customer_id => customer.id}
|
1395
|
+
:client_token_options => {:customer_id => customer.id},
|
1521
1396
|
)
|
1522
1397
|
|
1523
1398
|
Braintree::CreditCard.from_nonce(nonce)
|
@@ -1533,7 +1408,7 @@ describe Braintree::CreditCard do
|
|
1533
1408
|
:credit_card => {
|
1534
1409
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1535
1410
|
:expiration_date => "05/2010"
|
1536
|
-
}
|
1411
|
+
},
|
1537
1412
|
)
|
1538
1413
|
result = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00")
|
1539
1414
|
|
@@ -1552,13 +1427,13 @@ describe Braintree::CreditCard do
|
|
1552
1427
|
:credit_card => {
|
1553
1428
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1554
1429
|
:expiration_date => "05/2010"
|
1555
|
-
}
|
1430
|
+
},
|
1556
1431
|
)
|
1557
1432
|
result = Braintree::CreditCard.sale(customer.credit_cards[0].token,
|
1558
1433
|
:amount => "100.00",
|
1559
1434
|
:credit_card => {
|
1560
1435
|
:cvv => "301"
|
1561
|
-
}
|
1436
|
+
},
|
1562
1437
|
)
|
1563
1438
|
|
1564
1439
|
result.success?.should == true
|
@@ -1576,7 +1451,7 @@ describe Braintree::CreditCard do
|
|
1576
1451
|
:credit_card => {
|
1577
1452
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1578
1453
|
:expiration_date => "05/2010"
|
1579
|
-
}
|
1454
|
+
},
|
1580
1455
|
)
|
1581
1456
|
transaction = Braintree::CreditCard.sale!(customer.credit_cards[0].token, :amount => "100.00")
|
1582
1457
|
transaction.amount.should == BigDecimal("100.00")
|
@@ -1589,255 +1464,6 @@ describe Braintree::CreditCard do
|
|
1589
1464
|
end
|
1590
1465
|
end
|
1591
1466
|
|
1592
|
-
describe "sale" do
|
1593
|
-
it "creates a sale transaction using the credit card, returning a result object" do
|
1594
|
-
customer = Braintree::Customer.create!(
|
1595
|
-
:credit_card => {
|
1596
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1597
|
-
:expiration_date => "05/2010"
|
1598
|
-
}
|
1599
|
-
)
|
1600
|
-
result = customer.credit_cards[0].sale(
|
1601
|
-
:amount => "100.00"
|
1602
|
-
)
|
1603
|
-
result.success?.should == true
|
1604
|
-
result.transaction.amount.should == BigDecimal("100.00")
|
1605
|
-
result.transaction.type.should == "sale"
|
1606
|
-
result.transaction.customer_details.id.should == customer.id
|
1607
|
-
result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
|
1608
|
-
result.transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
1609
|
-
result.transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
1610
|
-
result.transaction.credit_card_details.expiration_date.should == "05/2010"
|
1611
|
-
end
|
1612
|
-
end
|
1613
|
-
|
1614
|
-
describe "sale!" do
|
1615
|
-
it "returns the created sale tranaction if valid" do
|
1616
|
-
customer = Braintree::Customer.create!(
|
1617
|
-
:credit_card => {
|
1618
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1619
|
-
:expiration_date => "05/2010"
|
1620
|
-
}
|
1621
|
-
)
|
1622
|
-
transaction = customer.credit_cards[0].sale!(:amount => "100.00")
|
1623
|
-
transaction.amount.should == BigDecimal("100.00")
|
1624
|
-
transaction.type.should == "sale"
|
1625
|
-
transaction.customer_details.id.should == customer.id
|
1626
|
-
transaction.credit_card_details.token.should == customer.credit_cards[0].token
|
1627
|
-
transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
1628
|
-
transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
1629
|
-
transaction.credit_card_details.expiration_date.should == "05/2010"
|
1630
|
-
end
|
1631
|
-
|
1632
|
-
it "raises a ValidationsFailed if invalid" do
|
1633
|
-
customer = Braintree::Customer.create!(
|
1634
|
-
:credit_card => {
|
1635
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1636
|
-
:expiration_date => "05/2010"
|
1637
|
-
}
|
1638
|
-
)
|
1639
|
-
expect do
|
1640
|
-
customer.credit_cards[0].sale!(:amount => "invalid")
|
1641
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
1642
|
-
end
|
1643
|
-
end
|
1644
|
-
|
1645
|
-
describe "update" do
|
1646
|
-
it "updates the credit card" do
|
1647
|
-
customer = Braintree::Customer.create!
|
1648
|
-
credit_card = Braintree::CreditCard.create!(
|
1649
|
-
:cardholder_name => "Original Holder",
|
1650
|
-
:customer_id => customer.id,
|
1651
|
-
:cvv => "123",
|
1652
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1653
|
-
:expiration_date => "05/2012"
|
1654
|
-
)
|
1655
|
-
update_result = credit_card.update(
|
1656
|
-
:cardholder_name => "New Holder",
|
1657
|
-
:cvv => "456",
|
1658
|
-
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1659
|
-
:expiration_date => "06/2013"
|
1660
|
-
)
|
1661
|
-
update_result.success?.should == true
|
1662
|
-
update_result.credit_card.should == credit_card
|
1663
|
-
updated_credit_card = update_result.credit_card
|
1664
|
-
updated_credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
1665
|
-
updated_credit_card.last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
1666
|
-
updated_credit_card.expiration_date.should == "06/2013"
|
1667
|
-
updated_credit_card.cardholder_name.should == "New Holder"
|
1668
|
-
end
|
1669
|
-
|
1670
|
-
it "verifies the update if options[verify_card]=true" do
|
1671
|
-
customer = Braintree::Customer.create!
|
1672
|
-
credit_card = Braintree::CreditCard.create!(
|
1673
|
-
:cardholder_name => "Original Holder",
|
1674
|
-
:customer_id => customer.id,
|
1675
|
-
:cvv => "123",
|
1676
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1677
|
-
:expiration_date => "05/2012"
|
1678
|
-
)
|
1679
|
-
update_result = credit_card.update(
|
1680
|
-
:cardholder_name => "New Holder",
|
1681
|
-
:cvv => "456",
|
1682
|
-
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
|
1683
|
-
:expiration_date => "06/2013",
|
1684
|
-
:options => {:verify_card => true}
|
1685
|
-
)
|
1686
|
-
update_result.success?.should == false
|
1687
|
-
update_result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
1688
|
-
end
|
1689
|
-
|
1690
|
-
it "fails on create if credit_card[options][fail_on_duplicate_payment_method]=true and there is a duplicated payment method" do
|
1691
|
-
customer = Braintree::Customer.create!
|
1692
|
-
Braintree::CreditCard.create(
|
1693
|
-
:customer_id => customer.id,
|
1694
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1695
|
-
:expiration_date => "05/2015"
|
1696
|
-
)
|
1697
|
-
|
1698
|
-
result = Braintree::CreditCard.create(
|
1699
|
-
:customer_id => customer.id,
|
1700
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1701
|
-
:expiration_date => "05/2015",
|
1702
|
-
:options => {:fail_on_duplicate_payment_method => true}
|
1703
|
-
)
|
1704
|
-
|
1705
|
-
result.success?.should == false
|
1706
|
-
result.errors.for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
|
1707
|
-
end
|
1708
|
-
|
1709
|
-
it "allows user to specify merchant account for verification" do
|
1710
|
-
customer = Braintree::Customer.create!
|
1711
|
-
credit_card = Braintree::CreditCard.create!(
|
1712
|
-
:cardholder_name => "Original Holder",
|
1713
|
-
:customer_id => customer.id,
|
1714
|
-
:cvv => "123",
|
1715
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1716
|
-
:expiration_date => "05/2012"
|
1717
|
-
)
|
1718
|
-
update_result = credit_card.update(
|
1719
|
-
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
1720
|
-
:expiration_date => "05/2009",
|
1721
|
-
:options => {
|
1722
|
-
:verify_card => true,
|
1723
|
-
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
1724
|
-
}
|
1725
|
-
)
|
1726
|
-
update_result.success?.should == false
|
1727
|
-
update_result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
1728
|
-
update_result.credit_card_verification.processor_response_code.should == "2000"
|
1729
|
-
update_result.credit_card_verification.processor_response_text.should == "Do Not Honor"
|
1730
|
-
update_result.credit_card_verification.cvv_response_code.should == "I"
|
1731
|
-
update_result.credit_card_verification.avs_error_response_code.should == nil
|
1732
|
-
update_result.credit_card_verification.avs_postal_code_response_code.should == "I"
|
1733
|
-
update_result.credit_card_verification.avs_street_address_response_code.should == "I"
|
1734
|
-
end
|
1735
|
-
|
1736
|
-
it "can update the billing address" do
|
1737
|
-
customer = Braintree::Customer.create!
|
1738
|
-
credit_card = Braintree::CreditCard.create!(
|
1739
|
-
:cardholder_name => "Original Holder",
|
1740
|
-
:customer_id => customer.id,
|
1741
|
-
:cvv => "123",
|
1742
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1743
|
-
:expiration_date => "05/2012",
|
1744
|
-
:billing_address => {
|
1745
|
-
:first_name => "Old First Name",
|
1746
|
-
:last_name => "Old Last Name",
|
1747
|
-
:company => "Old Company",
|
1748
|
-
:street_address => "123 Old St",
|
1749
|
-
:extended_address => "Apt Old",
|
1750
|
-
:locality => "Old City",
|
1751
|
-
:region => "Old State",
|
1752
|
-
:postal_code => "12345",
|
1753
|
-
:country_name => "Canada"
|
1754
|
-
}
|
1755
|
-
)
|
1756
|
-
result = credit_card.update(
|
1757
|
-
:options => {:verify_card => false},
|
1758
|
-
:billing_address => {
|
1759
|
-
:first_name => "New First Name",
|
1760
|
-
:last_name => "New Last Name",
|
1761
|
-
:company => "New Company",
|
1762
|
-
:street_address => "123 New St",
|
1763
|
-
:extended_address => "Apt New",
|
1764
|
-
:locality => "New City",
|
1765
|
-
:region => "New State",
|
1766
|
-
:postal_code => "56789",
|
1767
|
-
:country_name => "United States of America"
|
1768
|
-
}
|
1769
|
-
)
|
1770
|
-
result.success?.should == true
|
1771
|
-
address = result.credit_card.billing_address
|
1772
|
-
address.should == credit_card.billing_address # making sure credit card instance was updated
|
1773
|
-
address.first_name.should == "New First Name"
|
1774
|
-
address.last_name.should == "New Last Name"
|
1775
|
-
address.company.should == "New Company"
|
1776
|
-
address.street_address.should == "123 New St"
|
1777
|
-
address.extended_address.should == "Apt New"
|
1778
|
-
address.locality.should == "New City"
|
1779
|
-
address.region.should == "New State"
|
1780
|
-
address.postal_code.should == "56789"
|
1781
|
-
address.country_name.should == "United States of America"
|
1782
|
-
end
|
1783
|
-
|
1784
|
-
it "returns an error response if invalid" do
|
1785
|
-
customer = Braintree::Customer.create!
|
1786
|
-
credit_card = Braintree::CreditCard.create!(
|
1787
|
-
:cardholder_name => "Original Holder",
|
1788
|
-
:customer_id => customer.id,
|
1789
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1790
|
-
:expiration_date => "05/2012"
|
1791
|
-
)
|
1792
|
-
update_result = credit_card.update(
|
1793
|
-
:cardholder_name => "New Holder",
|
1794
|
-
:number => "invalid",
|
1795
|
-
:expiration_date => "05/2014"
|
1796
|
-
)
|
1797
|
-
update_result.success?.should == false
|
1798
|
-
update_result.errors.for(:credit_card).on(:number)[0].message.should == "Credit card number must be 12-19 digits."
|
1799
|
-
end
|
1800
|
-
end
|
1801
|
-
|
1802
|
-
describe "update!" do
|
1803
|
-
it "updates the credit card and returns true if valid" do
|
1804
|
-
customer = Braintree::Customer.create!
|
1805
|
-
credit_card = Braintree::CreditCard.create!(
|
1806
|
-
:cardholder_name => "Original Holder",
|
1807
|
-
:customer_id => customer.id,
|
1808
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1809
|
-
:expiration_date => "05/2012"
|
1810
|
-
)
|
1811
|
-
credit_card.update!(
|
1812
|
-
:cardholder_name => "New Holder",
|
1813
|
-
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1814
|
-
:expiration_date => "06/2013"
|
1815
|
-
).should == credit_card
|
1816
|
-
credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
1817
|
-
credit_card.last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
1818
|
-
credit_card.expiration_date.should == "06/2013"
|
1819
|
-
credit_card.cardholder_name.should == "New Holder"
|
1820
|
-
credit_card.updated_at.between?(Time.now - 60, Time.now).should == true
|
1821
|
-
end
|
1822
|
-
|
1823
|
-
it "raises a ValidationsFailed if invalid" do
|
1824
|
-
customer = Braintree::Customer.create!
|
1825
|
-
credit_card = Braintree::CreditCard.create!(
|
1826
|
-
:cardholder_name => "Original Holder",
|
1827
|
-
:customer_id => customer.id,
|
1828
|
-
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1829
|
-
:expiration_date => "05/2012"
|
1830
|
-
)
|
1831
|
-
expect do
|
1832
|
-
credit_card.update!(
|
1833
|
-
:cardholder_name => "New Holder",
|
1834
|
-
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1835
|
-
:expiration_date => "invalid/date"
|
1836
|
-
)
|
1837
|
-
end.to raise_error(Braintree::ValidationsFailed)
|
1838
|
-
end
|
1839
|
-
end
|
1840
|
-
|
1841
1467
|
describe "nonce" do
|
1842
1468
|
it "returns the credit card nonce" do
|
1843
1469
|
customer = Braintree::Customer.create!
|
@@ -1845,7 +1471,7 @@ describe Braintree::CreditCard do
|
|
1845
1471
|
:cardholder_name => "Original Holder",
|
1846
1472
|
:customer_id => customer.id,
|
1847
1473
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1848
|
-
:expiration_date => "05/2012"
|
1474
|
+
:expiration_date => "05/2012",
|
1849
1475
|
)
|
1850
1476
|
|
1851
1477
|
credit_card.nonce.should_not be_nil
|
@@ -1863,7 +1489,7 @@ describe Braintree::CreditCard do
|
|
1863
1489
|
credit_card = Braintree::CreditCard.create(
|
1864
1490
|
:customer_id => customer.id,
|
1865
1491
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1866
|
-
:expiration_date => "05/2009"
|
1492
|
+
:expiration_date => "05/2009",
|
1867
1493
|
).credit_card
|
1868
1494
|
credit_card_vaulted = Braintree::CreditCard.find(credit_card.token)
|
1869
1495
|
credit_card_vaulted.is_network_tokenized?.should == false
|