braintree 4.10.0 → 4.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d00fc1e35be1af3de05492fc2300a27ff643adec2d6c600088240c54f3ce59cf
4
- data.tar.gz: 5c8d2d3aa4e16d587dd83cda3aa5d5f0cda4d17414557564a0754857f4ca706b
3
+ metadata.gz: bfe8849002c4dbacd2476b61311adc19f0939a2c42bb61ccf2ca797d59248054
4
+ data.tar.gz: 7f97e328fdd729365a0117bc8297edac4e12e8e383e8c7b10b06f74862bd8e34
5
5
  SHA512:
6
- metadata.gz: b289dbe733557dd65754f36c2e8e592160619d3ea0222e3d645cbea2711752933f9b403140eb3b666531b0cb2372a58fc45f5286e37de111d2fb041d87f41d2a
7
- data.tar.gz: 4cdc5ed40d74adfd3d6b6cb3ad622670200f6c60bc9a5314c457e8bfb886265284ff8d62645ffa88d82f7bec6b10816e3919959e527238640e3f932b2b57b821
6
+ metadata.gz: 20e3ed69efa6b094974b3461165a3197958df6e62be5f9952d676d14c7411bdae5c2169b2f0e86eab743a94475f436baf3b907ff1dab4a45e984eafa741e3356
7
+ data.tar.gz: b7e5bcbe3a4c57e6aa2a60016e93b0adff02b9dd51601370d94f08d56307e319b19381274e032eb8bd80fffa4ecf5a8c601c3da9e17e38526a8860d981a7d471
@@ -46,11 +46,24 @@ module Braintree
46
46
 
47
47
  def self._create_signature
48
48
  [
49
- {:options => [:amount, :merchant_account_id, :account_type]},
50
- {:credit_card => [
51
- :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year,
52
- :number, {:billing_address => AddressGateway._shared_signature}
53
- ]}
49
+ {:credit_card => [
50
+ :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year,
51
+ :number, {:billing_address => AddressGateway._shared_signature}
52
+ ]},
53
+ :intended_transaction_source,
54
+ {:options => [:amount, :merchant_account_id, :account_type]},
55
+ :payment_method_nonce,
56
+ :three_d_secure_authentication_id,
57
+ {:three_d_secure_pass_thru => [
58
+ :eci_flag,
59
+ :cavv,
60
+ :xid,
61
+ :three_d_secure_version,
62
+ :authentication_response,
63
+ :directory_response,
64
+ :cavv_algorithm,
65
+ :ds_transaction_id,
66
+ ]},
54
67
  ]
55
68
  end
56
69
  end
@@ -83,6 +83,7 @@ module Braintree
83
83
  ExpirationYearIsInvalid = "81713"
84
84
  InvalidParamsForCreditCardUpdate = "91745"
85
85
  InvalidVenmoSDKPaymentMethodCode = "91727"
86
+ NetworkTokenizationAttributeCryptogramIsRequired = "81762"
86
87
  NumberIsInvalid = "81715"
87
88
  NumberIsProhibited = "81750"
88
89
  NumberIsRequired = "81714"
@@ -12,12 +12,14 @@ module Braintree
12
12
  attr_reader :last_4
13
13
  attr_reader :mandate_type
14
14
  attr_reader :merchant_or_partner_customer_id
15
+ attr_reader :subscriptions
15
16
  attr_reader :token
16
17
  attr_reader :updated_at
17
18
  attr_reader :view_mandate_url
18
19
 
19
20
  def initialize(gateway, attributes) # :nodoc:
20
21
  @gateway = gateway
22
+ @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
21
23
  set_instance_variables_from_hash(attributes)
22
24
  end
23
25
 
@@ -67,6 +67,10 @@ module Braintree
67
67
  def venmo_sdk?
68
68
  @venmo_sdk
69
69
  end
70
+
71
+ def is_network_tokenized?
72
+ @is_network_tokenized
73
+ end
70
74
  end
71
75
  end
72
76
  end
@@ -127,8 +127,11 @@ module Braintree
127
127
  attr_reader :installments
128
128
  attr_reader :local_payment_details
129
129
  attr_reader :merchant_account_id
130
+ attr_reader :merchant_advice_code
131
+ attr_reader :merchant_advice_code_text
130
132
  attr_reader :network_response_code # Response code from the card network
131
133
  attr_reader :network_response_text # Response text from the card network
134
+ attr_reader :network_token_details
132
135
  attr_reader :network_transaction_id
133
136
  attr_reader :order_id
134
137
  attr_reader :partial_settlement_transaction_ids
@@ -299,6 +302,7 @@ module Braintree
299
302
  @apple_pay_details = ApplePayDetails.new(@apple_pay)
300
303
  @billing_details = AddressDetails.new(@billing)
301
304
  @credit_card_details = CreditCardDetails.new(@credit_card)
305
+ @network_token_details = CreditCardDetails.new(@network_token)
302
306
  @custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {}
303
307
  @customer_details = CustomerDetails.new(@customer)
304
308
  @descriptor = Descriptor.new(@descriptor)
@@ -195,7 +195,7 @@ module Braintree
195
195
  :sca_exemption, :currency_iso_code, :exchange_rate_quote_id,
196
196
  {:line_items => [:quantity, :name, :description, :kind, :unit_amount, :unit_tax_amount, :total_amount, :discount_amount, :tax_amount, :unit_of_measure, :product_code, :commodity_code, :url]},
197
197
  {:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
198
- {:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}]},
198
+ {:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}, {:network_tokenization_attributes => [:cryptogram, :ecommerce_indicator, :token_requestor_id]}]},
199
199
  {:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
200
200
  {
201
201
  :billing => AddressGateway._shared_signature
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 4
4
- Minor = 10
4
+ Minor = 12
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -576,66 +576,6 @@ describe Braintree::CreditCard do
576
576
  end
577
577
  end
578
578
 
579
- context "venmo_sdk" do
580
- describe "venmo_sdk_payment_method_code" do
581
- it "can pass a venmo sdk payment method code" do
582
- customer = Braintree::Customer.create!
583
- result = Braintree::CreditCard.create(
584
- :customer_id => customer.id,
585
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode,
586
- )
587
- result.success?.should == true
588
- result.credit_card.venmo_sdk?.should == false
589
- result.credit_card.bin.should == "400934"
590
- result.credit_card.last_4.should == "1881"
591
- end
592
-
593
- it "success? returns false when given an invalid venmo sdk payment method code" do
594
- customer = Braintree::Customer.create!
595
- result = Braintree::CreditCard.create(
596
- :customer_id => customer.id,
597
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode,
598
- )
599
-
600
- result.success?.should == false
601
- result.message.should == "Invalid VenmoSDK payment method code"
602
- result.errors.first.code.should == "91727"
603
- end
604
- end
605
-
606
- describe "venmo_sdk_session" do
607
- it "venmo_sdk? returns true when given a valid session" do
608
- customer = Braintree::Customer.create!
609
- result = Braintree::CreditCard.create(
610
- :customer_id => customer.id,
611
- :number => Braintree::Test::CreditCardNumbers::Visa,
612
- :expiration_date => "05/2009",
613
- :cvv => "100",
614
- :options => {
615
- :venmo_sdk_session => Braintree::Test::VenmoSDK::Session
616
- },
617
- )
618
- result.success?.should == true
619
- result.credit_card.venmo_sdk?.should == false
620
- end
621
-
622
- it "venmo_sdk? returns false when given an invalid session" do
623
- customer = Braintree::Customer.create!
624
- result = Braintree::CreditCard.create(
625
- :customer_id => customer.id,
626
- :number => Braintree::Test::CreditCardNumbers::Visa,
627
- :expiration_date => "05/2009",
628
- :cvv => "100",
629
- :options => {
630
- :venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession
631
- },
632
- )
633
- result.success?.should == true
634
- result.credit_card.venmo_sdk?.should == false
635
- end
636
- end
637
- end
638
-
639
579
  context "client API" do
640
580
  it "adds credit card to an existing customer using a payment method nonce" do
641
581
  nonce = nonce_for_new_payment_method(
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
2
3
 
3
4
  describe Braintree::CreditCardVerification, "search" do
4
5
 
@@ -11,7 +12,7 @@ describe Braintree::CreditCardVerification, "search" do
11
12
  },
12
13
  :options => {
13
14
  :amount => "10.00"
14
- }
15
+ },
15
16
  }
16
17
 
17
18
  result = Braintree::CreditCardVerification.create(verification_params)
@@ -259,4 +260,126 @@ describe Braintree::CreditCardVerification, "search" do
259
260
  end
260
261
  end
261
262
  end
263
+
264
+ describe "intended transaction source" do
265
+ it "creates a new verification with intended transaction source installment" do
266
+ verification_params = {
267
+ :credit_card => {
268
+ :expiration_date => "05/2029",
269
+ :number => Braintree::Test::CreditCardNumbers::Visa,
270
+ },
271
+ :options => {
272
+ :amount => "10.00"
273
+ },
274
+ :intended_transaction_source => "installment"
275
+ }
276
+
277
+ result = Braintree::CreditCardVerification.create(verification_params)
278
+
279
+ result.should be_success
280
+ result.credit_card_verification.id.should =~ /^\w{6,}$/
281
+ result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::Verified
282
+ result.credit_card_verification.processor_response_code.should == "1000"
283
+ result.credit_card_verification.processor_response_text.should == "Approved"
284
+ result.credit_card_verification.processor_response_type.should == Braintree::ProcessorResponseTypes::Approved
285
+ expect(result.credit_card_verification.network_transaction_id).not_to be_nil
286
+ end
287
+ end
288
+
289
+ context "three_d_secure" do
290
+ it "can create a verification with a three_d_secure_authentication_id" do
291
+ three_d_secure_authentication_id = SpecHelper.create_3ds_verification(
292
+ SpecHelper::ThreeDSecureMerchantAccountId,
293
+ :number => Braintree::Test::CreditCardNumbers::Visa,
294
+ :expiration_month => "12",
295
+ :expiration_year => "2029",
296
+ )
297
+
298
+ verification_params = {
299
+ :credit_card => {
300
+ :expiration_date => "12/2029",
301
+ :number => Braintree::Test::CreditCardNumbers::Visa,
302
+ },
303
+ :options => {
304
+ :amount => "10.00",
305
+ :merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
306
+ },
307
+ :three_d_secure_authentication_id => three_d_secure_authentication_id,
308
+ }
309
+
310
+ result = Braintree::CreditCardVerification.create(verification_params)
311
+
312
+ result.should be_success
313
+ result.credit_card_verification.id.should =~ /^\w{6,}$/
314
+ result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::Verified
315
+ result.credit_card_verification.processor_response_code.should == "1000"
316
+ result.credit_card_verification.processor_response_text.should == "Approved"
317
+ result.credit_card_verification.processor_response_type.should == Braintree::ProcessorResponseTypes::Approved
318
+ expect(result.credit_card_verification.network_transaction_id).not_to be_nil
319
+ end
320
+
321
+ it "can create a verification with a payment_method_nonce" do
322
+ nonce = nonce_for_new_payment_method(
323
+ :credit_card => {
324
+ :number => Braintree::Test::CreditCardNumbers::Visa,
325
+ :expiration_month => "11",
326
+ :expiration_year => "2099",
327
+ },
328
+ )
329
+ nonce.should_not be_nil
330
+
331
+ verification_params = {
332
+ :credit_card => {
333
+ :number => Braintree::Test::CreditCardNumbers::Visa,
334
+ },
335
+ :options => {
336
+ :amount => "10.00",
337
+ :merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
338
+ },
339
+ :payment_method_nonce => nonce,
340
+ }
341
+
342
+ result = Braintree::CreditCardVerification.create(verification_params)
343
+
344
+ result.should be_success
345
+ result.credit_card_verification.id.should =~ /^\w{6,}$/
346
+ result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::Verified
347
+ result.credit_card_verification.processor_response_code.should == "1000"
348
+ result.credit_card_verification.processor_response_text.should == "Approved"
349
+ result.credit_card_verification.processor_response_type.should == Braintree::ProcessorResponseTypes::Approved
350
+ expect(result.credit_card_verification.network_transaction_id).not_to be_nil
351
+ end
352
+
353
+ it "can create a verification with a verification_three_d_secure_pass_thru" do
354
+ verification_params = {
355
+ :credit_card => {
356
+ :number => Braintree::Test::CreditCardNumbers::Visa,
357
+ :expiration_date => "12/12",
358
+ },
359
+ :options => {
360
+ :amount => "10.00",
361
+ },
362
+ :three_d_secure_pass_thru => {
363
+ :eci_flag => "02",
364
+ :cavv => "some_cavv",
365
+ :xid => "some_xid",
366
+ :three_d_secure_version => "1.0.2",
367
+ :authentication_response => "Y",
368
+ :directory_response => "Y",
369
+ :cavv_algorithm => "2",
370
+ :ds_transaction_id => "some_ds_id",
371
+ },
372
+ }
373
+
374
+ result = Braintree::CreditCardVerification.create(verification_params)
375
+
376
+ result.should be_success
377
+ result.credit_card_verification.id.should =~ /^\w{6,}$/
378
+ result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::Verified
379
+ result.credit_card_verification.processor_response_code.should == "1000"
380
+ result.credit_card_verification.processor_response_text.should == "Approved"
381
+ result.credit_card_verification.processor_response_type.should == Braintree::ProcessorResponseTypes::Approved
382
+ expect(result.credit_card_verification.network_transaction_id).not_to be_nil
383
+ end
384
+ end
262
385
  end
@@ -566,37 +566,6 @@ describe Braintree::Customer do
566
566
  result.errors.for(:customer).on(:custom_fields)[0].message.should == "Custom field is invalid: spouse_name."
567
567
  end
568
568
 
569
- describe "venmo_sdk" do
570
- it "can create a customer with a venmo sdk payment method code" do
571
- result = Braintree::Customer.create(
572
- :first_name => "Steve",
573
- :last_name => "Hamlin",
574
- :credit_card => {
575
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
576
- },
577
- )
578
- result.success?.should == true
579
- result.customer.credit_cards.first.bin.should == "400934"
580
- result.customer.credit_cards.first.last_4.should == "1881"
581
- end
582
-
583
- it "can create a customer with a venmo sdk session" do
584
- result = Braintree::Customer.create(
585
- :first_name => "Steve",
586
- :last_name => "Hamlin",
587
- :credit_card => {
588
- :number => Braintree::Test::CreditCardNumbers::MasterCard,
589
- :expiration_date => "05/2010",
590
- :options => {
591
- :venmo_sdk_session => Braintree::Test::VenmoSDK::Session
592
- }
593
- },
594
- )
595
- result.success?.should == true
596
- result.customer.credit_cards.first.venmo_sdk?.should == false
597
- end
598
- end
599
-
600
569
  context "client API" do
601
570
  it "can create a customer with a payment method nonce" do
602
571
  nonce = nonce_for_new_payment_method(
@@ -1097,7 +1066,7 @@ describe Braintree::Customer do
1097
1066
  venmo_account.username.should_not be_nil
1098
1067
  end
1099
1068
 
1100
- it "returns associated us bank accounts" do
1069
+ xit "returns associated us bank accounts" do
1101
1070
  result = Braintree::Customer.create(
1102
1071
  :payment_method_nonce => generate_non_plaid_us_bank_account_nonce,
1103
1072
  :credit_card => {
@@ -78,20 +78,6 @@ describe Braintree::Dispute, "search" do
78
78
  dispute = collection.disputes.first
79
79
  end
80
80
 
81
- it "correctly returns chargeback protected disputes" do
82
- collection = Braintree::Dispute.search do |search|
83
- search.case_number.is "CASE-CHARGEBACK-PROTECTED"
84
- end
85
-
86
- expect(collection.disputes.count).to eq(1)
87
- dispute = collection.disputes.first
88
-
89
- # NEXT_MAJOR_VERSION Remove this assertion when chargeback_protection_level is removed from the SDK
90
- expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Effortless)
91
- expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::EffortlessCBP)
92
- expect(dispute.reason).to eq(Braintree::Dispute::Reason::Fraud)
93
- end
94
-
95
81
  it "correctly returns disputes by chargeback protection level flag" do
96
82
  collection = Braintree::Dispute.search do |search|
97
83
  search.chargeback_protection_level.in [
@@ -104,7 +90,6 @@ describe Braintree::Dispute, "search" do
104
90
  collection.disputes.each do |dispute|
105
91
  expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Effortless)
106
92
  expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::EffortlessCBP)
107
- expect(dispute.reason).to eq(Braintree::Dispute::Reason::Fraud)
108
93
  end
109
94
  end
110
95
 
@@ -151,6 +151,33 @@ describe Braintree::Dispute do
151
151
  result.evidence.sent_to_processor_at.should == nil
152
152
  result.evidence.sequence_number.should == 7
153
153
  end
154
+
155
+ it "creates text evidence for the dispute with CARRIER_NAME shipping tracking" do
156
+ result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "UPS", category: "CARRIER_NAME", sequence_number: 0})
157
+
158
+ result.success?.should == true
159
+ result.evidence.category.should == "CARRIER_NAME"
160
+ result.evidence.comment.should == "UPS"
161
+ result.evidence.sequence_number.should == 0
162
+ end
163
+
164
+ it "creates text evidence for the dispute with TRACKING_NUMBER shipping tracking" do
165
+ result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "3", category: "TRACKING_NUMBER", sequence_number: 0})
166
+
167
+ result.success?.should == true
168
+ result.evidence.category.should == "TRACKING_NUMBER"
169
+ result.evidence.comment.should == "3"
170
+ result.evidence.sequence_number.should == 0
171
+ end
172
+
173
+ it "creates text evidence for the dispute with TRACKING_URL shipping tracking" do
174
+ result = Braintree::Dispute.add_text_evidence(dispute.id, {content: "https://example.com/tracking-number/abc12345", category: "TRACKING_URL", sequence_number: 1})
175
+
176
+ result.success?.should == true
177
+ result.evidence.category.should == "TRACKING_URL"
178
+ result.evidence.comment.should == "https://example.com/tracking-number/abc12345"
179
+ result.evidence.sequence_number.should == 1
180
+ end
154
181
  end
155
182
 
156
183
  describe "self.finalize" do
@@ -97,7 +97,7 @@ describe Braintree::Http do
97
97
  end
98
98
 
99
99
  describe "ssl_version" do
100
- it "causes failed requests to sandbox with incompatible SSL version" do
100
+ xit "causes failed requests to sandbox with incompatible SSL version" do
101
101
  begin
102
102
  original_env = Braintree::Configuration.environment
103
103
  Braintree::Configuration.environment = :sandbox
@@ -50,6 +50,26 @@ describe Braintree::SepaDirectDebitAccount do
50
50
  }.to raise_error(Braintree::NotFoundError)
51
51
  end
52
52
  end
53
+
54
+ context "subscriptions" do
55
+ it "returns subscriptions associated with a SEPA direct debit account" do
56
+ customer = Braintree::Customer.create!
57
+
58
+ subscription1 = Braintree::Subscription.create(
59
+ :payment_method_token => token,
60
+ :plan_id => SpecHelper::TriallessPlan[:id],
61
+ ).subscription
62
+
63
+ subscription2 = Braintree::Subscription.create(
64
+ :payment_method_token => token,
65
+ :plan_id => SpecHelper::TriallessPlan[:id],
66
+ ).subscription
67
+
68
+ sepa_debit_account = Braintree::SepaDirectDebitAccount.find(token)
69
+ subscription_ids = sepa_debit_account.subscriptions.map { |h| h[:id] }.sort
70
+ expect(subscription_ids).to eq([subscription1.id, subscription2.id].sort)
71
+ end
72
+ end
53
73
  end
54
74
 
55
75
  describe "self.delete" do
@@ -1002,10 +1002,12 @@ describe Braintree::Transaction do
1002
1002
  result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::TokenIssuance
1003
1003
  end
1004
1004
 
1005
- it "exposes the excessive_retry gateway rejection reason" do
1005
+ xit "exposes the excessive_retry gateway rejection reason" do
1006
1006
  with_duplicate_checking_merchant do
1007
1007
  result = nil
1008
- 16.times do
1008
+ counter = 0
1009
+ excessive_retry = false
1010
+ until excessive_retry || counter == 20
1009
1011
  result = Braintree::Transaction.sale(
1010
1012
  :amount => Braintree::Test::TransactionAmounts::Decline,
1011
1013
  :credit_card => {
@@ -1014,9 +1016,10 @@ describe Braintree::Transaction do
1014
1016
  :expiration_year => "2011"
1015
1017
  },
1016
1018
  )
1019
+ excessive_retry = result.transaction.status == "gateway_rejected"
1020
+ counter +=1
1017
1021
  end
1018
- result.success?.should == false
1019
- result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::ExcessiveRetry
1022
+ expect(result.transaction.gateway_rejection_reason). to eq(Braintree::Transaction::GatewayRejectionReason::ExcessiveRetry)
1020
1023
  end
1021
1024
  end
1022
1025
  end
@@ -1504,6 +1507,32 @@ describe Braintree::Transaction do
1504
1507
  result.transaction.recurring.should == true
1505
1508
  end
1506
1509
 
1510
+ it "successfully creates a transaction with installment_first" do
1511
+ result = Braintree::Transaction.create(
1512
+ :type => "sale",
1513
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1514
+ :credit_card => {
1515
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1516
+ :expiration_date => "12/12",
1517
+ },
1518
+ :transaction_source => "installment_first",
1519
+ )
1520
+ result.success?.should == true
1521
+ end
1522
+
1523
+ it "successfully creates a transaction with installment" do
1524
+ result = Braintree::Transaction.create(
1525
+ :type => "sale",
1526
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1527
+ :credit_card => {
1528
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1529
+ :expiration_date => "12/12",
1530
+ },
1531
+ :transaction_source => "installment",
1532
+ )
1533
+ result.success?.should == true
1534
+ end
1535
+
1507
1536
  it "marks a transactions as merchant" do
1508
1537
  result = Braintree::Transaction.create(
1509
1538
  :type => "sale",
@@ -1728,35 +1757,6 @@ describe Braintree::Transaction do
1728
1757
  end
1729
1758
  end
1730
1759
 
1731
- describe "venmo_sdk" do
1732
- it "can create a card with a venmo sdk payment method code" do
1733
- result = Braintree::Transaction.create(
1734
- :type => "sale",
1735
- :amount => Braintree::Test::TransactionAmounts::Authorize,
1736
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode,
1737
- )
1738
- result.success?.should == true
1739
- result.transaction.credit_card_details.bin.should == "400934"
1740
- result.transaction.credit_card_details.last_4.should == "1881"
1741
- end
1742
-
1743
- it "can create a transaction with venmo sdk session" do
1744
- result = Braintree::Transaction.create(
1745
- :type => "sale",
1746
- :amount => Braintree::Test::TransactionAmounts::Authorize,
1747
- :credit_card => {
1748
- :number => Braintree::Test::CreditCardNumbers::Visa,
1749
- :expiration_date => "12/12",
1750
- },
1751
- :options => {
1752
- :venmo_sdk_session => Braintree::Test::VenmoSDK::Session
1753
- },
1754
- )
1755
- result.success?.should == true
1756
- result.transaction.credit_card_details.venmo_sdk?.should == false
1757
- end
1758
- end
1759
-
1760
1760
  context "client API" do
1761
1761
  it "can create a transaction with a shared card nonce" do
1762
1762
  nonce = nonce_for_new_payment_method(
@@ -5226,6 +5226,49 @@ describe Braintree::Transaction do
5226
5226
  end
5227
5227
  end
5228
5228
 
5229
+
5230
+ context "3rd party Card on File Network Token" do
5231
+ it "Works with all params" do
5232
+ params = {
5233
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
5234
+ :credit_card => {
5235
+ :number => Braintree::Test::CreditCardNumbers::Visa,
5236
+ :expiration_date => "05/2009",
5237
+ :network_tokenization_attributes => {
5238
+ :cryptogram => "/wAAAAAAAcb8AlGUF/1JQEkAAAA=",
5239
+ :ecommerce_indicator => "05",
5240
+ :token_requestor_id => "45310020105"
5241
+ },
5242
+ }
5243
+ }
5244
+ result = Braintree::Transaction.sale(params)
5245
+ expect(result.success?).to eq true
5246
+ expect(result.transaction.status).to eq Braintree::Transaction::Status::Authorized
5247
+ expect(result.transaction.processed_with_network_token?).to eq true
5248
+
5249
+ network_token_details = result.transaction.network_token_details
5250
+ expect(network_token_details.is_network_tokenized?).to eq true
5251
+ end
5252
+
5253
+ it "returns errors if validations on cryptogram fails" do
5254
+ params = {
5255
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
5256
+ :credit_card => {
5257
+ :number => Braintree::Test::CreditCardNumbers::Visa,
5258
+ :expiration_date => "05/2009",
5259
+ :network_tokenization_attributes => {
5260
+ :ecommerce_indicator => "05",
5261
+ :token_requestor_id => "45310020105"
5262
+ },
5263
+ }
5264
+ }
5265
+ result = Braintree::Transaction.sale(params)
5266
+
5267
+ expect(result.success?).to eq(false)
5268
+ expect(result.errors.for(:transaction).for(:credit_card).map { |e| e.code }.sort).to eq [Braintree::ErrorCodes::CreditCard::NetworkTokenizationAttributeCryptogramIsRequired]
5269
+ end
5270
+ end
5271
+
5229
5272
  xit "Amex Pay with Points" do
5230
5273
  context "transaction creation" do
5231
5274
  it "succeeds when submit_for_settlement is true" do
@@ -6668,61 +6711,6 @@ describe Braintree::Transaction do
6668
6711
  Braintree::Transaction.find(transaction.id)
6669
6712
  end
6670
6713
 
6671
- context "venmo sdk" do
6672
- describe "venmo_sdk_payment_method_code" do
6673
- it "can create a transaction with venmo_sdk_payment_method_code" do
6674
- result = Braintree::Transaction.sale(
6675
- :amount => "10.00",
6676
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK.generate_test_payment_method_code(Braintree::Test::CreditCardNumbers::Visa),
6677
- )
6678
- result.success?.should == true
6679
- result.transaction.credit_card_details.venmo_sdk?.should == false
6680
- end
6681
-
6682
- it "errors when an invalid payment method code is passed" do
6683
- result = Braintree::Transaction.sale(
6684
- :amount => "10.00",
6685
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode,
6686
- )
6687
- result.success?.should == false
6688
- result.message.should include("Invalid VenmoSDK payment method code")
6689
- result.errors.map(&:code).should include("91727")
6690
- end
6691
- end
6692
-
6693
- describe "venmo_sdk_session" do
6694
- it "can create a transaction and vault a card when a venmo_sdk_session is present" do
6695
- result = Braintree::Transaction.sale(
6696
- :amount => "10.00",
6697
- :credit_card => {
6698
- :number => Braintree::Test::CreditCardNumbers::Visa,
6699
- :expiration_date => "05/2009"
6700
- },
6701
- :options => {
6702
- :venmo_sdk_session => Braintree::Test::VenmoSDK::Session
6703
- },
6704
- )
6705
- result.success?.should == true
6706
- result.transaction.credit_card_details.venmo_sdk?.should == false
6707
- end
6708
-
6709
- it "venmo_sdk boolean is false when an invalid session is passed" do
6710
- result = Braintree::Transaction.sale(
6711
- :amount => "10.00",
6712
- :credit_card => {
6713
- :number => Braintree::Test::CreditCardNumbers::Visa,
6714
- :expiration_date => "05/2009"
6715
- },
6716
- :options => {
6717
- :venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession
6718
- },
6719
- )
6720
- result.success?.should == true
6721
- result.transaction.credit_card_details.venmo_sdk?.should == false
6722
- end
6723
- end
6724
- end
6725
-
6726
6714
  context "paypal" do
6727
6715
  it "can create a transaction for a paypal account" do
6728
6716
  result = Braintree::Transaction.sale(
@@ -7273,4 +7261,19 @@ describe Braintree::Transaction do
7273
7261
  end
7274
7262
  end
7275
7263
  end
7264
+
7265
+ context "Merchant Advice Code" do
7266
+ it "exposes MAC and MAC text" do
7267
+ result = Braintree::Transaction.create(
7268
+ :type => "sale",
7269
+ :amount => Braintree::Test::TransactionAmounts::Decline,
7270
+ :credit_card => {
7271
+ :number => Braintree::Test::CreditCardNumbers::MasterCard,
7272
+ :expiration_date => DateTime.now.strftime("%m/%Y")
7273
+ },
7274
+ )
7275
+ expect(result.transaction.merchant_advice_code).to eq("01")
7276
+ expect(result.transaction.merchant_advice_code_text).to eq("New account information available")
7277
+ end
7278
+ end
7276
7279
  end
@@ -0,0 +1,51 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::CreditCardVerificationGateway do
4
+ describe "Credit Card Verification Gateway" do
5
+ let(:gateway) do
6
+ config = Braintree::Configuration.new(
7
+ :merchant_id => "merchant_id",
8
+ :public_key => "public_key",
9
+ :private_key => "private_key",
10
+ )
11
+ Braintree::Gateway.new(config)
12
+ end
13
+
14
+ it "creates a credit card verification gateway" do
15
+ result = Braintree::CreditCardVerificationGateway.new(gateway)
16
+
17
+ result.inspect.should include("merchant_id")
18
+ result.inspect.should include("public_key")
19
+ result.inspect.should include("private_key")
20
+ end
21
+
22
+ it "creates a credit card verification gateway signature" do
23
+ result = Braintree::CreditCardVerificationGateway._create_signature
24
+ result.inspect.should include("credit_card")
25
+ result.inspect.should include("credit_card")
26
+ result.inspect.should include("cardholder_name")
27
+ result.inspect.should include("cvv")
28
+ result.inspect.should include("expiration_date")
29
+ result.inspect.should include("expiration_month")
30
+ result.inspect.should include("expiration_year")
31
+ result.inspect.should include("number")
32
+ result.inspect.should include("billing_address")
33
+ result.inspect.should include("intended_transaction_source")
34
+ result.inspect.should include("options")
35
+ result.inspect.should include("amount")
36
+ result.inspect.should include("merchant_account_id")
37
+ result.inspect.should include("account_type")
38
+ result.inspect.should include("payment_method_nonce")
39
+ result.inspect.should include("three_d_secure_authentication_id")
40
+ result.inspect.should include("three_d_secure_pass_thru")
41
+ result.inspect.should include("eci_flag")
42
+ result.inspect.should include("cavv")
43
+ result.inspect.should include("xid")
44
+ result.inspect.should include("three_d_secure_version")
45
+ result.inspect.should include("authentication_response")
46
+ result.inspect.should include("directory_response")
47
+ result.inspect.should include("cavv_algorithm")
48
+ result.inspect.should include("ds_transaction_id")
49
+ end
50
+ end
51
+ end
@@ -15,18 +15,19 @@ describe Braintree::SepaDirectDebitAccount do
15
15
  let(:params) do
16
16
  {
17
17
  bank_reference_token: "a-reference-token",
18
- mandate_type: "ONE_OFF",
19
- last_4: "4321",
20
- merchant_or_partner_customer_id: "a-mp-customer-id",
21
- customer_id: "a-customer-id",
18
+ created_at: Time.now,
22
19
  customer_global_id: "a-customer-global-id",
20
+ customer_id: "a-customer-id",
23
21
  default: true,
24
- token: "a-token",
25
22
  global_id: "a-global-id",
26
23
  image_url: "a-image-url",
27
- view_mandate_url: "a-view-mandate-url",
28
- created_at: Time.now,
24
+ last_4: "4321",
25
+ mandate_type: "ONE_OFF",
26
+ merchant_or_partner_customer_id: "a-mp-customer-id",
27
+ subscriptions: [{price: "10.00"}],
28
+ token: "a-token",
29
29
  updated_at: Time.now,
30
+ view_mandate_url: "a-view-mandate-url",
30
31
  }
31
32
  end
32
33
 
@@ -46,4 +46,20 @@ describe Braintree::Transaction::CreditCardDetails do
46
46
  details.masked_number.should == "510510******5100"
47
47
  end
48
48
  end
49
+
50
+ describe "is_network_tokenized" do
51
+ it "returns true if is_network_tokenized is true" do
52
+ details = Braintree::Transaction::CreditCardDetails.new(
53
+ :is_network_tokenized => true,
54
+ )
55
+ details.is_network_tokenized?.should == true
56
+ end
57
+
58
+ it "returns false if is_network_tokenized is false" do
59
+ details = Braintree::Transaction::CreditCardDetails.new(
60
+ :is_network_tokenized => false,
61
+ )
62
+ details.is_network_tokenized?.should == false
63
+ end
64
+ end
49
65
  end
@@ -0,0 +1,111 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::TransactionGateway do
4
+ describe "Transaction Gateway" do
5
+ let(:gateway) do
6
+ config = Braintree::Configuration.new(
7
+ :merchant_id => "merchant_id",
8
+ :public_key => "public_key",
9
+ :private_key => "private_key",
10
+ )
11
+ Braintree::Gateway.new(config)
12
+ end
13
+
14
+ it "creates a transactionGateway gateway" do
15
+ result = Braintree::TransactionGateway.new(gateway)
16
+
17
+ result.inspect.should include("merchant_id")
18
+ result.inspect.should include("public_key")
19
+ result.inspect.should include("private_key")
20
+ end
21
+
22
+ describe "self.create" do
23
+ it "raises an exception if attributes contain an invalid key" do
24
+ expect do
25
+ transaction = Braintree::TransactionGateway.new(gateway)
26
+ transaction.create(:invalid_key => "val")
27
+ end.to raise_error(ArgumentError, "invalid keys: invalid_key")
28
+ end
29
+ end
30
+
31
+ it "creates a transaction gateway signature" do
32
+ expect(Braintree::TransactionGateway._create_signature).to match([
33
+ :amount, :billing_address_id, :channel, :customer_id, :device_data, :discount_amount,
34
+ :merchant_account_id, :order_id, :payment_method_nonce, :payment_method_token,
35
+ :product_sku, :purchase_order_number, :service_fee_amount, :shared_billing_address_id,
36
+ :shared_customer_id, :shared_payment_method_nonce, :shared_payment_method_token,
37
+ :shared_shipping_address_id, :shipping_address_id, :shipping_amount,
38
+ :ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,
39
+ :three_d_secure_token, :transaction_source, :type, :venmo_sdk_payment_method_code,
40
+ :sca_exemption, :currency_iso_code, :exchange_rate_quote_id,
41
+ {:line_items => [:quantity, :name, :description, :kind, :unit_amount, :unit_tax_amount, :total_amount, :discount_amount, :tax_amount, :unit_of_measure, :product_code, :commodity_code, :url]},
42
+ {:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
43
+ {:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}, {:network_tokenization_attributes => [:cryptogram, :ecommerce_indicator, :token_requestor_id]}]},
44
+ {:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
45
+ {
46
+ :billing => Braintree::AddressGateway._shared_signature
47
+ },
48
+ {
49
+ :shipping => Braintree::AddressGateway._shared_signature + [:shipping_method],
50
+ },
51
+ {
52
+ :three_d_secure_pass_thru => [
53
+ :eci_flag,
54
+ :cavv,
55
+ :xid,
56
+ :three_d_secure_version,
57
+ :authentication_response,
58
+ :directory_response,
59
+ :cavv_algorithm,
60
+ :ds_transaction_id,
61
+ ]
62
+ },
63
+ {:options => [
64
+ :hold_in_escrow,
65
+ :store_in_vault,
66
+ :store_in_vault_on_success,
67
+ :submit_for_settlement,
68
+ :add_billing_address_to_payment_method,
69
+ :store_shipping_address_in_vault,
70
+ :venmo_sdk_session,
71
+ :payee_id,
72
+ :payee_email,
73
+ :skip_advanced_fraud_checking,
74
+ :skip_avs,
75
+ :skip_cvv,
76
+ {:paypal => [:custom_field, :payee_id, :payee_email, :description, {:supplementary_data => :_any_key_}]},
77
+ {:three_d_secure => [:required]},
78
+ {:amex_rewards => [:request_id, :points, :currency_amount, :currency_iso_code]},
79
+ {:venmo => [:profile_id]},
80
+ {:credit_card => [:account_type]},
81
+ ]
82
+ },
83
+ {:external_vault => [
84
+ :status,
85
+ :previous_network_transaction_id,
86
+ ]},
87
+ {:custom_fields => :_any_key_},
88
+ {:descriptor => [:name, :phone, :url]},
89
+ {:paypal_account => [:email, :token, :paypal_data, :payee_id, :payee_email, :payer_id, :payment_id]},
90
+ {:industry => [
91
+ :industry_type,
92
+ {:data => [
93
+ :folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax,
94
+ :passenger_first_name, :passenger_last_name, :passenger_middle_initial, :passenger_title, :issued_date, :travel_agency_name, :travel_agency_code, :ticket_number,
95
+ :issuing_carrier_code, :customer_code, :fare_amount, :fee_amount, :tax_amount, :restricted_ticket, :no_show, :advanced_deposit, :fire_safe, :property_phone,
96
+ {:legs => [
97
+ :conjunction_ticket, :exchange_ticket, :coupon_number, :service_class, :carrier_code, :fare_basis_code, :flight_number, :departure_date, :departure_airport_code, :departure_time,
98
+ :arrival_airport_code, :arrival_time, :stopover_permitted, :fare_amount, :fee_amount, :tax_amount, :endorsement_or_restrictions,
99
+ ]},
100
+ {:additional_charges => [
101
+ :kind, :amount,
102
+ ]},
103
+ ]},
104
+ ]},
105
+ {:apple_pay_card => [:number, :cardholder_name, :cryptogram, :expiration_month, :expiration_year, :eci_indicator]},
106
+ {:google_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]},
107
+ {:installments => [:count]},
108
+ ])
109
+ end
110
+ end
111
+ end
@@ -147,6 +147,48 @@ describe Braintree::Transaction do
147
147
  transaction.credit_card_details.issuing_bank.should == "Mr Tumnus"
148
148
  end
149
149
 
150
+ it "sets up network token attributes in network_token_details" do
151
+ transaction = Braintree::Transaction._new(
152
+ :gateway,
153
+ :network_token => {
154
+ :token => "mzg2",
155
+ :bin => "411111",
156
+ :last_4 => "1111",
157
+ :card_type => "Visa",
158
+ :expiration_month => "08",
159
+ :expiration_year => "2009",
160
+ :customer_location => "US",
161
+ :prepaid => "Yes",
162
+ :healthcare => "Yes",
163
+ :durbin_regulated => "Yes",
164
+ :debit => "Yes",
165
+ :commercial => "No",
166
+ :payroll => "Unknown",
167
+ :product_id => "Unknown",
168
+ :country_of_issuance => "Narnia",
169
+ :issuing_bank => "Mr Tumnus",
170
+ :is_network_tokenized => true
171
+ },
172
+ )
173
+ transaction.network_token_details.token.should == "mzg2"
174
+ transaction.network_token_details.bin.should == "411111"
175
+ transaction.network_token_details.last_4.should == "1111"
176
+ transaction.network_token_details.card_type.should == "Visa"
177
+ transaction.network_token_details.expiration_month.should == "08"
178
+ transaction.network_token_details.expiration_year.should == "2009"
179
+ transaction.network_token_details.customer_location.should == "US"
180
+ transaction.network_token_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
181
+ transaction.network_token_details.healthcare.should == Braintree::CreditCard::Healthcare::Yes
182
+ transaction.network_token_details.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Yes
183
+ transaction.network_token_details.debit.should == Braintree::CreditCard::Debit::Yes
184
+ transaction.network_token_details.commercial.should == Braintree::CreditCard::Commercial::No
185
+ transaction.network_token_details.payroll.should == Braintree::CreditCard::Payroll::Unknown
186
+ transaction.network_token_details.product_id.should == Braintree::CreditCard::ProductId::Unknown
187
+ transaction.network_token_details.country_of_issuance.should == "Narnia"
188
+ transaction.network_token_details.issuing_bank.should == "Mr Tumnus"
189
+ transaction.network_token_details.is_network_tokenized?.should == true
190
+ end
191
+
150
192
  it "sets up three_d_secure_info" do
151
193
  transaction = Braintree::Transaction._new(
152
194
  :gateway,
@@ -256,6 +298,16 @@ describe Braintree::Transaction do
256
298
  expect(transaction.network_response_text).to eq("Successful approval/completion or V.I.P. PIN verification is successful")
257
299
  end
258
300
 
301
+ it "accepts merchant_advice_code and merchant_advice_text" do
302
+ transaction = Braintree::Transaction._new(
303
+ :gateway,
304
+ :merchant_advice_code => "01",
305
+ :merchant_advice_code_text => "New account information available",
306
+ )
307
+ expect(transaction.merchant_advice_code).to eq("01")
308
+ expect(transaction.merchant_advice_code_text).to eq("New account information available")
309
+ end
310
+
259
311
  it "accepts sepa_direct_debit_return_code" do
260
312
  transaction = Braintree::Transaction._new(
261
313
  :gateway,
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: 4.10.0
4
+ version: 4.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-11 00:00:00.000000000 Z
11
+ date: 2023-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -277,6 +277,7 @@ files:
277
277
  - spec/unit/braintree/configuration_spec.rb
278
278
  - spec/unit/braintree/credentials_parser_spec.rb
279
279
  - spec/unit/braintree/credit_card_spec.rb
280
+ - spec/unit/braintree/credit_card_verification_gateway_spec.rb
280
281
  - spec/unit/braintree/credit_card_verification_search_spec.rb
281
282
  - spec/unit/braintree/credit_card_verification_spec.rb
282
283
  - spec/unit/braintree/customer_spec.rb
@@ -322,6 +323,7 @@ files:
322
323
  - spec/unit/braintree/transaction/installment_spec.rb
323
324
  - spec/unit/braintree/transaction/paypal_details_spec.rb
324
325
  - spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb
326
+ - spec/unit/braintree/transaction_gateway_spec.rb
325
327
  - spec/unit/braintree/transaction_search_spec.rb
326
328
  - spec/unit/braintree/transaction_spec.rb
327
329
  - spec/unit/braintree/unknown_payment_method_spec.rb
@@ -362,7 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
364
  - !ruby/object:Gem::Version
363
365
  version: '0'
364
366
  requirements: []
365
- rubygems_version: 3.4.3
367
+ rubygems_version: 3.4.13
366
368
  signing_key:
367
369
  specification_version: 4
368
370
  summary: Braintree Ruby Server SDK