braintree 2.69.1 → 2.70.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -61,20 +61,14 @@ describe Braintree::MerchantGateway do
61
61
  )
62
62
  end
63
63
 
64
- it "creates a paypal-only merchant that accepts multiple currencies" do
64
+ it "creates a US multi currency merchant for paypal and credit_card" do
65
65
  result = @gateway.merchant.create(
66
66
  :email => "name@email.com",
67
67
  :country_code_alpha3 => "USA",
68
- :payment_methods => ["paypal"],
69
- :currencies => ["GBP", "USD"],
70
- :paypal_account => {
71
- :client_id => "paypal_client_id",
72
- :client_secret => "paypal_client_secret",
73
- }
68
+ :payment_methods => ["credit_card", "paypal"],
69
+ :currencies => ["GBP", "USD"]
74
70
  )
75
71
 
76
- result.should be_success
77
-
78
72
  merchant = result.merchant
79
73
  merchant.id.should_not be_nil
80
74
  merchant.email.should == "name@email.com"
@@ -102,27 +96,22 @@ describe Braintree::MerchantGateway do
102
96
  merchant_account.currency_iso_code.should == "GBP"
103
97
  end
104
98
 
105
- it "allows creation of non-US merchant if onboarding application is internal" do
99
+ it "creates an EU multi currency merchant for paypal and credit_card" do
106
100
  result = @gateway.merchant.create(
107
101
  :email => "name@email.com",
108
- :country_code_alpha3 => "JPN",
109
- :payment_methods => ["paypal"],
110
- :paypal_account => {
111
- :client_id => "paypal_client_id",
112
- :client_secret => "paypal_client_secret",
113
- }
102
+ :country_code_alpha3 => "GBR",
103
+ :payment_methods => ["credit_card", "paypal"],
104
+ :currencies => ["GBP", "USD"]
114
105
  )
115
106
 
116
- result.should be_success
117
-
118
107
  merchant = result.merchant
119
108
  merchant.id.should_not be_nil
120
109
  merchant.email.should == "name@email.com"
121
110
  merchant.company_name.should == "name@email.com"
122
- merchant.country_code_alpha3.should == "JPN"
123
- merchant.country_code_alpha2.should == "JP"
124
- merchant.country_code_numeric.should == "392"
125
- merchant.country_name.should == "Japan"
111
+ merchant.country_code_alpha3.should == "GBR"
112
+ merchant.country_code_alpha2.should == "GB"
113
+ merchant.country_code_numeric.should == "826"
114
+ merchant.country_name.should == "United Kingdom"
126
115
 
127
116
  credentials = result.credentials
128
117
  credentials.access_token.should_not be_nil
@@ -131,18 +120,24 @@ describe Braintree::MerchantGateway do
131
120
  credentials.token_type.should == "bearer"
132
121
 
133
122
  merchant_accounts = merchant.merchant_accounts
134
- merchant_accounts.count.should == 1
123
+ merchant_accounts.count.should == 2
135
124
 
136
- merchant_account = merchant_accounts.detect { |ma| ma.id == "JPY" }
125
+ merchant_account = merchant_accounts.detect { |ma| ma.id == "GBP" }
137
126
  merchant_account.default.should == true
138
- merchant_account.currency_iso_code.should == "JPY"
127
+ merchant_account.currency_iso_code.should == "GBP"
128
+
129
+ merchant_account = merchant_accounts.detect { |ma| ma.id == "USD" }
130
+ merchant_account.default.should == false
131
+ merchant_account.currency_iso_code.should == "USD"
139
132
  end
140
133
 
141
- it "defaults to USD for non-US merchant if onboarding application is internal and country currency not supported" do
134
+
135
+ it "creates a paypal-only merchant that accepts multiple currencies" do
142
136
  result = @gateway.merchant.create(
143
137
  :email => "name@email.com",
144
- :country_code_alpha3 => "YEM",
138
+ :country_code_alpha3 => "USA",
145
139
  :payment_methods => ["paypal"],
140
+ :currencies => ["GBP", "USD"],
146
141
  :paypal_account => {
147
142
  :client_id => "paypal_client_id",
148
143
  :client_secret => "paypal_client_secret",
@@ -155,10 +150,10 @@ describe Braintree::MerchantGateway do
155
150
  merchant.id.should_not be_nil
156
151
  merchant.email.should == "name@email.com"
157
152
  merchant.company_name.should == "name@email.com"
158
- merchant.country_code_alpha3.should == "YEM"
159
- merchant.country_code_alpha2.should == "YE"
160
- merchant.country_code_numeric.should == "887"
161
- merchant.country_name.should == "Yemen"
153
+ merchant.country_code_alpha3.should == "USA"
154
+ merchant.country_code_alpha2.should == "US"
155
+ merchant.country_code_numeric.should == "840"
156
+ merchant.country_name.should == "United States of America"
162
157
 
163
158
  credentials = result.credentials
164
159
  credentials.access_token.should_not be_nil
@@ -167,25 +162,22 @@ describe Braintree::MerchantGateway do
167
162
  credentials.token_type.should == "bearer"
168
163
 
169
164
  merchant_accounts = merchant.merchant_accounts
170
- merchant_accounts.count.should == 1
165
+ merchant_accounts.count.should == 2
171
166
 
172
167
  merchant_account = merchant_accounts.detect { |ma| ma.id == "USD" }
173
168
  merchant_account.default.should == true
174
169
  merchant_account.currency_iso_code.should == "USD"
175
- end
176
170
 
177
- it "creates a paypal-only merchant via the non multi-currency flow if the oauth_application is not internal" do
178
- gateway = Braintree::Gateway.new(
179
- :client_id => "client_id$development$integration_client_id",
180
- :client_secret => "client_secret$development$integration_client_secret",
181
- :logger => Logger.new("/dev/null")
182
- )
171
+ merchant_account = merchant_accounts.detect { |ma| ma.id == "GBP" }
172
+ merchant_account.default.should == false
173
+ merchant_account.currency_iso_code.should == "GBP"
174
+ end
183
175
 
184
- result = gateway.merchant.create(
176
+ it "allows creation of non-US merchant if onboarding application is internal" do
177
+ result = @gateway.merchant.create(
185
178
  :email => "name@email.com",
186
- :country_code_alpha3 => "USA",
179
+ :country_code_alpha3 => "JPN",
187
180
  :payment_methods => ["paypal"],
188
- :currencies => ["USD", "GBP"],
189
181
  :paypal_account => {
190
182
  :client_id => "paypal_client_id",
191
183
  :client_secret => "paypal_client_secret",
@@ -198,10 +190,10 @@ describe Braintree::MerchantGateway do
198
190
  merchant.id.should_not be_nil
199
191
  merchant.email.should == "name@email.com"
200
192
  merchant.company_name.should == "name@email.com"
201
- merchant.country_code_alpha3.should == "USA"
202
- merchant.country_code_alpha2.should == "US"
203
- merchant.country_code_numeric.should == "840"
204
- merchant.country_name.should == "United States of America"
193
+ merchant.country_code_alpha3.should == "JPN"
194
+ merchant.country_code_alpha2.should == "JP"
195
+ merchant.country_code_numeric.should == "392"
196
+ merchant.country_name.should == "Japan"
205
197
 
206
198
  credentials = result.credentials
207
199
  credentials.access_token.should_not be_nil
@@ -212,27 +204,45 @@ describe Braintree::MerchantGateway do
212
204
  merchant_accounts = merchant.merchant_accounts
213
205
  merchant_accounts.count.should == 1
214
206
 
215
- merchant_account = merchant_accounts.first
207
+ merchant_account = merchant_accounts.detect { |ma| ma.id == "JPY" }
216
208
  merchant_account.default.should == true
217
- merchant_account.currency_iso_code.should == "USD"
209
+ merchant_account.currency_iso_code.should == "JPY"
218
210
  end
219
211
 
220
- it "returns error if valid payment_method other than paypal is passed" do
212
+ it "defaults to USD for non-US merchant if onboarding application is internal and country currency not supported" do
221
213
  result = @gateway.merchant.create(
222
214
  :email => "name@email.com",
223
- :country_code_alpha3 => "USA",
224
- :payment_methods => ["credit_card", "paypal"],
225
- :currencies => ["USD", "GBP"],
215
+ :country_code_alpha3 => "YEM",
216
+ :payment_methods => ["paypal"],
226
217
  :paypal_account => {
227
218
  :client_id => "paypal_client_id",
228
219
  :client_secret => "paypal_client_secret",
229
220
  }
230
221
  )
231
222
 
232
- result.should_not be_success
233
- errors = result.errors.for(:merchant).on(:payment_methods)
223
+ result.should be_success
224
+
225
+ merchant = result.merchant
226
+ merchant.id.should_not be_nil
227
+ merchant.email.should == "name@email.com"
228
+ merchant.company_name.should == "name@email.com"
229
+ merchant.country_code_alpha3.should == "YEM"
230
+ merchant.country_code_alpha2.should == "YE"
231
+ merchant.country_code_numeric.should == "887"
232
+ merchant.country_name.should == "Yemen"
234
233
 
235
- errors[0].code.should == Braintree::ErrorCodes::Merchant::PaymentMethodsAreNotAllowed
234
+ credentials = result.credentials
235
+ credentials.access_token.should_not be_nil
236
+ credentials.refresh_token.should_not be_nil
237
+ credentials.expires_at.should_not be_nil
238
+ credentials.token_type.should == "bearer"
239
+
240
+ merchant_accounts = merchant.merchant_accounts
241
+ merchant_accounts.count.should == 1
242
+
243
+ merchant_account = merchant_accounts.detect { |ma| ma.id == "USD" }
244
+ merchant_account.default.should == true
245
+ merchant_account.currency_iso_code.should == "USD"
236
246
  end
237
247
 
238
248
  it "returns error if invalid currency is passed" do
@@ -492,12 +492,12 @@ describe Braintree::PaymentMethod do
492
492
  result.should be_success
493
493
  us_bank_account = result.payment_method
494
494
  us_bank_account.should be_a(Braintree::UsBankAccount)
495
- us_bank_account.routing_number.should == "123456789"
495
+ us_bank_account.routing_number.should == "021000021"
496
496
  us_bank_account.last_4.should == "1234"
497
497
  us_bank_account.account_type.should == "checking"
498
498
  us_bank_account.account_description.should == "PayPal Checking - 1234"
499
499
  us_bank_account.account_holder_name.should == "Dan Schulman"
500
- us_bank_account.bank_name.should == "UNKNOWN"
500
+ us_bank_account.bank_name.should =~ /CHASE/
501
501
  us_bank_account.default.should == true
502
502
  us_bank_account.ach_mandate.text.should == "cl mandate text"
503
503
  us_bank_account.ach_mandate.accepted_at.should be_a Time
@@ -902,7 +902,7 @@ describe Braintree::PaymentMethod do
902
902
  paypal_account = Braintree::PaymentMethod.find(paypal_account_token)
903
903
  paypal_account.should be_a(Braintree::PayPalAccount)
904
904
 
905
- result = Braintree::PaymentMethod.delete(paypal_account_token)
905
+ result = Braintree::PaymentMethod.delete(paypal_account_token, {:revoke_all_grants => false})
906
906
  result.success?.should == true
907
907
 
908
908
  expect do
@@ -2123,12 +2123,12 @@ describe Braintree::Transaction do
2123
2123
  result.transaction.payment_instrument_type.should == Braintree::PaymentInstrumentType::UsBankAccount
2124
2124
  result.transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
2125
2125
  result.transaction.status.should == Braintree::Transaction::Status::SettlementPending
2126
- result.transaction.us_bank_account_details.routing_number.should == "123456789"
2126
+ result.transaction.us_bank_account_details.routing_number.should == "021000021"
2127
2127
  result.transaction.us_bank_account_details.last_4.should == "1234"
2128
2128
  result.transaction.us_bank_account_details.account_type.should == "checking"
2129
2129
  result.transaction.us_bank_account_details.account_description.should == "PayPal Checking - 1234"
2130
2130
  result.transaction.us_bank_account_details.account_holder_name.should == "Dan Schulman"
2131
- result.transaction.us_bank_account_details.bank_name.should == "UNKNOWN"
2131
+ result.transaction.us_bank_account_details.bank_name.should =~ /CHASE/
2132
2132
  result.transaction.us_bank_account_details.ach_mandate.text.should == "cl mandate text"
2133
2133
  result.transaction.us_bank_account_details.ach_mandate.accepted_at.should be_a Time
2134
2134
  end
@@ -2149,12 +2149,12 @@ describe Braintree::Transaction do
2149
2149
  result.transaction.type.should == "sale"
2150
2150
  result.transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
2151
2151
  result.transaction.status.should == Braintree::Transaction::Status::SettlementPending
2152
- result.transaction.us_bank_account_details.routing_number.should == "123456789"
2152
+ result.transaction.us_bank_account_details.routing_number.should == "021000021"
2153
2153
  result.transaction.us_bank_account_details.last_4.should == "1234"
2154
2154
  result.transaction.us_bank_account_details.account_type.should == "checking"
2155
2155
  result.transaction.us_bank_account_details.account_description.should == "PayPal Checking - 1234"
2156
2156
  result.transaction.us_bank_account_details.account_holder_name.should == "Dan Schulman"
2157
- result.transaction.us_bank_account_details.bank_name.should == "UNKNOWN"
2157
+ result.transaction.us_bank_account_details.bank_name.should =~ /CHASE/
2158
2158
  result.transaction.us_bank_account_details.ach_mandate.text.should == "cl mandate text"
2159
2159
  result.transaction.us_bank_account_details.ach_mandate.accepted_at.should be_a Time
2160
2160
 
@@ -2172,12 +2172,12 @@ describe Braintree::Transaction do
2172
2172
  result.transaction.type.should == "sale"
2173
2173
  result.transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
2174
2174
  result.transaction.status.should == Braintree::Transaction::Status::SettlementPending
2175
- result.transaction.us_bank_account_details.routing_number.should == "123456789"
2175
+ result.transaction.us_bank_account_details.routing_number.should == "021000021"
2176
2176
  result.transaction.us_bank_account_details.last_4.should == "1234"
2177
2177
  result.transaction.us_bank_account_details.account_type.should == "checking"
2178
2178
  result.transaction.us_bank_account_details.account_description.should == "PayPal Checking - 1234"
2179
2179
  result.transaction.us_bank_account_details.account_holder_name.should == "Dan Schulman"
2180
- result.transaction.us_bank_account_details.bank_name.should == "UNKNOWN"
2180
+ result.transaction.us_bank_account_details.bank_name.should =~ /CHASE/
2181
2181
  result.transaction.us_bank_account_details.ach_mandate.text.should == "cl mandate text"
2182
2182
  result.transaction.us_bank_account_details.ach_mandate.accepted_at.should be_a Time
2183
2183
  end
@@ -2196,6 +2196,53 @@ describe Braintree::Transaction do
2196
2196
  result.errors.for(:transaction).on(:payment_method_nonce)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodNonceUnknown
2197
2197
  end
2198
2198
  end
2199
+
2200
+ context "ideal payment nonce" do
2201
+ it "returns a successful result for tansacting on an ideal payment nonce" do
2202
+ valid_ideal_payment_id = generate_valid_ideal_payment_nonce
2203
+ result = Braintree::Transaction.create(
2204
+ :type => "sale",
2205
+ :order_id => SpecHelper::DefaultOrderId,
2206
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
2207
+ :merchant_account_id => SpecHelper::IdealMerchantAccountId,
2208
+ :payment_method_nonce => valid_ideal_payment_id,
2209
+ :options => {
2210
+ :submit_for_settlement => true,
2211
+ }
2212
+ )
2213
+ result.success?.should == true
2214
+ result.transaction.id.should =~ /^\w{6,}$/
2215
+ result.transaction.type.should == "sale"
2216
+ result.transaction.payment_instrument_type.should == Braintree::PaymentInstrumentType::IdealPayment
2217
+ result.transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
2218
+ result.transaction.status.should == Braintree::Transaction::Status::Settled
2219
+ result.transaction.ideal_payment_details.ideal_payment_id.should =~ /^idealpayment_\w{6,}$/
2220
+ result.transaction.ideal_payment_details.ideal_transaction_id.should =~ /^\d{16,}$/
2221
+ result.transaction.ideal_payment_details.image_url.should start_with("https://")
2222
+ result.transaction.ideal_payment_details.masked_iban.should_not be_empty
2223
+ result.transaction.ideal_payment_details.bic.should_not be_empty
2224
+ end
2225
+
2226
+ it "returns a failure if ideal payment is not complete" do
2227
+ expired_payment_amount = "3.00"
2228
+
2229
+ incomplete_payment_id = generate_valid_ideal_payment_nonce(expired_payment_amount)
2230
+
2231
+ result = Braintree::Transaction.create(
2232
+ :type => "sale",
2233
+ :order_id => SpecHelper::DefaultOrderId,
2234
+ :amount => expired_payment_amount,
2235
+ :merchant_account_id => SpecHelper::IdealMerchantAccountId,
2236
+ :payment_method_nonce => incomplete_payment_id,
2237
+ :options => {
2238
+ :submit_for_settlement => true,
2239
+ }
2240
+ )
2241
+
2242
+ result.success?.should == false
2243
+ result.errors.for(:transaction).on(:ideal_payment)[0].code.should == Braintree::ErrorCodes::Transaction::IdealPaymentNotComplete
2244
+ end
2245
+ end
2199
2246
  end
2200
2247
 
2201
2248
  describe "self.create!" do
@@ -2651,6 +2698,21 @@ describe Braintree::Transaction do
2651
2698
  result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
2652
2699
  end
2653
2700
 
2701
+ it "skips advanced fraud checking if transaction[options][skip_advanced_fraud_checking] is set to true" do
2702
+ result = Braintree::Transaction.sale(
2703
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
2704
+ :credit_card => {
2705
+ :number => Braintree::Test::CreditCardNumbers::Visa,
2706
+ :expiration_date => "05/2009"
2707
+ },
2708
+ :options => {
2709
+ :skip_advanced_fraud_checking => true
2710
+ }
2711
+ )
2712
+ result.success?.should == true
2713
+ result.transaction.risk_data.id.should be_nil
2714
+ end
2715
+
2654
2716
  it "works with Apple Pay params" do
2655
2717
  params = {
2656
2718
  :amount => "3.12",
@@ -3937,6 +3999,7 @@ describe Braintree::Transaction do
3937
3999
  transaction.paypal_details.payer_id.should_not be_nil
3938
4000
  transaction.paypal_details.payer_first_name.should_not be_nil
3939
4001
  transaction.paypal_details.payer_last_name.should_not be_nil
4002
+ transaction.paypal_details.payer_status.should_not be_nil
3940
4003
  transaction.paypal_details.seller_protection_status.should_not be_nil
3941
4004
  transaction.paypal_details.capture_id.should_not be_nil
3942
4005
  transaction.paypal_details.refund_id.should_not be_nil
@@ -15,12 +15,12 @@ describe Braintree::UsBankAccount do
15
15
 
16
16
  us_bank_account = Braintree::UsBankAccount.find(result.payment_method.token)
17
17
  us_bank_account.should be_a(Braintree::UsBankAccount)
18
- us_bank_account.routing_number.should == "123456789"
18
+ us_bank_account.routing_number.should == "021000021"
19
19
  us_bank_account.last_4.should == "1234"
20
20
  us_bank_account.account_type.should == "checking"
21
21
  us_bank_account.account_description.should == "PayPal Checking - 1234"
22
22
  us_bank_account.account_holder_name.should == "Dan Schulman"
23
- us_bank_account.bank_name.should == "UNKNOWN"
23
+ us_bank_account.bank_name.should =~ /CHASE/
24
24
  us_bank_account.ach_mandate.text.should == "cl mandate text"
25
25
  us_bank_account.ach_mandate.accepted_at.should be_a Time
26
26
  end
@@ -49,12 +49,12 @@ describe Braintree::UsBankAccount do
49
49
  result.transaction.amount.should == BigDecimal.new("100.00")
50
50
  result.transaction.type.should == "sale"
51
51
  us_bank_account = result.transaction.us_bank_account_details
52
- us_bank_account.routing_number.should == "123456789"
52
+ us_bank_account.routing_number.should == "021000021"
53
53
  us_bank_account.last_4.should == "1234"
54
54
  us_bank_account.account_type.should == "checking"
55
55
  us_bank_account.account_description.should == "PayPal Checking - 1234"
56
56
  us_bank_account.account_holder_name.should == "Dan Schulman"
57
- us_bank_account.bank_name.should == "UNKNOWN"
57
+ us_bank_account.bank_name.should =~ /CHASE/
58
58
  us_bank_account.ach_mandate.text.should == "cl mandate text"
59
59
  us_bank_account.ach_mandate.accepted_at.should be_a Time
60
60
  end
@@ -76,12 +76,12 @@ describe Braintree::UsBankAccount do
76
76
  transaction.amount.should == BigDecimal.new("100.00")
77
77
  transaction.type.should == "sale"
78
78
  us_bank_account = transaction.us_bank_account_details
79
- us_bank_account.routing_number.should == "123456789"
79
+ us_bank_account.routing_number.should == "021000021"
80
80
  us_bank_account.last_4.should == "1234"
81
81
  us_bank_account.account_type.should == "checking"
82
82
  us_bank_account.account_description.should == "PayPal Checking - 1234"
83
83
  us_bank_account.account_holder_name.should == "Dan Schulman"
84
- us_bank_account.bank_name.should == "UNKNOWN"
84
+ us_bank_account.bank_name.should =~ /CHASE/
85
85
  us_bank_account.ach_mandate.text.should == "cl mandate text"
86
86
  us_bank_account.ach_mandate.accepted_at.should be_a Time
87
87
  end
@@ -40,6 +40,7 @@ unless defined?(SPEC_HELPER_LOADED)
40
40
  FakeAmexDirectMerchantAccountId = "fake_amex_direct_usd"
41
41
  FakeVenmoAccountMerchantAccountId = "fake_first_data_venmo_account"
42
42
  UsBankMerhantAccountId = "us_bank_merchant_account"
43
+ IdealMerchantAccountId = "ideal_merchant_account"
43
44
 
44
45
  TrialPlan = {
45
46
  :description => "Plan for integration tests -- with trial",
@@ -81,6 +82,8 @@ unless defined?(SPEC_HELPER_LOADED)
81
82
  Discount11 = "discount_11"
82
83
  Discount15 = "discount_15"
83
84
 
85
+ DefaultOrderId = "ABC123"
86
+
84
87
  TestMerchantConfig = Braintree::Configuration.new(
85
88
  :logger => Logger.new("/dev/null"),
86
89
  :environment => Braintree::Configuration.environment,
@@ -107,6 +110,20 @@ unless defined?(SPEC_HELPER_LOADED)
107
110
  response[:three_d_secure_verification][:three_d_secure_token]
108
111
  end
109
112
 
113
+ def self.create_merchant(params={})
114
+ gateway = Braintree::Gateway.new(
115
+ :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
116
+ :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
117
+ :logger => Logger.new("/dev/null")
118
+ )
119
+
120
+ gateway.merchant.create({
121
+ :email => "name@email.com",
122
+ :country_code_alpha3 => "GBR",
123
+ :payment_methods => ["credit_card", "paypal"],
124
+ }.merge!(params))
125
+ end
126
+
110
127
  def self.stub_time_dot_now(desired_time)
111
128
  Time.class_eval do
112
129
  class << self
@@ -205,6 +222,6 @@ RSpec.configure do |config|
205
222
  end
206
223
 
207
224
  config.mock_with :rspec do |mock|
208
- mock.syntax = :should
225
+ mock.syntax = [:should, :expect]
209
226
  end
210
227
  end
@@ -27,6 +27,33 @@ describe Braintree::PaymentMethod do
27
27
  end
28
28
  end
29
29
 
30
+ describe "delete" do
31
+ let(:http_stub) { double('http_stub').as_null_object }
32
+ it "accepts revoke_all_grants option with value true" do
33
+ Braintree::Http.stub(:new).and_return http_stub
34
+ http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=true")
35
+ Braintree::PaymentMethod.delete("some_token", {:revoke_all_grants => true})
36
+ end
37
+
38
+ it "accepts revoke_all_grants option with value false" do
39
+ Braintree::Http.stub(:new).and_return http_stub
40
+ http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=false")
41
+ Braintree::PaymentMethod.delete("some_token", {:revoke_all_grants => false})
42
+ end
43
+
44
+ it "throws error when an invalid param is used for options" do
45
+ expect do
46
+ Braintree::PaymentMethod.delete("some_token", {:invalid_key => false})
47
+ end.to raise_error(ArgumentError)
48
+ end
49
+
50
+ it "accepts just the token, revoke_all_grants is optional" do
51
+ Braintree::Http.stub(:new).and_return http_stub
52
+ http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token")
53
+ Braintree::PaymentMethod.delete("some_token")
54
+ end
55
+ end
56
+
30
57
  describe "timestamps" do
31
58
  it "exposes created_at and updated_at" do
32
59
  now = Time.now