braintree 2.83.0 → 2.84.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/address.rb +12 -12
  3. data/lib/braintree/address/country_names.rb +4 -1
  4. data/lib/braintree/address_gateway.rb +10 -0
  5. data/lib/braintree/client_token.rb +2 -2
  6. data/lib/braintree/client_token_gateway.rb +2 -0
  7. data/lib/braintree/credit_card.rb +20 -20
  8. data/lib/braintree/credit_card_gateway.rb +18 -0
  9. data/lib/braintree/credit_card_verification.rb +2 -2
  10. data/lib/braintree/customer.rb +18 -18
  11. data/lib/braintree/customer_gateway.rb +14 -2
  12. data/lib/braintree/dispute.rb +12 -12
  13. data/lib/braintree/dispute/history_event.rb +2 -0
  14. data/lib/braintree/dispute_search.rb +3 -0
  15. data/lib/braintree/document_upload.rb +6 -2
  16. data/lib/braintree/document_upload_gateway.rb +6 -0
  17. data/lib/braintree/ideal_payment.rb +3 -3
  18. data/lib/braintree/ideal_payment_gateway.rb +0 -1
  19. data/lib/braintree/merchant_account.rb +14 -6
  20. data/lib/braintree/merchant_account_gateway.rb +10 -0
  21. data/lib/braintree/payment_method.rb +20 -12
  22. data/lib/braintree/payment_method_gateway.rb +10 -0
  23. data/lib/braintree/payment_method_nonce.rb +8 -4
  24. data/lib/braintree/payment_method_nonce_gateway.rb +6 -0
  25. data/lib/braintree/settlement_batch_summary_gateway.rb +2 -0
  26. data/lib/braintree/subscription.rb +18 -14
  27. data/lib/braintree/subscription_gateway.rb +18 -0
  28. data/lib/braintree/transaction.rb +54 -54
  29. data/lib/braintree/transaction_gateway.rb +44 -1
  30. data/lib/braintree/transparent_redirect.rb +12 -12
  31. data/lib/braintree/us_bank_account.rb +5 -5
  32. data/lib/braintree/us_bank_account_gateway.rb +0 -1
  33. data/lib/braintree/version.rb +1 -1
  34. data/lib/braintree/webhook_notification.rb +4 -4
  35. data/lib/braintree/webhook_testing.rb +2 -2
  36. data/spec/httpsd.pid +1 -0
  37. data/spec/integration/braintree/client_api/spec_helper.rb +0 -15
  38. data/spec/integration/braintree/customer_spec.rb +73 -0
  39. data/spec/integration/braintree/dispute_search_spec.rb +69 -0
  40. data/spec/integration/braintree/document_upload_spec.rb +13 -0
  41. data/spec/integration/braintree/merchant_account_spec.rb +22 -0
  42. data/spec/integration/braintree/payment_method_nonce_spec.rb +29 -0
  43. data/spec/integration/braintree/payment_method_spec.rb +63 -93
  44. data/spec/integration/braintree/subscription_spec.rb +13 -0
  45. data/spec/integration/braintree/transaction_search_spec.rb +0 -41
  46. data/spec/integration/braintree/transaction_spec.rb +12 -1
  47. data/spec/unit/braintree/dispute_search_spec.rb +3 -0
  48. data/spec/unit/braintree/transaction_spec.rb +0 -1
  49. metadata +4 -3
@@ -41,6 +41,35 @@ describe Braintree::PaymentMethodNonce do
41
41
  end
42
42
  end
43
43
 
44
+ describe "self.create!" do
45
+ it "creates a payment method nonce from a vaulted credit card" do
46
+ customer = Braintree::Customer.create.customer
47
+ nonce = nonce_for_new_payment_method(
48
+ :credit_card => {
49
+ :number => "4111111111111111",
50
+ :expiration_month => "11",
51
+ :expiration_year => "2099",
52
+ }
53
+ )
54
+
55
+ payment_method = Braintree::PaymentMethod.create!(
56
+ :payment_method_nonce => nonce,
57
+ :customer_id => customer.id
58
+ )
59
+
60
+ payment_method.should be_a(Braintree::CreditCard)
61
+ token = payment_method.token
62
+
63
+ found_credit_card = Braintree::CreditCard.find(token)
64
+ found_credit_card.should_not be_nil
65
+
66
+ payment_method_nonce = Braintree::PaymentMethodNonce.create!(found_credit_card.token)
67
+ payment_method_nonce.should_not be_nil
68
+ payment_method_nonce.nonce.should_not be_nil
69
+ payment_method_nonce.details.should_not be_nil
70
+ end
71
+ end
72
+
44
73
  describe "self.find" do
45
74
  it "finds and returns the nonce if one was found" do
46
75
  result = Braintree::PaymentMethodNonce.find("fake-valid-nonce")
@@ -117,10 +117,10 @@ describe Braintree::PaymentMethod do
117
117
  android_pay_card.expiration_year.to_i.should > 0
118
118
  android_pay_card.default.should == true
119
119
  android_pay_card.image_url.should =~ /android_pay/
120
- android_pay_card.source_card_type.should == Braintree::CreditCard::CardType::Visa
120
+ android_pay_card.source_card_type.should == Braintree::CreditCard::CardType::Discover
121
121
  android_pay_card.source_card_last_4.should == "1111"
122
122
  android_pay_card.google_transaction_id.should == "google_transaction_id"
123
- android_pay_card.source_description.should == "Visa 1111"
123
+ android_pay_card.source_description.should == "Discover 1111"
124
124
  android_pay_card.customer_id.should == customer.id
125
125
  end
126
126
 
@@ -696,41 +696,6 @@ describe Braintree::PaymentMethod do
696
696
  end
697
697
  end
698
698
 
699
- context "SEPA" do
700
- it "returns the SEPA bank account behind the nonce" do
701
- config = Braintree::Configuration.instantiate
702
- customer = Braintree::Customer.create.customer
703
- raw_client_token = Braintree::ClientToken.generate(:customer_id => customer.id, :sepa_mandate_type => Braintree::EuropeBankAccount::MandateType::Business)
704
- client_token = decode_client_token(raw_client_token)
705
- authorization_fingerprint = client_token["authorizationFingerprint"]
706
- http = ClientApiHttp.new(
707
- config,
708
- :authorization_fingerprint => authorization_fingerprint
709
- )
710
-
711
- nonce = http.create_europe_bank_account_nonce(
712
- :accountHolderName => "Bob Holder",
713
- :iban => "DE89370400440532013000",
714
- :bic => "DEUTDEFF",
715
- :locale => "en-US",
716
- :billingAddress => {
717
- :region => "Hesse",
718
- :country_name => "Germany"
719
- }
720
- )
721
- nonce.should_not == nil
722
- result = Braintree::PaymentMethod.create(
723
- :payment_method_nonce => nonce,
724
- :customer_id => customer.id
725
- )
726
-
727
- result.should be_success
728
- result.payment_method.token.should_not == nil
729
- result.payment_method.image_url.should_not be_nil
730
- result.payment_method.customer_id.should == customer.id
731
- end
732
- end
733
-
734
699
  context "Unknown payment methods" do
735
700
  it "creates an unknown payment method from a nonce" do
736
701
  customer = Braintree::Customer.create.customer
@@ -750,6 +715,41 @@ describe Braintree::PaymentMethod do
750
715
  end
751
716
  end
752
717
 
718
+ describe "self.create!" do
719
+ it "creates a payment method from a vaulted credit card nonce" do
720
+ config = Braintree::Configuration.instantiate
721
+ customer = Braintree::Customer.create.customer
722
+ raw_client_token = Braintree::ClientToken.generate(:customer_id => customer.id)
723
+ client_token = decode_client_token(raw_client_token)
724
+ authorization_fingerprint = client_token["authorizationFingerprint"]
725
+ http = ClientApiHttp.new(
726
+ config,
727
+ :authorization_fingerprint => authorization_fingerprint,
728
+ :shared_customer_identifier => "fake_identifier",
729
+ :shared_customer_identifier_type => "testing"
730
+ )
731
+
732
+ response = http.create_credit_card(
733
+ :number => 4111111111111111,
734
+ :expirationMonth => 12,
735
+ :expirationYear => 2020
736
+ )
737
+ response.code.should == "201"
738
+
739
+ nonce = JSON.parse(response.body)["creditCards"].first["nonce"]
740
+ payment_method = Braintree::PaymentMethod.create!(
741
+ :payment_method_nonce => nonce,
742
+ :customer_id => customer.id
743
+ )
744
+
745
+ payment_method.should be_a(Braintree::CreditCard)
746
+ token = payment_method.token
747
+
748
+ found_credit_card = Braintree::CreditCard.find(token)
749
+ found_credit_card.should_not be_nil
750
+ end
751
+ end
752
+
753
753
  describe "self.find" do
754
754
  context "credit cards" do
755
755
  it "finds the payment method with the given token" do
@@ -882,10 +882,10 @@ describe Braintree::PaymentMethod do
882
882
  android_pay_card.expiration_year.to_i.should > 0
883
883
  android_pay_card.default.should == true
884
884
  android_pay_card.image_url.should =~ /android_pay/
885
- android_pay_card.source_card_type.should == Braintree::CreditCard::CardType::Visa
885
+ android_pay_card.source_card_type.should == Braintree::CreditCard::CardType::Discover
886
886
  android_pay_card.source_card_last_4.should == "1111"
887
887
  android_pay_card.google_transaction_id.should == "google_transaction_id"
888
- android_pay_card.source_description.should == "Visa 1111"
888
+ android_pay_card.source_description.should == "Discover 1111"
889
889
  android_pay_card.customer_id.should == customer.id
890
890
  end
891
891
 
@@ -1393,6 +1393,30 @@ describe Braintree::PaymentMethod do
1393
1393
  end
1394
1394
  end
1395
1395
 
1396
+ describe "self.update!" do
1397
+ it "updates the credit card" do
1398
+ customer = Braintree::Customer.create!
1399
+ credit_card = Braintree::CreditCard.create!(
1400
+ :cardholder_name => "Original Holder",
1401
+ :customer_id => customer.id,
1402
+ :cvv => "123",
1403
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1404
+ :expiration_date => "05/2012"
1405
+ )
1406
+ payment_method = Braintree::PaymentMethod.update!(credit_card.token,
1407
+ :cardholder_name => "New Holder",
1408
+ :cvv => "456",
1409
+ :number => Braintree::Test::CreditCardNumbers::MasterCard,
1410
+ :expiration_date => "06/2013"
1411
+ )
1412
+ payment_method.should == credit_card
1413
+ payment_method.cardholder_name.should == "New Holder"
1414
+ payment_method.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
1415
+ payment_method.last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
1416
+ payment_method.expiration_date.should == "06/2013"
1417
+ end
1418
+ end
1419
+
1396
1420
  context "payment method grant and revoke" do
1397
1421
  before(:each) do
1398
1422
  @partner_merchant_gateway = Braintree::Gateway.new(
@@ -1529,60 +1553,6 @@ describe Braintree::PaymentMethod do
1529
1553
  )
1530
1554
  result.should_not be_success
1531
1555
  end
1532
-
1533
- it "revokes grants upon deletion if :revoke_all_grants is true" do
1534
- customer_result = @partner_merchant_gateway.customer.create()
1535
- token = @partner_merchant_gateway.payment_method.create({
1536
- :payment_method_nonce => Braintree::Test::Nonce::Transactable,
1537
- :customer_id => customer_result.customer.id
1538
- }).payment_method.token
1539
-
1540
- code = Braintree::OAuthTestHelper.create_grant(@oauth_gateway, {
1541
- :merchant_public_id => "integration_merchant_id",
1542
- :scope => "grant_payment_method"
1543
- })
1544
- access_token_result = @oauth_gateway.oauth.create_token_from_code({
1545
- :code => code,
1546
- :scope => "grant_payment_method"
1547
- }).credentials
1548
-
1549
- access_token_gateway = Braintree::Gateway.new({
1550
- :access_token => access_token_result.access_token
1551
- })
1552
-
1553
- grant_result = access_token_gateway.payment_method.grant(token, {
1554
- :allow_vaulting => true,
1555
- :include_billing_postal_code => true,
1556
- })
1557
-
1558
- grant_result.should be_success
1559
-
1560
- delete_result = @partner_merchant_gateway.payment_method.delete(token, {
1561
- :revoke_all_grants => true
1562
- })
1563
-
1564
- delete_result.should be_success
1565
-
1566
- new_customer_result = Braintree::Customer.create({
1567
- :first_name => "Joe",
1568
- :last_name => "Brown",
1569
- :company => "ExampleCo",
1570
- :email => "joe@example.com",
1571
- :phone => "312.555.1234",
1572
- :fax => "614.555.5678",
1573
- :website => "www.example.com"
1574
- })
1575
-
1576
- # Revocations don't happen immediately so we add this.
1577
- sleep(6)
1578
-
1579
- token_request = Braintree::PaymentMethod.create({
1580
- :payment_method_nonce => grant_result.payment_method_nonce.nonce,
1581
- :customer_id => new_customer_result.customer.id
1582
- })
1583
-
1584
- token_request.should_not be_success
1585
- end
1586
1556
  end
1587
1557
  end
1588
1558
  end
@@ -1229,6 +1229,19 @@ describe Braintree::Subscription do
1229
1229
  end
1230
1230
  end
1231
1231
 
1232
+ describe "self.cancel!" do
1233
+ it "returns a updated subscription if valid" do
1234
+ subscription = Braintree::Subscription.create!(
1235
+ :payment_method_token => @credit_card.token,
1236
+ :price => 54.32,
1237
+ :plan_id => SpecHelper::TriallessPlan[:id]
1238
+ )
1239
+
1240
+ updated_subscription = Braintree::Subscription.cancel!(subscription.id)
1241
+ updated_subscription.status.should == Braintree::Subscription::Status::Canceled
1242
+ end
1243
+ end
1244
+
1232
1245
  describe "self.search" do
1233
1246
  describe "in_trial_period" do
1234
1247
  it "works in the affirmative" do
@@ -161,47 +161,6 @@ describe Braintree::Transaction, "search" do
161
161
  collection.first.id.should == transaction.id
162
162
  end
163
163
 
164
- context "SEPA bank account transactions" do
165
- it "does" do
166
- with_altpay_merchant do
167
- config = Braintree::Configuration.instantiate
168
- customer = Braintree::Customer.create.customer
169
- raw_client_token = Braintree::ClientToken.generate(:customer_id => customer.id, :sepa_mandate_type => Braintree::EuropeBankAccount::MandateType::Business)
170
- client_token = decode_client_token(raw_client_token)
171
- authorization_fingerprint = client_token["authorizationFingerprint"]
172
- http = ClientApiHttp.new(
173
- config,
174
- :authorization_fingerprint => authorization_fingerprint
175
- )
176
-
177
- nonce = http.create_europe_bank_account_nonce(
178
- :accountHolderName => "Bob Holder",
179
- :iban => "DE89370400440532013000",
180
- :bic => "DEUTDEFF",
181
- :locale => "en-US",
182
- :billingAddress => {
183
- :region => "Hesse",
184
- :country_name => "Germany"
185
- }
186
- )
187
- nonce.should_not == nil
188
-
189
- transaction = Braintree::Transaction.sale!(
190
- :amount => Braintree::Test::TransactionAmounts::Authorize,
191
- :payment_method_nonce => nonce,
192
- :merchant_account_id => "fake_sepa_ma"
193
- )
194
-
195
- collection = Braintree::Transaction.search do |search|
196
- search.europe_bank_account_iban.is "DE89370400440532013000"
197
- end
198
-
199
- collection.maximum_size.should >= 1
200
- collection.map(&:id).should include(transaction.id)
201
- end
202
- end
203
- end
204
-
205
164
  context "multiple value fields" do
206
165
  it "searches on created_using" do
207
166
  transaction = Braintree::Transaction.sale!(
@@ -1402,7 +1402,7 @@ describe Braintree::Transaction do
1402
1402
  android_pay_details.virtual_card_type.should == Braintree::CreditCard::CardType::Discover
1403
1403
  android_pay_details.last_4.should == "1117"
1404
1404
  android_pay_details.virtual_card_last_4.should == "1117"
1405
- android_pay_details.source_description.should == "Visa 1111"
1405
+ android_pay_details.source_description.should == "Discover 1111"
1406
1406
  android_pay_details.expiration_month.to_i.should > 0
1407
1407
  android_pay_details.expiration_year.to_i.should > 0
1408
1408
  android_pay_details.google_transaction_id.should == "google_transaction_id"
@@ -1472,6 +1472,17 @@ describe Braintree::Transaction do
1472
1472
  venmo_account_details.source_description.should == "Venmo Account: venmojoe"
1473
1473
  end
1474
1474
 
1475
+ it "can create a transaction with a fake venmo account nonce specifying a profile" do
1476
+ result = Braintree::Transaction.create(
1477
+ :type => "sale",
1478
+ :merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
1479
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1480
+ :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
1481
+ :options => {:store_in_vault => true, :venmo => {:profile_id => "integration_venmo_merchant_public_id" }}
1482
+ )
1483
+ result.should be_success
1484
+ end
1485
+
1475
1486
  it "can create a transaction with an unknown nonce" do
1476
1487
  customer = Braintree::Customer.create!
1477
1488
  result = Braintree::Transaction.create(
@@ -19,6 +19,9 @@ describe Braintree::DisputeSearch do
19
19
  :amount_disputed,
20
20
  :amount_won,
21
21
  :case_number,
22
+ :customer_id,
23
+ :disbursement_date,
24
+ :effective_date,
22
25
  :id,
23
26
  :merchant_account_id,
24
27
  :reason_code,
@@ -372,5 +372,4 @@ describe Braintree::Transaction do
372
372
  )
373
373
  end
374
374
  end
375
-
376
375
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braintree
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.83.0
4
+ version: 2.84.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-08 00:00:00.000000000 Z
11
+ date: 2018-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -182,6 +182,7 @@ files:
182
182
  - spec/fixtures/files/gif_extension_bt_logo.gif
183
183
  - spec/fixtures/files/malformed_pdf.pdf
184
184
  - spec/hacks/tcp_socket.rb
185
+ - spec/httpsd.pid
185
186
  - spec/integration/braintree/add_on_spec.rb
186
187
  - spec/integration/braintree/address_spec.rb
187
188
  - spec/integration/braintree/advanced_search_spec.rb
@@ -296,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
297
  version: '0'
297
298
  requirements: []
298
299
  rubyforge_project: braintree
299
- rubygems_version: 2.6.14
300
+ rubygems_version: 2.2.2
300
301
  signing_key:
301
302
  specification_version: 4
302
303
  summary: Braintree Gateway Ruby Client Library