braintree 4.23.0 → 4.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/braintree/address_gateway.rb +5 -0
- data/lib/braintree/apple_pay_card.rb +6 -0
- data/lib/braintree/bank_account_instant_verification_gateway.rb +38 -0
- data/lib/braintree/bank_account_instant_verification_jwt.rb +23 -0
- data/lib/braintree/bank_account_instant_verification_jwt_request.rb +21 -0
- data/lib/braintree/bin_data.rb +8 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card.rb +12 -5
- data/lib/braintree/credit_card_gateway.rb +1 -0
- data/lib/braintree/credit_card_verification_gateway.rb +5 -2
- data/lib/braintree/customer_session_gateway.rb +195 -0
- data/lib/braintree/dispute.rb +1 -0
- data/lib/braintree/error_codes.rb +58 -104
- data/lib/braintree/error_result.rb +1 -1
- data/lib/braintree/errors.rb +2 -1
- data/lib/braintree/gateway.rb +12 -0
- data/lib/braintree/google_pay_card.rb +5 -0
- data/lib/braintree/graphql/enums/recommendations.rb +9 -0
- data/lib/braintree/graphql/enums/recommended_payment_option.rb +10 -0
- data/lib/braintree/graphql/inputs/create_customer_session_input.rb +44 -0
- data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +40 -0
- data/lib/braintree/graphql/inputs/customer_session_input.rb +45 -0
- data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
- data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
- data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
- data/lib/braintree/graphql/inputs/phone_input.rb +34 -0
- data/lib/braintree/graphql/inputs/update_customer_session_input.rb +42 -0
- data/lib/braintree/graphql/types/customer_recommendations_payload.rb +129 -0
- data/lib/braintree/graphql/types/payment_options.rb +35 -0
- data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
- data/lib/braintree/graphql/unions/customer_recommendations.rb +47 -0
- data/lib/braintree/graphql_client.rb +16 -0
- data/lib/braintree/merchant_account.rb +1 -25
- data/lib/braintree/merchant_account_gateway.rb +0 -81
- data/lib/braintree/meta_checkout_card.rb +11 -6
- data/lib/braintree/meta_checkout_token.rb +11 -6
- data/lib/braintree/payment_method_gateway.rb +9 -0
- data/lib/braintree/paypal_payment_resource.rb +22 -0
- data/lib/braintree/paypal_payment_resource_gateway.rb +36 -0
- data/lib/braintree/successful_result.rb +3 -0
- data/lib/braintree/test/credit_card.rb +5 -0
- data/lib/braintree/transaction/apple_pay_details.rb +7 -0
- data/lib/braintree/transaction/credit_card_details.rb +22 -10
- data/lib/braintree/transaction/google_pay_details.rb +16 -10
- data/lib/braintree/transaction/meta_checkout_card_details.rb +11 -2
- data/lib/braintree/transaction/meta_checkout_token_details.rb +13 -3
- data/lib/braintree/transaction/paypal_details.rb +2 -0
- data/lib/braintree/transaction/visa_checkout_card_details.rb +10 -2
- data/lib/braintree/transaction.rb +3 -26
- data/lib/braintree/transaction_gateway.rb +52 -31
- data/lib/braintree/us_bank_account_verification.rb +3 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +10 -5
- data/lib/braintree/webhook_notification.rb +1 -4
- data/lib/braintree/webhook_testing_gateway.rb +16 -33
- data/lib/braintree/xml/{libxml.rb → nokogiri.rb} +18 -16
- data/lib/braintree/xml/parser.rb +4 -4
- data/lib/braintree.rb +21 -4
- data/spec/integration/braintree/advanced_search_spec.rb +7 -4
- data/spec/integration/braintree/apple_pay_spec.rb +6 -7
- data/spec/integration/braintree/bank_account_instant_verification_spec.rb +191 -0
- data/spec/integration/braintree/client_api/spec_helper.rb +81 -0
- data/spec/integration/braintree/credit_card_spec.rb +115 -1
- data/spec/integration/braintree/credit_card_verification_spec.rb +149 -0
- data/spec/integration/braintree/customer_session_spec.rb +154 -0
- data/spec/integration/braintree/customer_spec.rb +94 -10
- data/spec/integration/braintree/disbursement_spec.rb +1 -1
- data/spec/integration/braintree/dispute_spec.rb +13 -2
- data/spec/integration/braintree/merchant_account_spec.rb +19 -359
- data/spec/integration/braintree/merchant_spec.rb +4 -4
- data/spec/integration/braintree/payment_method_nonce_spec.rb +55 -0
- data/spec/integration/braintree/payment_method_spec.rb +57 -7
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +0 -3
- data/spec/integration/braintree/paypal_payment_resource_spec.rb +141 -0
- data/spec/integration/braintree/transaction_payment_facilitator_spec.rb +119 -0
- data/spec/integration/braintree/transaction_search_spec.rb +38 -33
- data/spec/integration/braintree/transaction_spec.rb +266 -350
- data/spec/integration/braintree/transaction_transfer_type_spec.rb +325 -0
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +0 -1
- data/spec/integration/braintree/us_bank_account_spec.rb +0 -3
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +1 -1
- data/spec/spec_helper.rb +46 -12
- data/spec/unit/braintree/apple_pay_card_spec.rb +7 -0
- data/spec/unit/braintree/bank_account_instant_verification_gateway_spec.rb +98 -0
- data/spec/unit/braintree/bank_account_instant_verification_jwt_request_spec.rb +71 -0
- data/spec/unit/braintree/client_token_spec.rb +11 -0
- data/spec/unit/braintree/configuration_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_spec.rb +27 -2
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -0
- data/spec/unit/braintree/customer_session_gateway_spec.rb +122 -0
- data/spec/unit/braintree/customer_spec.rb +2 -1
- data/spec/unit/braintree/dispute_spec.rb +6 -0
- data/spec/unit/braintree/error_result_spec.rb +28 -0
- data/spec/unit/braintree/google_pay_card_spec.rb +28 -0
- data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +102 -0
- data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +80 -0
- data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
- data/spec/unit/braintree/graphql/customer_session_input_spec.rb +81 -0
- data/spec/unit/braintree/graphql/phone_input_spec.rb +51 -0
- data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +107 -0
- data/spec/unit/braintree/graphql_client_spec.rb +37 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +61 -51
- data/spec/unit/braintree/meta_checkout_token_spec.rb +7 -1
- data/spec/unit/braintree/payment_method_nonce_spec.rb +11 -1
- data/spec/unit/braintree/payment_method_spec.rb +12 -0
- data/spec/unit/braintree/paypal_payment_resource_spec.rb +125 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +37 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +15 -1
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +37 -0
- data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +28 -0
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +28 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +5 -0
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +28 -0
- data/spec/unit/braintree/transaction_ach_mandate_spec.rb +82 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +58 -11
- data/spec/unit/braintree/transaction_spec.rb +66 -0
- data/spec/unit/braintree/visa_checkout_card_spec.rb +28 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +15 -51
- data/spec/unit/braintree/xml/{libxml_spec.rb → nokogiri_spec.rb} +7 -7
- data/spec/unit/braintree/xml/parser_spec.rb +57 -0
- data/spec/unit/credit_card_details_spec.rb +28 -0
- metadata +49 -10
- data/lib/braintree/merchant_account/business_details.rb +0 -17
- data/lib/braintree/merchant_account/funding_details.rb +0 -18
- data/lib/braintree/merchant_account/individual_details.rb +0 -20
- data/lib/ssl/securetrust_ca.crt +0 -44
- data/spec/unit/braintree/disbursement_spec.rb +0 -131
- data/spec/unit/braintree/merchant_account_spec.rb +0 -33
|
@@ -108,6 +108,7 @@ describe Braintree::PaymentMethod do
|
|
|
108
108
|
expect(apple_pay_card.payroll).not_to be_nil
|
|
109
109
|
expect(apple_pay_card.prepaid).not_to be_nil
|
|
110
110
|
expect(apple_pay_card.product_id).not_to be_nil
|
|
111
|
+
expect(apple_pay_card.is_device_token).to eq(true)
|
|
111
112
|
end
|
|
112
113
|
|
|
113
114
|
it "creates a payment method from a fake apple pay mpan nonce" do
|
|
@@ -126,8 +127,8 @@ describe Braintree::PaymentMethod do
|
|
|
126
127
|
expect(apple_pay_card.bin).not_to be_nil
|
|
127
128
|
expect(apple_pay_card.token).to eq(token)
|
|
128
129
|
expect(apple_pay_card.card_type).to eq(Braintree::ApplePayCard::CardType::Visa)
|
|
129
|
-
expect(apple_pay_card.payment_instrument_name).to eq("Visa
|
|
130
|
-
expect(apple_pay_card.source_description).to eq("Visa
|
|
130
|
+
expect(apple_pay_card.payment_instrument_name).to eq("Visa 2006")
|
|
131
|
+
expect(apple_pay_card.source_description).to eq("Visa 2006")
|
|
131
132
|
expect(apple_pay_card.default).to eq(true)
|
|
132
133
|
expect(apple_pay_card.image_url).to match(/apple_pay/)
|
|
133
134
|
expect(apple_pay_card.expiration_month.to_i).to be > 0
|
|
@@ -143,6 +144,7 @@ describe Braintree::PaymentMethod do
|
|
|
143
144
|
expect(apple_pay_card.prepaid).not_to be_nil
|
|
144
145
|
expect(apple_pay_card.product_id).not_to be_nil
|
|
145
146
|
expect(apple_pay_card.merchant_token_identifier).not_to be_nil
|
|
147
|
+
expect(apple_pay_card.is_device_token).not_to be_nil
|
|
146
148
|
expect(apple_pay_card.source_card_last4).not_to be_nil
|
|
147
149
|
end
|
|
148
150
|
|
|
@@ -205,9 +207,9 @@ describe Braintree::PaymentMethod do
|
|
|
205
207
|
expect(google_pay_card.image_url).to match(/android_pay/)
|
|
206
208
|
expect(google_pay_card.is_network_tokenized?).to eq(true)
|
|
207
209
|
expect(google_pay_card.source_card_type).to eq(Braintree::CreditCard::CardType::MasterCard)
|
|
208
|
-
expect(google_pay_card.source_card_last_4).to eq("
|
|
210
|
+
expect(google_pay_card.source_card_last_4).to eq("0005")
|
|
209
211
|
expect(google_pay_card.google_transaction_id).to eq("google_transaction_id")
|
|
210
|
-
expect(google_pay_card.source_description).to eq("MasterCard
|
|
212
|
+
expect(google_pay_card.source_description).to eq("MasterCard 0005")
|
|
211
213
|
expect(google_pay_card.customer_id).to eq(customer.id)
|
|
212
214
|
expect(google_pay_card.commercial).not_to be_nil
|
|
213
215
|
expect(google_pay_card.country_of_issuance).not_to be_nil
|
|
@@ -671,6 +673,30 @@ describe Braintree::PaymentMethod do
|
|
|
671
673
|
end
|
|
672
674
|
end
|
|
673
675
|
|
|
676
|
+
it "includes ani response when account information inquiry is sent in options" do
|
|
677
|
+
customer = Braintree::Customer.create!
|
|
678
|
+
nonce = nonce_for_new_payment_method(
|
|
679
|
+
:credit_card => {
|
|
680
|
+
:cvv => "123",
|
|
681
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
682
|
+
:expiration_date => "05/2029",
|
|
683
|
+
},
|
|
684
|
+
)
|
|
685
|
+
result = Braintree::PaymentMethod.create(
|
|
686
|
+
:payment_method_nonce => nonce,
|
|
687
|
+
:customer_id => customer.id,
|
|
688
|
+
:options => {
|
|
689
|
+
:verify_card => true,
|
|
690
|
+
:account_information_inquiry => "send_data",
|
|
691
|
+
},
|
|
692
|
+
)
|
|
693
|
+
|
|
694
|
+
expect(result).to be_success
|
|
695
|
+
verification = result.payment_method.verification
|
|
696
|
+
expect(verification.ani_first_name_response_code).not_to be_nil
|
|
697
|
+
expect(verification.ani_last_name_response_code).not_to be_nil
|
|
698
|
+
end
|
|
699
|
+
|
|
674
700
|
context "account_type" do
|
|
675
701
|
it "verifies card with account_type debit" do
|
|
676
702
|
nonce = nonce_for_new_payment_method(
|
|
@@ -1228,8 +1254,9 @@ describe Braintree::PaymentMethod do
|
|
|
1228
1254
|
expect(apple_pay_card.image_url).to match(/apple_pay/)
|
|
1229
1255
|
expect(apple_pay_card.expiration_month.to_i).to be > 0
|
|
1230
1256
|
expect(apple_pay_card.expiration_year.to_i).to be > 0
|
|
1231
|
-
expect(apple_pay_card.source_description).to eq("Visa
|
|
1257
|
+
expect(apple_pay_card.source_description).to eq("Visa 2006")
|
|
1232
1258
|
expect(apple_pay_card.customer_id).to eq(customer.id)
|
|
1259
|
+
expect(apple_pay_card.is_device_token).to eq(false)
|
|
1233
1260
|
apple_pay_card.merchant_token_identifier == "DNITHE302308980427388297"
|
|
1234
1261
|
apple_pay_card.source_card_last4 == "2006"
|
|
1235
1262
|
end
|
|
@@ -1310,9 +1337,9 @@ describe Braintree::PaymentMethod do
|
|
|
1310
1337
|
expect(google_pay_card.image_url).to match(/android_pay/)
|
|
1311
1338
|
expect(google_pay_card.is_network_tokenized?).to eq(true)
|
|
1312
1339
|
expect(google_pay_card.source_card_type).to eq(Braintree::CreditCard::CardType::MasterCard)
|
|
1313
|
-
expect(google_pay_card.source_card_last_4).to eq("
|
|
1340
|
+
expect(google_pay_card.source_card_last_4).to eq("0005")
|
|
1314
1341
|
expect(google_pay_card.google_transaction_id).to eq("google_transaction_id")
|
|
1315
|
-
expect(google_pay_card.source_description).to eq("MasterCard
|
|
1342
|
+
expect(google_pay_card.source_description).to eq("MasterCard 0005")
|
|
1316
1343
|
expect(google_pay_card.customer_id).to eq(customer.id)
|
|
1317
1344
|
end
|
|
1318
1345
|
end
|
|
@@ -1588,6 +1615,29 @@ describe Braintree::PaymentMethod do
|
|
|
1588
1615
|
end
|
|
1589
1616
|
end
|
|
1590
1617
|
|
|
1618
|
+
it "includes ani response after updating the options with account information inquiry" do
|
|
1619
|
+
customer = Braintree::Customer.create!
|
|
1620
|
+
credit_card = Braintree::CreditCard.create!(
|
|
1621
|
+
:customer_id => customer.id,
|
|
1622
|
+
:cvv => "123",
|
|
1623
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
1624
|
+
:expiration_date => "05/2032",
|
|
1625
|
+
)
|
|
1626
|
+
update_result = Braintree::PaymentMethod.update(
|
|
1627
|
+
credit_card.token,
|
|
1628
|
+
:options => {
|
|
1629
|
+
:verify_card => true,
|
|
1630
|
+
:account_information_inquiry => "send_data",
|
|
1631
|
+
},
|
|
1632
|
+
)
|
|
1633
|
+
|
|
1634
|
+
expect(update_result).to be_success
|
|
1635
|
+
verification = update_result.payment_method.verification
|
|
1636
|
+
expect(verification.ani_first_name_response_code).not_to be_nil
|
|
1637
|
+
expect(verification.ani_last_name_response_code).not_to be_nil
|
|
1638
|
+
end
|
|
1639
|
+
|
|
1640
|
+
|
|
1591
1641
|
context "verification_currency_iso_code" do
|
|
1592
1642
|
it "validates verification_currency_iso_code and updates the credit card " do
|
|
1593
1643
|
customer = Braintree::Customer.create!
|
|
@@ -32,7 +32,6 @@ describe Braintree::PaymentMethod do
|
|
|
32
32
|
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
|
33
33
|
expect(us_bank_account.bank_name).to match(/CHASE/)
|
|
34
34
|
expect(us_bank_account.default).to eq(true)
|
|
35
|
-
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
|
36
35
|
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
37
36
|
|
|
38
37
|
expect(us_bank_account.verifications.count).to eq(0)
|
|
@@ -100,7 +99,6 @@ describe Braintree::PaymentMethod do
|
|
|
100
99
|
expect(us_bank_account.account_holder_name).to eq("Dan Schulman")
|
|
101
100
|
expect(us_bank_account.bank_name).to match(/Wells Fargo/)
|
|
102
101
|
expect(us_bank_account.default).to eq(true)
|
|
103
|
-
expect(us_bank_account.ach_mandate.text).to eq("example mandate text")
|
|
104
102
|
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
105
103
|
|
|
106
104
|
expect(us_bank_account.verifications.count).to eq(1)
|
|
@@ -135,7 +133,6 @@ describe Braintree::PaymentMethod do
|
|
|
135
133
|
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
|
136
134
|
expect(us_bank_account.bank_name).to match(/CHASE/)
|
|
137
135
|
expect(us_bank_account.default).to eq(true)
|
|
138
|
-
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
|
139
136
|
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
|
140
137
|
|
|
141
138
|
expect(us_bank_account.verifications.count).to eq(1)
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
|
3
|
+
|
|
4
|
+
describe Braintree::PayPalPaymentResource do
|
|
5
|
+
|
|
6
|
+
describe "self.update" do
|
|
7
|
+
it "successfully updates a payment resource" do
|
|
8
|
+
nonce = nonce_for_paypal_account(
|
|
9
|
+
:intent => "order",
|
|
10
|
+
:payment_token => "fake-paypal-payment-token",
|
|
11
|
+
:payer_id => "fake-paypal-payer-id",
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
result = Braintree::PayPalPaymentResource.update(
|
|
15
|
+
:amount => BigDecimal("55.00"),
|
|
16
|
+
:amount_breakdown => {
|
|
17
|
+
:discount => BigDecimal("15.00"),
|
|
18
|
+
:handling => BigDecimal("0.00"),
|
|
19
|
+
:insurance => BigDecimal("5.00"),
|
|
20
|
+
:item_total => BigDecimal("45.00"),
|
|
21
|
+
:shipping => BigDecimal("10.00"),
|
|
22
|
+
:shipping_discount => BigDecimal("0.00"),
|
|
23
|
+
:tax_total => BigDecimal("10.00"),
|
|
24
|
+
},
|
|
25
|
+
:currency_iso_code => "USD",
|
|
26
|
+
:custom_field => "0437",
|
|
27
|
+
:description => "This is a test",
|
|
28
|
+
:line_items => [{
|
|
29
|
+
:description => "Shoes",
|
|
30
|
+
:image_url => "https://example.com/products/23434/pic.png",
|
|
31
|
+
:kind => "debit",
|
|
32
|
+
:name => "Name #1",
|
|
33
|
+
:product_code => "23434",
|
|
34
|
+
:quantity => "1",
|
|
35
|
+
:total_amount => BigDecimal("45.00"),
|
|
36
|
+
:unit_amount => BigDecimal("45.00"),
|
|
37
|
+
:unit_tax_amount => BigDecimal("10.00"),
|
|
38
|
+
:url => "https://example.com/products/23434",
|
|
39
|
+
}],
|
|
40
|
+
:order_id => "order-123456789",
|
|
41
|
+
:payee_email => "bt_buyer_us@paypal.com",
|
|
42
|
+
:payment_method_nonce => nonce,
|
|
43
|
+
:shipping => {
|
|
44
|
+
:country_name => "United States",
|
|
45
|
+
:country_code_alpha2 => "US",
|
|
46
|
+
:country_code_alpha3 => "USA",
|
|
47
|
+
:country_code_numeric => "484",
|
|
48
|
+
:extended_address => "Apt. #1",
|
|
49
|
+
:first_name => "John",
|
|
50
|
+
:international_phone => {
|
|
51
|
+
:country_code => "1",
|
|
52
|
+
:national_number => "4081111111",
|
|
53
|
+
},
|
|
54
|
+
:last_name => "Doe",
|
|
55
|
+
:locality => "Chicago",
|
|
56
|
+
:postal_code => "60618",
|
|
57
|
+
:region => "IL",
|
|
58
|
+
:street_address => "123 Division Street",
|
|
59
|
+
},
|
|
60
|
+
:shipping_options => [{
|
|
61
|
+
:amount => BigDecimal("10.00"),
|
|
62
|
+
:id => "option1",
|
|
63
|
+
:label => "fast",
|
|
64
|
+
:selected => true,
|
|
65
|
+
:type => "SHIPPING"
|
|
66
|
+
}],
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
expect(result.success?).to eq(true)
|
|
70
|
+
expect(result.payment_method_nonce).not_to be_nil
|
|
71
|
+
expect(result.payment_method_nonce.nonce).not_to be_nil
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "returns validation errors" do
|
|
75
|
+
nonce = nonce_for_paypal_account(
|
|
76
|
+
:intent => "order",
|
|
77
|
+
:payment_token => "fake-paypal-payment-token",
|
|
78
|
+
:payer_id => "fake-paypal-payer-id",
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
result = Braintree::PayPalPaymentResource.update(
|
|
82
|
+
:amount => BigDecimal("55.00"),
|
|
83
|
+
:amount_breakdown => {
|
|
84
|
+
:discount => BigDecimal("15.00"),
|
|
85
|
+
:handling => BigDecimal("0.00"),
|
|
86
|
+
:insurance => BigDecimal("5.00"),
|
|
87
|
+
:item_total => BigDecimal("45.00"),
|
|
88
|
+
:shipping => BigDecimal("10.00"),
|
|
89
|
+
:shipping_discount => BigDecimal("0.00"),
|
|
90
|
+
:tax_total => BigDecimal("10.00"),
|
|
91
|
+
},
|
|
92
|
+
:currency_iso_code => "USD",
|
|
93
|
+
:custom_field => "0437",
|
|
94
|
+
:description => "This is a test",
|
|
95
|
+
:line_items => [{
|
|
96
|
+
:description => "Shoes",
|
|
97
|
+
:image_url => "https://example.com/products/23434/pic.png",
|
|
98
|
+
:kind => "debit",
|
|
99
|
+
:name => "Name #1",
|
|
100
|
+
:product_code => "23434",
|
|
101
|
+
:quantity => "1",
|
|
102
|
+
:total_amount => BigDecimal("45.00"),
|
|
103
|
+
:unit_amount => BigDecimal("45.00"),
|
|
104
|
+
:unit_tax_amount => BigDecimal("10.00"),
|
|
105
|
+
:url => "https://example.com/products/23434",
|
|
106
|
+
}],
|
|
107
|
+
:order_id => "order-123456789",
|
|
108
|
+
:payee_email => "bt_buyer_us@paypal",
|
|
109
|
+
:payment_method_nonce => nonce,
|
|
110
|
+
:shipping => {
|
|
111
|
+
:country_name => "United States",
|
|
112
|
+
:country_code_alpha2 => "US",
|
|
113
|
+
:country_code_alpha3 => "USA",
|
|
114
|
+
:country_code_numeric => "484",
|
|
115
|
+
:extended_address => "Apt. #1",
|
|
116
|
+
:first_name => "John",
|
|
117
|
+
:international_phone => {
|
|
118
|
+
:country_code => "1",
|
|
119
|
+
:national_number => "4081111111",
|
|
120
|
+
},
|
|
121
|
+
:last_name => "Doe",
|
|
122
|
+
:locality => "Chicago",
|
|
123
|
+
:postal_code => "60618",
|
|
124
|
+
:region => "IL",
|
|
125
|
+
:street_address => "123 Division Street",
|
|
126
|
+
},
|
|
127
|
+
:shipping_options => [{
|
|
128
|
+
:amount => BigDecimal("10.00"),
|
|
129
|
+
:id => "option1",
|
|
130
|
+
:label => "fast",
|
|
131
|
+
:selected => true,
|
|
132
|
+
:type => "SHIPPING"
|
|
133
|
+
}],
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
expect(result.success?).to eq(false)
|
|
137
|
+
errors = result.errors.for(:paypal_payment_resource)
|
|
138
|
+
expect(errors.on(:payee_email)[0].code).to eq(Braintree::ErrorCodes::PayPalPaymentResource::InvalidEmail)
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
|
3
|
+
|
|
4
|
+
describe Braintree::Transaction do
|
|
5
|
+
|
|
6
|
+
describe "self.sale" do
|
|
7
|
+
|
|
8
|
+
it "should create a transaction with sub merchant and payment facilitator for a payfac merchant" do
|
|
9
|
+
transaction_params = {
|
|
10
|
+
:type => "sale",
|
|
11
|
+
:amount => "100.00",
|
|
12
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLPayFacMerchantAccountId,
|
|
13
|
+
:credit_card => {
|
|
14
|
+
:number => "4111111111111111",
|
|
15
|
+
:expiration_date => "06/2026",
|
|
16
|
+
:cvv => "123",
|
|
17
|
+
},
|
|
18
|
+
:descriptor => {
|
|
19
|
+
:name => "companynme12*product12",
|
|
20
|
+
:phone => "1232344444",
|
|
21
|
+
:url => "example.com",
|
|
22
|
+
},
|
|
23
|
+
:billing => {
|
|
24
|
+
:first_name => "Bob James",
|
|
25
|
+
:country_code_alpha2 => "CA",
|
|
26
|
+
:extended_address => "",
|
|
27
|
+
:locality => "Trois-Rivires",
|
|
28
|
+
:region => "QC",
|
|
29
|
+
:postal_code => "G8Y 156",
|
|
30
|
+
:street_address => "2346 Boul Lane",
|
|
31
|
+
},
|
|
32
|
+
:payment_facilitator => {
|
|
33
|
+
:payment_facilitator_id => "98765432109",
|
|
34
|
+
:sub_merchant => {
|
|
35
|
+
:reference_number => "123456789012345",
|
|
36
|
+
:tax_id => "99112233445577",
|
|
37
|
+
:legal_name => "Fooda",
|
|
38
|
+
:address => {
|
|
39
|
+
:street_address => "10880 Ibitinga",
|
|
40
|
+
:locality => "Araraquara",
|
|
41
|
+
:region => "SP",
|
|
42
|
+
:country_code_alpha2 => "BR",
|
|
43
|
+
:postal_code => "13525000",
|
|
44
|
+
:international_phone => {
|
|
45
|
+
:country_code => "55",
|
|
46
|
+
:national_number => "9876543210",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
:options => {
|
|
52
|
+
:store_in_vault_on_success => true,
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
result = Braintree::Transaction.sale(transaction_params)
|
|
57
|
+
expect(result.success?).to eq(true)
|
|
58
|
+
expect(result.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should fail on transaction with payment facilitator and non brazil merchant" do
|
|
62
|
+
transaction_params = {
|
|
63
|
+
:type => "sale",
|
|
64
|
+
:amount => "100.00",
|
|
65
|
+
:credit_card => {
|
|
66
|
+
:number => "4111111111111111",
|
|
67
|
+
:expiration_date => "06/2026",
|
|
68
|
+
:cvv => "123",
|
|
69
|
+
},
|
|
70
|
+
:descriptor => {
|
|
71
|
+
:name => "companynme12*product12",
|
|
72
|
+
:phone => "1232344444",
|
|
73
|
+
:url => "example.com",
|
|
74
|
+
},
|
|
75
|
+
:billing => {
|
|
76
|
+
:first_name => "Bob James",
|
|
77
|
+
:country_code_alpha2 => "CA",
|
|
78
|
+
:extended_address => "",
|
|
79
|
+
:locality => "Trois-Rivires",
|
|
80
|
+
:region => "QC",
|
|
81
|
+
:postal_code => "G8Y 156",
|
|
82
|
+
:street_address => "2346 Boul Lane",
|
|
83
|
+
},
|
|
84
|
+
:payment_facilitator => {
|
|
85
|
+
:payment_facilitator_id => "98765432109",
|
|
86
|
+
:sub_merchant => {
|
|
87
|
+
:reference_number => "123456789012345",
|
|
88
|
+
:tax_id => "99112233445577",
|
|
89
|
+
:legal_name => "Fooda",
|
|
90
|
+
:address => {
|
|
91
|
+
:street_address => "10880 Ibitinga",
|
|
92
|
+
:locality => "Araraquara",
|
|
93
|
+
:region => "SP",
|
|
94
|
+
:country_code_alpha2 => "BR",
|
|
95
|
+
:postal_code => "13525000",
|
|
96
|
+
:international_phone => {
|
|
97
|
+
:country_code => "55",
|
|
98
|
+
:national_number => "9876543210",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
:options => {
|
|
104
|
+
:store_in_vault_on_success => true,
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
ezp_gateway = Braintree::Gateway.new(
|
|
109
|
+
:environment => :development,
|
|
110
|
+
:merchant_id => "pp_credit_ezp_merchant",
|
|
111
|
+
:public_key => "pp_credit_ezp_merchant_public_key",
|
|
112
|
+
:private_key => "pp_credit_ezp_merchant_private_key",
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
result = ezp_gateway.transaction.sale(transaction_params)
|
|
116
|
+
expect(result.errors.for(:transaction).first.code).to eq(Braintree::ErrorCodes::PaymentFacilitator::PaymentFacilitatorNotApplicable)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -11,7 +11,8 @@ describe Braintree::Transaction, "search" do
|
|
|
11
11
|
expect(collection.maximum_size).to eq(0)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
#Disabling test until we have more stable CI
|
|
15
|
+
xit "can search on text fields" do
|
|
15
16
|
first_name = "Tim_#{rand(10**10)}"
|
|
16
17
|
token = "creditcard_#{rand(10**10)}"
|
|
17
18
|
customer_id = "customer_#{rand(10**10)}"
|
|
@@ -130,7 +131,8 @@ describe Braintree::Transaction, "search" do
|
|
|
130
131
|
expect(collection.first.id).to eq(transaction.id)
|
|
131
132
|
end
|
|
132
133
|
|
|
133
|
-
|
|
134
|
+
#Disabling test until we have more stable CI
|
|
135
|
+
xit "searches on users" do
|
|
134
136
|
transaction = Braintree::Transaction.sale!(
|
|
135
137
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
136
138
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
|
@@ -174,6 +176,16 @@ describe Braintree::Transaction, "search" do
|
|
|
174
176
|
expect(collection.first.id).to eq(transaction_id)
|
|
175
177
|
end
|
|
176
178
|
|
|
179
|
+
it "searches on reason_codes for 3 items" do
|
|
180
|
+
reason_code = ["R01", "R02"]
|
|
181
|
+
|
|
182
|
+
collection = Braintree::Transaction.search do |search|
|
|
183
|
+
search.reason_code.in reason_code
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
expect(collection.maximum_size).to eq(3)
|
|
187
|
+
end
|
|
188
|
+
|
|
177
189
|
it "searches on reason_code" do
|
|
178
190
|
transaction_id = "ach_txn_ret1"
|
|
179
191
|
reason_code = "R01"
|
|
@@ -181,10 +193,23 @@ describe Braintree::Transaction, "search" do
|
|
|
181
193
|
collection = Braintree::Transaction.search do |search|
|
|
182
194
|
search.reason_code.in reason_code
|
|
183
195
|
end
|
|
196
|
+
item = collection.find { |t| t.id == transaction_id }
|
|
197
|
+
expect(item.ach_return_code).to eq("R01")
|
|
198
|
+
expect(item.ach_return_responses.first[:reason_code]).to eq("R01")
|
|
199
|
+
end
|
|
184
200
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
201
|
+
it "searches on rejections reason_code" do
|
|
202
|
+
transaction_id = "ach_txn_ret3"
|
|
203
|
+
reason_code = "RJCT"
|
|
204
|
+
|
|
205
|
+
collection = Braintree::Transaction.search do |search|
|
|
206
|
+
search.reason_code.in reason_code
|
|
207
|
+
end
|
|
208
|
+
item = collection.find { |t| t.id == transaction_id }
|
|
209
|
+
expect(item.ach_return_code).to eq("RJCT")
|
|
210
|
+
expect(item.ach_reject_reason).to eq("Bank accounts located outside of the U.S. are not supported.")
|
|
211
|
+
expect(item.ach_return_responses.first[:reason_code]).to eq("RJCT")
|
|
212
|
+
expect(item.ach_return_responses.first[:reject_reason]).to eq("Bank accounts located outside of the U.S. are not supported.")
|
|
188
213
|
end
|
|
189
214
|
|
|
190
215
|
it "searches on reason_codes" do
|
|
@@ -194,7 +219,7 @@ describe Braintree::Transaction, "search" do
|
|
|
194
219
|
search.reason_code.is reason_code
|
|
195
220
|
end
|
|
196
221
|
|
|
197
|
-
expect(collection.maximum_size).to eq(
|
|
222
|
+
expect(collection.maximum_size).to eq(6)
|
|
198
223
|
end
|
|
199
224
|
|
|
200
225
|
context "multiple value fields" do
|
|
@@ -588,28 +613,6 @@ describe Braintree::Transaction, "search" do
|
|
|
588
613
|
expect(collection.first.id).to eq(transaction_id)
|
|
589
614
|
end
|
|
590
615
|
|
|
591
|
-
it "searches on reason_codes for 2 items" do
|
|
592
|
-
reason_code = ["R01", "R02"]
|
|
593
|
-
|
|
594
|
-
collection = Braintree::Transaction.search do |search|
|
|
595
|
-
search.reason_code.in reason_code
|
|
596
|
-
end
|
|
597
|
-
|
|
598
|
-
expect(collection.maximum_size).to eq(2)
|
|
599
|
-
end
|
|
600
|
-
|
|
601
|
-
it "searches on a reason_code" do
|
|
602
|
-
reason_code = ["R01"]
|
|
603
|
-
transaction_id = "ach_txn_ret1"
|
|
604
|
-
|
|
605
|
-
collection = Braintree::Transaction.search do |search|
|
|
606
|
-
search.reason_code.in reason_code
|
|
607
|
-
end
|
|
608
|
-
|
|
609
|
-
expect(collection.maximum_size).to eq(1)
|
|
610
|
-
expect(collection.first.id).to eq(transaction_id)
|
|
611
|
-
end
|
|
612
|
-
|
|
613
616
|
xit "searches on debit_network" do
|
|
614
617
|
transaction = Braintree::Transaction.sale!(
|
|
615
618
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
|
@@ -853,7 +856,7 @@ describe Braintree::Transaction, "search" do
|
|
|
853
856
|
search.ach_return_responses_created_at.between(DateTime.now - 1.0, DateTime.now + 1.0)
|
|
854
857
|
end
|
|
855
858
|
|
|
856
|
-
expect(date_search.maximum_size).to
|
|
859
|
+
expect(date_search.maximum_size).to be >= 1
|
|
857
860
|
end
|
|
858
861
|
|
|
859
862
|
it "it does not find records not within date range of the custom field" do
|
|
@@ -1002,7 +1005,7 @@ describe Braintree::Transaction, "search" do
|
|
|
1002
1005
|
}
|
|
1003
1006
|
end
|
|
1004
1007
|
|
|
1005
|
-
|
|
1008
|
+
xit "searches on dispute_date in UTC" do
|
|
1006
1009
|
collection = Braintree::Transaction.search do |search|
|
|
1007
1010
|
search.id.is @disputed_transaction.id
|
|
1008
1011
|
search.dispute_date.between(
|
|
@@ -1039,7 +1042,7 @@ describe Braintree::Transaction, "search" do
|
|
|
1039
1042
|
expect(collection.first.id).to eq(@disputed_transaction.id)
|
|
1040
1043
|
end
|
|
1041
1044
|
|
|
1042
|
-
|
|
1045
|
+
xit "searches on dispute_date in local time" do
|
|
1043
1046
|
now = @disputed_time.localtime("-06:00")
|
|
1044
1047
|
|
|
1045
1048
|
collection = Braintree::Transaction.search do |search|
|
|
@@ -1069,7 +1072,7 @@ describe Braintree::Transaction, "search" do
|
|
|
1069
1072
|
expect(collection.maximum_size).to eq(1)
|
|
1070
1073
|
end
|
|
1071
1074
|
|
|
1072
|
-
|
|
1075
|
+
xit "searches on dispute_date with date ranges" do
|
|
1073
1076
|
collection = Braintree::Transaction.search do |search|
|
|
1074
1077
|
search.id.is @disputed_transaction.id
|
|
1075
1078
|
search.dispute_date.between(
|
|
@@ -1375,7 +1378,8 @@ describe Braintree::Transaction, "search" do
|
|
|
1375
1378
|
end
|
|
1376
1379
|
end
|
|
1377
1380
|
|
|
1378
|
-
|
|
1381
|
+
#Disabling until we have a more stable CI
|
|
1382
|
+
xit "returns multiple results" do
|
|
1379
1383
|
collection = Braintree::Transaction.search
|
|
1380
1384
|
expect(collection.maximum_size).to be > 100
|
|
1381
1385
|
|
|
@@ -1510,6 +1514,7 @@ describe Braintree::Transaction, "search" do
|
|
|
1510
1514
|
|
|
1511
1515
|
collection = Braintree::Transaction.search do |search|
|
|
1512
1516
|
search.payment_instrument_type.in ["MetaCheckout"]
|
|
1517
|
+
search.ids.in [meta_checkout_card_transaction.id, meta_checkout_token_transaction.id]
|
|
1513
1518
|
end
|
|
1514
1519
|
|
|
1515
1520
|
collection.maximum_size.should == 2
|